I am having a little issue with my game trying to get the screen to draw a ton larger. I am going for a retro type of feel for my game and I believe that this would help with that.

I am basically trying to take a small area (example 100x177) and draw it 9 times the original size while still keeping the nearest neighbor. The image below shows what I am trying to achieve.

Resizing window content example

(image taken from: http://forums.tigsource.com/index.php?topic=27928.0).

I have been trying to set the current render area to an FrameBuffer then draw the Frame Buffer larger on the window. I have not been able to find any example code or how I would go about doing that.

Thank you in advance for the help.

EDIT: Added sample code

This code is in the same method where I initialize OpenGL

    fboID = GL30.glGenFramebuffers();
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fboID);
    colID = GL11.glGenTextures();
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, colID);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, scaleWidth, scaleHeight, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)null);
    depID = GL30.glGenRenderbuffers();
    GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, depID);
    GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL11.GL_DEPTH_COMPONENT, scaleWidth, scaleHeight);
    //GL32.glFramebufferTexture(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, colID, 0);
    drawBuffs = BufferUtils.createIntBuffer(1);
    drawBuffs.put(0, GL30.GL_COLOR_ATTACHMENT0);
    if(GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER) != GL30.GL_FRAMEBUFFER_COMPLETE){
        System.out.println("Framebuffer not complete!");
    } else {
        System.out.println("Framebuffer is complete!");

And this is my render method that the game loop runs (updates at 60fps)

    // clear screen

    // Start FBO Rendering Code
    //GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fboID);
    // Resets the current viewport
    GL11.glViewport(0, 0, scaleWidth, scaleHeight);                 // Set viewport to be the size of the FBO
    // Clear the FrameBuffer
    // Actual render code!

    // draw the texture from the FBO
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
    GL11.glViewport(0, 0, scaleWidth*scale, scaleHeight*scale);
    GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex3f(0.0f, 0.0f, 0.0f);
    GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex3f((float)scaleWidth*scale, 0.0f, 0.0f);
    GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex3f((float)scaleWidth*scale, (float)scaleHeight*scale, 0.0f);
    GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex3f(0.0f, (float)scaleHeight*scale, 0.0f);

    // Resets the current viewport
    GL11.glViewport(0, 0, scaleWidth*scale, scaleHeight*scale);


    // let subsystem paint
    if (callback != null) {

    // update window contents

I had to comment out "GL32.glFramebufferTexture(GL30.GL_FRAMEBUFFER,GL30.GL_COLOR_ATTACHMENT0, colID, 0);" because it was throwing a "Function not supported" error.



closed as off-topic by Anko, MrCranky, Josh Mar 17 '14 at 20:12

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about debugging a problem in your project must present a concise selection of code and context so as to allow a reader to diagnose the issue without needing to read all of your code or to engage in extensive back-and-forth dialog. For more information, see this meta thread." – Anko, MrCranky, Josh
If this question can be reworded to fit the rules in the help center, please edit the question.


I do this all the time with my graphics
What you should do is what you mention (render to a smaller frame buffer), then render its texture to fill the entire screen.

Perhaps you are not Re-Setting The Viewport every time you switch to a different frame buffer (bind the frame buffer, then set the viewport to the size of the frame buffer, then render your geometry, bind the window frame buffer, reset the viewport to match the screen resolution and finally render the frame buffer texture)

  • \$\begingroup\$ That is what I was trying to do but the main issue I am having is actually creating the frame buffer. Do you think you could link me to some source code to try and get an example? I have added the code that I was trying to use to the main post. \$\endgroup\$ – OstlerDev Mar 7 '14 at 23:46
  • \$\begingroup\$ By commenting out the color attachment you are not properly linking the texture to the FBO render target. A few things: Unbind your texture when you are done with it in the Frame Buffer creation. You seem to be loading the identity matrix after you render the full screen quad, you should first render your geometry to the frame buffer, and then (asuming you are drawing 3d) load an orthogonal projection matrix, then load an identity matrix to the modelview matrix to clear any previous camera transformations, and finally render the full screen quad with the texture attached to it. \$\endgroup\$ – germangb Mar 8 '14 at 0:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.