PDA

View Full Version : Transparent object Problem



Lobo86199
06-27-2000, 03:40 AM
I tried to display something but it always seems to be transparent. Please help me to show everything solid.

Heres my code:


void GLSetupRC(void *pData)
{

glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glEnable(GL_CULL_FACE);
glFrontFace(GL_CCW);

GLfloat ambientLight[] = { 0.1f, 0.1f, 0.1f, 1.0f };
GLfloat diffuseLight[] = { 0.6f, 0.6f, 0.6f, 1.0f };
GLfloat specular[] = { 1.0f, 1.0f, 1.0f, 1.0f};
GLfloat lightPos[] = { 0.0f, -30.0f, 150.0f, 1.0f };
GLfloat specref[] = { 1.0f, 1.0f, 1.0f, 1.0f };

glLightfv(GL_LIGHT0,GL_AMBIENT,ambientLight);
glLightfv(GL_LIGHT0,GL_DIFFUSE,diffuseLight);
glLightfv(GL_LIGHT0,GL_SPECULAR,specular);
glLightfv(GL_LIGHT0,GL_POSITION,lightPos);
glEnable(GL_LIGHTING);

glEnable(GL_COLOR_MATERIAL);


glEnable(GL_LIGHT0);
BuildFont();
}

void GLRenderScene(void *pData)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
GLfloat specular2[] = { 1.0f, 1.0f, 1.0f, 0.0f};
GLfloat specular1[] = { 0.0f, 0.0f, 0.0f, 0.0f};
glPushMatrix();
i+= 1.0 ;
glTranslatef(0,0,15);
glRotated(i, 0.0, 1.0, 0.0);
glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,specula r1);
glColor3f(0.95f, 0.49f, 0.0f);
obj1_mat1();
obj2_mat2();
obj3_mat3();
obj4_mat4();

glPopMatrix();

glPushMatrix();
glMaterialfv(GL_FRONT,GL_EMISSION,specular2);
glColor3f(1.0f, 1.0f, 1.0f);
glTranslatef(0.0f,0.0f,-3.0f);
glPrint(0,11,"So verstehen wir uns...");

Relic
06-27-2000, 11:09 AM
Some questions that might help:
Do you need the emissive materials? They have alpha = 0.
Does that work as you expect it in conjunction with GL_COLOR_MATERIAL enabled?
Why do you clear the color buffer with alpha = 0.5? Do you have some destination alpha blending in the program? Is it enabled/disabled properly when you draw your objects?

I forgot one: Do you have depth test enabled?
Maybe the face culling alone doesn't do the job with your objects.


[This message has been edited by Relic (edited 06-27-2000).]

Lobo86199
06-27-2000, 01:37 PM
Thank You that you tried to help me.
Ill try to answer your questions.

I need emissive Materials because otherways the text that Im drawing is not white, but grey.
Im a beginner an I dont know exactly why Im using some thins in the code. Im learning by doing, but sometimes that doesnt work.