org.lwjgl.opengl.OpenGLException: Out of memory

Started by JudoVana, November 26, 2006, 09:29:51

Previous topic - Next topic

JudoVana

org.lwjgl.opengl.OpenGLException: Out of memory (1285)
       at org.lwjgl.opengl.Util.checkGLError(Util.java:56)
       at org.lwjgl.opengl.Display.swapBuffers(Display.java:567)
       at org.lwjgl.opengl.Display.update(Display.java:583)

Im relly confusessed about those errors.  How can I find what evoke it:(

But: Im programing an aplication to work with as great textures as possible.
If 'textures non power of two'  (get by  GL11.glGetString(GL11.GL_EXTENSIONS) or GL11.glGetString(GL11.GL_VERSION)) are not suported i remake the texture to nearest greater 2^m x 2^n size
(then)If the textures is greater then maxtexture size(get by GLApp.getSettingInt(GL11.GL_MAX_TEXTURE_SIZE); )  I resize it (I take care about 2^m x 2^n)   to this size this maxsize before i send it to OGL to be a texture. On my comupter (NPOT textures  are supported and maxtexture size =4096) works all ok (even greater textures are resized and all is ok. Even simulations where i set maxtexturesize  to a litle value and and NPOT set to false) all seems ok.

Problem begun when i run it on computer where max texture size was 4096  and  NPOTD was not supported. All runs ok until image size>4096 x 4096. By log it seems ok. Texture was set to 2^m x 2^n and resized to 4096 x 4096.  But  program crashed with  org.lwjgl.opengl.OpenGLException: Out of memory (1285) as was posted before.

Have anybody any idea?

Fool Running

Its possible (maybe unlikely :? ) that the video card supports textures like 4096x2048, but not 4096x4096. If that is the case, then you can check for a GL error after you attempt to send the texture to OpenGL and if that error is returned, reduce the y resolution by 1/2 and try re-send it.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

JudoVana

Thank you very much for idea. I will try. but it makes me unhappy. What is then maxtexture size for? And how i found the true maxsize during the run of programm (mans this irracional 2048*4096 in maxtexturesize 4096)?
I cant find anything abou checking error that way.


JudoVana

Quote from: "Fool Running"If that is the case, then you can check for a GL error after you attempt to send the texture to OpenGL and if that error is returned, reduce the y resolution by 1/2 and try re-send it.
How can i do this:((

Fool Running

QuoteYou were true:((
I was afraid of that. I've seen it once or twice before. :cry: You might check to make sure that the drivers are up-to-date on the crashing machine.
QuoteHow can i do this:((
Check GL11.glGetError() after you try to send the texture to OpenGL. If it returns GL11.GL_OUT_OF_MEMORY then that error occured.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

JudoVana

do you mean something like this?

render{
glBindTexture(...)
glBegin()
glEnd()
glGetError()

if (????==GL_OUT_OF_MEMORY) then setup(something)
}



But my application  wil never reach setup(..) because it crashdown somewere before.
I m realy sorry for out-of-topic but i have never worked with glErrors...:((

Fool Running

Something like:
GL11.glBindTexture(...);
if(GL11.glGetError() == GL11.GL_OUT_OF_MEMORY){
    // Reduce the width by 1/2 and try again
}
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

darkprophet

I wouldn't suggest doing that. Mainly because the driver should be offloading work onto RAM if vram is full (at least it should be). By the time an out of memory error has been thrown, its too late.

I would suggest doing GL11.glGetInteger(GL11.GL_MAX_TEXTURE_SIZE); and work on that...

Also, org.lwjgl.opengl.Util.checkGLError(); is very very handy and throws a LWJGL error if anything does go wrong, so you can get a stack trace too...

DP

Fool Running

The problem that he's having is that GL11.glGetInteger(GL11.GL_MAX_TEXTURE_SIZE) is returning 4096, but a texture of 4096x4096 crashes with a GL_OUT_OF_MEMORY error. A texture size of 2048x4096 seems to work, however. There isn't a clear-cut way to deal with that (to my knowledge).
QuoteI wouldn't suggest doing that. Mainly because the driver should be offloading work onto RAM if vram is full (at least it should be). By the time an out of memory error has been thrown, its too late.
I think its a driver limitation: It just throws a GL_OUT_OF_MEMORY because it doesn't know what else to throw. :cry:

It is possible that I'm crazy, though :lol:
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

darkprophet

ah right...my mistake.

Im guessing this card is intel right? :P

JudoVana