PDA

View Full Version : Rendering using pBuffer



Mishuk
07-23-2004, 09:53 AM
Hi!
I'm trying to rendering noise in pBuffer and using it as texture.

My function is something like tha:

void OctaveManager::DrawReference(TextureO *Temp, TextureO* out)
{
wglReleaseTexImageARB
(mPbuffer,WGL_FRONT_LEFT_ARB)
wglMakeCurrent(mHdc, mHglrc)
glClear(GL_COLOR_BUFFER_BIT);

glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
Noise.Bind(); //here i bind the noise table texture
DrawQuad(); i draw the qaud
Temp->RenderToTexture(rand()%479, rand()%479);
//Here i cut the using glCopySubImage2D into a empty texture Temp

glClear(GL_COLOR_BUFFER_BIT);
// again i clear the pBuffer
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();

Temp->Bind(); Bind ing the new cutted texture
DrawQuad(); drawign quad

wglMakeCurrent(mPrevDC, mPrevRC);
out->Bind(); bind the output texture where i want to rendering data as texture
wglBindTexImageARB(mPbuffer, WGL_FRONT_LEFT_ARB)

}

No i call it from another function passing the noise and the target texture.

It is workign fine unless, i call 2 times one after another using to target texture.

For examle:

when i call,

DrawReference(noise, &texture1);

i get the content of the pBuffer as texture1,

but when i call:

DrawReference(noise, &texture1);
DrawReference(noise, &texture2);

to get the content in two texture, i got the problem is: the texture1 is blank. but texture2 is ok.

can anyone focus a light on this problem?

Tahnk you

3B
07-23-2004, 10:18 AM
It looks like you are trying to bind 1 pbuffer to 2 textures at once, don't think that will work...you either need a pbuffer for each texture, or use CopyTexImage to copy data from the pbuffer to the texture

Mishuk
07-23-2004, 10:52 AM
Is it not possible to bind rendering content into different texture from the same pBuffer.
Yes i'm trying to create 2 texture from same pBuffer.

I tried something like this:

Goto redering context;
Render the object;
Back to Original context;
Bind the content to texture 1;

Goto rendering context;
Render the object;
Back to Original context;
Bind the content to texture 2;

is it a mistake?

In practical, in my case texture one is lost,
but texture two is ok. What is the good way to do this?

Thank you