glapp.h
上传用户:qccn516
上传日期:2013-05-02
资源大小:3382k
文件大小:2k
源码类别:

游戏引擎

开发平台:

Visual C++

  1. /* OpenGL App
  2.  *
  3.  * Copyright (C) 2003-2004, Alexander Zaprjagaev <frustum@frustum.org>
  4.  *
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or
  8.  * (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18.  */
  19. #ifndef __GLAPP_H__
  20. #define __GLAPP_H__
  21. #include <stdio.h>
  22. #ifdef _WIN32
  23. #include <windows.h>
  24. #endif
  25. #include <GL/gl.h>
  26. #include <GL/glext.h>
  27. #include <GL/glu.h>
  28. class GLApp {
  29. public:
  30. GLApp();
  31. virtual ~GLApp();
  32. int setVideoMode(int w,int h,int fs = 0);
  33. void setTitle(const char *title);
  34. void setCursor(int x,int y);
  35. void showCursor(int show);
  36. void checkExtension(const char *extension);
  37. void error();
  38. static void exit(const char *error = NULL,...);
  39. int selectFile(const char *title,char *name);
  40. void main();
  41. virtual void idle() { }
  42. virtual void render() { }
  43. virtual void buttonPress(int) { }
  44. virtual void buttonRelease(int) { }
  45. virtual void keyPress(int) { }
  46. virtual void keyRelease(int) { }
  47. enum {
  48. KEY_ESC = 256,
  49. KEY_TAB,
  50. KEY_RETURN,
  51. KEY_BACKSPACE,
  52. KEY_DELETE,
  53. KEY_HOME,
  54. KEY_END,
  55. KEY_PGUP,
  56. KEY_PGDOWN,
  57. KEY_LEFT,
  58. KEY_RIGHT,
  59. KEY_UP,
  60. KEY_DOWN,
  61. KEY_SHIFT,
  62. KEY_CTRL,
  63. KEY_ALT
  64. };
  65. enum {
  66. BUTTON_LEFT = 1 << 0,
  67. BUTTON_MIDDLE = 1 << 1,
  68. BUTTON_RIGHT = 1 << 2,
  69. BUTTON_UP = 1 << 3,
  70. BUTTON_DOWN = 1 << 4
  71. };
  72. int keys[512];
  73. int windowWidth;
  74. int windowHeight;
  75. int fullScreen;
  76. char title[1024];
  77. int mouseX;
  78. int mouseY;
  79. int mouseButton;
  80. float fps;
  81. float ifps;
  82. };
  83. #endif /* __GLAPP_H__ */