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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:06:17+00:00 2026-06-14T04:06:17+00:00

I use the word semi-cube here, isn’t a real cube, it has only 3

  • 0

I use the word semi-cube here, isn’t a real cube, it has only 3 faces.I do the following:

1. Draw three faces of a cube in blue, the first face is blue, the other two are red;
2. Rotate the semi-cube of 45 degrees, in a way that I should see half of the red face.

But then I display the cube only the blue face is there, I should see half blue and half red.
Maybe I fail to enable the depth (I use glEnable()), I have the impression that the depth dimension is ignored in my drawing.

#import <OpenGL/OpenGL.h>
#import <GLUT/GLUT.h>

int width=500, height=500, depth=500;

void init()
{
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glEnable(GL_DEPTH_TEST);
    glViewport(0, 0, width, height);
    glOrtho(0, width, height, 0, 0, 1);
}

void display()
{
    glClearColor(0.9, 0.9, 0.9, 0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glColor4f(0, 0, 1, 0);
    glBegin(GL_QUADS);


    // First face
    glVertex3i(100, 100,0);
    glVertex3i(300, 100,0);
    glVertex3i(300, 300,0);
    glVertex3i(100, 300,0);

    glColor4f(1, 0, 0, 0);
    // Second face
    glVertex3i(300,100,0);
    glVertex3i(300,300,0);
    glVertex3i(300,100,300);
    glVertex3i(300,100,300);

    // Third face
    glVertex3i(100, 100,300);
    glVertex3i(300, 100,300);
    glVertex3i(300, 300,300);
    glVertex3i(100, 300,300);

    glEnd();
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glRotatef(45, 1, 0, 0);

    glFlush();
}

int main(int argc, char * argv[])
{
    glutInit(&argc, argv);
    glutInitWindowPosition(100, 100);
    glutInitWindowSize(width, height);
    glutCreateWindow("Test");
    glutDisplayFunc(display);
    init();
    glutMainLoop();
    return 0;
}

This is the image of what I get instead:

Image

EDIT : I kinda resolved changing the viewport:

glOrtho(0, width, height, 0, -depth, depth);

But I’m still missing basics, for now I’ll go ahead.

  • 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-14T04:06:19+00:00Added an answer on June 14, 2026 at 4:06 am

    Rotation only effects objects that are drawn after the rotation. When you call glBegin, whatever you draw is immediately drawn using the current modelview matrix on the stack.

    Modifying the matrix after drawing has no effect. You should move the rotation before the draw call.

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

Sidebar

Related Questions

(I use the word var in the following because I'm not sure what it
I use the word Notation because fabien potencier has its own generator but i
I have a user who has to use Microsoft Word 2007 to create and
What I want to know is how do I use word boundaries in the
I am trying to use some Word 2007 automation where we give the user
When people discuss about internationalization, they use the word i18n more often. For first
I can use the MS Word ActiveX control in order to access some parameters
I'm trying to use the CSS word-wrap property with break-word value. I want to
I'm wondering if it's possible (recommended might be the better word) to use sed
I have a question but I'm not sure of the word to use. My

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.