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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:40:43+00:00 2026-05-15T21:40:43+00:00

I have a simple rectangle i have drawn on screen in opengl. My target

  • 0

I have a simple rectangle i have drawn on screen in opengl.

My target is to draw this rectangle in 3D so the left side of it is deeper (z-axis) than the right side.

Look at this pic so you can see what i mean:
http://www.battleteam.net/tech/fis/docs/images/metroid_hud1.png

This is the code i use to draw a rectangle which uses different colors and i moved both points on left side up a bit.

glColor4f( 1.0, 1.0, 1.0, 1.0 );
glVertex3f( 0,            -20,           z_left );

glColor4f( 0.0, 1.0, 1.0, 1.0 );
glVertex3f( SQUARE_WIDTH, 0,             0 );

glColor4f( 1.0, 0.0, 1.0, 1.0 );
glVertex3f( SQUARE_WIDTH, SQUARE_HEIGHT, 0 );

glColor4f( 1.0, 1.0, 0.0, 1.0 );
glVertex3f( 0,            SQUARE_HEIGHT-20, z_left );

I use the z_left variable to dynamically change the z-value for the both points on the left side to move these points on the z-axis. But what happens is that the rectangle gets cut off from the left side. This happens when the z_left value reaches the zFar or zNear Variable defined via the “glOrtho” function call.

My glOrtho looks like this:
glOrtho( 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -100, 100 );

So if the z_left gets higher than 100 or less than -100 then that strange cutting off begins. I dont know why. I expected to get the left side of the rectangle to be moved on z-axis, means moving it deeper (away from eye) or closer.

Can somebody tell me whats wrong here? The rest of the code is pretty simple and standard.
A simple rectangle in a 3D environment being changed a bit to have a “3d panel” like rectangle.

My OpenGL init looks like this.

glClearColor( 0, 0, 0, 0 );
glMatrixMode( GL_PROJECTION );
glLoadIdentity(); glOrtho( 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -100, 100 ); 
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();

Thanks for any help.

  • 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-15T21:40:44+00:00Added an answer on May 15, 2026 at 9:40 pm

    Ortographic projections have that property, you can move them in the Z axis, but the object looks the same. Switch to a perspective projection, on which objects get smaller with distance to the camera.

    About the culling, you’re drawing outside the viewing cube (when Z < -100 or Z > 100). The projection will cull away anything outside it’s view.

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

Sidebar

Related Questions

I have a problem using opengl on android to draw a simple rectangle. This
I want to draw a rectangle using OPENGL in Android... Just a simple rectangle
I have simple form. <form target=_blank action=somescript.php method=Post id=simpleForm> <input type=hidden name=url value=http://...> <input
I have a simple custom UIView (a rectangle) that is implemented with drawRect. The
I have a simple Javascript program that displays a small rectangle in a canvas.
Come see the amazing disappearing rectangle! But seriously I have a really simple HTML5
I have this simple code each time i click the button its drawing a
I have to know how to add color to the rectangle drawn with the
This simple Canvas script creates a rectangle with a border and text . It
I have five shape draw able rectangular, I have to set the rectangle at

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.