pbuffers and ATI

Hi all,

I have a problem related with pbuffer rendering and ATI cards…I was trying to make GKW’s RTTDemo work with ATI cards so as to see how rendering to texture works. Although the same demo works flawlessly with NVIDIA cards, when I’m trying to use an ATI card I get the following exception :

net.java.games.jogl.GLException: pbuffer creation error: wglChoosePixelFormatARB() failed…

Although I changed the texture_rectangle parameters so as the demo to use only square power of two drawable contexts, the problem remains (in ATI cards). Searching a little more I found out that if
GLCapabilities.setOffscreenRenderToTextureRectangle( true );
wasn’t used, then the demo executed normally, but without rendering anything to texture! The same code executed perfectly on an NVIDIA card, so there must be something about ATI cards, or I might be missing something obvious.

Any clues? GKW?

TIA

N

ATI cards do not support setOffscreenRenderToTextureRectangle(true) since they don’t support rendering to a non-power of two texture. Even though ATI supports non-power of two textures via extension they have yet to come out with a render to texture rectangle extension and at this point I doubt they will. I am guessing that if you still see a white cube rotating that you still have GL_TEXTURE_RECTANGLE_NV enabled rather than GL_TEXTURE_2D.

1- Make sure your pbuffer is a power of two

2- Make sure you have enabled GL_TEXTURE_2D instead of GL_TEXTURE_RECTANGLE_NV

3- Make sure your pbuffer is single buffered. If you are using render to texture you MUST have a single buffered pbuffer. Right now Jogl only supports single-buffer pbuffers even though you can have double-buffered pbuffers legally.

GKW, you were right, I had not set GL_TEXTURE_2D mode. But still, the problem partially remains : I now see a black cube (instead of a white one), but there is nothing drawn on the texture. The same thing happens when testing it with nVIDIA. My pbuffer is a power of two and it is not double buffered…

Try changing the clear color for the framebuffer. If that does change the color of the texture then you probably have the viewmatrix set up wrong or something of that nature. Also make sure you are binding and unbinding the pbuffer. Drawing to a bound pbuffer is undefined so that may cause a blank texture.

Clearing the color for the framebuffer with a specific color does work but when using GL_TEXTURE_2D mode

a) on ATI cards, if I use a red clear color, I see a red cube. On nVidia cards, I see a white cube

b) when using setOffscreenRenderToTextureRectangle and GL_TEXTURE_2D, ATI card throws the wglChoosePixelFormatARB() failed exception, and nVidia displays a white cube (again)

so, the code only seems to work when GL_TEXTURE_RECTANGLE_NV mode is used and offscreenRenderToTextureRectangle is enabled. The only thing I did was changing texture modes, and using(or not) offscreenRenderToTextureRectangle capabilities. Since I use square, power of two textures, and the behavior of the two cards for the same code and GL_TEXTURE_MODE is totally different, I’m starting to think that pbuffer rendering with jogl DOESN’T work on ATI cards. GKW, if it is not too much trouble, would you like me to send you the modified RTTDemo code so as to check it yourself?

N

ATI cards will not render to a rectangular texture so don’t even bother asking for it. If you ask for a rectangular texture on a nvidia card then you have to use GL_TEXTURE_RECTANGLE_NV as the texture token not GL_TEXTURE_2D. Go ahead and post the code here.

OK, here (http://students.ceid.upatras.gr/~mantesat/RTTDemo.java) is the modified code of GKW’s RTTDemo. Note that I don’t want to use rectangular textures with ATI cards, but only square, power of two textures.

You need to change the texture coordinates from the [0,w/h] range which you use for texture rectangles to [0,1] which is used with normal textures.

glTexCoord2f( 256.0f, 0.0f ) --> glTexCoord2f( 1.0f, 0.0f )

!!! I haven’t noticed that texture coords had changed! (How stupid of me, that’s what happens when someone uses replaceAll when editing code…)

Thanks GKW, it now works fine!