Hi All,
I’m trying to render some AA lines, so far I 've created a texture (RGBA) with a filled circle and a smooth boundary.
I get a good result with this, however the lines get the texture color, and I want if possible, to use this texture as a Alpha Pattern, and get the RGB channels from the glColor4x primitive.
I’m using GL_MODULATE, and from the documentation I read that it will mix the texture color with the light or primitive color.
My lack of knowledge is:
how to create an alpha texture, and if it will work after updating the texture with GL_ALPHA definition.
basically something like this,
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D);
// get a free texture
glGenTextures(1, &textureId);
// bind texture
glBindTexture(GL_TEXTURE_2D, textureId);
// send buffer to opengl
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 128, 128, 0, GL_ALPHA, GL_UNSIGNED_BYTE, circle->getBitmap());
glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameterx(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterx(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
Because I’ve tried to use the current RGBA texture uploaded as GL_ALPHA but it didn’t work.
Thanks in advance,
Victor