Copying from the back-buffer

Hi,

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?
Jan.

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).]

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…

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!

Jan.

line 562 of main.cpp

g_cubemap->Update(CubeMapDefines[i]);

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.

Nutty

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.

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.

Jan.

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.

Jan.

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

Jan.