def test_info_strings(self): self.assertIsInstance(glfw.GetVersion(), tuple) self.assertIsInstance(glfw.GetVersionString(), str)
Unfortunately PyOpenGL doesn't always handle error cases well. """) version = 3,2 glfw.WindowHint(glfw.CONTEXT_VERSION_MAJOR, version[0]) glfw.WindowHint(glfw.CONTEXT_VERSION_MINOR, version[1]) glfw.WindowHint(glfw.OPENGL_FORWARD_COMPAT, 0) glfw.WindowHint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE) window = glfw.CreateWindow(640, 480, 'Hello World') if not window: glfw.Terminate() print('Failed to create window') exit() glfw.MakeContextCurrent(window) print('GL:',GL.glGetString(GL.GL_VERSION)) print('GLFW3:',glfw.GetVersionString()) for iteration in range(100): if glfw.WindowShouldClose(window): break GL.glClearColor(0.2, 0.2, 0.2, 1.0) GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT) glfw.SwapBuffers(window) glfw.PollEvents() glfw.DestroyWindow(window) glfw.Terminate()
import cyglfw3 as glfw import atexit @atexit.register def on_exit(): glfw.Terminate() print '%d.%d.%d' % glfw.GetVersion() print glfw.GetVersionString() # error codes: http://www.glfw.org/docs/latest/group__errors.html def glfw_error_callback(e, description): print e, description #glfw.NOT_INITIALIZED #glfw.NO_CURRENT_CONTEXT: #glfw.INVALID_ENUM: #glfw.INVALID_VALUE #glfw.OUT_OF_MEMORY #glfw.API_UNAVAILABLE #glfw.VERSION_UNAVAILABLE #glfw.PLATFORM_ERROR #glfw.FORMAT_UNAVAILABLE #glfw.NO_WINDOW_CONTEXT glfw.SetErrorCallback(glfw_error_callback)