I have a problem with rendering to texture and offscreen framebuffer with OpenGLES
on iPhone.
(source: imagehost.org)
(source: imagehost.org)
First image shows mahjong tiles rendered to CAEAGLLayer
directly and this is correct. Second one shows tiles rendered to offscreen framebuffer, copied to texture using glCopyTexImage2D
and the texture rendered to CAEAGLLayer
. Both use white opaque quad for background. I also have tried rendering directly to texture but effect was the same as with offscreen framebuffer.
My code for creating framebuffer:
GLuint framebuffer;
glGenFramebuffersOES(1, &framebuffer);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, framebuffer);
GLuint renderbuffer;
glGenRenderbuffersOES(1, &renderbuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, renderbuffer);
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_RGB8_OES,
512, 512);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES,
GL_RENDERBUFFER_OES, renderbuffer);
I draw all tiles from a texture atlas with one call to glDrawElements
using VBO for passing interlaced vertex data (coordinates, texture coordinate, color). I use RGBA8888 texture format, drawing each image on two triangles (quad) with glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
blending function. I do not use depth buffer (in all cases).
Can somebody tell me what could be the problem?