Sign in to follow this  
m_power_hax

VBO/point sprites/alpha

Recommended Posts

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_ATTENUATION_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?

Share this post


Link to post
Share on other sites
You need to ask more specific questions, it's not clear at all what you're trying to do with that code. Nobody knows what "is not working correctly from all directions" means. I don't see any alpha values anywhere in your code, so I have no idea where you're getting these values from or how you intend to use them.

Share this post


Link to post
Share on other sites
glColorPointer(3, GL_FLOAT, 0, (void*)(sizeof(vertices)+sizeof(normals)));

The 3 means 3 components (RBG), if you use 4 then its (RGBA). Does your array have rgba, or rgb?

Standard blending is glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

Share this post


Link to post
Share on other sites
Quote:
Original post by karwosts
You need to ask more specific questions, it's not clear at all what you're trying to do with that code. Nobody knows what "is not working correctly from all directions" means. I don't see any alpha values anywhere in your code, so I have no idea where you're getting these values from or how you intend to use them.


glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);

this do the alpha for all point sprites. For now the point sprite are white or black. When they are black, the alpha make them invisible. When turning around the cube of white point sprites rendered, they are not drawed for a certain angle.


Share this post


Link to post
Share on other sites
Quote:
Original post by dpadam450
glColorPointer(3, GL_FLOAT, 0, (void*)(sizeof(vertices)+sizeof(normals)));

The 3 means 3 components (RBG), if you use 4 then its (RGBA). Does your array have rgba, or rgb?

Standard blending is glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);


That's probably it. I'll have to call the glColorPointer with a 4 components. I'll try that, thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this