/* * PVVMUD a 3D MUD * Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include "pvvmud.H" #include "glutgui.H" #include "glrenderer.H" #include "pvvmudclient.H" CGlutGUI * CGlutGUI::m_glutgui = NULL; void glutgui_display(){ CGlutGUI::m_glutgui->display(); } void glutgui_idle() { CGlutGUI::m_glutgui->idle(); } void glutgui_reshape(int height, int width){ CGlutGUI::m_glutgui->reshape(height,width); } void glutgui_visible(int vis) { CGlutGUI::m_glutgui->visible(vis); } void glutgui_key(unsigned char k, int x, int y) { CGlutGUI::m_glutgui->getClient()->getInputFunction()->key(k, x, y); } void glutgui_special(int k, int x, int y) { CGlutGUI::m_glutgui->getClient()->getInputFunction()->special(k, x, y); } void glutgui_mouse(int button, int state, int x, int y) { CGlutGUI::m_glutgui->getClient()->getInputFunction()->mouse(button, state, x, y); } CGlutGUI::CGlutGUI(int argc, char * argv[], CRenderer * r, CPvvmudClient * cli, int width, int height) : CGUI(r, cli, width, height) { m_glutgui = this; glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH ); glutInitWindowSize(width, height); glutCreateWindow("PVVMUD"); glutDisplayFunc(glutgui_display); glutReshapeFunc(glutgui_reshape); glutVisibilityFunc(glutgui_visible); glutKeyboardFunc(glutgui_key); glutSpecialFunc(glutgui_special); glutMouseFunc(glutgui_mouse); } //int * CGlutGUI::getSize() {} void CGlutGUI::display() { ((COGLRenderer*)getRenderer())->setMode(GL_RENDER); getRenderer()->draw(); glutSwapBuffers(); } void CGlutGUI::idle() { // manager->communicate(); getClient()->getTimeKeeper()->poll(0); getClient()->pollConsole(); glutPostRedisplay(); } void CGlutGUI::visible(int vis) { if (vis == GLUT_VISIBLE) glutIdleFunc(glutgui_idle); else glutIdleFunc(NULL); } void CGlutGUI::reshape(int width, int height) { getRenderer()->reshape(width, height); } void CGlutGUI::run() { glutMainLoop(); }