PDA

View Full Version : glCopyTexImage



powerpad
07-07-2005, 12:17 AM
I render a scene to my viewport and create a rectangular texture. I want to render the viewport to that rectangular texture which works just fine if i define the texture's format to be rgba, however, if the format is rgba32f_ so a 32bit floating point texture the rendering speed drops amazingly.

can someone tell me please what i did wrong or how to do it better (with respect to glCopyTexImage)

here is some code


//set up texture
Gl.glGenTextures(1, out this.iTexture);

Gl.glBindTexture(Gl.GL_TEXTURE_RECTANGLE_ARB, this.iTexture);

Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_MODULATE);
Gl.glTexParameteri(Gl.GL_TEXTURE_RECTANGLE_ARB, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_RECTANGLE_ARB, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_RECTANGLE_ARB, Gl.GL_TEXTURE_WRAP_S, Gl.GL_CLAMP_TO_EDGE);
Gl.glTexParameteri(Gl.GL_TEXTURE_RECTANGLE_ARB, Gl.GL_TEXTURE_WRAP_T, Gl.GL_CLAMP_TO_EDGE);

Gl.glEnable(Gl.GL_TEXTURE_RECTANGLE_ARB);
//rendering stuff Gl.glBindTexture(Gl.GL_TEXTURE_RECTANGLE_ARB, this.iTexture);
//render scene Gl.glCopyTexImage2D(Gl.GL_TEXTURE_RECTANGLE_ARB, 0, Gl.GL_RGB32F_ARB, 0, 0, 640, 480, 0);

jide
07-07-2005, 12:50 AM
Just use RGB and not RGBA. There's absolutely no need for the alpha channel that consumes memory but is not used at all.

Hope that helps.

powerpad
07-07-2005, 03:53 AM
it still runs slow (if one could call that running)

carl_lewis
07-07-2005, 04:29 AM
try using glCopyTexSubImage(...);
it's much much quicker!



the RGBA32 format uses 32 bits per channel, so that's 4x the memory access of a standard RGBA format. it should take longer.

Jan
07-07-2005, 06:07 AM
Is your framebuffer RGBA8 or RGBA32 ?

powerpad
07-07-2005, 10:42 AM
I setup the framebuffer with the normal pixel format like PFD_TYPE_RGBA (I hope that this is what you mean) or so ... should I use something different?

Omaha
07-07-2005, 11:22 AM
I think they are referring to the format and internal_format parameters of all of the glTex*Image* calls.

powerpad
07-07-2005, 11:59 AM
well the glcopyteximage() call is visible in my first post

Overmind
07-07-2005, 01:03 PM
No. The question was what pixel format does your framebuffer have?

Because if the framebuffer has RGB(A)8 fixed point format, the glCopyTex(Sub)Image call with internal format RGBA32F has to do a format conversion (in the worst case this has to be done on the CPU), while with internal format RGBA8 it can simply copy the data...

powerpad
07-08-2005, 12:56 AM
How I can I set this up or query for the framebuffer format?

Jan
07-08-2005, 01:22 AM
The question is: Why do you want to copy RGBA8 data from your framebuffer into a RGBA32 texture? You don't gain anything from that.

However, if you want to render 32 Bit data to your texture, you should check out the "Framebuffer Object" (FBO) extension.

Jan.

powerpad
07-08-2005, 06:37 AM
I want to implement some algorithm that is described in a paper. Therein geometry is processed by a pair of shaders (that forwards the x,y,z coordinate of a vertex to the fragment shader - the fragment shader writes x,y,z to r,g,b color values - this I figured I need a floating point texture).