Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: problem with glPush/PopAttrib on ATi glslang (cat4.5)

  1. #1
    Member Regular Contributor
    Join Date
    Nov 2003
    Location
    Germany
    Posts
    293

    problem with glPush/PopAttrib on ATi glslang (cat4.5)

    hi,
    i am working on some scene graph glslang extension. so i depend somewhat on glPush/PopAttrib.

    here a short code snip:
    Code :
    void setup1()
    {
        static float blue[4] = {0, 0, 1, 1};
        glUseProgramObjectARB(_programObj1);
        int colorpos = glGetUniformLocationARB(_programObj1, "color");
        if (colorpos >= 0)
            glUniform4fvARB(colorpos, 1, blue);
    }
     
    void setup2()
    {
        static float green[4] = {0, 1, 0, 1};
        glUseProgramObjectARB(_programObj2);
        int colorpos = glGetUniformLocationARB(_programObj2, "color");
        if (colorpos >= 0)
            glUniform4fvARB(colorpos, 1, green);
     
        glBlendFunc(GL_ONE, GL_ONE);
        glEnable(GL_BLEND);
        glDepthFunc(GL_EQUAL);
        glEnable(GL_DEPTH_TEST);
     
    }
     
    void draw()
    {
        glPushMatrix();
            glRotatef(angl, 1,1,1);
            glutSolidCube(2);
        glPopMatrix();
    }
    void display()
    {
        glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
     
        glColor3f(1,0.5f,0.5f);
     
        glPushAttrib(GL_CURRENT_BIT);
        glPushAttrib(GL_ENABLE_BIT);
        glPushAttrib(GL_TEXTURE_BIT);
        glPushAttrib(GL_LIGHTING_BIT);
     
        glPushAttrib(GL_COLOR_BUFFER_BIT);
        glPushAttrib(GL_DEPTH_BUFFER_BIT);
     
        glPushMatrix();
            glTranslatef(-1.5,0,-5);
            setup1();
            draw();
            setup2();
            draw();
        glPopMatrix();
     
        //glUseProgramObjectARB(0);
        glPopAttrib();
        glPopAttrib();
     
        glPopAttrib();
        glPopAttrib();
        glPopAttrib();
        glPopAttrib();
     
        glPushMatrix();
            glTranslatef(1.5,0,-5);
            draw();
        glPopMatrix();
     
     
        glutSwapBuffers();
     
        angl += 0.3f;
    }
    where program1 and program2 are the same source, but i needed different programs:

    Code :
    fragment:
     
        uniform vec4        color;
        void main()
        {
            gl_FragColor =  gl_Color*color;
        }
     
    vertex:
        void main()
        {
            gl_Position      = gl_ModelViewProjectionMatrix * gl_Vertex;
            gl_FrontColor    = gl_Color;
        }
    the code above should render a red lighted cube on the right and some bright blueisch cube in the left. GL_LIGHT0 and GL_COLOR_MATERIAL enabled.

    but, on ATi glSlang the lighting state isn't recovered, so the right cube is only red without lighting (even when calling glUseProgramObject(0)).
    also a problem is the recovery from before used program objects with bound uniforms. on nvidia drivers (61.12) it works fine to push a program object and use another with other uniforms on the same slots. when you pop the program object the old is bound with the previous uniforms. on ATi the uniforms aren't reloaded. well i could find a way to live with that, but is this a bug or will this be solved in future releases.

    please no flames about driver quality. i want to know what the right behavior should be. thx.

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,453

    Re: problem with glPush/PopAttrib on ATi glslang (cat4.5)

    I thought I answered that before.
    See ARB_shader_object specs chapter 2.17 Required State
    The values are not part of the state, so cannot be pushed.
    Sounds like an implementation dependency. The right thing would be to reload the values.

    BTW, the glPushAttrib takes a bitfield, that's why the enums have the _BIT suffix use a single call and OR all bits together.

  3. #3
    Member Regular Contributor
    Join Date
    Nov 2003
    Location
    Germany
    Posts
    293

    Re: problem with glPush/PopAttrib on ATi glslang (cat4.5)

    Originally posted by Relic:
    I thought I answered that before.
    BTW, the glPushAttrib takes a bitfield, that's why the enums have the _BIT suffix use a single call and OR all bits together.
    thanks for answering, i know about the _BIT stuff, but when doing very much changes to the code because of debugging i it like this way .

    the main problem was, that the lighting state is _not_ recovered on ATi drivers.

    the other issue for me is. _should_ the bound uniforms be enabled to react to glPush/PopAttrib? on nVidia drivers they do, maybe some more people should give their opinion obout this issue, so it can be added to the discussion of, maybe, extending the shader objects spec in the future.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •