Created
January 14, 2017 00:50
-
-
Save kdrnic/53e3df90bc29bec174d4fc3655309a67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float RadToDegree(float rad) | |
{ | |
return (360.0 * rad) / (2.0 * M_PI); | |
} | |
float DegreeToRad(float degree) | |
{ | |
return (degree * 2.0 * M_PI) / 360.0; | |
} | |
void InverseModelView(GLfloat *_m) | |
{ | |
GLfloat m[16]; | |
glGetFloatv(GL_MODELVIEW_MATRIX, m); | |
for(int i = 0; i < 16; i++) _m[i] = 0; | |
/* | |
a[0] a[4] a[8] a[12] | |
a[1] a[5] a[9] a[13] | |
a[2] a[6] a[10]a[14] | |
a[3] a[7] a[11]a[15] | |
*/ | |
/* | |
_m[0] = m[0]; | |
_m[5] = m[5]; | |
_m[10] = m[10]; | |
_m[1] = m[4]; | |
_m[4] = m[1]; | |
_m[2] = m[8]; | |
_m[8] = m[2]; | |
_m[6] = m[9]; | |
_m[9] = m[6]; | |
_m[15] = 1.0; | |
*/ | |
_m[0] = m[0]; | |
_m[5] = m[5]; | |
_m[10] = m[10]; | |
_m[1] = m[1]; | |
_m[4] = m[4]; | |
_m[2] = m[2]; | |
_m[8] = m[8]; | |
_m[6] = m[6]; | |
_m[9] = m[9]; | |
_m[15] = 1.0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GLuint skyTexture; | |
GLUquadric *skyQuadric; | |
const float skyRadius = 1000.0; | |
void InitSky() | |
{ | |
BITMAP *bmp = load_bitmap("sky.bmp", 0); | |
skyTexture = allegro_gl_make_texture(bmp); | |
destroy_bitmap(bmp); | |
skyQuadric = gluNewQuadric(); | |
gluQuadricTexture(skyQuadric, true); | |
} | |
void RenderSky() | |
{ | |
glCullFace(GL_FRONT); | |
//glDisable(GL_DEPTH_TEST); | |
glDepthMask(false); | |
glPushMatrix(); | |
GLfloat m[16]; | |
InverseModelView(m); | |
glLoadMatrixf(m); | |
glRotatef(90, 1.0, 0.0, 0.0); | |
glBindTexture(GL_TEXTURE_2D, skyTexture); | |
gluSphere(skyQuadric, skyRadius, 10, 20); | |
glPopMatrix(); | |
glDepthMask(true); | |
//glEnable(GL_DEPTH_TEST); | |
glCullFace(GL_BACK); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment