Use FBO-Texture in FBO

Hello,

is it possible to use a texture in fbo, which the fbo renders in. Here is an example:

FBO::MakeCurrent()

RenderScene() // into 4 textures (colour/depth/position/normal)

FBO::ColourTexture::Bind() // <- does this work?
FBO::PositionTexture::Bind() // <- does this work?
FBO::NormalTexture::Bind() // <- does this work?

FragShader::Bind()

RenderQuad()

FragShader::Unbind()

FBO::ColourTexture::Unbind()
FBO::PositionTexture::Unbind()
FBO::NormalTexture::Unbind()

Device::MakeCurrent()

None of those are OpenGL functions. You’re not talking about OpenGL; you’re talking about some library layered on top of OpenGL. What library are you using?

its pseudo code, I m using opengl

You’re asking “does this work?” for “pseudo” code. OpenGL doesn’t execute “pseudo” code; it executes actual code. So we can’t know if your “pseudo” code works unless we can see what the actual code you’re intending to call is.

For example:


FBO::ColourTexture::Bind()

What does this do? Does it attach the “ColourTexture” to the FBO (glFramebufferTexture)? Does it bind the “ColourTexture” in the FBO to the OpenGL context (ie: glBindTexture)?

Without knowing what you’re talking about, we can’t really help.

Ok, I solve the problem myself but I have another one. If I use multitexturing it only works if I activate a texture_unit with the same id as the texture is bound to.

Like this:

glUniform1i(UniformLocation[i], TexturenID[i]); glActiveTexture(GL_TEXTURE0 + TexturenID[i]); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, TexturenID[i]);

So I activate GL_TEXTURE0 + eg. 20 by why does it not work using GL_TEXTURE0 + 0 , GL_TEXTURE0 + 1 for ervery texture?

I hope this question is easier to understand :slight_smile:

glActiveTexture(GL_TEXTURE0 + TexturenID[b]);

Um, no. That’s not how you bind textures to the context.

TexturenID[ i] is a texture object you created with glGenTextures. It is not a “number”; it is a handle that represents the texture you created. You should [i]never[/b] use it as a number the way you do here.

This explains how to bind textures to samplers.

Thx for the link,

but the strange thing is, that the texture is allways black when I m doing it the way your tutorial says. Is there a reason why he activates texture unit 0,2,4 and not 0,1,2?

but the strange thing is, that the texture is allways black when I m doing it the way your tutorial says.

Then there is something else wrong. And since I sadly lack the power to read your mind or sufficient clairvoyance to see your code from where I’m sitting, I have no way to know what the problem is unless you post a more complete example.

Is there a reason why he activates texture unit 0,2,4 and not 0,1,2?

To demonstrate that the texture unit indices don’t have to be in any particular order.

the problem is my code is very very long and an example is complicated to make. Could the problem be that I m using GL_TEXTURE_RECT and GL_TEXTURE_2D

the problem is my code is very very long and an example is complicated to make.

Then your first step needs to be isolating the problem. That is, make a small demo app that just proves whether or not you can get multitexturing to work. Then build back up, slowly figuring out how your code in your main project differs from the code in your demo project.

I guess you are right, thx for a lot for your help

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.