Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6532683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:02:04+00:00 2026-05-25T10:02:04+00:00

Total noob here learning openGL and I don’t have any code to post because

  • 0

Total noob here learning openGL and I don’t have any code to post because this is a question about a concept, not my current implementation. If code is absolutely required let me know and to my nooby shame I will post some.

Basically I have a VBO that is displaying a 2D image in GL. However, since my viewport is 800×600 and the image is 1024×1024, the image is being scaled down to fit inside the viewport. I’ve googled for a very long time about this issue and all I can find are references to this in things such as the NeHe tutorials where they say this will happen, but with no explanation as to why and how to prevent it from happening. I think I found one forum that said it’s possible to prevent but again, no details.

So, I’m curious, how can this be done? I’m JUST learning GL so I’m pretty much a brand new baby noob in this area. If it helps, I’m making a 2D game and I’m trying to use this VBO for displaying the background image for a level, so as you move the camera left and right, up and down you’re essentially scrolling this background image. Any help would be greatly appreciated and thanks. 🙂

P.S. Also, I realize this probably should be in a separate question but any explanation or links to explain the coordinate system for vertex/texture maps would be appreciated as well. I’m not really grasping how one is supposed to map textures from 0-1 and convert that to pixel coordinates in space.

UPDATE

Okay so after some more googling the ONLY solution I’ve found is to adjust the viewport temporarily to be at least the size of your 2D texture, then draw your 2D texture, then set the viewport back to the window size (or whatever it ought to be). Like so:

//Set viewport so size of the current texture - note this is using a VBO
glViewport(0, 0, 1024, 1024);
glBindTexture(GL_TEXTURE_2D, texture);

glDrawArrays(GL_QUADS, 0, 4 );

glPopAttrib();

glBindBuffer(GL_ARRAY_BUFFER, 0);

glBindTexture(GL_TEXTURE_2D, 0);

//Set the viewport back to the window size
glViewport(0, 0, 800, 600);

Only thing is, these seems like a MAJOR hack. Is this the official or an acceptable solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:02:05+00:00Added an answer on May 25, 2026 at 10:02 am

    The best way to do that is to scale the vertices you are drawing to the current viewport size.

    For example, to draw a 10px by 10px box(Ignore obsolete api).

    glBegin( GL_QUADS );
    glVertex2d(0.0                    ,0.0);
    glVertex2d(10.0/viewportWidth * 2,0.0);
    glVertex2d(10.0/viewportWidth * 2,10.0/viewportHeight * 2);
    glVertex2d(0.0                    ,10.0/viewportHeight * 2);
    glEnd();
    

    You could do it in a shader or on the CPU.

    Changing the viewport looks like yet another of those expensive OpenGL state changes.

    NOTE:
    This could become more complicated with a more complex projection matrix.(I assume the default -1 to 1)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Total OO noob question here. I have these two methods in a class private
Hey! Total CakePHP noob here. Updated at bottom / This is sort of a
Total noob question, but here. CSS .product__specfield_8_arrow { /*background-image:url(../../upload/orng_bg_arrow.png); background-repeat:no-repeat;*/ background-color:#fc0; width:50px !important; height:33px
Total noobie question here. I'm just learning Java, and studying passing arguments to functions.
Total noob question here, but not finding the answer via search. What is the
OK, total noob question, for msysgit on Windows 7, but I have a remote
total noob here with about 2 months of C++ experience (no other background) so
I am a noob to Python and have not had any luck figuring this
well...just about all I needed to say...lookie here, I'm a total noob in web
I am a total noob on this issue, and I wonder if I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.