View Full Version : Copying from the back-buffer

07-09-2003, 01:28 PM

i try to make a dynamic cubemap. For this i first render the six cubefaces into the backbuffer and want to make a cubemap out of them. To ensure that the rendering is over before i call glCopyWhatever, i call glFinish. However this seems not to work. The program runs for some seconds, and i can see that the cubemap is white (which means, there was some error, so that the cubemap is "invalid" and therefore white). Then the program crashes with an "abnormal program termination".
So now i guess, that glFinish didnīt do the job i expected and therefore copying was done during rendering, which might yield to a crash. Could that be? I checked everything. Rendering works pretty fine, only when i add the copy-stuff it crashes.

Any ideas?

BTW: @Nutty: I took a program from your page to see how you have done that, but the copying from the framebuffer is not included in the source-code. So how have you done that?

[This message has been edited by Jan2000 (edited 07-09-2003).]

07-09-2003, 01:52 PM
glFinish should not crash your app.
there must be something other wrong with your code.
did you checked your code for errors with glGetError() ?
in most cases, checking for this errors helps a lot to tack down your problems...

07-09-2003, 02:18 PM
Ah, yes i have one error.

glCombinerParameteriNV (GL_NUM_GENERAL_COMBINERS_NV, 0);

This creates an error. Well, i guess it is not allowed to have 0 general combiners. Althoug i copyed&pasted this one from an nVidia presentation!
Well, i use 1 gc now, and donīt get any error from glGetError.
And still it crashes after 3 to 5 seconds!


07-10-2003, 03:01 AM
line 562 of main.cpp


The functionality is basically hidden in the texture class. All it does is a glTexCopySubImage.

I use a glFlush afterwards, not glFinish. In actual fact, I dont think you need _any_ synchronization methods when updating textures from the framebuffer, as subsequent rendering commands wont be executed until the copy is finished anyway. I'm not 100% sure on that, but I recall it working without it, I just put it in for safety.


07-10-2003, 03:03 AM
P.S. If it crashes after a few frames, perhaps you have uneven Push/Pop, which eventually overflows and crashes. Count the number of pushes, and pops in your code, they should be even.

07-10-2003, 03:40 AM
Hm, i donīt use any pushs/pops, and it really only crashes, when i do the copying.
But iīll try glTexCopySubImage instead of glTexCopyImage.


07-10-2003, 05:50 AM
Strange. I switched to glCopyTexSubImage and now it works. First i tried the other function with GL_LUMINANCE (as a test). In this case i still got a white texture, but it didnīt crash anymore. So might there be a problem with GL_RGBA8 for cubemaps? Itīs the same format i used, when i created the texture.
Anyway, for glCopyTexSubImage you neither have to specify the format nor the border.
BTW: The other function did not return any error. Maybe there is a bug in the driver, which yields to this crash and doesnīt give out any error message. AFAIK the specs always say "Allow program termination, but donīt crash.".
Well, if itīs a bug, itīs one i can live with.


07-10-2003, 06:32 AM
Does anyone know, if i can flip the image when copying from the framebuffer? My cubemap is upside-down when i get it from the framebuffer. I tried it with negative values, but that seems not to work. Well, of course i could do it with other texcoords, but than all my Skyboxes would be upside-down. Itīs really annoying, that images are sometimes stored top-to-bottom and sometimes the other way round. *sigh*