Thread: [Plib-users] Texture remains enabled after first use
Brought to you by:
sjbaker
From: Daniel S. <djs...@uc...> - 2004-12-30 19:45:06
|
Hi - I have a simple app which draws a textured shape, then draws a non-textured (solid color) shape. Problem is that the non-textured shape uses the same texture that the textured shape did. Full disclosure: My non-textured shape is a custom class derived from ssgaShape. It implements a rectangle in this test phase. If I reverse the order that the shapes are added to the root, the problem disappears. If I explicitly use a state (for the non-textured shape) that calls rect_state -> disable ( GL_TEXTURE_2D ) ; then the problem disappears also. It seems that when a leaf which uses texture is rendered, the GL state GL_TEXTURE_2D remains enabled until it is explicitly disabled. Is this by design? If so, is this true of other enable/disable states? Thanks, Dan |
From: Steve B. <sjb...@ai...> - 2004-12-30 21:15:00
|
Daniel Sperka wrote: > If I explicitly use a state (for the non-textured shape) that calls > rect_state -> disable ( GL_TEXTURE_2D ) ; > then the problem disappears also. That is the correct solution. The way ssgState works (and in retrospect, this may not have been so smart) is that each attribute (like texture being enabled) has THREE states: Enabled, Disabled and Don't Care. By default, everything is Don't Care. So if you don't explicitly disable or enable texture, you'll get whatever state was last applied. This is a good thing for *most* state elements because very often you don't care what state the graphic pipe is in for many of the states and SSG can save time by not making lots of redundant state change calls. > Is this by design? Yes. > If so, is this true of other enable/disable states? Yes. ---------------------------- Steve Baker ------------------------- HomeEmail: <sjb...@ai...> WorkEmail: <sj...@li...> HomePage : http://www.sjbaker.org Projects : http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net -----BEGIN GEEK CODE BLOCK----- GCS d-- s:+ a+ C++++$ UL+++$ P--- L++++$ E--- W+++ N o+ K? w--- !O M- V-- PS++ PE- Y-- PGP-- t+ 5 X R+++ tv b++ DI++ D G+ e++ h--(-) r+++ y++++ -----END GEEK CODE BLOCK----- |
From: Daniel S. <djs...@uc...> - 2004-12-30 21:47:01
|
Thanks, Steve. Sounds like the best thing is to create a dummy SimpleState and use it for ALL objects in the tree. If I use texture anywhere, create a distinct SimpleState and use it for those objects that need it, and make certain that the dummy state explicitly disables GL_TEXTURE_2D. Same goes for other GL states. Dan |
From: Steve B. <sjb...@ai...> - 2004-12-31 14:33:04
|
Daniel Sperka wrote: > Sounds like the best thing is to create a dummy SimpleState and use it > for ALL objects in the tree. If I use texture anywhere, create a > distinct SimpleState and use it for those objects that need it, and make > certain that the dummy state explicitly disables GL_TEXTURE_2D. Same > goes for other GL states. Yes - that's certainly a reasonable approach. What I do in my games is to use the ssgLoaderOptions::setCreateStateCallback() to have the loaders call my application whenever a new ssgState is needed. I use the texture filename to look up the full desired GL state in a text file that I load separately on startup. All polygons without texture (and there are VERY few of those in my applications) are given a 1x1 pure white texture instead - so SSG doesn't have to turn texture on and off. I also use that to set things like the Alpha clamp value that AC3D doesn't give you a way to set in the model. That text file also tells my application things about the polygons (such as their 'solidity', their coefficient of friction and their temperature) that SSG doesn't need to know - but which matter in the game. It's really easy to tag my fire texture as being hot and insubstantial, and my ice texture as being cold, hard and slippery. There is also a default entry in the table for polygons with textures that aren't listed in the file. I also (in my son's first serious game effort) swap out some polygons for particle systems based on their texture. So I paint a texture which is red with the words "IMAGINE A FIRE HERE" written on it. You can model a triangle with that texture on it - and when that model loads, the game's loader will replace it with an ssgaFire of similar size. Now you can light fires in your game level just by dropping in these special polygons in AC3D (or whatever). Someday, it would be nice to make that feature be a part of ssgAux, but I don't have the time right now. ---------------------------- Steve Baker ------------------------- HomeEmail: <sjb...@ai...> WorkEmail: <sj...@li...> HomePage : http://www.sjbaker.org Projects : http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net -----BEGIN GEEK CODE BLOCK----- GCS d-- s:+ a+ C++++$ UL+++$ P--- L++++$ E--- W+++ N o+ K? w--- !O M- V-- PS++ PE- Y-- PGP-- t+ 5 X R+++ tv b++ DI++ D G+ e++ h--(-) r+++ y++++ -----END GEEK CODE BLOCK----- |