开发者

openGL sphere that is both wireframe and solid

开发者 https://www.devze.com 2023-01-24 19:52 出处:网络
I manually drew a sphere, at last :) I want my sphere to be red, but the outlines to be green: In order to achieve this I did the following. I drew a solid sphere in red, and then I drew the same sph

I manually drew a sphere, at last :) I want my sphere to be red, but the outlines to be green:

openGL sphere that is both wireframe and solid

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:

openGL sphere that is both wireframe and solid

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, 开发者_JS百科I am aware of the existence of glu quadrics routines and glut's sphere.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消