Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9221135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:30:41+00:00 2026-06-18T03:30:41+00:00

It seems like if i use texture(texture0,textCoord) for one time and then i try

  • 0

It seems like if i use texture(texture0,textCoord) for one time and then i try to use it again with an other texture texture(texture1,textCoord); it returns (0,0,0,0); and i just dont know why .

In my program it seems to be an order of workines ,if the depht works than the others wont ,
if i dont use the depth than only the color works and so on .( Depht , Color , Normal , Pos , Shine is the order)

this is the fragment shader :

uniform sampler2D tex0;
uniform sampler2D tex1;
uniform sampler2D tex2;
uniform sampler2D tex3;
uniform sampler2D depht;

void main()
{
    float UNIT = 1./640. ;

    //vec4 depht = texture(depht,gl_TexCoord[0].st);
    vec4 color = texture(tex0,gl_TexCoord[0].st);
    vec4 norma = texture(tex1,gl_TexCoord[0].st);
    vec4 posit = texture(tex2,gl_TexCoord[0].st);
    vec4 shine = texture(tex3,gl_TexCoord[0].st);


    if(false){
            gl_FragColor=(  texture2D(tex0,gl_TexCoord[0].st +vec2(0,0))+
                            texture2D(tex0,gl_TexCoord[0].st +vec2(0,-UNIT))+
                            texture2D(tex0,gl_TexCoord[0].st +vec2(UNIT,-UNIT))+
                            texture2D(tex0,gl_TexCoord[0].st +vec2(UNIT,0))+
                            texture2D(tex0,gl_TexCoord[0].st +vec2(UNIT,UNIT))+
                            texture2D(tex0,gl_TexCoord[0].st +vec2(0,UNIT))+
                            texture2D(tex0,gl_TexCoord[0].st +vec2(-UNIT,UNIT))+
                            texture2D(tex0,gl_TexCoord[0].st +vec2(-UNIT,0))+
                            texture2D(tex0,gl_TexCoord[0].st +vec2(-UNIT,-UNIT)))/9.;
    }else{
        gl_FragColor=(norma+color);
    }
}

this is the binding part :

    fbotest.drawFBO();
DEFERRED.UseNow();
DrawGLScene();

fbotest.readFBO();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

DEFERRED2.UseNow();

//glBlendFunc (GL_ONE, GL_ONE);
glEnable( GL_BLEND );

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, fbotest.Color);
glEnable(GL_TEXTURE_2D);

glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, fbotest.Normal);
glEnable(GL_TEXTURE_2D);

glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, fbotest.Pos);
glEnable(GL_TEXTURE_2D);

glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, fbotest.Shine);
glEnable(GL_TEXTURE_2D);

glActiveTexture(GL_TEXTURE4);
glBindTexture(GL_TEXTURE_2D, fbotest.Depht);
glEnable(GL_TEXTURE_2D);

glUniform1i(glGetUniformLocation(DEFERRED2.PR,"tex0"),0);
glUniform1i(glGetUniformLocation(DEFERRED2.PR,"tex1"),1);
glUniform1i(glGetUniformLocation(DEFERRED2.PR,"tex2"),2);
glUniform1i(glGetUniformLocation(DEFERRED2.PR,"tex3"),3);
glUniform1i(glGetUniformLocation(DEFERRED2.PR,"depht"),4);

glLoadIdentity();
glBegin(GL_QUADS);
        glMultiTexCoord2f(GL_TEXTURE0, 1.0, 0.0);
        glMultiTexCoord2f(GL_TEXTURE1, 1.0, 0.0);
        glMultiTexCoord2f(GL_TEXTURE2, 1.0, 0.0);
        glMultiTexCoord2f(GL_TEXTURE3, 1.0, 0.0);
        glMultiTexCoord2f(GL_TEXTURE4, 1.0, 0.0);
    glVertex3f( 1,-1,-3);
        glMultiTexCoord2f(GL_TEXTURE0, 1.0, 1.0);
        glMultiTexCoord2f(GL_TEXTURE1, 1.0, 1.0);
        glMultiTexCoord2f(GL_TEXTURE2, 1.0, 1.0);
        glMultiTexCoord2f(GL_TEXTURE3, 1.0, 1.0);
        glMultiTexCoord2f(GL_TEXTURE4, 1.0, 1.0);
    glVertex3f( 1,1 ,-3);
        glMultiTexCoord2f(GL_TEXTURE0, 0.0, 1.0);
        glMultiTexCoord2f(GL_TEXTURE1, 0.0, 1.0);
        glMultiTexCoord2f(GL_TEXTURE2, 0.0, 1.0);
        glMultiTexCoord2f(GL_TEXTURE3, 0.0, 1.0);
        glMultiTexCoord2f(GL_TEXTURE4, 0.0, 1.0);
    glVertex3f( -1,1,-3);
        glMultiTexCoord2f(GL_TEXTURE0, 0.0, 0.0);
        glMultiTexCoord2f(GL_TEXTURE1, 0.0, 0.0);
        glMultiTexCoord2f(GL_TEXTURE2, 0.0, 0.0);
        glMultiTexCoord2f(GL_TEXTURE3, 0.0, 0.0);
        glMultiTexCoord2f(GL_TEXTURE4, 0.0, 0.0);
    glVertex3f(-1,-1,-3);
glEnd();

glActiveTextureARB(GL_TEXTURE4);
    glBindTexture(GL_TEXTURE_2D, 0);
glActiveTextureARB(GL_TEXTURE3);
    glBindTexture(GL_TEXTURE_2D, 0);
