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

  • Home
  • SEARCH
  • 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 3973850
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:29:57+00:00 2026-05-20T04:29:57+00:00

edit: I have added a few new lines of code to the beginning for

  • 0

edit: I have added a few new lines of code to the beginning for depth buffering with no luck. See code..

edit 2: I am constructing the model builder on a wxglcanvas via wxwidgets. I have initialized WX_GL_DEPTH_SIZE of 16 and WX_GL_DOUBLEBUFFER on top of enabling depthbuffering and glClear(GL_DEPTH_BUFFER_BIT) with no luck. One thing that might be useful to note is that when I draw a cone, it seems to be drawing the cone as if I am looking at the inside of it rather than the outside portion, so it looks as if it’s concaved in.

I have an odd problem where my openGL models do not overlap correctly. I am building a model builder so that the user can create and rotate a model on a canvas.

For example: If I have a circle within a box and I rotate the model around, I can still see the circle within the box as if the box is transparent. How I picture this is that if the circle is in the box, I should not be able to see it. Does anyone have any guesses to what causes this type of problem? I have not implemented any type of transparency, so I’m not really sure what is causing this. I am still very new to openGL so a lot of my efforts have just been trying lines of code I find on the forums and hoping it works. Also, parts of this code are inherited from other programs.

This problem seems to only occur in Ubuntu and not under Win 7 when I test my program after adding two lines of code (shown below).

Here are some lines of code for drawing the models…

//Newly Added code
      glEnable(GL_DEPTH_TEST);
      glDepthFunc(GL_GEQUAL);
      glClearDepth(1.0f);
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//End newly added code  

glGetIntegerv(GL_MATRIX_MODE, &mm);

glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(identity);
       GrGetInfo();

glViewport(0,0,gw->gc.width,gw->gc.height);
       GrGetInfo();

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

// Set some predefined parameters

glOrtho ((GLdouble)tmpOtherAxis.minval, (GLdouble)tmpOtherAxis.maxval, 
               (GLdouble)tmpRangeAxis.minval, (GLdouble)tmpRangeAxis.maxval,  
               -range_dist, range_dist);
glMatrixMode(mm);

//ADDED THESE TWO LINES AND MODEL DISPLAYED
//CORRECTLY IN WIN7 BUT NOT UBUNTU
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glPushMatrix();
//Draw model here
glPopMatrix();

Any help would be greatly appreciated, and feel free to ask me whatever questions you need regarding this.

  • 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-20T04:29:57+00:00Added an answer on May 20, 2026 at 4:29 am

    Sounds to me like your z-buffer isn’t enabled. Without a z-buffer, the geometry is simply drawn in the order of the issued OpenGL commands. Effectivly, there is no “behind”.

    To get the z-buffer to function properly, you’ll need to:

    1. Request a z-buffer for your rendering window. This is platform specific.
    2. Call glEnable( GL_DEPTH_TEST ).
    3. Use glClear( … | GL_DEPTH_BUFFER_BIT );

    Two possible explanations why your code is behaving different on different platforms, is (a) the z-buffer not being allocated (properly) on one of the platforms, or (b) the default state of GL_DEPTH_TEST being ON for one of the platforms, OFF for the other.

    Edit

    In a windows application, you’ll be using a ChoosePixelFormat/SetPixelFormat pair on your HDC somewhere, right before you use wglCreateContext(). That is where you specify your depth buffer.

                HDC hdc = GetDC(hwnd);
    
                PIXELFORMATDESCRIPTOR pfd;
                memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
                pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
                pfd.nVersion = 1;
                pfd.cColorBits = 16;
                pfd.cDepthBits = 16;  // <---- !!! Depth buffer !!!
                pfd.dwFlags = PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER;
                pfd.iPixelType = PFD_TYPE_RGBA;
    
                int format;
                if ((format = ChoosePixelFormat(hdc, &pfd)) != 0)
                        SetPixelFormat(hdc, format, &pfd);
    
                HGLRC hrc = wglCreateContext(hdc);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have quite a few working examples of jqGrid, and yesterday I added a
I currently have some code which needs to perform multiple updates per user for
I have few items on my ComboBox items collection, and i'd like to select
Basically, I have a table which contains a few properties for a company. This
I have window containing multiple panels. I don't have access to window code. (I
I've added a web service into my project in Visual Studio but I can't
I am fairly new to the .NET programming and I am currently developing a
I'm new to Magento. I've read a dozen of questions here and posts on
I am playing around with C# and the jQuery UI Dialog box tonight. I
When the user clicks the submit button on a form I want to return

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.