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
|
#ifdef G_OS_WIN32
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#endif
#include <GL/gl.h>
#include "button.h"
#include "bitmap.h"
#define BUTTON_CLICK_HEIGHT 49
void ButtonClickRender(struct ButtonStruct *f_sButton)
{
char l_pcTitle[BUTTON_MAX_TITLE];
double l_dWidth = f_sButton->m_dWidth;
double l_dXPos = f_sButton->m_dXPos;
double l_dYPos = f_sButton->m_dYPos;
int l_iType = f_sButton->m_iType;
memset(&l_pcTitle, 0, sizeof(l_pcTitle));
memcpy(&l_pcTitle, f_sButton->m_pcTitle, sizeof(f_sButton->m_pcTitle));
BitmapLoad("img/button_click_left.bmp");
glBegin(GL_QUADS);
glTexCoord3d(0, 1, 0); glVertex3d(l_dXPos, l_dYPos, 0);
glTexCoord3d(1, 1, 0); glVertex3d(l_dXPos + 26, l_dYPos, 0);
glTexCoord3d(1, 0, 0); glVertex3d(l_dXPos + 26, l_dYPos - BUTTON_CLICK_HEIGHT, 0);
glTexCoord3d(0, 0, 0); glVertex3d(l_dXPos, l_dYPos - BUTTON_CLICK_HEIGHT, 0);
glEnd();
BitmapLoad("img/button_click_right.bmp");
glBegin(GL_QUADS);
glTexCoord3d(0, 1, 0); glVertex3d(l_dXPos + 24 + l_dWidth, l_dYPos, 0);
glTexCoord3d(1, 1, 0); glVertex3d(l_dXPos + 24 + l_dWidth + 25, l_dYPos, 0);
glTexCoord3d(1, 0, 0); glVertex3d(l_dXPos + 24 + l_dWidth + 25, l_dYPos - BUTTON_CLICK_HEIGHT, 0);
glTexCoord3d(0, 0, 0); glVertex3d(l_dXPos + 24 + l_dWidth, l_dYPos - BUTTON_CLICK_HEIGHT, 0);
glEnd();
if (l_dWidth > 0)
{
BitmapLoad("img/button_click_center.bmp");
glBegin(GL_QUADS);
glTexCoord3d(0, 1, 0); glVertex3d(l_dXPos + 25, l_dYPos, 0);
glTexCoord3d(1, 1, 0); glVertex3d(l_dXPos + 25 + l_dWidth, l_dYPos, 0);
glTexCoord3d(1, 0, 0); glVertex3d(l_dXPos + 25 + l_dWidth, l_dYPos - BUTTON_CLICK_HEIGHT, 0);
glTexCoord3d(0, 0, 0); glVertex3d(l_dXPos + 25, l_dYPos - BUTTON_CLICK_HEIGHT, 0);
glEnd();
}
} // ButtonClickRender
void ButtonRender(struct ButtonStruct *f_sButton)
{
int l_iType = f_sButton->m_iType;
switch (l_iType)
{
case BUTTON_CLICK:
ButtonClickRender(f_sButton);
break;
case BUTTON_RADIO:
case BUTTON_LABEL:
default:
break;
}
} // ButtonRender
|