Description
Overview
Included files
Included by
Source
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "Application.hpp"
static void entryCallback(int state)
{
Application* app = (Application*)Application::TheApplication;
if (app)
app->onEntry();
}
static void closeCallback()
{
Application* app = (Application*)Application::TheApplication;
if (app)
app->onClose();
glutLeaveMainLoop();
}
static void displayCallback()
{
Application* app = (Application*)Application::TheApplication;
if (app)
app->onDisplay();
}
static void idleCallback()
{
Application* app = (Application*)Application::TheApplication;
if (app)
app->onIdle();
glutPostRedisplay();
}
static void reshapeCallback(int width, int height)
{
Application* app = (Application*)Application::TheApplication;
if (app)
app->onReshape(width, height);
}
static void keyUpCallback(unsigned char key, int x, int y)
{
Application* app = (Application*)Application::TheApplication;
if (app)
app->onKeyUp(key, x, y);
}
static void keyDownCallback(unsigned char key, int x, int y)
{
Application* app = (Application*)Application::TheApplication;
if (app)
app->onKeyDown(key, x, y);
}
static void specialKeyUpCallback(int key, int x, int y)
{
Application* app = (Application*)Application::TheApplication;
if (app)
app->onSpecialKeyUp(key, x, y);
}
static void specialKeyDownCallback(int key, int x, int y)
{
Application* app = (Application*)Application::TheApplication;
if (app)
app->onSpecialKeyDown(key, x, y);
}
static void mouseClickCallback(int button, int upOrDown, int x, int y)
{
Application* app = (Application*)Application::TheApplication;
if (app)
app->onMouseClick(button, upOrDown, x, y);
}
static void mouseWheelCallback(int wheel, int direction, int x, int y)
{
Application* app = (Application*)Application::TheApplication;
if (app)
app->onMouseWheel(wheel, direction, x, y);
}
static void motionCallback(int x, int y)
{
Application* app = (Application*)Application::TheApplication;
if (app)
app->onMotion(x, y);
}
static void passiveMotionCallback(int x, int y)
{
Application* app = (Application*)Application::TheApplication;
if (app)
app->onPassiveMotion(x, y);
}
int Application::main(int argumentCount, char** argumentValues)
{
Application* app = (Application*)Application::TheApplication;
ilInit();
ilEnable(IL_CONV_PAL);
ilutEnable(ILUT_OPENGL_CONV);
glutInit(&argumentCount, argumentValues);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL);
glutInitWindowSize(app->getWidth(), app->getHeight());
glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION) ;
app->setWindowID(glutCreateWindow(app->getWindowTitle()));
glewInit();
app->onEntry();
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glutDisplayFunc(displayCallback);
glutIdleFunc(idleCallback);
glutReshapeFunc(reshapeCallback);
glutKeyboardFunc(keyDownCallback);
glutSpecialFunc(specialKeyDownCallback);
glutKeyboardUpFunc(keyUpCallback);
glutSpecialUpFunc(specialKeyUpCallback);
glutMouseFunc(mouseClickCallback);
glutMouseWheelFunc(mouseWheelCallback);
glutMotionFunc(motionCallback);
glutPassiveMotionFunc(passiveMotionCallback);
glutEntryFunc(entryCallback);
glutCloseFunc(closeCallback);
glutMainLoop();
return(0);
}