Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Qrikko

States, little help needed...

This topic is 5128 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I''m trying to wrap som OGL and create some kind of an easy 2D engine. But I have a problem with this whole state based paradigm. Well as I said I have one little problem, say that i have a textured 3D model, that can be in different "states" like: alpha-blended, lighting on/off, drawing visual rep. of normals or enviroment maped. Then I would like to have some kind of "callbacking" from the states... so I want to get rid of code like: if(alpha) alpa on; if(lighting) lighting on; ... I would like to have a "state checking routine" something like: if(state_updates_have_occured) update_state(); but I can''t seem to find a good way of doing it.. as I thougt of it I might create a class "statmachine" that have all the attributes, and my objects have a instance of it, and if some state changes it will have a bool member "has_changed" that would be used to see if update is nessecery... but I don''t know what the best way to attack the problem is, so if someone have som clever solution to it i''ll be glad //Qrikko "All it takes is for the rendered image to look right" -Jim Blinn

Share this post


Link to post
Share on other sites
Advertisement
I see. So you really don''t want to have to check the states each time around, only if you know that somehow they''ve changed.

Ultimately, you''d have to wrap the entire state system OGL uses into your own classes like you proposed if you wanted some sort of callback mechanism, because as far as I know OGL doesn''t have anything like that built-in. That, or you go with the old system you''re using and just wrap that up into a nicer system.

Share this post


Link to post
Share on other sites
Well then I''m not aming totaly wrong then

It''s actualy not that big a deal either, just feels like it''s kind of ugly to check it each and every time i would like to render... my thought of the statemachine was simply that if every renderable object have an instance of the statemachine every renderable object would not have to do all controling every time.. but than again it would be pretty hard to have full controll over it taken that opengl is entierly statebased in itself...

well I''ll think of it some more, but if someone have had the same kind of problem pleas tell me

It would be intresting to know how OpenGLs "glEnable" works.. someone that knows? It would maby help me out a bit.

//Qrikko

"All it takes is for the rendered image to look right" -Jim Blinn

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!