summaryrefslogtreecommitdiffstats
path: root/menu_demo/button.c
blob: 2e9828650ffa6de327613cf02e21c34a9c873df4 (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
#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 ButtonRender(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));

  switch (l_iType)
  {
    case BUTTON_CLICK:
      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();
      break;
  }

} // ButtonRender