# 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/vlEGL/EGLWindow.hpp

Go to the documentation of this file.

    00001 /**************************************************************************************/
    00002 /*                                                                                    */
    00003 /*  Visualization Library                                                             */
    00004 /*  http://www.visualizationlibrary.org                                               */
    00005 /*                                                                                    */
    00006 /*  Copyright (c) 2005-2011, 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 EGL_Window_INCLUDE_ONCE
    00033 #define EGL_Window_INCLUDE_ONCE
    00034
    00035 #include <vlGraphics/OpenGLContext.hpp>
    00036 #include <vlEGL/link_config.hpp>
    00037 #include <EGL/egl.h>
    00038 #include <map>
    00039
    00040 namespace vlEGL
    00041 {
    00042 //-----------------------------------------------------------------------------
    00043   VLEGL_EXPORT int messageLoop();
    00044   VLEGL_EXPORT void peekMessage(MSG& msg);
    00045   VLEGL_EXPORT void dispatchUpdate();
    00046 //-----------------------------------------------------------------------------
    00047 // EGLWindow
    00048 //-----------------------------------------------------------------------------
    00052   class VLEGL_EXPORT EGLWindow: public vl::OpenGLContext
    00053   {
    00054   public:
    00055     static const wchar_t* EGLWindowClassName;
    00056     static LONG WINAPI WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
    00057
    00058   public:
    00059     EGLWindow();
    00060     ~EGLWindow();
    00061
    00062     // *** OpenGLContext implementation ***
    00063
    00064     void swapBuffers();
    00065     void makeCurrent();
    00066     void update();
    00067     void quitApplication();
    00068     void setMouseVisible(bool visible);
    00069     void setPosition(int x, int y);
    00070     void setSize(int w, int h);
    00071     void setWindowSize(int w, int h);
    00072     vl::ivec2 position() const;
    00073     vl::ivec2 windowSize() const;
    00074     vl::ivec2 size() const;
    00075     void setWindowTitle(const vl::String& title);
    00076     void show();
    00077     void hide();
    00078     void getFocus();
    00079     void setMousePosition(int x, int y);
    00080
    00083     bool initEGLWindow(HWND parent, const vl::String& title, const vl::OpenGLContextFormat& fmt, int x=0, int y=0, int width=640, int height=480);
    00084
    00086     void destroyEGLGLWindow();
    00087
    00088     HWND  hwnd()  const { return mHWND;  }
    00089
    00091     DWORD style() const { return mStyle; }
    00092
    00094     void setStyle(DWORD style) { mStyle = style; }
    00095
    00097     DWORD exStyle() const { return mStyle; }
    00098
    00100     void setExStyle(DWORD ex_style) { mStyle = ex_style; }
    00101
    00103     const wchar_t* windowClassName() const { return mWindowClassName; }
    00104
    00106     void setWindowClassName(const wchar_t* name) { mWindowClassName = name; }
    00107
    00108     const EGLDisplay& eglDisplay() const { return mEGL_Display; }
    00109     const EGLContext& eglContext() const { return mEGL_Context; }
    00110     const EGLSurface& eglSurface() const { return mEGL_Surface; }
    00111
    00112   protected:
    00113     int   mMouseDownCount;
    00114     HWND  mHWND;
    00115     DWORD mStyle;
    00116     DWORD mExStyle;
    00117     const wchar_t* mWindowClassName;
    00118
    00119     EGLDisplay mEGL_Display;
    00120     EGLContext mEGL_Context;
    00121     EGLSurface mEGL_Surface;
    00122
    00123     // *** static members start here ***
    00124
    00125   public:
    00127     static EGLWindow* getWindow(HWND hWnd);
    00128     static const std::map< HWND, EGLWindow* >& winMap() { return mWinMap; }
    00129
    00130   protected:
    00131     static std::map< HWND, EGLWindow* > mWinMap;
    00132   };
    00133 //-----------------------------------------------------------------------------
    00134   VLEGL_EXPORT void translateKeyEvent(WPARAM wParam, LPARAM lParam, unsigned short& unicode_out, vl::EKey& key_out);
    00135 //-----------------------------------------------------------------------------
    00136 }
    00137
    00138 #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.