I’ve been fiddling around making things with jME for a little while now and have become moderately familiar with the inner workings of the engine. Something I’ve been working on recently requires that I’m able to modify the scissoring on a per geometry basis. To me, the obvious place for this seemed like RenderState so that it can be accessed per Material using getAdditionalRenderState(). I went ahead and tried it and it works fine. However, there are a few things I would like to clear up that stem from not having a complete understanding of the engine.
-
Am I way off base including this in RenderState? Does that make sense?
-
Whenever a ViewPort gets set on a Renderer, setClipRect() gets called too so that the scissoring matches the viewport. Obviously, this makes sense and is required for having more than one ViewPort on screen at a time. However this means that any “override” to glScissor via RenderState needs to be the intersection between this override and the existing ViewPort scissor settings so that things don’t end up where they’re not supposed to be. Obviously this override would be undone on the next run through applyRenderState() if the scissor is disabled. Am I missing anything here?
-
In situations when the scissoring from RenderState is enabled I ensure that GL_SCISSOR_TEST is actually enabled. However, as mentioned above, setClipRect() is getting called when the ViewPort is set and so glEnable(GL_SCISSOR_TEST) is always going to get called anyway. Is it necessary therefore to check that it is enabled? Is there any circumstance in which applyRenderState() can be called without setClipRect() having already been called first?
-
Is it satisfactory to leave these render states modified by applyRenderState? (And that goes for any of them, not just scissor.) Unless I’ve missed something, that’s how it appears to work. The implication being that nothing unusual can happen because everything is rendered via this process and when rendering occurs it will always be preceded by applyRenderState() that will ensure things are set up sensibly. This may seem like a dumb question, but it makes me slightly uncomfortable that things aren’t returned to some default state after a cycle of rendering has concluded, even if it is completely unnecessary.
I am sorry if this is a little noobish, I just wanted to make sure that I wasn’t doing anything completely stupid.