LWJGL Forum

Programming => OpenGL => Topic started by: dronus on October 26, 2005, 08:05:22

Title: OpenGL vs. Java state buffering
Post by: dronus on October 26, 2005, 08:05:22
While working on a growing complex thing, i'm in question if it would be usefull to hold gl's state local rather than in OpenGL only.
It is stated by OpenGL specs that many state changes are instantly done without checking for neccesserity involving maybe costly functions.

So even if i try to ceap my states clean, often a glPushAttrib is more convinient, and maybe i set states even if they are already set. As LWJGL is a kind of bottleneck making gl calls more costly as they woul be in c, is seems useful to cache the state on Java-side, only telling the real changes to gl, and maybe even replace glPush/PopAttrib by single state setters, if only a few values are modified.

Somebody any experience/opinion to that? As this seems quite complicated, i dont like to implement only to see there is no factual performance gain...

thanks
Paul
Title: OpenGL vs. Java state buffering
Post by: princec on October 26, 2005, 17:26:13
We would like to keep the LWJGL a pure binding with the minimum of bells and whistles, and allow others to build this kind of thing on top as they see fit.

Cas :)
Title: hmmmmm...
Post by: Fool Running on October 26, 2005, 19:33:46
I think he's asking if there would be a performace benifit for him to do it in his project as he is setting the OpenGL state without checking it beforehand.
Unfortunatly, I don't know the answer  :lol:
EDIT: my guess would be it would be a benifit since JNI is expensive.
Title: OpenGL vs. Java state buffering
Post by: spasi on October 26, 2005, 20:17:43
Besides the JNI overhead (which is not that important), it is ALWAYS a good idea to cache GL state and only change what needs to be changed. Keep in mind that the cost of an unnecessary state change may be far greater than a simple JNI call.
Title: OpenGL vs. Java state buffering
Post by: dronus on October 26, 2005, 22:33:53
hmm yeah.. "maybe far greater".. but maybe not? if gl is as optimized one might think, the most state changes would maybe actually be reflected in a new saved state and nothing else.. until some operation evaluates it.

maybe i should go for a test ride.

thanks
Paul


EDIT: ps.. cas..   fool runing was right... hey you fell your "baby" attacked quite fast, huh? :-)    so i state:
"yes, i confess to know lwjgl is just a most simple wrapper to opengl" and beeing a hardcore specs freak: thats just the way it should.  *g*