/* =============================================================================
* File - main.cpp
* -----------------------------------------------------------------------------
* GLbyte 8-bit integer signed char
* GLshort 16-bit integer short
* GLint 32-bit integer long
* GLsizei 32-bit integer long
* GLfloat 32-bit floating point float
* GLclampf 32-bit floating point float
* GLdouble 64-bit floating point double
* GLclampd 64-bit floating point double
* GLubyte 8-bit unsigned integer unsigned char
* GLboolean 8-bit unsigned integer unsigned char
* GLushort 16-bit unsigned integer unsigned short
* GLuint 32-bit unsigned integer unsigned long
* GLenum 32-bit unsigned integer unsigned long
* GLbitfield 32-bit unsigned integer unsigned long
*/
/* =============================================================================
* -----------------------------------------------------------------------------
*/
#include <GLUT/glut.h>
#include <OpenGL/gl.h>
#if 0
/* =============================================================================
* -----------------------------------------------------------------------------
*/
inline bool IsButtonUp(int button_state) {
return ((button_state bitand GLUT_UP) ? true : false);
}
/* =============================================================================
* -----------------------------------------------------------------------------
*/
inline bool IsButtonDown(int button_state) {
return ((button_state bitand GLUT_DOWN) ? true : false);
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Example usage -
* IsShiftKeyDown(glutGetModifiers())
*/
inline bool IsShiftKeyDown(int key_modifier) {
return ((key_modifier bitand GLUT_ACTIVE_SHIFT) ? true : false);
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Example usage -
* IsControlKeyDown(glutGetModifiers())
*/
inline bool IsControlKeyDown(int key_modifier) {
return ((key_modifier bitand GLUT_ACTIVE_CTRL) ? true : false);
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Example usage -
* IsAltKeyDown(glutGetModifiers())
*/
inline bool IsAltKeyDown(int key_modifier) {
return ((key_modifier bitand GLUT_ACTIVE_ALT) ? true : false);
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutOverlayDisplayFunc(OverlayDisplayHandler);
*/
static void OverlayDisplayHandler()
{
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutMotionFunc(MotionHandler);
*/
static void MotionHandler(int x, int y)
{
#pragma unused(x, y)
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutPassiveMotionFunc(PassiveMotionHandler);
*/
static void PassiveMotionHandler(int x, int y)
{
#pragma unused(x, y)
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutVisibilityFunc(VisibilityHandler);
*/
static void VisibilityHandler(int state)
{
if ( GLUT_NOT_VISIBLE == state)
{
;
} else if ( GLUT_VISIBLE == state)
{
;
}
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutEntryFunc(EntryHandler);
*/
static void EntryHandler(int state)
{
if ( GLUT_LEFT == state )
{
;
}
else if ( GLUT_ENTERED == state)
{
;
}
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutSpecialFunc(SpecialKeyDownHandler);
*
* May want to disable key repeat with -
* glutIgnoreKeyRepeat(1);
*/
static void SpecialKeyDownHandler(int key, int x, int y)
{
#pragma unused(x, y)
int key_modifier = glutGetModifiers();
switch ( key )
{
case GLUT_KEY_F1:
break;
case GLUT_KEY_F2:
break;
case GLUT_KEY_F3:
break;
case GLUT_KEY_F4:
break;
case GLUT_KEY_F5:
break;
case GLUT_KEY_F6:
break;
case GLUT_KEY_F7:
break;
case GLUT_KEY_F8:
break;
case GLUT_KEY_F9:
break;
case GLUT_KEY_F10:
break;
case GLUT_KEY_F11:
break;
case GLUT_KEY_F12:
break;
case GLUT_KEY_LEFT:
break;
case GLUT_KEY_UP:
break;
case GLUT_KEY_RIGHT:
break;
case GLUT_KEY_DOWN:
break;
case GLUT_KEY_PAGE_UP:
break;
case GLUT_KEY_PAGE_DOWN:
break;
case GLUT_KEY_HOME:
break;
case GLUT_KEY_END:
break;
case GLUT_KEY_INSERT:
break;
}
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutSpecialUpFunc(SpecialKeyUpHandler);
*
* May want to disable key repeat with -
* glutIgnoreKeyRepeat(1);
*/
static void SpecialKeyUpHandler(int key, int x, int y)
{
#pragma unused(x, y)
int key_modifier = glutGetModifiers();
switch ( key )
{
case GLUT_KEY_F1:
break;
case GLUT_KEY_F2:
break;
case GLUT_KEY_F3:
break;
case GLUT_KEY_F4:
break;
case GLUT_KEY_F5:
break;
case GLUT_KEY_F6:
break;
case GLUT_KEY_F7:
break;
case GLUT_KEY_F8:
break;
case GLUT_KEY_F9:
break;
case GLUT_KEY_F10:
break;
case GLUT_KEY_F11:
break;
case GLUT_KEY_F12:
break;
case GLUT_KEY_LEFT:
break;
case GLUT_KEY_UP:
break;
case GLUT_KEY_RIGHT:
break;
case GLUT_KEY_DOWN:
break;
case GLUT_KEY_PAGE_UP:
break;
case GLUT_KEY_PAGE_DOWN:
break;
case GLUT_KEY_HOME:
break;
case GLUT_KEY_END:
break;
case GLUT_KEY_INSERT:
break;
}
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutSpaceballMotionFunc(SpaceBallMotionHandler);
*/
static void SpaceBallMotionHandler(int x, int y, int z)
{
#pragma unused(x, y, z)
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutSpaceballRotateFunc(SpaceBallRotateHandler);
*/
static void SpaceBallRotateHandler(int x, int y, int z)
{
#pragma unused(x, y, z)
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutSpaceballButtonFunc(SpaceBallButtonHandler);
*/
static void SpaceBallButtonHandler(int button, int button_state)
{
#pragma unused(button, button_state)
// glutDeviceGet(GLUT_NUM_SPACEBALL_BUTTONS)
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutButtonBoxFunc(ButtonBoxHandler);
*/
static void ButtonBoxHandler(int button, int button_state)
{
#pragma unused(button, button_state)
// glutDeviceGet(GLUT_NUM_BUTTON_BOX_BUTTONS)
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutDialsFunc(DialsHandler);
*/
static void DialsHandler(int dial, int value)
{
#pragma unused(dial, value)
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutTabletMotionFunc(TabletMotionHandler);
*/
static void TabletMotionHandler(int x, int y)
{
#pragma unused(x, y)
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutTabletButtonFunc(TabletButtonHandler);
*/
static void TabletButtonHandler(int button, int button_state, int x, int y)
{
#pragma unused(button, button_state, x, y)
// glutDeviceGet(GLUT_NUM_TABLET_BUTTONS)
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutMenuStatusFunc(MenuStatusHandler);
*/
static void MenuStatusHandler(int status, int x, int y)
{
#pragma unused(x, y)
if ( GLUT_MENU_IN_USE == status )
{
;
}
else if ( GLUT_MENU_NOT_IN_USE == status )
{
;
}
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutIdleFunc(IdleHandler);
*/
static void IdleHandler()
{
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutTimerFunc(unsigned int msecs, TimerHandler, value);
*/
static void TimerHandler(int value)
{
#pragma unused(value)
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutReshapeFunc(ReshapeHandler);
*/
static void ReshapeHandler(int xWidth, int yHeight)
{
#pragma unused(xWidth, yHeight)
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutMouseFunc(MouseHandler);
*/
static void MouseHandler(int button, int button_state, int x, int y)
{
#pragma unused(button, button_state, x, y)
int key_modifier = glutGetModifiers();
}
#endif
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutKeyboardFunc(KeyboardHandler);
*
* May want to disable key repeat with -
* glutIgnoreKeyRepeat(1);
*/
static void KeyboardHandler(unsigned char key, int x, int y)
{
#pragma unused(key, x, y)
// int key_modifier = glutGetModifiers();
}
/* =============================================================================
* -----------------------------------------------------------------------------
* Callback Handler registered with -
* void glutDisplayFunc(DisplayHandler);
*/
static void DisplayHandler()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f, 0.0f, 0.0f);
glBegin(GL_LINES);
glVertex2i(180, 15);
glVertex2i(10, 45);
glEnd();
glFlush();
}
/* =============================================================================
* -----------------------------------------------------------------------------
*/
static void ApplicationSetUp()
{
glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0.0, 200.0, 0.0, 150.0);
}
/* =============================================================================
* -----------------------------------------------------------------------------
*/
int main( int argc, char** argv )
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(50, 100);
glutInitWindowSize(400, 300);
glutCreateWindow("An Example");
ApplicationSetUp();
glutDisplayFunc(DisplayHandler);
glutKeyboardFunc(KeyboardHandler);
glutMainLoop();
return 0;
}