Skip to main content
deleted 779 characters in body
Source Link
mdkdy
  • 2.2k
  • 1
  • 13
  • 21

Rendering to different viewports (parts) of the same screen can be easily done with blending. As far as I know GL_BLEND or glBlendFunc isn't considered legacy.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();

glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);

//left bottom
glViewport(0, 0, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(1);
scene->draw();

//right bottom
glViewport(WindowWidth*0.5, 0, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(2);
scene->draw();

//left top
glViewport(0, WindowHeight*0.5, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(3);
scene->draw();

//right top
glViewport(WindowWidth*0.5, WindowHeight*0.5, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(4);
scene->draw();

glViewport(0, 0, WindowWidth, WindowHeight); //restore default
glDisable(GL_BLEND);

This use GL_ONE, GL_ONE blend mode but for some effects like overlapping different modes can be used. This is nice visual representation of different modes

EDIT:

I thought about that and it can be done without blending. You just need four framebuffers or one with bunch of color attachments. To each of them you render your scene with different viewport enabled. Then in render pass to screen you bind those textures and blend them in more modern way using fragment shader. That's more complex but with more freedom of applying desired results.

Rendering to different viewports (parts) of the same screen can be easily done with blending. As far as I know GL_BLEND or glBlendFunc isn't considered legacy.

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();

glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);

//left bottom
glViewport(0, 0, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(1);
scene->draw();

//right bottom
glViewport(WindowWidth*0.5, 0, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(2);
scene->draw();

//left top
glViewport(0, WindowHeight*0.5, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(3);
scene->draw();

//right top
glViewport(WindowWidth*0.5, WindowHeight*0.5, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(4);
scene->draw();

glViewport(0, 0, WindowWidth, WindowHeight); //restore default
glDisable(GL_BLEND);

This use GL_ONE, GL_ONE blend mode but for some effects like overlapping different modes can be used. This is nice visual representation of different modes

EDIT:

I thought about that and it can be done without blending. You just need four framebuffers or one with bunch of color attachments. To each of them you render your scene with different viewport enabled. Then in render pass to screen you bind those textures and blend them in more modern way using fragment shader. That's more complex but with more freedom of applying desired results.

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 bottom
glViewport(0, 0, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(1);
scene->draw();

//right bottom
glViewport(WindowWidth*0.5, 0, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(2);
scene->draw();

//left top
glViewport(0, WindowHeight*0.5, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(3);
scene->draw();

//right top
glViewport(WindowWidth*0.5, WindowHeight*0.5, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(4);
scene->draw();

glViewport(0, 0, WindowWidth, WindowHeight); //restore default
added 283 characters in body
Source Link
mdkdy
  • 2.2k
  • 1
  • 13
  • 21

Rendering to different viewports (parts) of the same screen can be easily done with blending. As far as I know GL_BLEND or glBlendFunc isn't considered legacy.

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();

glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);

//left bottom
glViewport(0, 0, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(1);
scene->draw();

//right bottom
glViewport(WindowWidth*0.5, 0, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(2);
scene->draw();

//left top
glViewport(0, WindowHeight*0.5, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(3);
scene->draw();

//right top
glViewport(WindowWidth*0.5, WindowHeight*0.5, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(4);
scene->draw();

glViewport(0, 0, WindowWidth, WindowHeight); //restore default
glDisable(GL_BLEND);

This use GL_ONE, GL_ONE blend mode but for some effects like overlapping different modes can be used. This is nice visual representation of different modes

EDIT:

I thought about that and it can be done without blending. You just need four framebuffers or one with bunch of color attachments. To each of them you render your scene with different viewport enabled. Then in render pass to screen you bind those textures and blend them in more modern way using fragment shader. That's more complex but with more freedom of applying desired results.

Rendering to different viewports (parts) of the same screen can be easily done with blending. As far as I know GL_BLEND or glBlendFunc isn't considered legacy.

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();

glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);

//left bottom
glViewport(0, 0, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(1);
scene->draw();

//right bottom
glViewport(WindowWidth*0.5, 0, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(2);
scene->draw();

//left top
glViewport(0, WindowHeight*0.5, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(3);
scene->draw();

//right top
glViewport(WindowWidth*0.5, WindowHeight*0.5, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(4);
scene->draw();

glViewport(0, 0, WindowWidth, WindowHeight); //restore default
glDisable(GL_BLEND);

This use GL_ONE, GL_ONE blend mode but for some effects like overlapping different modes can be used. This is nice visual representation of different modes

Rendering to different viewports (parts) of the same screen can be easily done with blending. As far as I know GL_BLEND or glBlendFunc isn't considered legacy.

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();

glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);

//left bottom
glViewport(0, 0, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(1);
scene->draw();

//right bottom
glViewport(WindowWidth*0.5, 0, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(2);
scene->draw();

//left top
glViewport(0, WindowHeight*0.5, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(3);
scene->draw();

//right top
glViewport(WindowWidth*0.5, WindowHeight*0.5, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(4);
scene->draw();

glViewport(0, 0, WindowWidth, WindowHeight); //restore default
glDisable(GL_BLEND);

This use GL_ONE, GL_ONE blend mode but for some effects like overlapping different modes can be used. This is nice visual representation of different modes

EDIT:

I thought about that and it can be done without blending. You just need four framebuffers or one with bunch of color attachments. To each of them you render your scene with different viewport enabled. Then in render pass to screen you bind those textures and blend them in more modern way using fragment shader. That's more complex but with more freedom of applying desired results.

added 1 character in body
Source Link
mdkdy
  • 2.2k
  • 1
  • 13
  • 21

Rendering to different viewports (parts) of the same screen can be easily done with blending. As far as I know glBlendGL_BLEND or glBlendFunc isn't considered legacy.

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();

glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);

//left bottom
glViewport(0, 0, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(1);
scene->draw();

//right bottom
glViewport(WindowWidth*0.5, 0, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(2);
scene->draw();

//left top
glViewport(0, WindowHeight*0.5, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(3);
scene->draw();

//right top
glViewport(WindowWidth*0.5, WindowHeight*0.5, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(4);
scene->draw();

glViewport(0, 0, WindowWidth, WindowHeight); //restore default
glDisable(GL_BLEND);

This use GL_ONE, GL_ONE blend mode but for some effects like overlapping different modes can be used. This is nice visual representation of different modes

Rendering to different viewports (parts) of the same screen can be easily done with blending. As far as I know glBlend or glBlendFunc isn't considered legacy.

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();

glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);

//left bottom
glViewport(0, 0, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(1);
scene->draw();

//right bottom
glViewport(WindowWidth*0.5, 0, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(2);
scene->draw();

//left top
glViewport(0, WindowHeight*0.5, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(3);
scene->draw();

//right top
glViewport(WindowWidth*0.5, WindowHeight*0.5, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(4);
scene->draw();

glViewport(0, 0, WindowWidth, WindowHeight); //restore default
glDisable(GL_BLEND);

This use GL_ONE, GL_ONE blend mode but for some effects like overlapping different modes can be used. This is nice visual representation of different modes

Rendering to different viewports (parts) of the same screen can be easily done with blending. As far as I know GL_BLEND or glBlendFunc isn't considered legacy.

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();

glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);

//left bottom
glViewport(0, 0, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(1);
scene->draw();

//right bottom
glViewport(WindowWidth*0.5, 0, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(2);
scene->draw();

//left top
glViewport(0, WindowHeight*0.5, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(3);
scene->draw();

//right top
glViewport(WindowWidth*0.5, WindowHeight*0.5, WindowWidth*0.5, WindowHeight*0.5);
scene->setVarPerFrameUniforms(4);
scene->draw();

glViewport(0, 0, WindowWidth, WindowHeight); //restore default
glDisable(GL_BLEND);

This use GL_ONE, GL_ONE blend mode but for some effects like overlapping different modes can be used. This is nice visual representation of different modes

added 230 characters in body
Source Link
mdkdy
  • 2.2k
  • 1
  • 13
  • 21
Loading
Source Link
mdkdy
  • 2.2k
  • 1
  • 13
  • 21
Loading