2

I'm learning some OpenGL basics and when I decided to make a particle system I met some problems. When I'm trying to render GL_POINT with GL_POINT_SPRITE they do not show on the screen unless they are renderer first. Code I'm using for rendering:

glClear(GL_COLOR_BUFFER_BIT);

    glPushMatrix();
    glColor3f(1.0f,1.0f,1.0f);
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, t->id());
    glBegin(GL_QUADS);
        glTexCoord2f(0.0f,0.0f);
        glVertex2f(10,10);

        glTexCoord2f(1.0f,0.0f);
        glVertex2f(100,10);

        glTexCoord2f(1.0f,1.0f);
        glVertex2f(100,100);

        glTexCoord2f(0.0f,1.0f);
        glVertex2f(10,100);
    glEnd();
    glDisable(GL_TEXTURE_2D);
    glPopMatrix();

    glPushMatrix();
    glColor3f(1.0f,1.0f,1.0f);
    glEnable(GL_TEXTURE_2D);
    glEnable(GL_POINT_SPRITE_ARB);
    glBindTexture(GL_TEXTURE_2D, t->id());
    glTexEnvf(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE);
    glPointSize(32);
    glBegin(GL_POINTS);
    glVertex2f(300,300);
    glEnd();
    glDisable(GL_POINT_SPRITE);
    glDisable(GL_TEXTURE_2D);
    glPopMatrix();

SDL_GL_SwapBuffers();

This only renders a textured quad but not point. When I change the order (first render point then quad) they both appear on the screen (textured point and textured quad).

Am I doing something wrong here or is this correct behavior?

Some info about my PC migh be helpful - Arch Linux 64bit with AMD Mobility Radeon HD 4550 (Catalyst 12.6 driver)

4

1 回答 1

0

我今天遇到了这个问题。这似乎为我解决了这个问题:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT|GL_ACCUM_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);  

我希望它正在清除执行它的深度缓冲区。我知道这是一个非常古老的问题,但以防万一其他人偶然发现同样的问题......

于 2013-08-11T22:25:39.940 回答