OpenGL scope, which is both wireframe and solid

I manually painted a sphere, finally :) I want my sphere to be red, but the outlines should be green:
alt text
For this, I did the following. I painted a solid sphere in red, and then painted the same sphere, but the frame and green. When I turned on DEPTH_TEST, I got strange behavior, for example: alt text

And to avoid this strange behavior, I just drew a wire sphere scaled (1.001, 1.001, 1.001) , and everything is drawn perfectly, as in the first picture. My question is: am I really a newbie doing it badly? Are there any better ways to do what I want to do? Thanks in advance.

PS I draw a sphere manually for exercises, I know about the existence of glu quadrics and glut sphere routines.

+7
c ++ geometry opengl outlining
source share
1 answer

You are not doing something terribly bad, but if you need to compensate for the geometry in order to avoid the Z-battle, you can take a look at glPolygonOffset .

+6
source share

All Articles