I created 4 textures and attached them to an FBO named fbo_texture0 - fbo_texture3. All of them were successfully created, as shown in the following screenshot:
image 1
Now I wanted to create the 5th texture obtained from previous textures (fbo_texture0 - fbo_texture3) using GLSL. For now, I just want to copy the first texture to the fifth texture. Unfortunately, here is what I got:
image 2
The question arises:
- How can I access these fbo textures in GLSL?
- How can I create a 5th texture? (or copy from the first texture to the fifth texture?)
Here is the full program code (if necessary):
#include <windows.h>
Here is the vertex shader:
void main(void) { gl_TexCoord[0] = gl_MultiTexCoord0; gl_Position = ftransform(); }
And here is a fragment of a shader:
uniform sampler2D tex0; uniform sampler2D tex1; uniform sampler2D tex2; uniform sampler2D tex3; void main(void) { gl_FragColor = texture2D(tex0, gl_TexCoord[0].st); }
EDIT NO. 1
After changing the code suggested by @Damon (the code has also been edited), here is a screenshot of the result:
image 3
Now I really don't know what the problem is. I tried changing the fragment shader to access a different texture, for example. gl_FragColor = texture2D(tex2, gl_TexCoord[0].st); but I still got the same display as above. So I think this is definitely not a model / projection problem.
EDIT No. 2
The problem is still unclear. However, I tried to give only one command glActiveTexture(GL_TEXTUREn); in the program and comment on another glActiveTexture command (without modifying the shader) and got the following result:
Image 4 Enabled only glActiveTexture(GL_TEXTURE0); .
Image 5 Enabled only glActiveTexture(GL_TEXTURE1); .
Image 6 Only glActiveTexture(GL_TEXTURE2); activated.
Image 7 glActiveTexture(GL_TEXTURE3); only glActiveTexture(GL_TEXTURE3); activated.
When at least 2 glActiveTexture(GL_TEXTUREn); , I got the same result as image 5. It made me think that the problem was actually.