problems with rendering to texture



Hi.

I have a problem with rendering to texture. I'm using glCopyTexImage2D
function. When I'm trying to render a cube where each vertex has different
color I get texture with image of cube having all vertices with the same
colour. Precisely this is the colour of the last rendered vertex.

int viewport[4];
glGetIntegerv(GL_VIEWPORT,(int*)viewport);
glViewport(0,0,w,h);

/*The cube is untextured so I have to turn of the texturing
to display colors. Maybe this is the problem. */

glDisable(GL_TEXTURE_2D);

/*here I'm rendering the cube*/
renderCube();
glEnable(GL_TEXTURE_2D);

glBindTexture(GL_TEXTURE_2D, texture[0]);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, w, h, 0);


glViewport(viewport[0],viewport[1],viewport[2],viewport[3]);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex3f(0.0f, 0.0f,0.0f);
glTexCoord2f(1.0f, 0.0f);
glVertex3f(1.0f, 0.0f,0.0f);
glTexCoord2f(1.0f, 1.0f);
glVertex3f(1.0f, 1.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f);
glVertex3f(0.0f, 1.0f, 0.0f);
glEnd();

Can anyone help?
Thanks.
.



Relevant Pages

  • Re: display list optimization / performance
    ... I use hierarchical rendering, lets say a cube, used in many ... largely biased to the overhead. ... actually gain the performance of display lists. ...
    (comp.graphics.api.opengl)
  • Text without Z buffer
    ... I want to label my vertices, which I'm rendering as cubes, with red text ... display with nothing else drawn. ... If I try to display my text at the same point where the cube is rendered, ... disabling the depth buffer before rendering prevents newly drawn pixels ...
    (comp.graphics.api.opengl)
  • Re: attach texture to a cube.
    ... To do this accurately you will need to split the cube into 6 subsets, ... Also note if your cube only has 8 vertices you will need 2 texture coords ... The tex coords for each vertex will then be. ... To map the texture just call Device->SetTexture before rendering each side. ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Rendering grid of cubes. Ray casting?
    ... I m interested in rendering a grid in the x,y plane. ... represents a cube of the respective height. ... The view point would always be the bird's eye view of the grid. ... num is the number of visible cubes ...
    (comp.graphics.algorithms)
  • Re: Text without Z buffer
    ... I am showing text using glCallLists after the rest of my scene is rendered, and it works just fine as long as I offset the text to an area of the display with nothing else drawn. ... If I try to display my text at the same point where the cube is rendered, ... disabling the depth buffer before rendering prevents newly drawn pixels from being obscured. ...
    (comp.graphics.api.opengl)

Loading