blob: 265c4d8639360c8802850bd9661b2e7a3e4fd680 (
plain)
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
|
#ifdef G_OS_WIN32
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#endif
#include <GL/gl.h>
#include <stdlib.h>
#include "menu.h"
#include "button.h"
#define MENU_MAX_BUTTONS 16
enum MenuState {
MENU_MAIN,
MENU_START,
MENU_OPTIONS
};
struct MenuStruct {
enum MenuState m_eMenuId;
int m_iButtonCount;
struct ButtonStruct m_sButtons[MENU_MAX_BUTTONS];
};
struct MenuStruct g_sMenuMain; // definition of the main menu
struct MenuStruct g_sMenuStart; // definition of the start menu
struct MenuStruct g_sMenuOptions; // definition of the options menu
struct MenuStruct *g_pCurMenu; // current menu
int g_iWinWidth;
int g_iWinHeight;
void MenuInit(int f_iWinWidth, int f_iWinHeight)
{
// init menu props
g_iWinWidth = f_iWinWidth;
g_iWinHeight = f_iWinHeight;
// init main menu
g_sMenuMain.m_eMenuId = MENU_MAIN;
g_sMenuMain.m_sButtons[0].m_dWidth = 200;
g_sMenuMain.m_sButtons[0].m_dXPos = 0;
g_sMenuMain.m_sButtons[0].m_dYPos = 0;
g_sMenuMain.m_sButtons[0].m_iType = BUTTON_CLICK;
g_sMenuMain.m_iButtonCount = 1;
// init start menu
g_sMenuStart.m_eMenuId = MENU_START;
g_sMenuStart.m_iButtonCount = 0;
// init options menu
g_sMenuOptions.m_eMenuId = MENU_OPTIONS;
g_sMenuOptions.m_iButtonCount = 0;
// set pointer to the current menu
g_pCurMenu = &g_sMenuMain;
} // InitMenu
void MenuRender(void)
{
int i = 0;
glDisable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
glColor3d(1, 1, 1);
glPushMatrix();
while (i < g_pCurMenu->m_iButtonCount)
{
ButtonRender(&g_pCurMenu->m_sButtons[i]);
i++;
}
glPopMatrix();
} // Render
|