Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to force a gluDisk to the foreground

Posted on 2006-07-22
11
Medium Priority
?
484 Views
Last Modified: 2013-12-06
I'm using gluDisk to draw some disks.  I want these disks to be in the foreground.  However, the disks are blocked from view by the rectangles I've drawn.  I'm drawing the rectangles using glREct.  How do I force the disks to the foreground, so they draw over the rectangles?

Thanks you.
0
Comment
Question by:clintMon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 25

Expert Comment

by:InteractiveMind
ID: 17162731
If you're doing 2D rendering here, then why not just render the disks last?
0
 

Author Comment

by:clintMon
ID: 17163675
I've tried that, and they still show up under the rectangles.  Some rectangles are drawn using glVertex3d.  I've set the 3rd parameter in this function to 0.0, which should allow ALL other ojbects to display "OVER" the rectangles.  However, my disks still show up BEHIND the rectangles.  Other rectangles are drawn using glRectd().  In the case of glRectd(), there is no parameter for the "depth".
0
 
LVL 25

Expert Comment

by:InteractiveMind
ID: 17163682
Hmm


Out of interest, does using glVertex2d have *any* effect?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:clintMon
ID: 17163748
When I switch from glVertex2D instead of glVertex3D, rectangle b (the rectangle that is drawn second) shows up BEHIND the retangle A (the rectangle that is drawn first, using glRect).  However, my disks, which are drawn last, still show up under both rectanlges.

Ultimately, what I want is the disks to be on top, rectangle B to display "immediately under" the disks, and rectangle A to be on the bottom.
0
 
LVL 25

Expert Comment

by:InteractiveMind
ID: 17163766
Hm
Any chance I could see any of your code please?
0
 

Author Comment

by:clintMon
ID: 17163789
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();

glEnable(GL_POLYGON_STIPPLE);
glRectd(dblLeft, dblYCoordBot, dbRight, dblYCoordTop);//rectangle A, which should show up on the bottom
glDisable(GL_POLYGON_STIPPLE);


//rectangle B, which should show up 2nd from bottom
glColor3f(0.6f, 0.6f, 0.5f)
glBegin(GL_POLYGON);
                        glVertex3d(dblLeft+(1 - currentDia/startDia)*scaleRadius, dblBottom, 1.0);      
                        glVertex3d(dblLeft+(1 - currentDia/startDia)*scaleRadius, dblTop, 1.0);      
                        glVertex3d(dblRight-(1 - currentDia/startDia)*scaleRadius, dblTop, 1.0);      
                        glVertex3d(dblRight-(1 - currentDia/startDia)*scaleRadius, dbltBottom, 1.0);      
glEnd();

//the disks, which should show up ON TOP of the rectangles
glColor3f(0.0f, 0.0f, 0.0f);
GLUquadricObj *quadObj;
quadObj = gluNewQuadric();
gluQuadricOrientation( quadObj, GLU_OUTSIDE );
gluQuadricDrawStyle( quadObj, GLU_FILL );
gluQuadricNormals( quadObj, GLU_SMOOTH );
gluDisk( quadObj, 0.0, .01, 450, 300);
gluDeleteQuadric( quadObj );

glPopMatrix();
0
 
LVL 25

Expert Comment

by:InteractiveMind
ID: 17163811
If you pass the glVertex3d() functions a z-value of -1.0 instead, then does this make a difference at all?

(Sorry, I would test this out myself, but I don't have OpenGL (or any C++ IDE's) installed on this machine).
0
 

Author Comment

by:clintMon
ID: 17163885
Yes.  That worked, but I had to make another change as well.

//for rectangle A, I replaced the call to glRect with glRect3D.  I did this because glRect3D let's you explicitly specify a Z coord (even though I'm using a 2D window).  So my new drawing for rectangle A looks like this:
glBegin(GL_POLYGON);
      glVertex3d(dblLayerLeft, dblYCoordBot, -1.0);
      glVertex3d(dblLayerLeft, dblYCoordTop, -1.0);
      glVertex3d(dblLayerRight, dblYCoordTop, -1.0);      
      glVertex3d(dblLayerRight, dblYCoordBot, -1.0);
glEnd();

//then, for rectangle B, I changed the Z parameter to -0.5.  I did this b/c I wanted the B rectangle to be drawn OVER rectangle A.  So rectangle B's code looks like this:
glColor3f(0.6f, 0.6f, 0.5f)
glBegin(GL_POLYGON);
                    glVertex3d(dblLeft+(1 - currentDia/startDia)*scaleRadius, dblBottom,-0.5);    
                    glVertex3d(dblLeft+(1 - currentDia/startDia)*scaleRadius, dblTop,-0.5);    
                    glVertex3d(dblRight-(1 - currentDia/startDia)*scaleRadius, dblTop,-0.5);    
                    glVertex3d(dblRight-(1 - currentDia/startDia)*scaleRadius, dbltBottom,-0.5);    
glEnd();

//I left the code for the disks the same, which I draw last, using gluDisk.

OK, so everything draws correctly.  One small problem.  NOW, when I click on one of my disks, the hit record shows 3 hits (because the disks are drawn over 2 rectangles).  How do I get access to the hit record for the disk that was clicked on?
0
 
LVL 25

Accepted Solution

by:
InteractiveMind earned 2000 total points
ID: 17163917
Right, we're nearly there..


For the Hit Record problem, see if this helps:
http://www.lighthouse3d.com/opengl/picking/index.php3?openglway3

You'll just need to extract the first hit, seeing as it is on top, right?
0
 

Author Comment

by:clintMon
ID: 17163968
Thank you for all your help!!!
0
 
LVL 25

Expert Comment

by:InteractiveMind
ID: 17163974
You're welcome :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question