iDevGames Forums
Render-To-Texture? - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Render-To-Texture? (/thread-7061.html)



Render-To-Texture? - MacFiend - May 27, 2003 06:20 PM

I'm looking at the Render-To-Texture example located at http://www.pol-online.net/download.php?file=Render_In_Texture and it doesn't appear to work on MacOS X.2.6 (or nVidia geForce cards). Can anybody point out why?


Render-To-Texture? - kelvin - May 28, 2003 03:07 PM

Seems to work fine for me.
450Mhz B&W G3/Rage128 16MB/X.2.6

What seems to be the problem on your mac?


Render-To-Texture? - OneSadCookie - May 28, 2003 03:54 PM

I just get a white square on a black background on a GeForce4Ti.

I can't see anything wrong with the code, but it's clearly not working!


Render-To-Texture? - MacFiend - May 28, 2003 08:50 PM

Yes I have a geForce as well, and all I see is a black background with a white square. It seems, from the code, the square is supposed to change color randomly. Hmm.


Render-To-Texture? - kelvin - May 29, 2003 09:40 PM

Try this:

change the pixelformat attributes to the following:
[sourcecode]NSOpenGLPixelFormatAttribute attributes[] = {
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAAccelerated,
0 };
NSOpenGLPixelFormatAttribute attributes2[] = {
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAAccelerated,
0 };[/sourcecode]

This may fix pixelformat incompatability problems.


Render-To-Texture? - OneSadCookie - May 29, 2003 09:49 PM

Doesn't help (and it doesn't say invalid drawable in the console, which is what usually happens under those circumstances).


Render-To-Texture? - kelvin - May 29, 2003 10:13 PM

oh, the code is written wrong. I didn't look at it indepth because when I first ran it it made some color changing squares. Actually the pattern looks like invalid pointer access. Whoever wrote the demo is trying to make a texture from an offscreen context. This is fine and all, but 1)the texture is never updated and 2)he's trying to update it by changing it's context.

Code:
//this line is the dead give away:
    [mainContext createTexture:GL_TEXTURE_2D fromView:[offscreenWindow contentView] internalFormat:GL_RGBA];

from this point on, your results vary depending on what kind of memory GL is trying to read from. in my case GL was trying to get some of the actual context, so I saw some pretty garbage in the intervening space. (I thought this was intended but it is not.)

on your geforce's you're probably getting blank texture memory. I doubt this demo has any real value at all.


Render-To-Texture? - David - May 29, 2003 10:48 PM

Lugaru has neat render-to-texture Smile

For some reason some systems don't like it though :/


Render-To-Texture? - MacFiend - May 30, 2003 01:11 AM

What/who/where is Lugaru?


Render-To-Texture? - MacFiend - May 30, 2003 01:37 AM

Ok so obviously the previous example isn't going to work for me. So I tried Lesson #36 on NeHe (Radial Blur) which appears to have render-to-texture functionality. However, it STILL doesn't work. All I see is a plain twirly model spinning around, no blur...again this is on a geForce. Any ideas?


Render-To-Texture? - MacFiend - May 30, 2003 03:26 AM

I figured it out. Changing GL_LUMINANCE to GL_RGBA in the glTexImage2D function seems to fix it. It looks pretty cool. I guess I'll stick to this method. Thanks everyone.


Render-To-Texture? - OneSadCookie - May 30, 2003 04:46 AM

Quote:Originally posted by kelvin
Whoever wrote the demo is trying to make a texture from an offscreen context. This is fine and all, but 1)the texture is never updated and 2)he's trying to update it by changing it's context.

Code:
//this line is the dead give away:
    [mainContext createTexture:GL_TEXTURE_2D fromView:[offscreenWindow contentView] internalFormat:GL_RGBA];

I don't understand. What's wrong with this?