Tkinter frame with opengl Tkinter frame with opengl tkinter tkinter

Tkinter frame with opengl


The line does not render, because you don't setup an Orthographic projection. If you don't set an orthographic projection, then you have to specify the coordinates in normalized device space. NDC are a unique cube, with the left, bottom, near of (-1, -1, -1) and the right, top, far of (1, 1, 1).

Specify an orthographic GL_PROJECTION matrix (see glMatrixMode ) by glOrtho, that maps the window coordinates to NDC:

class frame(OpenGLFrame):    def initgl(self):        glViewport(0, 0, self.width, self.height)        glClearColor(0.0,1.0,0.0,0.0)        # setup projection matrix        glMatrixMode(GL_PROJECTION)        glLoadIdentity()        glOrtho(0, self.width, self.height, 0, -1, 1)        # setup identity model view matrix        glMatrixMode(GL_MODELVIEW)        glLoadIdentity()            def redraw(self):        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER)        glLoadIdentity()        glBegin(GL_LINES)        glColor3f(1.0,0.0,3.0)        glVertex2f(200,100)        glVertex2f(100,100)        glEnd()        gl_Flush()