I am trying to draw a square with opengl using tkinter frame but the square didn't render.
Here is my code:
import tkinter as tk
from opengl.gl import *
from pyopengltk import OpenGLFrame
class frame(OpenGLFrame):
def initgl(self):
glViewport(0.0,self.width,self.height)
glClearColor(0.0,1.0,0.0,0.0)
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()
if __name__=='__main__':
root = tk.Tk()
app = frame(root,width=500,height=500)
app.pack(fill=tk.BOTH, expand=tk.YES)
app.mainloop()
I got no error expect the green screen without no lines drawn.
This is the image of the codes result it shows no error but the lines didn't show:
