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 8036319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:34:49+00:00 2026-06-05T02:34:49+00:00

I am having some trouble with full screen mode. I can set my window

  • 0

I am having some trouble with full screen mode. I can set my window to be 800×600, but when I full screen that resolution, it stretches. I assume this is because of a change in aspect ratio. How can I fix this?

Edit #1

Here’s a screen shot of what I see happening.

image

Left: 800×600

Right: 1366×768

Edit #2

My initGraphics function gets called every time I re-size the window (WM_SIZE).

void initGraphics(int width, int height) {
    float aspect = (float)width / (float)height;
    glViewport(0, 0, width, height);
    glEnable(GL_TEXTURE_2D);
    glEnable(GL_BLEND); //Enable alpha blending
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(0.0, width, height * aspect, 0.0);
    glMatrixMode(GL_MODELVIEW);
}
  • 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-06-05T02:34:51+00:00Added an answer on June 5, 2026 at 2:34 am

    SOLUTION:
    The real problem ended up being that you were misusing the gluOrtho2D function. Instead of using this:

    gluOrtho2D(0.0, width, height * aspect, 0.0);
    

    You needed to switch it to the correct form this:

    gluOrtho2D(0.0, width, 0.0, height);
    

    The latter creates a 2D orthographic projection, that fills the entire width and height of your viewport, so no stretching occurs.

    ORIGINAL ANSWER:

    You need to modify your projection in order to account for the new aspect ratio.

    Make sure you first of all set glViewport to the new window size. After the viewport is set you will need to switch your matrix mode to projection with a call to glMatrixMode and then finally calculate your new aspect ratio with width / height and pass the new aspect ratio to gluPerspective. You can also use straight glFrustum instead of gluPerspective you can find source to gluPerspective to achieve that same effect with glFrustum.

    Something like this:

        float aspectRatio = width / height;
        glMatrixMode(GL_PROJECTION_MATRIX);
        glLoadIdentity();
        gluPerspective(fov, aspectRatio, near, far); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I´m having some trouble retrieving a collection of strings in a projection: say that
i was playing around with the instapaper full api and im having some trouble
I'm trying to add a UIButton to a UIView, but am having some trouble
Im created a custom block, with the below code, but im having some trouble
I'm having some trouble with a MySQL Select Where statement that uses aliases and
Having some trouble trying to put together a page where images are placed properly.
Having some trouble (lack of understanding) with how to calculate percentages. I need to
Having some trouble with what should be a very simple scenario. For example purposes,
Im having some trouble targeting my buttons in ie7. Doesnt this work with an
Basically having some trouble with using Hover to hide or show an item. The

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.