Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef GLUT_Window_INCLUDE_ONCE
00033 #define GLUT_Window_INCLUDE_ONCE
00034
00035 #include <vlGLUT/link_config.hpp>
00036 #include <vlCore/Vector4.hpp>
00037 #include <vlGraphics/OpenGLContext.hpp>
00038 #include <map>
00039 #include <cstdlib>
00040 #if defined(__APPLE__)
00041 #include <GLUT/glut.h>
00042 #else
00043 #include <GL/freeglut.h>
00044 #endif
00045
00046 namespace vlut
00047 {
00048 class Applet;
00049 }
00050
00051 namespace vlGLUT
00052 {
00053
00054
00055
00059 class VLGLUT_EXPORT GLUTWindow: public vl::OpenGLContext
00060 {
00061 public:
00062 GLUTWindow();
00063
00064 GLUTWindow(const vl::String& title, const vl::OpenGLContextFormat& info, int x, int y, int width, int height);
00065
00067 bool initGLUTWindow(const vl::String& title, const vl::OpenGLContextFormat& info, int x, int y, int width, int height);
00068
00069 ~GLUTWindow()
00070 {
00071 destroyWindow();
00072 }
00073
00074 virtual void setMouseVisible(bool visible);
00075
00076 virtual void setMousePosition(int x, int y);
00077
00079 void quitApplication() { eraseAllEventListeners(); exit(0); }
00080
00081 void update();
00082
00083 bool setFullscreen(bool fs);
00084
00085 void makeCurrent();
00086
00087 void updateOverlay();
00088
00089 void swapBuffers();
00090
00091 void setWindowTitle(const vl::String& title) ;
00092
00093 int handle() const { return mHandle; }
00094
00095 void setPosition(int x, int y) ;
00096
00097 void setSize(int w, int h) ;
00098
00099 vl::ivec2 position() const;
00100
00101 vl::ivec2 size() const;
00102
00103 void show();
00104
00105 void hide();
00106
00107 void getFocus();
00108
00109 protected:
00110 void destroyWindow();
00111 void initKeymap();
00112
00113 vl::EKey mapAsciiKey(unsigned char ascii);
00114
00115 static vl::EKey mapSpecialKey(int special_key);
00116
00117 void updateModifiers();
00118
00119 static void glut_keyboard_func(unsigned char ch, int x, int y);
00120
00121 static void glut_keyboard_up_func(unsigned char ch, int x, int y);
00122
00123 static void glut_special_func(int key, int x, int y);
00124
00125 static void glut_special_up_func(int key, int x, int y);
00126
00127 static void glut_mouse_func(int button, int state, int x, int y);
00128
00129 static void glut_motion_func(int x, int y);
00130
00131 static void glut_passive_motion_func(int x, int y);
00132
00133 static void glut_mouse_wheel_func(int a, int rotation, int c, int d);
00134
00135 static void glut_visibility_func(int visibility);
00136
00137 static void glut_reshape_func(int w, int h);
00138
00139 static void glut_display_func();
00140
00141 static void glut_close_func();
00142
00143 static void glut_wmclose_func();
00144
00145
00146 static void glut_idle_func();
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156 protected:
00157 std::map<unsigned char, vl::EKey> mKeymap;
00158 int mHandle;
00159 bool mInited;
00160
00161 static std::map< int, GLUTWindow* > mWinMap;
00162 };
00163
00164 VLGLUT_EXPORT void atexit_visualization_library_shutdown();
00165 }
00166
00167 #endif