Commit 96ea06bd authored by Oliver Bock's avatar Oliver Bock
Browse files

Objects have to be rendered in the right order for alpha blending to work

parent 401554dc
...@@ -73,11 +73,12 @@ PulsarAnimationWidget::~PulsarAnimationWidget() ...@@ -73,11 +73,12 @@ PulsarAnimationWidget::~PulsarAnimationWidget()
void PulsarAnimationWidget::initializeGL() void PulsarAnimationWidget::initializeGL()
{ {
glShadeModel(GL_SMOOTH);
glClearColor(0.0, 0.0, 0.0, 0.0); glClearColor(0.0, 0.0, 0.0, 0.0);
glClearDepth(1.0f); glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
GLfloat LightAmbient[] = { 0.3f, 0.3f, 0.3f, 1.0f }; GLfloat LightAmbient[] = { 0.3f, 0.3f, 0.3f, 1.0f };
...@@ -98,8 +99,8 @@ void PulsarAnimationWidget::initializeGL() ...@@ -98,8 +99,8 @@ void PulsarAnimationWidget::initializeGL()
glEnable(GL_LIGHT0); glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
m_quadricPulsarOrbitPlane = gluNewQuadric(); m_quadricPulsarOrbitPlane = gluNewQuadric();
m_quadricPulsar = gluNewQuadric(); m_quadricPulsar = gluNewQuadric();
...@@ -135,19 +136,6 @@ void PulsarAnimationWidget::paintGL() ...@@ -135,19 +136,6 @@ void PulsarAnimationWidget::paintGL()
0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0); 0.0, 1.0, 0.0);
if(m_cameraInteraction) {
static GLfloat pulsarOrbitAmbientDiffuse[] = { 1.0, 1.0, 1.0, 0.25 };
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, pulsarOrbitAmbientDiffuse);
glPushMatrix();
glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
gluDisk(m_quadricPulsarOrbitPlane,
m_pulsarOrbitRadius * 0.9f,
m_pulsarOrbitRadius * 1.1f,
64, 1);
glPopMatrix();
}
// TODO: should be located elsewhere // TODO: should be located elsewhere
static GLfloat no_mat[] = { 0.0, 0.0, 0.0, 1.0 }; static GLfloat no_mat[] = { 0.0, 0.0, 0.0, 1.0 };
static GLfloat mat_diffuse[] = { 0.5, 0.5, 0.5, 1.0 }; static GLfloat mat_diffuse[] = { 0.5, 0.5, 0.5, 1.0 };
...@@ -198,6 +186,19 @@ void PulsarAnimationWidget::paintGL() ...@@ -198,6 +186,19 @@ void PulsarAnimationWidget::paintGL()
gluCylinder(m_quadricPulsarCone2, 0.5f, 0.0f, 3.0f, 32, 32); gluCylinder(m_quadricPulsarCone2, 0.5f, 0.0f, 3.0f, 32, 32);
glPopMatrix(); glPopMatrix();
glPopMatrix(); glPopMatrix();
if(m_cameraInteraction) {
static GLfloat pulsarOrbitAmbientDiffuse[] = { 1.0, 1.0, 1.0, 0.33 };
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, pulsarOrbitAmbientDiffuse);
glPushMatrix();
glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
gluDisk(m_quadricPulsarOrbitPlane,
m_pulsarOrbitRadius * 0.9f,
m_pulsarOrbitRadius * 1.1f,
64, 1);
glPopMatrix();
}
} }
void PulsarAnimationWidget::runAnimation() void PulsarAnimationWidget::runAnimation()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment