Are materials affected differently than colors in blending?
Something simple like this was producing a blank screen:
//init
glClearColor(100.0/256, 100.0/256, 100.0/256, 0);
glClearDepth(1.0f);
//lighting setup
glEnable (GL_DEPTH_TEST);
glEnable (GL_LIGHTING);
glEnable (GL_LIGHT0);
glShadeModel (GL_SMOOTH);
glViewport(0, 0, (GLsizei)width, (GLsizei)height);
glMatrixMode(GL_PROJECTION);
gluPerspective(fovy, (GLfloat)width/(GLfloat)height, 1, 100 );
glMatrixMode(GL_MODELVIEW);
glEnable(GL_TEXTURE_2D);
glEnable( GL_BLEND );
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//render
GLfloat blankMaterial[] = {0.0, 0.0, 0.0};
GLfloat redDiffuseMaterial[] = {1.0f, 0.0f, 0.0f};
GLfloat mShininess0[] = {0};
//lighting
GLfloat DiffuseLight[] = {1.0f, 1.0f, 1.0f};
GLfloat LightPosition[] = {0.0f, 0.0f, 0.0f, 1.0f};
GLfloat AmbientLight[] = {0.0f, 0.0f, 0.0f};
GLfloat whiteSpecularLight[] = {1.0, 1.0, 1.0};
glLightfv (GL_LIGHT0, GL_AMBIENT, AmbientLight);
glLightfv(GL_LIGHT0, GL_SPECULAR, whiteSpecularLight);
glLightfv (GL_LIGHT0, GL_DIFFUSE, DiffuseLight);
glLightfv (GL_LIGHT0, GL_POSITION, LightPosition);
//end lighting
GLfloat radius, height;
glPushMatrix();
glTranslatef(0.0f, 0.0f, -5.0f);
glRotatef( 140, 1.0f, 0.0f, 0.0f );
//Render inner Cylinder
radius = 1.f;
height = .2f;
quadratic=gluNewQuadric();
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, redDiffuseMaterial);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, blankMaterial);
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mShininess0);
gluQuadricOrientation(quadratic,GLU_OUTSIDE);
gluCylinder(quadratic, radius, radius, .2f, 1000, 1);
//cap
gluQuadricOrientation(quadratic,GLU_INSIDE);
gluDisk( quadratic, 0.0, radius, 1000, 1);
glPopMatrix();
but if i take out
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
then I can see my objects
I’m trying to place a texture on the top of the cylinder, so I have a transparent png being loaded as a texture. The texture works, but I can’t seem to combine the two.