M//Hax
12-02-2010, 01:17 PM
Hi,
Huge thanks for your help in my other threads guys. I have another question, this time i'm trying to put some alpha values on the color of the point sprites the code is generating with a VBO. Here the code for the VBO:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vboId);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glNormalPointer(GL_FLOAT, 0, (void*)sizeof(vertices));
glColorPointer(3, GL_FLOAT, 0, (void*)(sizeof(vertices)+sizeof(normals)));
glVertexPointer(3, GL_FLOAT, 0, 0);
float quadratic[] = {1.0f, 0.0f, 0.01f};
glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATIO N_ARB, quadratic );
float maxSize = 0.0f;
glGetFloatv(GL_POINT_SIZE_MAX_ARB, &maxSize );
if(maxSize > 100.0f)
maxSize = 100.0f;
glPointSize(maxSize);
glPointParameterfARB(GL_POINT_FADE_THRESHOLD_SIZE_ ARB, 60.0f);
glPointParameterfARB(GL_POINT_SIZE_MIN_ARB, 1.0f);
glPointParameterfARB(GL_POINT_SIZE_MAX_ARB, maxSize);
glEnable(GL_POINT_SPRITE_ARB);
glDrawArrays(GL_POINTS, 0, numPoints);
glDisable(GL_POINT_SPRITE_ARB);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
glDisable(GL_BLEND);
I tried using the GL_BLEND function, and it worked. But the alpha is not working correctly in all direction. I would like to know if it is the right way of doing it or should i load the alpha from a shader?
Huge thanks for your help in my other threads guys. I have another question, this time i'm trying to put some alpha values on the color of the point sprites the code is generating with a VBO. Here the code for the VBO:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vboId);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glNormalPointer(GL_FLOAT, 0, (void*)sizeof(vertices));
glColorPointer(3, GL_FLOAT, 0, (void*)(sizeof(vertices)+sizeof(normals)));
glVertexPointer(3, GL_FLOAT, 0, 0);
float quadratic[] = {1.0f, 0.0f, 0.01f};
glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATIO N_ARB, quadratic );
float maxSize = 0.0f;
glGetFloatv(GL_POINT_SIZE_MAX_ARB, &maxSize );
if(maxSize > 100.0f)
maxSize = 100.0f;
glPointSize(maxSize);
glPointParameterfARB(GL_POINT_FADE_THRESHOLD_SIZE_ ARB, 60.0f);
glPointParameterfARB(GL_POINT_SIZE_MIN_ARB, 1.0f);
glPointParameterfARB(GL_POINT_SIZE_MAX_ARB, maxSize);
glEnable(GL_POINT_SPRITE_ARB);
glDrawArrays(GL_POINTS, 0, numPoints);
glDisable(GL_POINT_SPRITE_ARB);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
glDisable(GL_BLEND);
I tried using the GL_BLEND function, and it worked. But the alpha is not working correctly in all direction. I would like to know if it is the right way of doing it or should i load the alpha from a shader?