glEnable(GL_DEPTH_TEST) glClearColor(1.0, 1.0, 1.0, 1.0) glEnable(GL_LINE_SMOOTH) glLineWidth(4) glPointSize(8) # create the shader program to run on the gpu: shader = Shader("shader.vs", "shader.fs") shader.use() # set the uniform color to black (the corresponding shader must be in use): shader.setVector("outlineColor", 0.0, 0.0, 0.0) camera = Camera() view = camera.getViewMatrix() shader.setMatrix("view", view) projection = glm.perspective(glm.radians(45.0), width / height, 0.1, 100.0) shader.setMatrix("projection", projection) # initialize the last_frame_time: last_frame_time = time.time() # set the mouse position to the center of the screen: pygame.mouse.set_pos([width / 2, height / 2]) # set_visible and set_grab together with pygame.mouse.get_rel make a full 360° # rotaion possible, not restricted to screen -> called: virtual input mode! pygame.mouse.set_visible(False) # mouse can no longer leave the window: pygame.event.set_grab(True)
def __init__(self, width, height): """---------Create Camera--------""" camera = Camera() self.camera = camera """-------Create Matricies-------""" model = glm.mat4() view = camera.getViewMatrix() projection = glm.perspective(glm.radians(45.0), width/height, 0.1, 100.0) """--------------Compile Shaders--------------""" shader = Shader(fullpath("shaderPC.vs"), fullpath("shaderPC.fs")) shader.use() shader.setMatrix("view", view) shader.setMatrix("projection", projection) shader.setMatrix("model", model) # for drawing position and color - data self.shaderPC = shader shader = Shader(fullpath("shaderPT.vs"), fullpath("shaderPT.fs")) shader.use() shader.setMatrix("view", view) shader.setMatrix("projection", projection) shader.setMatrix("model", model) # for drawing position and texture - data self.shaderPT = shader shader = Shader(fullpath("shaderPCT.vs"), fullpath("shaderPCT.fs")) shader.use() shader.setMatrix("view", view) shader.setMatrix("projection", projection) shader.setMatrix("model", model) # for drawing position, color and texture - data self.shaderPCT = shader shader = Shader(fullpath("GUIshader.vs"), fullpath("GUIshader.fs")) # for drawing GUI elements self.GUIshader = shader