PDA

View Full Version : WGL_ARB_render_texture and glGetTexImage



Asgard
08-12-2002, 05:29 AM
Hello,

I've got a weird problem with render-2-texture and reading out the rendered image from the texture object.
What I do is, create a pbuffer, render some scene to that pbuffer and then create a texture object, bind it and finally bind the color buffer of the pbuffer to the texture object by calling wlgBindTexImageARB.

Now if I render a quad using the texture everything is fine. The scene rendered to the pbuffer before appears correctly on the quad.
But if I try to retrieve the image (after having called wglBindTexImageARB) by calling glGetTexImage, the heap gets corrupted because glGetTexImage apparently copies more memory than my application expects. The pbuffer has a size of 256x256 and has 32 bits depth. Therefore I create a buffer of 256x256x4 = 262144 bytes that I then pass to glGetTexImage. However the returned data is some 3000 bytes larger. Why?
This occurs with the latest Nvidia 30.82 drivers on a GeForce2 as well as on an ATI Radeon 8500.
I'd appreciated any helpful ideas on what I'm doing wrong and why glGetTexImage returns more than 262144 bytes.

Also another thing that only occurs on the Radeon 8500: If, after retrieving the image with glGetTexImage, I try to write it back to the texture by calling glTexSubImage2D, I get an access violation in the ATI OpenGL driver. Works fine with Nvidia though, and according to the WGL_ARB_render_texture specs I think it should be possible.

Cheers.

Asgard
08-13-2002, 02:36 AM
Well, I did some more investigating, and it turns out that the problem only occurs when I try to call glGetTexImage with GL_RGBA as base format. If I use GL_RGB it works fine, even though the pbuffer has been created with the attribute WGL_TEXTURE_RGBA_ARB.
With a "normal" texture, both GL_RGB and GL_RGBA work fine and it doesn't matter what internal format the texture has.

Does anyone have any ideas on what I'm doing wrong, or is this a driver bug (with both Nvidia and ATI drivers)?

Regards,
Asgard

Asgard
09-04-2002, 05:40 AM
I'm replying to myself again...to an admittedly rather old post that describes a problem of mine that still hasn't been solved unfortunately.
Instead of the problems described above, I now get an access violation in NVOGLNT.dll, using the new NVIDIA 40.41 drivers, whenever I call glGetTexImage on a texture used for render-2-texture (after it was bound to a texture object).

Has anyone here ever successfully managed to call glGetTexImage on an RGBA render-2-texture texture?

