1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
void clsBuffer::RenderImage (wxImage *dst) {
int w = dst->GetWidth(); int h = dst->GetHeight();
GLuint tmpTex;
glGenTextures (1, &tmpTex);
glBindTexture (GL_TEXTURE_2D, tmpTex);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
GLuint FBO=0;
glGenFramebuffers(1, &FBO);
glBindFramebuffer(GL_FRAMEBUFFER, FBO);
glViewport (0, 0, (GLint)w, (GLint)h);
Render2D ();
glBindTexture (GL_TEXTURE_2D, tmpTex);
glReadPixels (0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, (GLuint*)(dst->GetData()));
glBindFramebuffer (GL_FRAMEBUFFER, 0);
glActiveTexture (GL_TEXTURE0);
glDeleteFramebuffers(1, &FBO);
glDeleteTextures (1, &tmpTex);
}
|