Folks,
I am trying to make render to texture work on opengl es 2. I am testing my code on ubuntu using opengles2 mesa.
I don’t get any error but my texture contains only background color. Any advice?
Core looks like this:
glGenFramebuffers(1, &this->m_frameBufferHandle);
glGenTextures(1, &this->m_textureHandle);
glBindTexture(GL_TEXTURE_2D, this->m_textureHandle);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, texture.width, texture.height, 0, GL_RGB,
GL_UNSIGNED_SHORT_5_6_5, NULL);
glGenRenderbuffers(1, &this->renderBufferHandle);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16,
texture.width(), texture.height());
glBindFramebuffer(GL_FRAMEBUFFER, this->m_frameBufferHandle);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, this->m_textureHandle, 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, this->renderBufferHandle);
…
…
render()
…