initial commit
[safbench] / menus.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
20 #include "menus.h"
21 #include "bmp_alpha.h"
22 #include <stdio.h>
23
24 #define for if(0);else for      // C2374 VC6++ on Alpha bug
25
26 #ifdef _WIN32
27 #pragma warning( disable : 4305 )
28 #define for if(0);else for      // VC6++ on Alpha bug
29 #endif
30
31 int menu = 1;                   // what menu to render
32 GLfloat check_pos;              // position of check marker in settings menu
33 GLfloat res_dial_w;             // rotate the width  resolution dial
34 GLfloat res_dial_h;             // rotate the height resolution dial
35
36 static GLuint texture_main_menu, texture_settings_menu, texture_check;          // Textures
37
38 // Load textures
39 void textures_menus()
40 {
41 #ifdef macintosh
42         texture_main_menu = LoadTexture(":textures:menu:main.bmp", 256, 256);
43         texture_settings_menu = LoadTexture(":textures:menu:settings.bmp", 256, 256);
44         texture_check = LoadTexture(":textures:menu:check.bmp", 16, 16);
45 #else
46         texture_main_menu = LoadTexture("textures/menu/main.bmp", 256, 256);
47         texture_settings_menu = LoadTexture("textures/menu/settings.bmp", 256, 256);
48         texture_check = LoadTexture("textures/menu/check.bmp", 16, 16);
49 #endif
50 }
51
52 // code for drwaing menus
53 void menus()
54 {
55         // draw main menu or settings menu
56         switch(menu)
57         {
58         case 1:
59                 glBindTexture( GL_TEXTURE_2D, texture_main_menu );
60                 glEnable(GL_TEXTURE_2D);
61                 glBegin(GL_QUADS);
62                 glNormal3f(0, 0, 1);
63                 glColor3f(1, 1, 1);
64                 glTexCoord2f(.005,0);glVertex3f(-32, -24, -41.5);
65                 glTexCoord2f(.995,0); glVertex3f(32, -24, -41.5);
66                 glTexCoord2f(.995,1);glVertex3f(32, 24, -41.5);
67                 glTexCoord2f(.005,1);glVertex3f(-32, 24, -41.5);
68                 glEnd();
69
70                 // disable texture
71                 glDisable(GL_TEXTURE_2D);
72
73                 // draw width resolution dial indicator
74                 glPushMatrix();
75                 glTranslatef (6, -17, 0);                       // position the dial indicator
76                 glRotatef(res_dial_w, 0, 0, -1);        // rotate the dial indicator
77                 glBegin(GL_QUADS);
78                 glNormal3f(0, 0, 1);
79                 glColor3f(1, 1, 1);
80                 glVertex3f(-0.5, 0, -41.0);
81                 glVertex3f(-0.1, -3.5, -41.0);
82                 glVertex3f(0.1, -3.5, -41.0);
83                 glVertex3f(0.5, 0, -41.0);
84                 glEnd();
85                 glPopMatrix();
86
87                 // draw height resolution dial indicator
88                 glPushMatrix();
89                 glTranslatef (6, -17, 0);                       // position the dial indicator
90                 glRotatef(res_dial_h, 0, 0, -1);        // rotate the dial indicator
91                 glBegin(GL_QUADS);
92                 glNormal3f(0, 0, 1);
93                 glColor3f(0.8, 0.8, 0.8);
94                 glVertex3f(-1, 0, -40.5);
95                 glVertex3f(0, -3, -40.5);
96                 glVertex3f(1, 0, -40.5);
97                 glVertex3f(0, 1, -40.5);
98                 glEnd();
99                 glPopMatrix();
100
101                 break;
102         case 2:
103                 // draws settings menu
104                 glBindTexture( GL_TEXTURE_2D, texture_settings_menu );
105                 glEnable(GL_TEXTURE_2D);
106                 glBegin(GL_QUADS);
107                 glNormal3f(0, 0, 1);
108                 glColor3f(1, 1, 1);
109                 glTexCoord2f(.005,0);glVertex3f(-32, -24, -41.5);
110                 glTexCoord2f(.995,0);glVertex3f(32, -24, -41.5);
111                 glTexCoord2f(.995,1);glVertex3f(32, 24, -41.5);
112                 glTexCoord2f(.005,1);glVertex3f(-32, 24, -41.5);
113                 glEnd();
114
115                 // disable texture
116                 glDisable(GL_TEXTURE_2D);
117
118                 // draw marker in check box in settins menu
119                 glEnable(GL_BLEND);
120                 glBindTexture( GL_TEXTURE_2D, texture_check );
121                 //else if (left_mouse_button == 1 && mouse_x_pos >= 15 && mouse_x_pos <= 47 && mouse_y_pos >= 39 && mouse_y_pos <= 62 && mouse_lock == 0)
122                 glEnable(GL_TEXTURE_2D);
123                 glBegin(GL_QUADS);
124                 glNormal3f(0, 0, 1);
125                 glColor3f(1, 1, 1);
126                 glTexCoord2f(.005,0);glVertex3f(-28.8, 16.7 - check_pos, -41);
127                 glTexCoord2f(.995,0);glVertex3f(-26.8,16.7 - check_pos, -41);
128                 glTexCoord2f(.995,1);glVertex3f(-26.8, 18.7 - check_pos, -41);
129                 glTexCoord2f(.005,1);glVertex3f(-28.8, 18.7 - check_pos, -41);
130                 glEnd();
131                 glDisable(GL_BLEND);
132                 // disable texture
133                 glDisable(GL_TEXTURE_2D);
134                 break;
135         }
136 }