KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'd like to render a scene to an initially empty texture. To do so, I use a Framebuffer Object to which I attach an empty 2d texture and a depth buffer. After the set up, as for testing, I draw a simple quad into the scene. Every vertex has a different color, so I eventually expect a color-interpolated quad in the texture. I then use that texture containing the quad and map it on another quad. So evetually, I have a quad in my default Framebuffer which has a texture containing a colored quad. I hope this is not too confusing... Anyway, I must be missing something here, since what I get is nothing but a grey texture. I basically followed this instructions which are pretty straight forward. However, I cannot quite figure out what I am missing here. I would be grateful if somebody could give me a clue. Thanks Walter This is the code I have so far: // create frame buffer object glGenFramebuffers(1, &frameBufferObject); // create depth buffer glGenRenderbuffers(1, &depthAttachment); // create empty texture int width = 512; int height = 512; int numberOfChannels = 3; GLuint internalFormat = GL_RGB; GLuint format = GL_RGB; unsigned char* texels = new unsigned char[width * height * numberOfChannels]; glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, texels); glGenerateMipmap(GL_TEXTURE_2D); delete[] texels; texels = NULL; // activate & bind empty texture glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture); // attach empty texture to
Tags (comma-separated)
Save Edits
Cancel