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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:03:35+00:00 2026-05-14T07:03:35+00:00

I am rendering a scene in which I have two spheres. I am revolving

  • 0

I am rendering a scene in which I have two spheres. I am revolving a camera around one of them. What happens is counter-intuitive. When the camera goes around the sphere the other gets in front of it when you’d expect it to be behind. So it appears as though the spheres aren’t revolving around each other and the one the should go around is always upfront. Please help.

Here is the code that renders the scene:

glLoadIdentity();

[self positionCamera];

glutSolidSphere(2, 12,12);

glPushMatrix();
glTranslatef(5, 0, 0);
glutSolidSphere(0.5, 12,12);
glPopMatrix();

glFlush();  

This block is part of a class that gets called on using.

[NSTimer scheduledTimerWithTimeInterval:DEFAULT_ANIMATION_INTERVAL 
                                 target:self 
                               selector:@selector(drawRect) 
                               userInfo:nil 
                                repeats:YES];

And

-(void)positionCamera{}

Contains math do camera revolution and gluLookAt()

  • 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-14T07:03:35+00:00Added an answer on May 14, 2026 at 7:03 am

    Basically what you’re doing now is a back-to-front rendering, where the last primitive drawn will always appear be drawn over the others.

    What you want to do is enable the depth test, where the depth of each fragment will be compared before being drawn on screen. glEnable(DEPTH_TEST) should help.

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

Sidebar

Related Questions

I have a simple Three.js scene around which I want to move the camera.
I have a problem when rendering cubes in OpenGL.I am drawing two cubes, one
I have an opengl scene rendering on an EAGLView layer and some other elements
I have a nice scene set up, and everything is rendering fine, and now
I have a UITabBarController that contains two view controllers. One is the default view
I am rendering a scene to a texture, then using that texture and its
I have a 2D scene, 2 textures set as render targets, and a vertex
I'm rendering simple scene with library GLESv1_CM on Android with NDK. void render(Rect viewport)
I have been tasked with rendering and manipulating 3d objects in the browser and
I'm using Java OpenGL (JOGL 2.x, built from Git source). I'm rendering my scene

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.