RenderState idea

Inside MaterialState, create the variable

public static MaterialState prevState;



Inside LWJGLMaterialState.apply(), add the following at the top.



if (MaterialState.prevState == this) return;

MaterialState.prevState = this;





I tried this on a scene with 200 objects sharing states, and got about 30+ FPS increase. This could extend to all states in a similar way. Just reset the prevState during displayBackBuffer. Will this work, or am I missing something about OpenGL?

I like the idea, but I think that we should use the Equal function instead of ==. This would handle a case where there are two States that are identical but have different instances. Also what would happens if one of the program called opengl directly? I think that this feature should be optional to handle such a case.

Render state type calls would be a render state. If someone needed to make an OpenGL call that they knew wouldn’t play well with MaterialState, they could just do MaterialState.prevState=null; after their call. Only developers would make OpenGL calls, so we would know when to add this. Users shouldn’t make OpenGL calls, so it wouldn’t affect them. And any user that wants to make OpenGL calls and change core jME classes in their game, you’ld assume would know LWJGL enough to know when to null a prevState.

"Cep21" wrote:
Render state type calls would be a render state. If someone needed to make an OpenGL call that they knew wouldn't play well with MaterialState, they could just do MaterialState.prevState=null; after their call. Only developers would make OpenGL calls, so we would know when to add this. Users shouldn't make OpenGL calls, so it wouldn't affect them. And any user that wants to make OpenGL calls and change core jME classes in their game, you'ld assume would know LWJGL enough to know when to null a prevState.
Good point, I should of thought of that. ://

We use that sort of speed up in several other places in the state code so that probably would be fine.