texturemapping and masking problem...
3 days ago, I posted question about rendering 500 solidspheres!!
someone answer me to use texture mapping instead of using like
glutSolidSphere() functions makes computer slow.
well,I just tried to do that...but It doesnt do well..
the source codes below..
please help me~~
texture[3]:Masking Image
texture[4];Image File
void DrawMyBall(GLvoid)
{
glDisable(GL_LIGHTING);
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_DST_COLOR,GL_ZERO);
glBindTexture(GL_TEXTURE_2D, TextureRam.texture[3]);
glPushMatrix();
glRotatef(MainCtrlRam.xrot,-1.0,0.0,0.0);
glRotatef(MainCtrlRam.yrot,0.0,-1.0,0.0);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.5f, -0.5f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.5f, -0.5f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.5f, 0.5f, 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.5f, 0.5f, 0.0f);
glEnd();
glColor3f(1.0,0.0,0.0);
glBlendFunc(GL_ONE, GL_ONE);
glBindTexture(GL_TEXTURE_2D, TextureRam.texture[4]);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-0.5f, -0.5f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 0.5f, -0.5f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 0.5f, 0.5f, 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-0.5f, 0.5f, 0.0f);
glEnd();
glPopMatrix();
glEnable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
glEnable(GL_LIGHTING);
}
I don''t really get how you''re trying to draw this... By using ONE,ONE you basically add each pixel of the second quad to the pixel currently under it : the whole quad will appear on the screen. You are going to have to work another solution out. Something like writing some alpha to the buffer, and then alpha blending the second quad using destination alpha.
ToohrVyk
ToohrVyk
I believe you are blending correctly for masking. What exactly isn''t working? Could you post a screen shot? Is anything appearing at all? What do you mean by "but It doesnt do well.."?
this is what I want to draw( using glutSolidSphere() functions )
and this is the capture of using texture mapping.
I think "depth_test" makes that problem.please help me..
I really want to know how to make a molecule simulation program.. how can they draw hundreds of sphere(atom) !!!
and this is the capture of using texture mapping.
I think "depth_test" makes that problem.please help me..
I really want to know how to make a molecule simulation program.. how can they draw hundreds of sphere(atom) !!!
Cants I use Masking and GL_DEPTH_TEST at the same time???
I cant sort by the distance of all the spheres,,Its kind of
complicated!! any good way to render texture spheres with
GL_DEPTH_TEST ??
Enabled GL_DEPTH_TEST ,something strange masking..
Disabled GL_DEPTH_TEST...its different from reality..
Depth testing works like this : every time a pixel (even a transparent one) is rendered its depth is stored into a buffer, and used for testing after that. Which means that although a circle is visible on the screen, the invisible black areas of the quad you are rendering are written to the depth buffer, and will be considered as opaques after that.
The only way to render transparent polygons is to sort them by order of distance, and render the furthest ones first.
ToohrVyk
The only way to render transparent polygons is to sort them by order of distance, and render the furthest ones first.
ToohrVyk
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement