I'm now using opengl3.3 and glfw to draw+show. However, currently, OpenGL draws in its internal frame buffer. I suppose it is "glBindFramebuffer(GL_FRAMEBUFFER, 0);"
I wonder if I can define a buffer by myself and let OpenGL draw in this buffer? e.g.
GLuint ownbuffer[800*600*4]; // width:800, height:600, ARGB channel
// by setting some APIs to let OpenGL draw in the above buffer?
I read about FBO, my original thinking is that I can use it to draw in FBO buffer by filling the buffer address in the texture buffer. However, it seems that it does not work. I get an all-zero buffer. e.g.
GLuint frameBuffer;
glGenFramebuffers(1, &frameBuffer);
glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer);
GLuint texColorBuffer;
GLuint ownbuffer[800*600*4];
glGenTextures(1, &texColorBuffer);
glActiveTexture(GL_TEXTURE8);
glBindTexture(GL_TEXTURE_2D, texColorBuffer);
glTexImage2D(
GL_TEXTURE_2D, 0, GL_RGBA, 800, 600, 0, GL_RGBA, GL_UNSIGNED_BYTE, ownbuffer
); // by setting buffer here instead of fill in NULL
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texColorBuffer, 0);
Moreover, is it possible to let glfw show our own buffer? e.g. ownbuffer mentioned above.
In this case, I don't need to dump buffer data into files for checking the result.