automatic download of data files
[safbench] / runway.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 not 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 "runway.h"
21
22 static GLuint texture_bg, texture_grass, texture_ground;
23
24
25 void textures_runway()
26 {
27 #ifdef macintosh
28         texture_bg = LoadTexture(":textures:runway:runway.bmp" , 256, 256);
29         texture_grass = LoadTexture(":textures:runway:grass_runway.bmp" , 256, 256);
30         texture_ground = LoadTexture(":textures:runway:ground.bmp" , 256, 256);
31 #else
32         texture_bg = LoadTexture("textures/runway/runway.bmp" , 256, 256);
33         texture_grass = LoadTexture("textures/runway/grass_runway.bmp" , 256, 256);
34         texture_ground = LoadTexture("textures/runway/ground.bmp" , 256, 256);
35 #endif
36 }
37
38 void runway()
39 {
40         // enable blending
41         glEnable(GL_BLEND);
42
43         // Enable culling. Remove one side of the polygons, back or front.
44         glEnable(GL_CULL_FACE);
45         glCullFace(GL_BACK);
46
47         //draw ground texture
48         glBindTexture( GL_TEXTURE_2D, texture_ground );
49         glEnable(GL_TEXTURE_2D);
50
51         glBegin(GL_QUADS);
52         glNormal3f(0, 1, 0);
53         glTexCoord2f(.005,0);glVertex3f(-2100, -0.2, 2100);
54         glTexCoord2f(50,0);glVertex3f(2100, -0.2, 2100);
55         glTexCoord2f(50,50);glVertex3f(2100, -0.2, -2100);
56         glTexCoord2f(.005,50);glVertex3f(-2100, -0.2, -2100);
57         glEnd();
58
59         //draw grass texture
60         glBindTexture( GL_TEXTURE_2D, texture_grass );
61
62         glBegin(GL_QUADS);
63         glNormal3f(0, 1, 0);
64         glTexCoord2f(.005,0);glVertex3f(-1032, -0.04, 32);
65         glTexCoord2f(50,0);glVertex3f(1032, -0.04, 32);
66         glTexCoord2f(50,1);glVertex3f(1032, -0.04, -32);
67         glTexCoord2f(.005,1);glVertex3f(-1032, -0.04, -32);
68         glEnd();
69
70         //draw runway texture
71         glBindTexture( GL_TEXTURE_2D, texture_bg );
72
73         glBegin(GL_QUADS);
74         glNormal3f(0, 1, 0);
75         glTexCoord2f(.005,0);glVertex3f(-1000, 0, 8);
76         glTexCoord2f(50,0);glVertex3f(1000, 0, 8);
77         glTexCoord2f(50,1);glVertex3f(1000, 0, -8);
78         glTexCoord2f(.005,1);glVertex3f(-1000, 0, -8);
79         glEnd();
80
81         // disable texture
82         glDisable(GL_TEXTURE_2D);
83
84         // disable culling
85         glDisable(GL_CULL_FACE);
86
87         // disable blending
88         glDisable(GL_BLEND);
89
90 }