@@ -82,8 +82,6 @@ def initgl(self):
8282 GL .glClearColor (0.15 , 0.15 , 0.15 , 1.0 )
8383 GL .glEnable (GL .GL_DEPTH_TEST )
8484 GL .glEnable (GL .GL_PROGRAM_POINT_SIZE )
85- print ("GL_VERSION:" ,GL .glGetString (GL .GL_VERSION ))
86- print ("GLSL_VERSION" ,GL .glGetString (GL .GL_SHADING_LANGUAGE_VERSION ))
8785 if not hasattr (self , "shader" ):
8886 self .shader = OpenGL .GL .shaders .compileProgram (
8987 OpenGL .GL .shaders .compileShader (vertex_shader , GL .GL_VERTEX_SHADER ),
@@ -92,6 +90,7 @@ def initgl(self):
9290 self .vertex_array_object = create_object (self .shader )
9391 self .proj = GL .glGetUniformLocation ( self .shader , 'proj' )
9492 self .nframes = 0
93+ self .start = time .time ()
9594
9695 def redraw (self ):
9796 GL .glClear (GL .GL_COLOR_BUFFER_BIT | GL .GL_DEPTH_BUFFER_BIT )
@@ -105,7 +104,7 @@ def redraw(self):
105104 GL .glBindVertexArray ( 0 )
106105 GL .glUseProgram ( 0 )
107106 GL .glRasterPos2f (- 0.99 ,- 0.99 );
108- if self .nframes > 0 :
107+ if self .nframes > 1 :
109108 t = time .time ()- self .start
110109 fps = "fps: %5.2f frames: %d" % (self .nframes / t , self .nframes )
111110 for c in fps :
@@ -116,9 +115,10 @@ def redraw(self):
116115def main ():
117116 root = tk .Tk ()
118117 app = ShaderFrame (root , width = 512 ,height = 512 )
119- app .start = time .time ()
120118 app .pack (fill = tk .BOTH , expand = tk .YES )
119+ app .after (100 , app .printContext )
121120 app .animate = 1000 // 60
121+ app .animate = 1
122122 app .mainloop ()
123123if __name__ == '__main__' :
124124 main ()
0 commit comments