I have copied the back buffer with glCopyTexSubImage2D, but whenever I
display a shape with the texture, the intensity of the colours depend upon
the value that has been used for clearing the buffer, so if I clear with
glClearColor (1.0, 1.0, 0.0, 0.0);
and then draw a triangle using
glColor3f (1.0, 0.0, 1.0);
The copy the buffer, clear it to black and draw a shape with colour (1.0,
1.0, 1.0); using the texture coordinates, I will get a shape with the
corrext background colour, but the Triangle in the texture will be Red, the
blue value has been lost. Why does this happen?
Thanks,
Darren
|
|
0
|
|
|
|
Reply
|
Darren
|
10/7/2004 2:19:38 PM |
|
"Darren Guscott" <darren.guscott@nospam.baesystems.com> schrieb im
Newsbeitrag news:41654e03$1_1@baen1673807.greenlnk.net...
>I have copied the back buffer with glCopyTexSubImage2D, but whenever
>I
> display a shape with the texture, the intensity of the colours
> depend upon
> the value that has been used for clearing the buffer, so if I clear
> with
>
> glClearColor (1.0, 1.0, 0.0, 0.0);
>
> and then draw a triangle using
>
> glColor3f (1.0, 0.0, 1.0);
>
> The copy the buffer, clear it to black and draw a shape with colour
> (1.0,
> 1.0, 1.0); using the texture coordinates, I will get a shape with
> the
> corrext background colour, but the Triangle in the texture will be
> Red, the
> blue value has been lost. Why does this happen?
Send a code snippet starting with glClear anding with glEnd of drawing
the image you just copied with glCopyTexSubImage2D. It's really hard
to tell (for me) this way.
I guess you have not really allocated memory correctly or you have set
the wrong pixel format description when copying sub image...
|
|
0
|
|
|
|
Reply
|
Gernot
|
10/7/2004 2:32:57 PM
|
|
Here's the code, it is all in classes but I have just pulled them together
for this snippet.
wglMakeCurrent(m_hDC, m_hRC);
// Clear the buffers.
glClearColor (0.0, 0.0, 1.0, 0.0); // Clear to BLUE buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// perform OpenGL viewport and generic Initialisaion
glEnable(GL_TEXTURE_2D);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-25,25,-20,20,-1,1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
// Draw a GREEN triangle
glColor3f (0.0f, 1.0f, 0.0f);
glBegin (GL_TRIANGLES);
glVertex2f (10.0f, 10.0f);
glVertex2f (10.0f, 0.0f);
glVertex2f (-20.0f, 10.0f);
glEnd();
glReadBuffer (GL_BACK);
glBindTexture (GL_TEXTURE_2D, m_Texture);
if (asd == 0)
{
glCopyTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 256, 256, 0);
}
else
{
glCopyTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, 0, 0, 256, 256);
}
if ((x = glGetError()) != GL_NO_ERROR)
{
m_strLastError = "OpenGL error copying the back buffer to texture.";
return false;
}
// Clear the buffer.
glClearColor (1.0, 1.0, 1.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//Texture wrap to quad.
glColor3f (1.0f, 1.0f, 1.0f);
glBegin(GL_QUADS);
glTexCoord2f (0.0f, 0.0f);
glVertex2f (0.0f, 0.0f);
glTexCoord2f (1.0f, 0.0f);
glVertex2f (10.0f, 0.0f);
glTexCoord2f (1.0f, 1.0f);
glVertex2f (10.0f, 10.0f);
glTexCoord2f (0.0f, 1.0f);
glVertex2f (0.0f, 10.0f);
glEnd();
glFlush();
|
|
0
|
|
|
|
Reply
|
Darren
|
10/7/2004 3:06:12 PM
|
|
I now have it down to one function, If I only copy the backbuffer once, I
get the correct result, if I try to capture on every frame, then I get the
problems, this is when I am continually overwriting the same texture.
"Darren Guscott" <darren.guscott@nospam.baesystems.com> wrote in message
news:41654e03$1_1@baen1673807.greenlnk.net...
> I have copied the back buffer with glCopyTexSubImage2D, but whenever I
> display a shape with the texture, the intensity of the colours depend upon
> the value that has been used for clearing the buffer, so if I clear with
>
> glClearColor (1.0, 1.0, 0.0, 0.0);
>
> and then draw a triangle using
>
> glColor3f (1.0, 0.0, 1.0);
>
> The copy the buffer, clear it to black and draw a shape with colour (1.0,
> 1.0, 1.0); using the texture coordinates, I will get a shape with the
> corrext background colour, but the Triangle in the texture will be Red,
the
> blue value has been lost. Why does this happen?
>
> Thanks,
>
> Darren
>
>
|
|
0
|
|
|
|
Reply
|
Darren
|
10/8/2004 9:54:37 AM
|
|
|
3 Replies
136 Views
(page loaded in 0.334 seconds)
|