I use SDL2.Currently my only shader has a MVP matrix, and transforms the points with it.I calculate my View and Projection matrix for a camera with GLM:glm::lookAt(pos, pos + forward, up);glm::perspective(fov, aspectRatio, zNear, zFar);I searched it, but I can only find legacy implementation of multiple viewports.If I create for example 4 cameras and let's say that they all the same, except every camera has a different quarter of the screen to render. (So I want 4 viewports with the same content)How can I do this? Sorry if I didn't give enough informations, feel free to ask.
Multiple viewports with modern OpenGL?
opengl;glm
Rendering to different viewports (parts) of the same screen can be done as follows:For example splitting screen into four parts and rendering the same scene four times to each corner with different uniforms and different viewports:bindFramebuffer();glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);scene->setConstPerFrameUniforms();//left bottomglViewport(0, 0, WindowWidth*0.5, WindowHeight*0.5);scene->setVarPerFrameUniforms(1);scene->draw();//right bottomglViewport(WindowWidth*0.5, 0, WindowWidth*0.5, WindowHeight*0.5);scene->setVarPerFrameUniforms(2);scene->draw();//left topglViewport(0, WindowHeight*0.5, WindowWidth*0.5, WindowHeight*0.5);scene->setVarPerFrameUniforms(3);scene->draw();//right topglViewport(WindowWidth*0.5, WindowHeight*0.5, WindowWidth*0.5, WindowHeight*0.5);scene->setVarPerFrameUniforms(4);scene->draw();glViewport(0, 0, WindowWidth, WindowHeight); //restore default