OK i think we are getting somewhere I made the changes you said and now the cube is completely black except for the edges that have some white pixels.
Here is the code of what I changed.
Pbuffer initialization
Code:
iPBuffer = eglCreatePbufferSurface( iDisplay, iPConfig, attrib_list2 );
if ( iPBuffer == NULL ) {
_LIT(KCreatePbufferSurfaceFailed, "eglCreatePbufferSurface failed");
User::Panic( KCreatePbufferSurfaceFailed, 0 );
}
glGenTextures(1, &pbufferTex);
glBindTexture(GL_TEXTURE_2D, pbufferTex);
glTexParameterx(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterx(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_NEAREST);
rgbxBuffer = new TUint[256 *256];
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256 ,256 , 0, GL_RGB, GL_UNSIGNED_BYTE, rgbxBuffer);
and the render loop
Code:
void CTarget::renderLoop(TInt aFrame) {
front->switchCurrent(1);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glLoadIdentity();
glTranslatex( 0 , 0 , -100 << 16 );
glRotatex( aFrame << 16, 1 << 16, 0 , 0 );
glRotatex( aFrame << 15, 0 , 1 << 16, 0 );
glRotatex( aFrame << 14, 0 , 0 , 1 << 16 );
glScalef( 15.f, 15.f, 15.f );
glColorPointer( 4, GL_UNSIGNED_BYTE, 0, colors );
glVertexPointer( 3, GL_BYTE, 0, vertices );
glDrawElements( GL_TRIANGLES, 12 * 3, GL_UNSIGNED_BYTE, triangles );
// render to window
front->switchCurrent(0);
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glLoadIdentity();
glTranslatex( 0 << 16, 0, -100 << 16 );
glScalex( 10 << 16, 10 << 16, 10 << 16 );
glRotatex( aFrame << 16, 1 << 16, 0 , 0 );
glRotatex( aFrame << 15, 0 , 1 << 16, 0 );
glRotatex( aFrame << 14, 0 , 0 , 1 << 16 );
glBindTexture(GL_TEXTURE_2D, front->pbufferTex);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 256, 256, 0);
glVertexPointer( 3, GL_FLOAT, 0, objVertexdata );
glNormalPointer( GL_BYTE, 0, objNormaldata );
glTexCoordPointer( 2, GL_BYTE, 0, objTexdata );
glDrawElements( GL_TRIANGLES, NUM_FACES_CUBE * 3, GL_UNSIGNED_BYTE, objFacedataCube );
eglSwapBuffers( front->iDisplay, front->iWindow );
}
Thanks for your help
EDIT: when I change all the GL_RGB to GL_RGBA the cube becomes invisible except for the white pixels in the borders.