//Used to bind the postprocessing, and clear the screen and the colour buffer //to get the screen ready, then renders the Skybox and other GameObjects //then adds renders the postprocessing effects. void SplashScreen::render(SDL_Window *window) { postProcessor.bind(); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClearDepth(1.0f); //clear the colour and depth buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderSkyBox(); //alternative sytanx for (auto iter = displayList.begin(); iter != displayList.end(); iter++) { renderGameObject((*iter)); } postProcessor.preDraw(); GLint colourFilterLocation = postProcessor.getUniformVariableLocation("colourFilter"); glUniformMatrix3fv(colourFilterLocation, 1, GL_FALSE, glm::value_ptr(selectedColour)); //draw postProcessor.draw(); //post draw postProcessor.postDraw(); SDL_GL_SwapWindow(window); }
//Function to draw/render void render() { /* //Set the clear color(background) glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //Clear the color and depth buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Make the new VBO active. Repeat here as a sanity check( may have changed since initialisation) glBindBuffer(GL_ARRAY_BUFFER, triangleVBO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, triangleEBO); glUseProgram(shaderProgram); //This line and the three below might have to go below the EBO linkBuffer //Gets the location of the MVP, Creates a combined Model View Projection Matrix and then sends it to the shader GLint MVPLocation = glGetUniformLocation(shaderProgram, "MVP"); mat4 MVP = projMatrix * viewMatrix * worldMatrix; glUniformMatrix4fv(MVPLocation, 1, GL_FALSE, glm::value_ptr(MVP)); //Tells the Shader that 0 is the position element glEnableVertexAttribArray(0); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL); glEnableVertexAttribArray(1); glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void**)(sizeof(vec3)+sizeof(vec2))); glEnableVertexAttribArray(2); glVertexArrayAttribPointer(2, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void**)(sizeof(vec3)+sizeof(vec2))); glEnableVertexAttribArray(1); glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void**)sizeof(vec3)); GLint texture0Location = glGetUniformLocation(shaderProgram, "texture0"); //This gets the texture location and sends the location of the texture to the shader glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture); //Changed in Lab 2 - 3D to allow to draw both EBOs and VBOs glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_INT, 0); //required to swap the back and front buffer SDL_GL_SwapWindow(window); */ //Not needed anymore postProcessor.bind(); //old imediate mode! //Set the clear colour(background) glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClearDepth(1.0f); //clear the colour and depth buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Alterantive Syntax for (auto iter = displayList.begin(); iter != displayList.end(); iter++) { renderGameObject((*iter)); } /* render2D(); //Calls the render 2D function render3D(); //Calls the render 3D function */ //Switching to the normal framebuffer postprocessor.preDraw(); //Grab stuff from the shader GLint colourFilterLocation = postProcessor.getUniformVariableLocation("colourFilter"); glUniformMatrix3fv(colourFilterLocation, 1, GL_FALSE, glm::value_ptr(SEPIA_FILTER)); //Draw postProcessor.Draw(); //Post Draw postProcessor.postDraw(); SDL_GL_SwapWindow(window); }