Ecco_the_dolphin

Possible OpenGL bug with latest Catalyst driver for Radeon

Discussion created by Ecco_the_dolphin on Aug 8, 2008
strange thing with glEdgeFlagPointer

Hello!
I have strange problem with latest ATI drivers on Radeon 9550/X1100 Series (tested with Catalyst 8.7,8.6,8.5). I think that it is a driver problem because with very old drivers everything works fine (I tested with Catalyst 6.5 Release date: xx.xx.2006).

I wrote a test application and tested it on 2 PC's with Windows XP SP2 and Windows XP SP3. with Catalyst 8.7,8.6,8.5.  The problem repeats...

The problem:

First, I render a group of triangles with
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL) using GL_VERTEX_ARRAY,
then render the same triangles with glPolygonMode(GL_FRONT_AND_BACK,GL_LINE) using GL_VERTEX_ARRAY and GL_EDGE_FLAG_ARRAY and here something strange happens...Some of triangles that must be filled with color won't draw at all.

Here is some screenshots:


[or if html won't work] http://s46.radikal.ru/i114/0808/50/98f6fd02172ct.jpg


This is a first frame of app...Last triangle must be filled with "teal", however, as you can see this is not true, it filled red.

[or if html won't work]http://s56.radikal.ru/i153/0808/33/857d94b0ee1ct.jpg


This is one of another frames. Another strange thing...(detailes on screenshot).

Here is the source code of application (it is just a demo example):
I used glut 3.7.6. I dont think that this problem related with glut, I can rewrite this app using win32 api only if needed. (bad English...sorry...)

Source code:

[source lang="cpp"]
#include <windows.h>
#include <gl/gl.h>
#include <gl/glut.h>


//first group of triangles
const GLfloat triangle_vertexes[] ={1,100.0f,    70.0f,90.0f,    1.0f,1.0f
                                   ,30.0f,160.0f, 80.0f,70.0f,   60.0f,15.0f
                                   ,40.0f,60.0f, 120.0f,100.0f,  130.0f,110.0f
                                   ,40.0f,50.0f, 120.0f,90.0f,   130.0f,20.0f};
//second group of triangles (1 triangle)
const GLfloat triangle_vertexes2[] = {120.0f,12.0f, 40.0f,80.0f, 10.0f,110.0f};

//edge flags of the first group
const GLboolean edge_flags[] = { true ,false,false
                                ,true ,true ,false
                                ,false,false,false
                                ,true ,true ,true};

//edge flags of the second group
const GLboolean edge_flags2[] = {true,true,true};


GLfloat angle = 0;
int     size_x;
int     size_y;
bool    increment = true;

void Reshape (int w,int h)
{
    glViewport(0,0,w,h);
    size_x = w;
    size_y = h;
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0,w/8,0,h/8,-1,1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}
void Display (void)
{
    glClearColor(1.0f,1.0f,1.0f,1.0f);
    glClear(GL_COLOR_BUFFER_BIT);
   
    //Change modelview matrix
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glRotatef(angle,0,0,-1.0f);

    //Draw first group of triangles
    glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
    glVertexPointer(2,GL_FLOAT,0,triangle_vertexes);
    glEnableClientState(GL_VERTEX_ARRAY);
    glColor3f(1.0f,0,0);
    glDrawArrays(GL_TRIANGLES,0,sizeof(triangle_vertexes)/sizeof(GLfloat));
    glEnable(GL_POLYGON_OFFSET_FILL);
    glPolygonOffset(1.0, 1.0);
    //Draw borders with edge flags
    glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
    glEnable(GL_BLEND);
    glEdgeFlagPointer(0,edge_flags);
    glEnableClientState(GL_EDGE_FLAG_ARRAY);
    glColor3f(0,1,0);
    glDrawArrays(GL_TRIANGLES,0,sizeof(triangle_vertexes)/sizeof(GLfloat));
    glDisable(GL_BLEND);
    glDisableClientState(GL_EDGE_FLAG_ARRAY);
   
    //Change modelview matrix
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glRotatef(angle,0,0,1.0f);

    //Draw second group of triangles (1 triangle actually )
    glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
    glVertexPointer(2,GL_FLOAT,0,triangle_vertexes2);
    glColor3f(0,0.5f,0.5f);
    glDrawArrays(GL_TRIANGLES,0,sizeof(triangle_vertexes2)/sizeof(GLfloat));
   
    //Draw its border with edge flags
    glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
    glEnable(GL_BLEND);
    glColor3f(0,1,0);
    glEdgeFlagPointer(0,edge_flags2);
    glEnableClientState(GL_EDGE_FLAG_ARRAY);
    glDrawArrays(GL_TRIANGLES,0,sizeof(triangle_vertexes2)/sizeof(GLfloat));
    glDisableClientState(GL_EDGE_FLAG_ARRAY);
    glDisable(GL_BLEND);

    glDisableClientState(GL_VERTEX_ARRAY);
   
    //Change angle
    if (increment)
    {
        angle+=5.0f;
        if (angle>25.0)
            increment = false;
    }
    else
    {
        angle-=5.0f;
            if (angle<-25.0)
                increment = true;
    }
    glutSwapBuffers();
}
void Init (void)
{
    //we want antialiased triangle border
    glEnable(GL_LINE_SMOOTH);
    glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    //set flat shading
    glShadeModel(GL_FLAT);
}
void TimerFunc (int some)
{
    glutPostRedisplay();
    glutTimerFunc(500,TimerFunc,0);
}
int main (int argc,char **argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA);
    glutInitWindowSize(1024,1024);
    glutInitWindowPosition(100,100);
    glutCreateWindow("Problem_demo");
    glutDisplayFunc(Display);
    glutReshapeFunc(Reshape);
    Init();
    glutTimerFunc(1000,TimerFunc,0);

    glutMainLoop();

    return 0;
}
[/source] 


The question is if it is a driver problem or am I doing something wrong? By the way, i tried this example on some NVIDIA cards (GeForce 9400 GT M and GeForce 8400 M GS) and everything works fine. I also tried Microsoft generic implementation it works fine to.

P.S. Please sorry for my awful English.

Outcomes