Regarding the problems with the ATI Radeon 8500 described in my first post: They seem to be connected to the fact that I can't get render-2-texture work at all with the Radeon. The rendering to the pbuffer works fine (which a glReadPixels shows), but when I bind the color buffer of the pbuffer to a texture object, the image is lost and all I get is a white texture.
I tried the simple NVIDIA WGL_ARB_render_texture example (http://developer.nvidia.com/docs/IO/2669/ATT/simple_render_texture.zip), and all I get with it is again a white quad. Then I also tried the RTT demo here http://www.delphi3d.net/oldnews.php?page=3, which causes a reboot when switched to use the WGL_ARB_render_texture extensions on the Radeon.
Any Radeon users here who have RTT up and running?

[This message has been edited by Asgard (edited 09-04-2002).]

Humus
09-04-2002, 09:09 AM
RTT works just fine for me. I've had problem with rendering to a cubemap with some driver before, notified ATi about the problem, not sure if it ever got fixed, never returned to that code.

Anyway, you may want to look at my "Refractions and reflections" or "Refractions" demo at my site (http://esprit.campus.luth.se/~humus/?page=3D) .

Asgard
09-04-2002, 09:21 AM
Hello Humus,

Thanks for your reply. I'm actually trying to render to a cube texture.

I looked at your (really nice) demos and I'm pretty much doing everything the way you are...not everything though, since my project is a rather large engine, so the GL calls are scattered all over the place. The only thing I do differently from your code, is that I call wglBindTexImage before I switch back to the window render context. So I changed that, but still, the cube map stays white on the Radeon. Everything works fine on my GeForce though.

Could you please try the simple NVIDIA exmaple of which I posted the link above on your Radeon? Maybe something is wrong with my driver installation, although I just recently installed the newest XP driver.

Cheers.

PH
09-04-2002, 09:25 AM
I have RTT running on my 8500 too. Last time I tried the Delphi3D demo, my system locked up.

Humus
09-04-2002, 12:02 PM
The Delphi3D demo hangs my system, the nVidia demo works though (except that when it exits the app goes nuts and goes into an infinite loop filling the console with zillions of "Win32 Error: 6").

Anyway, I'd guess it's a driver bug. Not sure why it never got fixed, ATi is usually very quick on fixing driver problems and providing feedback, but apparently not with this problem, I've notified ATi two times about it. I'll check my old rendering to cubemap code and see if it still crashes.

Humus
09-04-2002, 12:09 PM
Well, back again after testing to old projects that I never finished because of this problem. Both locked my computer. Guess it's time to notify ATi about it again ...
I had rendering to cubemap working half a year ago or so, but then it got broken and never seams to be fixed.


[This message has been edited by Humus (edited 09-04-2002).]

mcraighead
09-04-2002, 12:36 PM
To the best of my knowledge, GetTexImage should work fine with render_texture in our latest (release 40) drivers. If you see otherwise, send me a test app.

- Matt

Asgard
09-05-2002, 03:53 AM
Matt, I wish I could send you a sample app that easily, but I can't reproduce it with a simple OpenGL app and I don't have the time to write an OpenGL app that does the same things in the same order my engine does. It's just too much code to go through, and I make a lot of OpenGL calls while the pbuffer's context is current.

The bottom line is this: For various architectural reasons, my engine does wglBindTexImage before switching back to the window rendering context (which shouldn't be a problem). The pbuffer and window contexts share objects.
I can successfully call glGetTexImage on the texture in between wglBindTexImage and wglMakeCurrent(windowRC). But after the wglMakeCurrent (and binding the texture object again), using the exact same code to call glGetTexImage, I get an access violation in the driver.

If I can recreate it in a simple example, I'll send you the app. But I doubt that I'll find time for it. Anyway, I can live without using glGetTexImage for now. I could send you my entire project, as I'll open source it sooner or later anyway, but it's around 5 meg source code alone, and I don't think you want to debug through all that ;-)

On the RTT issue with the Radeon: I just installed the newest XP drivers (again) and the newest drivers on Win98 on the same machine. But all I get when trying any RTT demo (even the simple NVIDIA demo) is a white texture. I give up.

PH
09-05-2002, 04:00 AM
On the RTT issue with the Radeon: I just installed the newest XP drivers (again) and the newest drivers on Win98 on the same machine. But all I get when trying any RTT demo (even the simple NVIDIA demo) is a white texture. I give up.


What drivers are those ? NVIDIA's simple_render_texture works with the 6143 Win2000 drivers. With some of the older drivers, I got a white texture too. There's still a viewport bug in those but I have a feeling it'll be fixed soon http://www.opengl.org/discussion_boards/ubb/smile.gif. GetTexImage didn't work with the Catalyst 2.2 ( I haven't tried with the 6143 ).

Asgard
09-05-2002, 04:08 AM
They're the 6.13.10.6118, released August 1, from ati.com. Where did you get those newer drivers from? Thanks.

Asgard
09-05-2002, 04:13 AM
Nevermind. Just found them after a bit of googleing http://www.opengl.org/discussion_boards/ubb/smile.gif

Humus
09-05-2002, 12:50 PM
If you're looking for the latest driver (including leaked ones) on ATi hardware Rage3D (http://www.rage3d.com) is usually a safe bet.