# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

# D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGLUT/GLUTWindow.hpp

Go to the documentation of this file.

    00001 /**************************************************************************************/
    00002 /*                                                                                    */
    00003 /*  Visualization Library                                                             */
    00004 /*  http://www.visualizationlibrary.org                                               */
    00005 /*                                                                                    */
    00006 /*  Copyright (c) 2005-2010, Michele Bosi                                             */
    00007 /*  All rights reserved.                                                              */
    00008 /*                                                                                    */
    00009 /*  Redistribution and use in source and binary forms, with or without modification,  */
    00010 /*  are permitted provided that the following conditions are met:                     */
    00011 /*                                                                                    */
    00012 /*  - Redistributions of source code must retain the above copyright notice, this     */
    00013 /*  list of conditions and the following disclaimer.                                  */
    00014 /*                                                                                    */
    00015 /*  - Redistributions in binary form must reproduce the above copyright notice, this  */
    00016 /*  list of conditions and the following disclaimer in the documentation and/or       */
    00017 /*  other materials provided with the distribution.                                   */
    00018 /*                                                                                    */
    00019 /*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND   */
    00020 /*  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED     */
    00021 /*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE            */
    00022 /*  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR  */
    00023 /*  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    */
    00024 /*  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;      */
    00025 /*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON    */
    00026 /*  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT           */
    00027 /*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS     */
    00028 /*  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                      */
    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> // exit()
    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 // GLUTWindow
    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     // used for continuous update
    00146     static void glut_idle_func();
    00147
    00148     // static void glut_overlay_display_func();
    00149
    00150     // does not seem to work properly or usefully
    00151     // static void glut_entry_func(int leave_enter);
    00152
    00153     // not used
    00154     // static void glut_timer_func(int value);
    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

Visualization Library v2011.09.1162 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu Jan 26 2012 00:43:35.
Permission is granted to use this page to write and publish articles regarding Visualization Library.