OpenGL State Changes

Started by
3 comments, last by aleks_1661 20 years, 8 months ago
redundant state changes can cost performance, would using a function such as the following improve performance by detecting redundant calls or does opengl do this anyway?

void fglEnable( int cap )
{
	if ( !glIsEnabled(cap) )
	{
		glEnable(cap);
	}
}
"Very funny, Scotty. Now beam down my clothes." [edited by - aleks_1661 on August 10, 2003 10:35:05 AM]

Twitter: [twitter]CaffinePwrdAl[/twitter]

Website: (Closed for maintainance and god knows what else)

Advertisement
it would only slow it down. and if you are calling it alot, it would be very noticable.
Beer - the love catalystgood ol' homepage
Most implementations will check to see if the state change is redundant before flushing the pipe.
thats what i thought, cheers

Twitter: [twitter]CaffinePwrdAl[/twitter]

Website: (Closed for maintainance and god knows what else)

Some implementations don't (or rather, you can't count on that being a guarantee). Another possibility is to store your own states as you modify them in OpenGL. Then you could just check your own value for redundancy in your routine that sets the state.

Again, I don't know how big of a deal that is.

The best way to avoid many state changes is to group your objects such that the state changes are kept to a minimum.

[edited by - Waverider on August 10, 2003 11:19:29 AM]
It's not what you're taught, it's what you learn.

This topic is closed to new replies.

Advertisement