-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsafe__game_mainmenu.h
151 lines (106 loc) · 3.59 KB
/
safe__game_mainmenu.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#ifndef GAME_MAINMENU_H
#define GAME_MAINMENU_H
#include "cgame.h"
#include "main.h"
#include "ccamera.h"
#include "ctexture.h"
#include <FTGL/ftgl.h>
#include "cbutton.h"
namespace NSGame_MainMenu{
/* File Variables : **********************************************************************************************************************/
int work_thread_anim_delay_msecs = 100.0;
CButton singlePlayer_button;
CButton multiPlayer_button;
CButton controls_button;
CButton exit_button;
GLuint filter; // Which Filter To Use
GLuint fogMode[]= { GL_EXP, GL_EXP2, GL_LINEAR }; // Storage For Three Types Of Fog
GLuint fogfilter= 1; // Which Fog To Use
GLfloat fogColor[4]= {0.7f, 0.7f, 0.7f, 1.0f}; // Fog Color
int numTimes_for_accum_buffer = 1;
CTexture mainMenu_backgroundImage;
float mainMenu_width, mainMenu_height;
/**********************************************************************************************************************************************/
SDL_Thread *work_thread = NULL;
void initCamera( ){
game_MainMenu.camera1 = new CCamera( );
game_MainMenu.camera1->init( CAMERA_TYPE_PERSP, 60.0, 60.0, 30.0, 1.0, 30.0 );
game_MainMenu.camera2 = new CCamera( );
game_MainMenu.camera2->init( CAMERA_TYPE_ORTHO, 0.0, 20000.0, 0.0, mainMenu_width, mainMenu_height, 100.0 );
return;
}
void renderScene( ){
glClearColor( 1.0, 1.0, 1.0, 1.0 );
glClearAccum( 0.0, 0.0, 0.0, 0.0 );
glClear(GL_ACCUM_BUFFER_BIT);
for( int i=0; i<numTimes_for_accum_buffer; i++ ){
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
game_MainMenu.camera1->writeLookAt( );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity( );
/*
glFogi(GL_FOG_MODE, fogMode[fogfilter]); // Fog Mode
glFogfv(GL_FOG_COLOR, fogColor); // Set Fog Color
glFogf(GL_FOG_DENSITY, 0.00f); // How Dense Will The Fog Be
glHint(GL_FOG_HINT, GL_NICEST); // Fog Hint Value
glFogf(GL_FOG_START, 1.0f); // Fog Start Depth
glFogf(GL_FOG_END, 100.0f); // Fog End Depth
glEnable(GL_FOG); // Enables GL_FOG
*/
game_MainMenu.camera1->rotateAboutAxis( ((i%4)>1)?X_AXIS:Z_AXIS, 0.008*(i%2?-1.0:1.0) );
board.draw( );
glAccum(GL_ACCUM, 1.0/numTimes_for_accum_buffer);
// singlePlayer_button.draw( );
}
glAccum(GL_RETURN, 1.0);
SDL_GL_SwapBuffers( );
return;
};
void eventHandler( SDL_Event &event ){
if( event.type == SDL_QUIT ){
exit(0);
}
if( event.type == SDL_KEYDOWN ){
if( event.key.keysym.sym == SDLK_ESCAPE ){
exit(0);
return;
}
if( event.key.keysym.sym == SDLK_UP ){
game_MainMenu.camera1->rotateAboutAxis( Z_AXIS, 5.0 );
game_MainMenu.camera1->setRedrawTrue( );
}
if( event.key.keysym.sym == SDLK_DOWN ){
game_MainMenu.camera1->rotateAboutAxis( Z_AXIS, -5.0 );
game_MainMenu.camera1->setRedrawTrue( );
}
}
return;
}
int work( void * ){
while( 1 ){
SDL_Delay( work_thread_anim_delay_msecs );
game_MainMenu.camera1->rotateAboutAxis( Z_AXIS, 1.0 );
}
return 0;
}
void init( ){
game_MainMenu.init( );
game_MainMenu.setGameState( MAIN_MENU );
NSGame_MainMenu::initCamera( );
game_MainMenu.setRenderScene( NSGame_MainMenu::renderScene );
game_MainMenu.setEventHandler( NSGame_MainMenu::eventHandler );
float w = get_GW( );
float h = get_GH( );
singlePlayer_button.init( "SinglePlayer", w*10/100.0, h*85/100.0, 50 );
mainMenu_width = get_GW( );
mainMenu_height = get_GH( );
mainMenu_backgroundImage.makeTexture( "./resources/images/mainMenu_background.png", PNG );
work_thread = SDL_CreateThread( work, NULL );
return;
}
void cleanup( ){
SDL_KillThread( work_thread );
return;
}
};
#endif // GAME_MAINMENU_H