def error_callback(errnum, descr): print("Called GLFW Error Callback", err, descr) def framebuffer_size_callback(window, width, height): # make sure the viewport matches the new window dimensions; note that width and # height will be significantly larger than specified on retina displays. glViewport(0, 0, width, height) camera.setRatio(width / height) # process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly # --------------------------------------------------------------------------------------------------------- import mycamera camera = mycamera.Camera() ipressed = False def processInput(window): # global rotate, rpressed global cameraPos, cameraFront, ipressed if glfw.get_key(window, glfw.KEY_ESCAPE) == glfw.PRESS: glfw.set_window_should_close(window, True) if glfw.get_key(window, glfw.KEY_W) == glfw.PRESS: camera.processKeyboard(mycamera.FORWARD, deltaTime) if glfw.get_key(window, glfw.KEY_S) == glfw.PRESS: camera.processKeyboard(mycamera.BACKWARD, deltaTime)
import mycamera import myinput import mytexture import myshader print("""Based on examples from the learnopengl tutorial use keys QWASDZ to move around and mouse to point camera. use key i to display info. use RTY to turn light models on/off """) pos0 = glm.vec3(1.3, -0.2, 6.2) fro0 = glm.vec3(-0.1, 0, -1.0) camera = mycamera.Camera(position=pos0, front=fro0) inputMgr = myinput.InputManager(camera) width = 800 height = 600 # Initialize the glfw library if not glfw.init(): print("Failed to init glfw") else: glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3) glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3) glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE) glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, GL_TRUE) window = glfw.create_window(width, height, "LearnOpenGL", None, None)
def error_callback(errnum, descr): print("Called GLFW Error Callback", err, descr) def framebuffer_size_callback(window, width, height): # make sure the viewport matches the new window dimensions; note that width and # height will be significantly larger than specified on retina displays. glViewport(0, 0, width, height) camera.setRatio( width/height ) # process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly # --------------------------------------------------------------------------------------------------------- import mycamera camera = mycamera.Camera( position = glm.vec3( 1.3, -0.2, 6.2 ), front = glm.vec3( -0.1, 0, -1.0 ) ) ipressed = False def processInput(window): # global rotate, rpressed global cameraPos, cameraFront, ipressed if glfw.get_key(window, glfw.KEY_ESCAPE) == glfw.PRESS: glfw.set_window_should_close(window, True) if glfw.get_key(window, glfw.KEY_W) == glfw.PRESS: camera.processKeyboard( mycamera.FORWARD, deltaTime ) if glfw.get_key(window, glfw.KEY_S) == glfw.PRESS: camera.processKeyboard( mycamera.BACKWARD, deltaTime )