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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:49:12+00:00 2026-06-11T16:49:12+00:00

Possible Duplicate: Changing projection in OpenGL I want to find a way to keep

  • 0

Possible Duplicate:
Changing projection in OpenGL

I want to find a way to keep the same size of the object. I have this square which moves from upper left to right bottom of screen. When I resize the output window the size of the square increases as well.

Below is my display and reshape function.

void Changesize(int w,int h)
{

    ww=w;
         wh=h;
    glViewport(0,0,w,h);
    glMatrixMode(GL_PROJECTION);
        glLoadIdentity() ;
    glMatrixMode(GL_MODELVIEW);

}

void display(void)
{   

    printf("i=%f & j=%f \n",i,j);
    glClear (GL_COLOR_BUFFER_BIT);
    glColor3i (rand(), rand(), rand());
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    glLoadIdentity();
    glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
    glBegin(GL_POLYGON);
    glColor3i (rand(), rand(), rand());
    glVertex3f (i, j-0.125, 0.0);
    glVertex3f (i+0.125, j-0.125, 0.0);
    glVertex3f (i+0.125, j , 0.0);
    glVertex3f (i, j, 0.0);
    glEnd();
    glFlush ();
    usleep(100000);
    i=i+0.0125;
    j=j-0.0125;

    if (i>0.999999)
        {
            i=0;
            j=1;
        }
    glutSwapBuffers();
    glutPostRedisplay();

}
  • 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-11T16:49:13+00:00Added an answer on June 11, 2026 at 4:49 pm

    Give this a shot:

    #include <GL/glut.h>
    
    void display(void)
    {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
    
        glColor3ub(255,0,0);
        glPushMatrix();
            glScalef(50,50,50);
            glBegin(GL_QUADS);
                glVertex2f(-1,-1);
                glVertex2f(1,-1);
                glVertex2f(1,1);
                glVertex2f(-1,1);
            glEnd();
        glPopMatrix();
    
        glutSwapBuffers();
    }
    
    void reshape(int w, int h)
    {
        glViewport(0, 0, w, h);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho( -w/2.0, w/2.0, -h/2.0, h/2.0, -1, 1);
    }
    
    int main(int argc, char **argv)
    {
        glutInit(&argc, argv);
        glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
    
        glutInitWindowSize(800,600);
        glutCreateWindow("Scale");
    
        glutDisplayFunc(display);
        glutReshapeFunc(reshape);
        glutMainLoop();
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Changing scaling of MATLAB Figure I have an m-size vector f. By
Possible Duplicate: Changing Scrollbar Position I have a div that will act like an
Possible Duplicate: How do I overload the square-bracket operator in C#? Basically I want
Possible Duplicate: Spring + Hibernate : a different object with the same identifier value
Possible Duplicate JavaScript: Changing src-attribute of a embed-tag but this is not working for
Possible Duplicate: Changing only y pos of background image via Jquery I want to
Possible Duplicate: Any way of changing the duration of zoomToRect for UIScrollView? Is there
Possible Duplicate: CodeSign Error after changing Product Name I have been stuck in a
Possible Duplicate: Javascript for loop and setTimeout issue I want this loop to change
Possible Duplicate: Changing a CSS rule-set from Javascript Dear experts, Is there a way

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.