Commit 2b4a20d6 authored by Oliver Bock's avatar Oliver Bock

Added preliminary texture for pulsar

parent 57281889
......@@ -105,6 +105,17 @@ void PulsarAnimationWidget::initializeGL()
gluQuadricNormals(m_quadricPulsar, GLU_SMOOTH);
gluQuadricNormals(m_quadricPulsarCone1, GLU_SMOOTH);
gluQuadricNormals(m_quadricPulsarCone2, GLU_SMOOTH);
// load pulsar texture
m_pulsarTexture = bindTexture(QImage(":/textures/resources/texture_pulsar.png"), GL_TEXTURE_2D, GL_RGBA);
// use mipmap filter
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
// enable 2D sphere mapping (s/t coordinates)
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
}
void PulsarAnimationWidget::resizeGL(int w, int h)
......@@ -135,7 +146,7 @@ void PulsarAnimationWidget::paintGL()
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_specular[] = { 1.0, 1.0, 1.0, 1.0 };
static GLfloat low_shininess[] = { 5.0 };
static GLfloat low_shininess[] = { 2.5 };
glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat);
glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
......@@ -156,9 +167,21 @@ void PulsarAnimationWidget::paintGL()
cos(m_orbitRotationAngle * deg2rad) * m_pulsarOrbitRadius);
glPushMatrix();
// enable texture coordinates and bind texture
glEnable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glBindTexture(GL_TEXTURE_2D, m_pulsarTexture);
// FIXME: how to rotate texture?
glRotatef(m_pulsarRotationAngle, 0.0f, 1.0f, 0.0f);
glRotatef(m_pulsarSpinAxisInclination, 1.0f, 0.0f, 0.0f);
gluSphere(m_quadricPulsar, 1.0f, 32, 32);
// disable texture coordinates
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_2D);
glPopMatrix();
// TODO: should be located elsewhere
......
......@@ -71,6 +71,8 @@ protected:
GLUquadricObj *m_quadricPulsarCone1;
GLUquadricObj *m_quadricPulsarCone2;
GLuint m_pulsarTexture;
int m_framesPerSecond;
float m_pulsarRotationAngle;
......
......@@ -9,4 +9,7 @@
<file>resources/help-website.png</file>
<file>resources/aei-icon48.png</file>
</qresource>
<qresource prefix="textures" >
<file>resources/texture_pulsar.png</file>
</qresource>
</RCC>
Markdown is supported
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