Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

openGL sphere that is both wireframe and solid

I manually drew a sphere, at last :) I want my sphere to be red, but the outlines to be green:
alt text
In order to achieve this I did the following. I drew a solid sphere in red, and then I drew the same sphere, but wireframe and green. When I turned DEPTH_TEST on, I got some weird behavior, like this:alt text

And in order to avoid this weird behavior I just drew the wired sphere scaled by (1.001, 1.001, 1.001) and everything is drawn perfectly, as in the first picture. My question is, am I, a real newbie, doing it in a bad way? Are there any better ways to do what I want to do? Thanks in advance.

P.S. I am drawing the sphere manually for an exercise's sake, I am aware of the existence of glu quadrics routines and glut's sphere.

like image 887
Armen Tsirunyan Avatar asked Nov 11 '10 15:11

Armen Tsirunyan


1 Answers

You're not doing something awfully bad, but if you need to offset geometry to avoid Z-fighting you might want to have a look at glPolygonOffset.

like image 58
Stringer Avatar answered Nov 09 '22 13:11

Stringer