Is it possible to find out a gpu’s memory status in jogl?
I think the answer is no, not just for jogl, but OpenGL. You can find whether a given texture could load, using GL_PROXY_TEXTURE_2D for target & NULL for the texels of a glTexImage2D call. Perhaps you could write a routine that does this in a loop, increasing the size until it no longer fits. The result would be the largest single texture that could ever fit on this gpu. See red book, pg. 380.
[quote=“AI_Guy,post:2,topic:30986”]
If you just want the largest texture size possible, then just use glGet() with GL_MAX_TEXTURE_SIZE.
I guess I could use com.sun.opengl.util.texture.Texture.getEstimatedMemorySize(); with GL_MAX_TEXTURE_SIZE to calculate the space used… but what about vertex buffers and display lists?
com.sun.* classes are VM dependant and subject to change/removal between vm versions. Using them means your code will probably break on different vms/platforms.
Rather use glGet :
IntBuffer buffer=BufferUtil.newIntBuffer(1);
gl.glGetIntegerv(GL.GL_MAX_ELEMENTS_VERTICES,buffer);
Nevertheless, it gives you only the maximum count of vertices that should be drawn with a drawArrays() call (or any methods doing the same thing). If there aren’t enough memory, a GLException is thrown when you create a VBO or a display list. Nevertheless, it depends on the implementation. Sometimes, an error is generated and the program crashes.
Regarding the opengl-classes Ken recently disagreed: http://www.java-gaming.org/forums/index.php?topic=17635.msg138562#msg138562
GL_MAX_TEXTURE_SIZE is just of the maximum size of a dimension of a texture. I can envision that the above giving a low #, because what if a 4 component, of 32 bit float, texture of GL_MAX_TEXTURE_SIZE size is less than the maximum amount? If GL_MAX_TEXTURE_SIZE was 2048, this texture would be:
2048 * 2048 * 4 * 4 = 67mb.
I have to also withdraw my suggestion. There is no way to know how GL_MAX_TEXTURE_SIZE relates to the amount of memory in any given graphics card.
Unless, maybe need to use 3 dimensional textures.
And you are correct, GL_MAX_TEXTURE_SIZE actually has little to nothing to do with the amount of memory. A Geforce 8100 with 32MB or ram all the way up to a Geforce 8800 with 768MB of ram will both report 4096 because that’s the biggest texture their texture units can address.