I have a small python program that uses PyOpenGL
libraries to draw to spheres. The code has the below process
-
draw spheres
if there is a hit, then uses the below
SELECT_BUFFER_SIZE = 512 x, y = event.x(), event.y() # required to call this to force PyQt to read from the correct, updated buffer viewport = glGetIntegerv(GL_VIEWPORT) # print viewport w = viewport[2] - viewport[0] h = viewport[3] - viewport[1] aspect_ratio = w / h glSelectBuffer(SELECT_BUFFER_SIZE) glRenderMode(GL_SELECT) glInitNames() glPushName(0) glMatrixMode(GL_PROJECTION) glPushMatrix() glLoadIdentity() gluPickMatrix(x, viewport[3] - y, 5, 5, viewport) glOrtho( *** setting the schene***) **-draw spheres using glLoadName(for each)** glMatrixMode(GL_PROJECTION) glPopMatrix() glFlush() buffer = glRenderMode(GL_RENDER) # print buffer for hit_record in buffer: _, _, names = hit_record print(names)
But when I try to print the names, although I hit only one of them on the window, both names are printed. What should be the solution for that
In short, I am trying to draw three spheres(in white color) in a Pyqt5 window using PyOpenGL with the same colors, but I am trying to make them eligible for picking. I have also the capabilities of rotating, moving, and zoom in-out. So these capabilities should not break picking when they are done.(As it is asked in the comment, it is not homework. It is a side project that I work on for the last 2 years. So this problem is only a really small portion of my code.)
from PyOpenGL or OpenGL picking question (Not color picking)
No comments:
Post a Comment