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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:56:43+00:00 2026-05-26T02:56:43+00:00

/* OpenGL animation code goes here */ glClearColor (0.0f, 0.0f, 0.0f, 0.0f); glClear (GL_COLOR_BUFFER_BIT);

  • 0
 /* OpenGL animation code goes here */
        glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
        glClear (GL_COLOR_BUFFER_BIT);
        glDisable(GL_DEPTH_TEST);

        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0.0f,512.0f,0.0f,512.0f,0.0f,1.0f);

        glMatrixMode(GL_MODELVIEW_MATRIX);
        glPushMatrix ();
        glLoadIdentity();
        glTranslatef(x,y,0.0f);
        //glRotatef (theta, 0.0f, 0.0f, 1.0f);

        glBegin (GL_TRIANGLES);
        glColor3f (1.0f, 0.0f, 0.0f);   glVertex2f (0.0f, 1.0f);
        glColor3f (0.0f, 1.0f, 0.0f);   glVertex2f (0.8f, -0.5f);
        glColor3f (0.0f, 0.0f, 1.0f);   glVertex2f (-0.8f, -0.5f);
        glEnd ();
        glPopMatrix ();

        SwapBuffers (hDC);
        //theta += 0.1f;
        Sleep(1);
        }

This is the main simple opengl loop.

Recently, I come back to study Opengl (after leaving it for like 2 yrs). The problem is, I tried to use glOrtho to create 2D environment, but It is not working. I mean, the program seems to ignore glOrtho call (no errors, no warnings, no projection, nothing). This causes the vertex (0,1) of GL_TRIANGLE to hit the top of windows, and anything more than 1.0f will fly off the viewport (it is still an identity matrix I think?). I tried changing the parameters but no changes occur in the vieewport. I don’t know if I am missing something (maybe missing some initialization step or some deprecation that I am not aware of).

  • 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-26T02:56:44+00:00Added an answer on May 26, 2026 at 2:56 am
    glOrtho(0.0f,512.0f,0.0f,512.0f,0.0f,1.0f);
    

    This projection effectively selects the box of width 512, height 512 and depth 1 units to be the visible world space. However the vertices you specify will all be within a very small subset of the box, i.e. within one unit.

    glBegin (GL_TRIANGLES);
    glColor3f (1.0f, 0.0f, 0.0f);   glVertex2f (0.0f, 1.0f);
    glColor3f (0.0f, 1.0f, 0.0f);   glVertex2f (0.8f, -0.5f);
    glColor3f (0.0f, 0.0f, 1.0f);   glVertex2f (-0.8f, -0.5f);
    glEnd();
    

    I think you just confused the use of glOrtho with glViewport.

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

Sidebar

Related Questions

I was wondering how basic animation is done in OpenGL. In my code I
I am looking into converting my OpenGL rendering code to take advantage of a
From the documentation it appears that core animation layer is above OpenGL and Quartz2D.
I recently switched from using NSTimer to CVDisplayLink to redraw my OpenGL animation, but
I'm currently designing a simple opengl es 1.1 animation on the Android platform, where
I'm currently using CADisplayLink to show an OpenGL animation which works great. Sometimes, however
I just want to do a simple animation (for example in C++ using OpenGL)
i need to create a camera class which draw animation from openGL ES. image
I'm currently trying to integrate some animation drawing code of mine into a third
Assume I want to program a Star Field animation. Not by using OpenGL but

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.