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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:39:26+00:00 2026-05-30T03:39:26+00:00

I have a cube with ofcourse 6 sides. Now I want not to render

  • 0

I have a cube with ofcourse 6 sides. Now I want not to render all sides when some of these sides are out of view. So I pass the rotations of the camera to the draw function seen below:

void Voxel::draw(QGLWidget *parent, GLfloat rotationX, GLfloat rotationY, GLfloat rotationZ) {

    glBegin(GL_QUADS);
    parent->qglColor(color);

    if ((rotationY > -90 && rotationY < 90) | rotationY < -270) {
        // Side top
        glVertex3f(-1.0f,  1.0f,  1.0f);  // Top Left Of The Texture and Quad
        glVertex3f( 1.0f,  1.0f,  1.0f);  // Top Right Of The Texture and Quad
        glVertex3f( 1.0f,  1.0f,  -1.0f);  // Bottom Right Of The Texture and Quad
        glVertex3f(-1.0f,  1.0f,  -1.0f);  // Bottom Left Of The Texture and Quad
    }

    // Side bottom
    glVertex3f(-1.0f,  -1.0f,  -1.0f);  // Bottom Left Of The Texture and Quad
    glVertex3f( 1.0f,  -1.0f,  -1.0f);  // Bottom Right Of The Texture and Quad
    glVertex3f( 1.0f,  -1.0f,  1.0f);  // Top Right Of The Texture and Quad
    glVertex3f(-1.0f,  -1.0f,  1.0f);  // Top Left Of The Texture and Quad

    // Side 1
    glVertex3f(-1.0f, -1.0f,  1.0f);  // Bottom Left Of The Texture and Quad
    glVertex3f( 1.0f, -1.0f,  1.0f);  // Bottom Right Of The Texture and Quad
    glVertex3f( 1.0f,  1.0f,  1.0f);  // Top Right Of The Texture and Quad
    glVertex3f(-1.0f,  1.0f,  1.0f);  // Top Left Of The Texture and Quad

    // Side 2
    glVertex3f(-1.0f,  1.0f,  -1.0f);  // Top Left Of The Texture and Quad
    glVertex3f( 1.0f,  1.0f,  -1.0f);  // Top Right Of The Texture and Quad
    glVertex3f( 1.0f, -1.0f,  -1.0f);  // Bottom Right Of The Texture and Quad
    glVertex3f(-1.0f, -1.0f,  -1.0f);  // Bottom Left Of The Texture and Quad

    // Side 3
    glVertex3f(1.0f, -1.0f,  -1.0f);  // Bottom Right Of The Texture and Quad
    glVertex3f(1.0f,  1.0f,  -1.0f);  // Top Left Of The Texture and Quad
    glVertex3f(1.0f,  1.0f,  1.0f);  // Top Right Of The Texture and Quad
    glVertex3f(1.0f, -1.0f,   1.0f);  // Bottom Left Of The Texture and Quad

    // Side 4
    glVertex3f(-1.0f, -1.0f,   1.0f);  // Bottom Left Of The Texture and Quad
    glVertex3f(-1.0f,  1.0f,  1.0f);  // Top Right Of The Texture and Quad
    glVertex3f(-1.0f,  1.0f,  -1.0f);  // Top Left Of The Texture and Quad
    glVertex3f(-1.0f, -1.0f,  -1.0f);  // Bottom Right Of The Texture and Quad

    glEnd();
}

For some reason however, this does not fully work. Especially while rotating around the X axis. At some points of rotation it does not show the quad, while it should be in display.

I’m setting the rotation like this:

glRotatef(rotationX, 1.0, 0.0, 0.0);
glRotatef(rotationY, 0.0, 1.0, 0.0);

If I need to explain more, please ask. If one knows some good documentation about these things, please say so.

  • 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-30T03:39:27+00:00Added an answer on May 30, 2026 at 3:39 am

    This might not be the answer you’re expecting, but, usually OpenGL hardware is quite good at not display the faces that are not facing the camera, this is called backface culling. Modern desktop hardware can discard about 4 billion triangles / second. So this optimization may not be one, and may not be worth of the time you’re spending with it.

    More over, assuming that you are using a perspective projection, your assumption about the visibility of a cube face being related to its rotation may not be true, regarding the position of the cube relative to the ‘camera’.

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

Sidebar

Related Questions

I have a cube that I want to paint with same color on all
I have a cube which I want to rotate. I also have a light
In our cube, we have hierarchies with All as the default member at the
So I have a cube of images. 512X512X512, I want to sum up the
I have an SSAS cube with limited users. I don't want to grant any
I have created a rotating CUBE with the help of OPENGL in Android now
i have a std::vector, namely vector<vector<vector> > > mdata; i want pass data from
I have a 3D cube and I open the camera preview, and I want
I have cube which contains geographic sales data. I want to pull sales of
I have a Cube which I want to rotate using mouse motion. So if

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.