ARB_point_sprite Howto?

Started by Rainer, September 25, 2008, 20:57:29

Previous topic - Next topic

Rainer

Since i need some performant particles, i wanted to ask, if there is some simple example how to use ARB_point_sprite with lwjgl?
Has anybody done it already? ;)

Matthias

Hi,

I used ARB_point_sprite in the past, but with newer ATI drivers they appear to be broken (or better - everything except point sprites is then broken). So now I moved to screen aligned quads - using the geometry shader if available.

Ciao Matthias

Rainer

sounds strange, but i'd like to try it anyway :D

Rainer

Just tested some C examples on my ATI, this definitly works.
Could someone give an example for lwjgl?

Rainer

Ok, solved by trying...

Fore those having the same problem, here the code:
        float quadratic[] = {1.0f, 0.0f, 0.01f, 1};
        ByteBuffer temp = ByteBuffer.allocateDirect(16);
        temp.order(ByteOrder.nativeOrder());
        ARBPointParameters.glPointParameterARB(ARBPointParameters.GL_POINT_DISTANCE_ATTENUATION_ARB, (FloatBuffer) temp.asFloatBuffer().put(quadratic).flip());

        ARBPointParameters.glPointParameterfARB(ARBPointParameters.GL_POINT_FADE_THRESHOLD_SIZE_ARB, 60);
        ARBPointParameters.glPointParameterfARB(ARBPointParameters.GL_POINT_SIZE_MIN_ARB, 1.0f);
        ARBPointParameters.glPointParameterfARB(ARBPointParameters.GL_POINT_SIZE_MAX_ARB, 100);
        
        GL11.glPointSize(100);
        
        GL11.glEnable(ARBPointSprite.GL_POINT_SPRITE_ARB);
        GL11.glTexEnvf(ARBPointSprite.GL_POINT_SPRITE_ARB, ARBPointSprite.GL_COORD_REPLACE_ARB, GL11.GL_TRUE);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);

        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_BLEND);

        GL11.glBegin(GL11.GL_POINTS);

        GL11.glColor4f(0f, 0f, 1, 1);

        GL11.glVertex3f(0, 0, 0);

        GL11.glEnd();

        GL11.glDisable(GL11.GL_BLEND);

        GL11.glDisable(ARBPointSprite.GL_POINT_SPRITE_ARB);