automatic download of data files
[safbench] / skybox1.cpp
1 // License information.
2 // The Software "SAF BENCH" was written by Patrik.A, also known as Nitton Attiofyra
3 // on YouTube. (https://www.youtube.com/@NittonAttiofyra)
4
5 // The software is released in to the Public Domain and comes with no warranty and is used
6 // at your own risk!
7
8 #include <stdlib.h> // VS 2005 wont compile it if its noth placed here, need to investigate
9 #ifdef macintosh
10 #include <glut.h>
11 #include <gl.h>
12 #include <glu.h>
13 #else
14 #include <GL/glut.h>
15 #include <GL/gl.h>
16 #include <GL/glu.h>
17 #endif
18 #include <iostream>
19 #include "bmp_alpha.h"
20 #include "skybox1.h"
21
22 #define for if(0);else for      // C2374 VC6++ on Alpha bug
23
24 static GLuint texture_sky1;
25
26
27 void textures_skybox1()
28 {
29 #ifdef macintosh
30         texture_sky1 = LoadTexture(":textures:runway:sky1.bmp" , 256, 256);
31 #else
32         texture_sky1 = LoadTexture("textures/runway/sky1.bmp" , 256, 256);
33 #endif
34 }
35
36 void skybox1()
37 {
38         glDisable(GL_LIGHTING);
39         glDisable(GL_LIGHT0);
40
41         // enable blending
42         //      glEnable(GL_BLEND);
43
44         // Enable culling. Remove one side of the polygons, back or front.
45         glEnable(GL_CULL_FACE);
46         glCullFace(GL_BACK);
47
48         //draw texture
49         glBindTexture( GL_TEXTURE_2D, texture_sky1 );
50         glEnable(GL_TEXTURE_2D);
51         //      glDepthMask(GL_FALSE);
52         //      glDisable(GL_DEPTH_TEST);
53
54         // left side of skybox relative to start of demo
55         glBegin(GL_QUADS);
56         glTexCoord2f(.005,.995);glVertex3f(-800, 700, -800);
57         glTexCoord2f(.995,.995);glVertex3f(-800, 700, 800);
58         glTexCoord2f(.995,.005);glVertex3f(-800, -5, 800);
59         glTexCoord2f(0,.005);glVertex3f(-800, -5, -800);
60         glEnd();
61
62         //front side of skybox realtive to start of demo
63         glBegin(GL_QUADS);
64         glTexCoord2f(0,.005);glVertex3f(-800, -5, -800);
65         glTexCoord2f(.995,.005);glVertex3f(800, -5, -800);
66         glTexCoord2f(.995,.995);glVertex3f(800, 700, -800);
67         glTexCoord2f(.005,.995);glVertex3f(-800, 700, -800);
68         glEnd();
69
70         // right side of skybox relative to start of demo
71         glBegin(GL_QUADS);
72         glTexCoord2f(0,.005);glVertex3f(800, -5, -800);
73         glTexCoord2f(.995,.005);glVertex3f(800, -5, 800);
74         glTexCoord2f(.995,.995);glVertex3f(800, 700, 800);
75         glTexCoord2f(.005,.995);glVertex3f(800, 700, -800);
76         glEnd();
77
78         //rear side of skybox realtive to start of demo
79         glBegin(GL_QUADS);
80         glTexCoord2f(.005,.995);glVertex3f(-800, 700, 800);
81         glTexCoord2f(.995,.995);glVertex3f(800, 700, 800);
82         glTexCoord2f(.995,.005);glVertex3f(800, -5, 800);
83         glTexCoord2f(0,.005);glVertex3f(-800, -5, 800);
84         glEnd();
85
86         //      glDepthMask(GL_TRUE);
87         //      glEnable(GL_DEPTH_TEST);
88
89         // disable texture
90         glDisable(GL_TEXTURE_2D);
91
92         // disable culling
93         glDisable(GL_CULL_FACE);
94
95         // disable blending
96         //      glDisable (GL_BLEND);
97
98         glEnable(GL_LIGHTING);
99         glEnable(GL_LIGHT0);
100
101 }