glActiveTextureARB(GL_TEXTURE2);
    glBindTexture(GL_TEXTURE_2D, 0);
glActiveTextureARB(GL_TEXTURE1);
    glBindTexture(GL_TEXTURE_2D, 0);
glActiveTextureARB(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, 0);
glDisable( GL_BLEND );

and this is may FBO class :

    class deferred{
        public :
    unsigned int FBO;
    unsigned int Depht;
    unsigned int Color;
    unsigned int Normal;
    unsigned int Pos;
    unsigned int Shine;

    deferred();
    void initFBO();
    void readFBO();
    void drawFBO();

};

    void deferred::readFBO(){
        glBindFramebuffer(GL_DRAW_FRAMEBUFFER,0);
        glBindFramebuffer(GL_READ_FRAMEBUFFER,FBO);
    }

    void deferred::drawFBO(){
        glBindFramebuffer(GL_READ_FRAMEBUFFER,0);
        glBindFramebuffer(GL_DRAW_FRAMEBUFFER,FBO);
    }

    deferred::deferred(){
        FBO     =0;
        Depht   =0;
        Color   =0;
        Normal  =0;
        Pos     =0;
        Shine   =0;
    }

    void deferred::initFBO(){
        glGenFramebuffers(1, &FBO);
        glBindFramebuffer(GL_DRAW_FRAMEBUFFER, FBO);


        glGenTextures(1,&Depht );
        glGenTextures(1,&Color );
        glGenTextures(1,&Normal);
        glGenTextures(1,&Pos   );
        glGenTextures(1,&Shine );

        int WindowWidth = Ww;
        int WindowHeight= Wh;

        glBindTexture(GL_TEXTURE_2D, Color);
        glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB32F, WindowWidth, WindowHeight, 0, GL_RGB, GL_FLOAT, NULL);
        glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, Color, 0);

        glBindTexture(GL_TEXTURE_2D, Normal);
        glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB32F, WindowWidth, WindowHeight, 0, GL_RGB, GL_FLOAT, NULL);
        glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, Normal, 0);

        glBindTexture(GL_TEXTURE_2D, Pos);
        glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB32F, WindowWidth, WindowHeight, 0, GL_RGB, GL_FLOAT, NULL);
        glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, Pos, 0);

        glBindTexture(GL_TEXTURE_2D, Shine);
        glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB32F, WindowWidth, WindowHeight, 0, GL_RGB, GL_FLOAT, NULL);
        glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, Shine, 0);

        glBindTexture(GL_TEXTURE_2D, Depht);
        glTexImage2D (GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32F, WindowWidth, WindowHeight, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
        glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, Depht, 0);

        GLenum DrawBuffers[] = { GL_COLOR_ATTACHMENT0,
                                 GL_COLOR_ATTACHMENT1,
                                 GL_COLOR_ATTACHMENT2,
                                 GL_COLOR_ATTACHMENT3};

        glDrawBuffers(4, DrawBuffers);

        GLenum Status = glCheckFramebufferStatus(GL_FRAMEBUFFER);

        if (Status != GL_FRAMEBUFFER_COMPLETE) {
            cout <<"Frame Buffer ERROR : "<< Status << "\n" ;
        }

        glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:30:42+00:00Added an answer on June 18, 2026 at 3:30 am

    I’ve changed this :

    void deferred::readFBO(){
        glBindFramebuffer(GL_DRAW_FRAMEBUFFER,0);
        glBindFramebuffer(GL_READ_FRAMEBUFFER,FBO);
    
    }
    
    void deferred::drawFBO(){
        glBindFramebuffer(GL_READ_FRAMEBUFFER,0);
        glBindFramebuffer(GL_DRAW_FRAMEBUFFER,FBO);
    }
    

    with this :

    > void deferred::readFBO(){
    >     glBindFramebuffer(GL_DRAW_FRAMEBUFFER,0);
    >     glBindFramebuffer(GL_READ_FRAMEBUFFER,FBO);
    > 
    >     glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
    >     glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, 0, 0);
    >     glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, 0, 0);
    >     glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, 0, 0);
    >     glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT , GL_TEXTURE_2D, 0, 0); 
    }
    > 
    > void deferred::drawFBO(){
    >     glBindFramebuffer(GL_READ_FRAMEBUFFER,0);
    >     glBindFramebuffer(GL_DRAW_FRAMEBUFFER,FBO);
    > 
    >     glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, Color , 0);
    >     glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, Normal, 0);
    >     glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, Pos   , 0);
    >     glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, Shine , 0);
    >     glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT , GL_TEXTURE_2D, Depht , 0); 
    }
    

    and now it works . I belive it is a litle slow even if i dont see any changes in framerates and i dont quite know why i cant let the textures binded to the framebuffer , but yea it solved the problem .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to use the FBDialog from the Facebook SDK, but it seems like
It seems like you could use a mashup of Relector and a Debugger to
I have the following line of jQuery but it seems like overkill to use
I have a problem with using the prefix, seems like whenever I use the
It seems like I can't use shell_exec or proc_open on my shared server. The
Executor seems like a clean abstraction. When would you want to use Thread directly
I use GLUT to create window ( glutCreateWindow() ). It seems like glut creates
I've been trying to use the setActionView from the ActionBar in ICS Seems like
I like the ease of use of Notification.Builder but it seems not support the
I noticed that this recipe seems to use __rlshift__ , __ror__ like operators. But,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.