automatic download of data files
[safbench] / ground2.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 #include <iostream>
18 #endif
19 #include "bmp_alpha.h"
20 #include "ground2.h"
21
22 static GLuint texture_ground2_1,texture_ground2_2,texture_ground2_3,texture_ground2_4;
23 static GLuint texture_ground3_1,texture_ground3_2,texture_ground3_3,texture_ground3_4;
24 int draw_ground2 = 1;           // draw ground2 or ground3
25
26
27 void textures_ground2()
28 {
29 #ifdef macintosh
30         texture_ground2_1 = LoadTexture(":textures:ground2:ground2_1.bmp" , 256, 256);
31         texture_ground2_2 = LoadTexture(":textures:ground2:ground2_2.bmp" , 256, 256);
32         texture_ground2_3 = LoadTexture(":textures:ground2:ground2_3.bmp" , 256, 256);
33         texture_ground2_4 = LoadTexture(":textures:ground2:ground2_4.bmp" , 256, 256);
34         texture_ground3_1 = LoadTexture(":textures:ground3:ground3_1.bmp" , 256, 256);
35         texture_ground3_2 = LoadTexture(":textures:ground3:ground3_2.bmp" , 256, 256);
36         texture_ground3_3 = LoadTexture(":textures:ground3:ground3_3.bmp" , 256, 256);
37         texture_ground3_4 = LoadTexture(":textures:ground3:ground3_4.bmp" , 256, 256);
38 #else
39         texture_ground2_1 = LoadTexture("textures/ground2/ground2_1.bmp" , 256, 256);
40         texture_ground2_2 = LoadTexture("textures/ground2/ground2_2.bmp" , 256, 256);
41         texture_ground2_3 = LoadTexture("textures/ground2/ground2_3.bmp" , 256, 256);
42         texture_ground2_4 = LoadTexture("textures/ground2/ground2_4.bmp" , 256, 256);
43         texture_ground3_1 = LoadTexture("textures/ground3/ground3_1.bmp" , 256, 256);
44         texture_ground3_2 = LoadTexture("textures/ground3/ground3_2.bmp" , 256, 256);
45         texture_ground3_3 = LoadTexture("textures/ground3/ground3_3.bmp" , 256, 256);
46         texture_ground3_4 = LoadTexture("textures/ground3/ground3_4.bmp" , 256, 256);
47 #endif
48
49 }
50
51 void ground2()
52 {
53         // enable blending
54         glEnable(GL_BLEND);
55
56         // Enable culling. Remove one side of the polygons, back or front.
57         glEnable(GL_CULL_FACE);
58         glCullFace(GL_BACK);
59
60         if ( draw_ground2 == 1 )
61         {
62                 //draw texture
63                 glBindTexture( GL_TEXTURE_2D, texture_ground2_1 );
64                 glEnable(GL_TEXTURE_2D);
65
66                 glBegin(GL_QUADS);
67                 glNormal3f(0, 1, 0);
68                 glTexCoord2f(.002,0);glVertex3f(0, 0, 700);
69                 glTexCoord2f(.998,0);glVertex3f(0, 0, 0);
70                 glTexCoord2f(.998,1);glVertex3f(-700, 0, 0);
71                 glTexCoord2f(.002,1);glVertex3f(-700, 0, 700);
72                 glEnd();
73
74                 //draw texture
75                 glBindTexture( GL_TEXTURE_2D, texture_ground2_2 );
76
77                 glBegin(GL_QUADS);
78                 glNormal3f(0, 1, 0);
79                 glTexCoord2f(.002,0);glVertex3f(0, 0, 0);
80                 glTexCoord2f(.998,0);glVertex3f(0, 0, -700);
81                 glTexCoord2f(.998,1);glVertex3f(-700, 0, -700);
82                 glTexCoord2f(.002,1);glVertex3f(-700, 0, 0);
83                 glEnd();
84
85                 //draw texture
86                 glBindTexture( GL_TEXTURE_2D, texture_ground2_3 );
87
88                 glBegin(GL_QUADS);
89                 glNormal3f(0, 1, 0);
90                 glTexCoord2f(.002,0);glVertex3f(700, 0, 700);
91                 glTexCoord2f(.998,0);glVertex3f(700, 0, 0);
92                 glTexCoord2f(.998,1);glVertex3f(0, 0, 0);
93                 glTexCoord2f(.002,1);glVertex3f(0, 0, 700);
94                 glEnd();
95
96                 //draw texture
97                 glBindTexture( GL_TEXTURE_2D, texture_ground2_4 );
98
99                 glBegin(GL_QUADS);
100                 glNormal3f(0, 1, 0);
101                 glTexCoord2f(.002,0);glVertex3f(700, 0, 0);
102                 glTexCoord2f(.998,0);glVertex3f(700, 0, -700);
103                 glTexCoord2f(.998,1);glVertex3f(0, 0, -700);
104                 glTexCoord2f(.002,1);glVertex3f(0, 0, 0);
105                 glEnd();
106
107         }
108
109         else if ( draw_ground2 == 0 )
110         {
111                 //draw texture
112                 glBindTexture( GL_TEXTURE_2D, texture_ground3_1 );
113                 glEnable(GL_TEXTURE_2D);
114
115                 glBegin(GL_QUADS);
116                 glNormal3f(0, 1, 0);
117                 glTexCoord2f(.002,0);glVertex3f(0, 0, 2100);
118                 glTexCoord2f(.998,0);glVertex3f(0, 0, 0);
119                 glTexCoord2f(.998,1);glVertex3f(-2100, 0, 0);
120                 glTexCoord2f(.002,1);glVertex3f(-2100, 0, 2100);
121                 glEnd();
122
123                 //draw texture
124                 glBindTexture( GL_TEXTURE_2D, texture_ground3_2 );
125
126                 glBegin(GL_QUADS);
127                 glNormal3f(0, 1, 0);
128                 glTexCoord2f(.002,0);glVertex3f(0, 0, 0);
129                 glTexCoord2f(.998,0);glVertex3f(0, 0, -2100);
130                 glTexCoord2f(.998,1);glVertex3f(-2100, 0, -2100);
131                 glTexCoord2f(.002,1);glVertex3f(-2100, 0, 0);
132                 glEnd();
133
134                 //draw texture
135                 glBindTexture( GL_TEXTURE_2D, texture_ground3_3 );
136                 glEnable(GL_TEXTURE_2D);
137
138                 glBegin(GL_QUADS);
139                 glNormal3f(0, 1, 0);
140                 glTexCoord2f(.002,0);glVertex3f(2100, 0, 2100);
141                 glTexCoord2f(.998,0);glVertex3f(2100, 0, 0);
142                 glTexCoord2f(.998,1);glVertex3f(00, 0, 0);
143                 glTexCoord2f(.002,1);glVertex3f(0, 0, 2100);
144                 glEnd();
145
146                 //draw texture
147                 glBindTexture( GL_TEXTURE_2D, texture_ground3_4 );
148                 glEnable(GL_TEXTURE_2D);
149
150                 glBegin(GL_QUADS);
151                 glNormal3f(0, 1, 0);
152                 glTexCoord2f(.002,0);glVertex3f(2100, 0, 0);
153                 glTexCoord2f(.998,0);glVertex3f(2100, 0, -2100);
154                 glTexCoord2f(.998,1);glVertex3f(0, 0, -2100);
155                 glTexCoord2f(.002,1);glVertex3f(0, 0, 0);
156                 glEnd();
157         }
158
159         // disable texture
160         glDisable(GL_TEXTURE_2D);
161
162         // disable culling
163         glDisable(GL_CULL_FACE);
164
165         // disable blending
166         glDisable (GL_BLEND);
167 }