Skip to main content
In the last paragraph changed the statement telling that artifacts would certainly rise to a more precise one telling that thay may rise, since this could be the case
Source Link

All you have to do is create the FBOs textures with the desired width and height and adjust the viewport accordingly when rendering, as shown in this Shadow Map tutorial by Fabien Sanglard.

First create the FBO and it's textures with the desired dimensions. Here fbo_intermediary_colortexture is the FBO id, window_width and window_height are what the name implies and intermediaryTextureSizeRatio is a float that tells how much the FBO texture dimensions should be reduced:

void createFrameBuffer() { // Color texture glGenTextures(1, &fbo_intermediary_colortexture); glBindTexture(GL_TEXTURE_2D, fbo_intermediary_colortexture); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, window_width * intermediaryTextureSizeRatio, window_height * intermediaryTextureSizeRatio, 0, GL_RGB, GL_UNSIGNED_BYTE, 0); glBindTexture(GL_TEXTURE_2D, 0); // FBO glGenFramebuffersEXT(1, &fbo_intermediary); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_intermediary); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fbo_intermediary_colortexture, 0); // Test if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) cout << "Couldn't create frame buffer" << endl; glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); } 

After that, when rendering, just adjust the viewport dimensions accordingly to where it's being done (in that case, first on the FBO, and then on the screen):

// Rendering on the FBO, first bind the created FBO and then adjust the viewport dimensions glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_intermediary); glViewport(0,0, window_width * intermediaryTextureSizeRatio, window_height * intermediaryTextureSizeRatio); /** rendering to off screen FBO goes here **/ // Then bind the screen frame buffer, adjust the viewport dimensions again, and render // Notice that the window dimensions are not being multiplied by the reducing factor here glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glViewport(0,0, window_width, window_height); /** rendering to screen goes here **/ 

You can check the generated textures dimensions with gDEBugger or some similar application.

One last thing: be warned that, as shown in the aforementioned tutorial, some artifacts will certainlymay rise from a small texture being rendered on a bigger screen, which can be a bad outcome depending on the scenario.

All you have to do is create the FBOs textures with the desired width and height and adjust the viewport accordingly when rendering, as shown in this Shadow Map tutorial by Fabien Sanglard.

First create the FBO and it's textures with the desired dimensions. Here fbo_intermediary_colortexture is the FBO id, window_width and window_height are what the name implies and intermediaryTextureSizeRatio is a float that tells how much the FBO texture dimensions should be reduced:

void createFrameBuffer() { // Color texture glGenTextures(1, &fbo_intermediary_colortexture); glBindTexture(GL_TEXTURE_2D, fbo_intermediary_colortexture); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, window_width * intermediaryTextureSizeRatio, window_height * intermediaryTextureSizeRatio, 0, GL_RGB, GL_UNSIGNED_BYTE, 0); glBindTexture(GL_TEXTURE_2D, 0); // FBO glGenFramebuffersEXT(1, &fbo_intermediary); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_intermediary); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fbo_intermediary_colortexture, 0); // Test if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) cout << "Couldn't create frame buffer" << endl; glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); } 

After that, when rendering, just adjust the viewport dimensions accordingly to where it's being done (in that case, first on the FBO, and then on the screen):

// Rendering on the FBO, first bind the created FBO and then adjust the viewport dimensions glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_intermediary); glViewport(0,0, window_width * intermediaryTextureSizeRatio, window_height * intermediaryTextureSizeRatio); /** rendering to off screen FBO goes here **/ // Then bind the screen frame buffer, adjust the viewport dimensions again, and render // Notice that the window dimensions are not being multiplied by the reducing factor here glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glViewport(0,0, window_width, window_height); /** rendering to screen goes here **/ 

You can check the generated textures dimensions with gDEBugger or some similar application.

One last thing: be warned that, as shown in the aforementioned tutorial, some artifacts will certainly rise from a small texture being rendered on a bigger screen, which can be a bad outcome depending on the scenario.

All you have to do is create the FBOs textures with the desired width and height and adjust the viewport accordingly when rendering, as shown in this Shadow Map tutorial by Fabien Sanglard.

First create the FBO and it's textures with the desired dimensions. Here fbo_intermediary_colortexture is the FBO id, window_width and window_height are what the name implies and intermediaryTextureSizeRatio is a float that tells how much the FBO texture dimensions should be reduced:

void createFrameBuffer() { // Color texture glGenTextures(1, &fbo_intermediary_colortexture); glBindTexture(GL_TEXTURE_2D, fbo_intermediary_colortexture); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, window_width * intermediaryTextureSizeRatio, window_height * intermediaryTextureSizeRatio, 0, GL_RGB, GL_UNSIGNED_BYTE, 0); glBindTexture(GL_TEXTURE_2D, 0); // FBO glGenFramebuffersEXT(1, &fbo_intermediary); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_intermediary); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fbo_intermediary_colortexture, 0); // Test if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) cout << "Couldn't create frame buffer" << endl; glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); } 

After that, when rendering, just adjust the viewport dimensions accordingly to where it's being done (in that case, first on the FBO, and then on the screen):

// Rendering on the FBO, first bind the created FBO and then adjust the viewport dimensions glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_intermediary); glViewport(0,0, window_width * intermediaryTextureSizeRatio, window_height * intermediaryTextureSizeRatio); /** rendering to off screen FBO goes here **/ // Then bind the screen frame buffer, adjust the viewport dimensions again, and render // Notice that the window dimensions are not being multiplied by the reducing factor here glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glViewport(0,0, window_width, window_height); /** rendering to screen goes here **/ 

You can check the generated textures dimensions with gDEBugger or some similar application.

One last thing: be warned that, as shown in the aforementioned tutorial, some artifacts may rise from a small texture being rendered on a bigger screen, which can be a bad outcome depending on the scenario.

Source Link

All you have to do is create the FBOs textures with the desired width and height and adjust the viewport accordingly when rendering, as shown in this Shadow Map tutorial by Fabien Sanglard.

First create the FBO and it's textures with the desired dimensions. Here fbo_intermediary_colortexture is the FBO id, window_width and window_height are what the name implies and intermediaryTextureSizeRatio is a float that tells how much the FBO texture dimensions should be reduced:

void createFrameBuffer() { // Color texture glGenTextures(1, &fbo_intermediary_colortexture); glBindTexture(GL_TEXTURE_2D, fbo_intermediary_colortexture); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, window_width * intermediaryTextureSizeRatio, window_height * intermediaryTextureSizeRatio, 0, GL_RGB, GL_UNSIGNED_BYTE, 0); glBindTexture(GL_TEXTURE_2D, 0); // FBO glGenFramebuffersEXT(1, &fbo_intermediary); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_intermediary); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, fbo_intermediary_colortexture, 0); // Test if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) cout << "Couldn't create frame buffer" << endl; glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); } 

After that, when rendering, just adjust the viewport dimensions accordingly to where it's being done (in that case, first on the FBO, and then on the screen):

// Rendering on the FBO, first bind the created FBO and then adjust the viewport dimensions glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo_intermediary); glViewport(0,0, window_width * intermediaryTextureSizeRatio, window_height * intermediaryTextureSizeRatio); /** rendering to off screen FBO goes here **/ // Then bind the screen frame buffer, adjust the viewport dimensions again, and render // Notice that the window dimensions are not being multiplied by the reducing factor here glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glViewport(0,0, window_width, window_height); /** rendering to screen goes here **/ 

You can check the generated textures dimensions with gDEBugger or some similar application.

One last thing: be warned that, as shown in the aforementioned tutorial, some artifacts will certainly rise from a small texture being rendered on a bigger screen, which can be a bad outcome depending on the scenario.