diff --git a/opengl-test-two/main.cpp b/opengl-test-two/main.cpp index 1250b2c..334551d 100644 --- a/opengl-test-two/main.cpp +++ b/opengl-test-two/main.cpp @@ -148,6 +148,27 @@ GLuint LoadShaders(const char * vertex_file_path,const char * fragment_file_path return ProgramID; } +GLuint WriteTexture(int textw, int texth){ + // The framebuffer, which regroups 0, 1, or more textures, and 0 or 1 depth buffer. + GLuint FramebufferName = 0; + glGenFramebuffers(1, &FramebufferName); + glBindFramebuffer(GL_FRAMEBUFFER, FramebufferName); + + // The texture we're going to render to + GLuint renderedTexture; + glGenTextures(1, &renderedTexture); + + // "Bind" the newly created texture : all future texture functions will modify this texture + glBindTexture(GL_TEXTURE_2D, renderedTexture); + + // Give an empty image to OpenGL ( the last "0" ) + glTexImage2D(GL_TEXTURE_2D, 0,GL_RGB, textw, texth, 0,GL_RGB, GL_UNSIGNED_BYTE, 0); + + // Poor filtering. Needed ! + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + +} int main(int argc, char* args[]) {