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)

winglot
  • 21
  • 3
  • 1
    Is this **exactly** the code you are running, or is this cut and paste from different places? Can you show the exact code that works in one code block, followed by the exact code that doesn't work in a separate block? If that's your real code, then I think it shouldn't make any difference. – Tim Aug 27 '12 at 06:27
  • This code runs in a while loop in main function. Rest of the code is SDL initialization and setting up OpenGL ortho to properly display 2d graphics, disabling depth buffer and loading texture. – winglot Aug 28 '12 at 15:34

1 Answers1

0

I had this issue today. This seemed to fix it for me:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT|GL_ACCUM_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);  

I expect it was clearing the depth buffer that did it. I'm aware this is a very old question, but just in case anyone else stumbles across the same issue......

John
  • 536
  • 5
  • 16