00001
00005 #ifndef GLUTWINDOW_H
00006 #define GLUTWINDOW_H
00007
00008 #include <G3D/G3DAll.h>
00009
00010 #if G3D_VER < 60300
00011 #error Requires G3D 6.03
00012 #endif
00013
00014 #define GLUT_API_VERSION 4
00015 #include <GL/glut.h>
00016
00017
00018
00036
00037
00038
00039 class GlutWindow : public GWindow {
00040 private:
00041
00043 static bool glutInitialized;
00044
00046 int glutWindowHandle;
00047
00048 int _mouseHideCount;
00049
00050 std::string _windowTitle;
00051
00052 Rect2D _dimensions;
00053
00054 GWindow::Settings settings;
00055
00056 Queue<GEvent> eventQueue;
00057
00058 Vector2 mouse;
00059
00060 uint8 mouseButtons;
00061
00063 static GlutWindow* currentGlutWindow;
00064
00066 void postEvent(GEvent& evt);
00067
00068
00069 static void g_reshape(int width, int height);
00070 static void g_keyboard(unsigned char c, int x, int y);
00071 static void g_keyboardspecial(int key, int x, int y);
00072 static void g_keyboardup(unsigned char c, int x, int y);
00073 static void g_keyboardspecialup(int key, int x, int y);
00074 static void g_mousemotion(int x, int y);
00075 static void g_mousebtn(int b, int s, int x, int y);
00076 static void g_draw();
00077
00078 public:
00079
00080 GlutWindow(const GWindow::Settings& s);
00081 virtual ~GlutWindow();
00082 virtual void getSettings(GWindow::Settings& settings) const;
00083 virtual int width() const;
00084 virtual int height() const;
00085 virtual Rect2D dimensions() const;
00086 virtual void setDimensions(const Rect2D& dims);
00087 virtual void setPosition(int x, int y);
00088 virtual bool hasFocus() const;
00089 virtual std::string getAPIVersion() const;
00090 virtual std::string getAPIName() const;
00091 virtual void setGammaRamp(const Array<uint16>& gammaRamp);
00092 virtual void setCaption(const std::string& caption);
00093 virtual int numJoysticks() const;
00094 virtual std::string joystickName(unsigned int sticknum);
00095 virtual std::string caption();
00096 virtual void setIcon(const GImage& image);
00097 virtual void swapGLBuffers();
00098 virtual void notifyResize(int w, int h);
00099 virtual bool pollEvent(GEvent& e);
00100
00101 virtual bool requiresMainLoop() const {
00102 return true;
00103 }
00104
00105 virtual void runMainLoop();
00106 virtual void setRelativeMousePosition(double x, double y);
00107 virtual void setRelativeMousePosition(const Vector2& p);
00108 virtual void getRelativeMouseState(Vector2& position, uint8& mouseButtons) const;
00109 virtual void getRelativeMouseState(int& x, int& y, uint8& mouseButtons) const;
00110 virtual void getRelativeMouseState(double& x, double& y, uint8& mouseButtons) const;
00111 virtual void getJoystickState(unsigned int stickNum, Array<float>& axis, Array<bool>& button);
00112 virtual void setInputCapture(bool c);
00113 virtual bool inputCapture() const;
00114
00115 virtual bool mouseVisible() const;
00116 virtual void setMouseVisible(bool v);
00117 virtual void incMouseHideCount();
00118 virtual void decMouseHideCount();
00119
00120 virtual void getDroppedFilenames(G3D::Array<std::string>&);
00121 };
00122
00123
00124 #endif