Visualization Library v1.0.3A lightweight C++ OpenGL middleware for 2D/3D graphics |
[Download] [Tutorials] [All Classes] [Grouped Classes] |
00001 /**************************************************************************************/ 00002 /* */ 00003 /* Visualization Library */ 00004 /* http://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 Win32Context_INCLUDE_ONCE 00033 #define Win32Context_INCLUDE_ONCE 00034 00035 #include <vlWin32/link_config.hpp> 00036 #include <vlGraphics/OpenGLContext.hpp> 00037 00038 namespace vlWin32 00039 { 00040 //----------------------------------------------------------------------------- 00041 VLWIN32_EXPORT int choosePixelFormat(const vl::OpenGLContextFormat& fmt, bool verbose = true); 00042 //----------------------------------------------------------------------------- 00046 class VLWIN32_EXPORT Win32Context: public vl::OpenGLContext 00047 { 00048 public: 00049 Win32Context(): mHDC(NULL), mHGLRC(NULL) {} 00050 00051 Win32Context(int w, int h): OpenGLContext(w,h), mHDC(NULL), mHGLRC(NULL) {} 00052 00053 ~Win32Context(); 00054 00055 virtual HWND hwnd() const = 0; 00056 00057 HDC hdc() const { return mHDC; } 00058 00059 HGLRC hglrc() const { return mHGLRC; } 00060 00066 void shareOpenGLResources(HGLRC hGLRC); 00067 00068 void makeCurrent(); 00069 00070 void update(); 00071 00072 void swapBuffers(); 00073 00074 void setWindowTitle(const vl::String& title); 00075 00076 void show(); 00077 00078 void hide(); 00079 00080 void getFocus(); 00081 00082 void setMouseVisible(bool visible); 00083 00084 void setMousePosition(int x, int y); 00085 00086 void setPosition(int x, int y); 00087 00088 vl::ivec2 position() const; 00089 00092 void setSize(int w, int h); 00093 00095 vl::ivec2 size() const; 00096 00098 void setWindowSize(int w, int h); 00099 00102 vl::ivec2 windowSize() const; 00103 00104 bool setFullscreen(bool fullscreen_on); 00105 00107 void quitApplication(); 00108 00111 const std::vector<int>& contextAttribs() const { return mContextAttribs; } 00112 00115 std::vector<int>& contextAttribs() { return mContextAttribs; } 00116 00119 void setContextAttribs(const int* attribs, int size); 00120 00121 protected: 00122 bool initWin32GLContext(HGLRC share_context, const vl::String& title, const vl::OpenGLContextFormat& fmt, int x, int y, int width, int height); 00123 00124 protected: 00125 std::vector<int> mContextAttribs; 00126 00127 HDC mHDC; 00128 HGLRC mHGLRC; 00129 00130 vl::ivec2 mNormPosit; 00131 vl::ivec2 mNormSize; 00132 unsigned int mNormFlags; 00133 }; 00134 } 00135 //----------------------------------------------------------------------------- 00136 00137 #endif