[Plib-devel] A COLOR_MATERIAL test case.
Brought to you by:
sjbaker
From: Steve B. <sjb...@ai...> - 2000-05-18 05:32:46
|
OK - I've spent some time to write a nice, simple test case to allow us to better discuss the color material problem in a clear manner. The program is derived from a logo competition entry at work - and I've applied nice simple textures and deliberately screwed with the polygon ordering to make for LOTS of state switching. It's also timed to run no faster than 60Hz with a nasty hack - try to ignore that - I was in a hurry. So - Compile 'logo.cxx' using the attached Makefile. Run it in the same directory as the two texture maps I provide. You should see a little animation of some origami - with spots on one side of the paper and stripes on the other. Admire it for a while...fun isn't it! OK - so now you can play around by editing logo.cxx and rebuilding it. * Go to line 446 - notice that the vertex colours are alternating between white and magenta (see the 'i & 1' part?). You don't see that in the animation because glColorMaterial is *not* enabled and White is the default glMaterial colour. * At line 497 you can see where I set up two material properties - one for the spotted side of the paper, the other for the stripes. Try changing *one* of the 'disable(GL_COLOR_MATERIAL)' calls to an 'enable'. Running the program again will show that one side of the paper is now covered with purple splotches. This is good. It's working just fine. * Now try enabling GL_COLOR_MATERIAL for *both* sides of the paper - and change the 'setMaterial(GL_EMISSION...)' calls to make one side of the paper emit (say) Blue light and the other side (say) Red. You might want to change the vertex colours to darker values to make this more obvious (because White+Anything is still White) - but even without doing that it's obvious in the shadowed areas. According to Curt's theory, this test should fail because we'd be making glMaterial calls while GL_COLOR_MATERIAL is enabled. But guess what? It works OK! Now, that's on a GeForce card with the nVidia Linux drivers. YMMV. In fact, I tried a dozen things - and SSG performed flawlessly in all situations....which suprised me quite a bit because other programs that I've written HAVE shown problems that appear to be GL_COLOR_MATERIAL related. 8-P -- Steve Baker http://web2.airmail.net/sjbaker1 sjb...@ai... (home) http://www.woodsoup.org/~sbaker sj...@ht... (work) |