summaryrefslogtreecommitdiffstats
path: root/menu_demo/button.c
blob: cafa94a7be541567e101d1562677c01adf84b60d (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
#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 50

enum ButtonType {
  BUTTON_CLICK,
  BUTTON_RADIO,
  BUTTON_LABEL
};

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));

  glBegin(GL_QUADS);
    glVertex3d(l_dXPos,            l_dYPos,                       0);
    glVertex3d(l_dXPos + l_dWidth, l_dYPos,                       0);
    glVertex3d(l_dXPos + l_dWidth, l_dYPos - BUTTON_CLICK_HEIGHT, 0);
    glVertex3d(l_dXPos,            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