- Your Widget Set For OpenGL
Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | Related Pages

uxwgldriver.hpp

00001 /*************************************************************************** 00002 LibUFO - UI For OpenGL 00003 copyright : (C) 2001-2005 by Johannes Schmidt 00004 email : schmidtjf at users.sourceforge.net 00005 ------------------- 00006 00007 file : include/ufo/ux/uxwgldriver.hpp 00008 begin : Thu Sep 23 2004 00009 $Id: uxwgldriver.hpp,v 1.8 2005/10/29 15:36:16 schmidtjf Exp $ 00010 ***************************************************************************/ 00011 00012 /*************************************************************************** 00013 * This library is free software; you can redistribute it and/or * 00014 * modify it under the terms of the GNU Lesser General Public * 00015 * License as published by the Free Software Foundation; either * 00016 * version 2.1 of the License, or (at your option) any later version. * 00017 * * 00018 * This library is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00021 * Lesser General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU Lesser General Public * 00024 * License along with this library; if not, write to the Free Software * 00025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 00026 ***************************************************************************/ 00027 00028 #ifndef UXWGLDRIVER_HPP 00029 #define UXWGLDRIVER_HPP 00030 00031 #include "../uvideodriver.hpp" 00032 #include "../uvideodevice.hpp" 00033 00034 #include "../events/ukeysym.hpp" 00035 00036 #include <map> 00037 00038 // FIXME should be done by ufo_config ? 00039 #include <windows.h> 00040 00041 namespace ufo { 00042 00043 class UXContext; 00044 class UXDisplay; 00045 class UXWGLDevice; 00046 class UVideoPlugin; 00047 class UPluginBase; 00048 class USharedLib; 00049 00055 class UFO_EXPORT UXWGLDriver : public UVideoDriver { 00056 UFO_DECLARE_DYNAMIC_CLASS(UXWGLDriver) 00057 public: 00058 UXWGLDriver(); 00059 virtual ~UXWGLDriver(); 00060 00061 public: // Implements UVideoDriver 00062 virtual bool init(); 00063 virtual bool isInitialized(); 00064 virtual void quit(); 00065 virtual std::string getName(); 00066 00067 virtual void pumpEvents(); 00068 00069 virtual UVideoDevice * createVideoDevice(); 00070 00071 bool isValid() const; 00072 00073 #define UFO_WGL_PROC(ret,func,params) ret (WINAPI *func) params; 00074 UFO_WGL_PROC(BOOL,wglMakeCurrent,(HDC, HGLRC)) 00075 UFO_WGL_PROC(HGLRC,wglCreateContext,(HDC)) 00076 UFO_WGL_PROC(BOOL,wglDeleteContext,(HGLRC)) 00077 UFO_WGL_PROC(BOOL,wglShareLists,(HGLRC, HGLRC)) 00078 #undef UFO_WGL_PROC 00079 00080 public: // Public methods 00081 HINSTANCE getInstance() const; 00082 UXContext * getContextFromWindow(HWND window); 00083 UXWGLDevice * getDeviceFromWindow(HWND window); 00084 00085 public: // Public methods 00086 void initKeymap(); 00087 00088 LRESULT windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); 00089 UMod_t mapWin32Button(int msg); 00090 00091 public: // plugin methods 00092 static UPluginBase * createPlugin(); 00093 static void destroyPlugin(UPluginBase * plugin); 00094 00095 private: // Private attributes 00096 bool m_isValid; 00097 bool m_isInit; 00098 bool m_createdGLDriver; 00099 UXDisplay * m_display; 00100 HINSTANCE m_instance; 00101 std::vector<UXWGLDevice*> m_windowMap; 00102 00103 // FIXME: do not use static array size 00104 UKeyCode_t VK_keymap[256]; 00105 }; 00106 00107 00113 class UFO_EXPORT UXWGLDevice : public UVideoDevice { 00114 UFO_DECLARE_DYNAMIC_CLASS(UXWGLDevice) 00115 public: 00116 UXWGLDevice(UXWGLDriver * driver); 00117 public: // Implements UVideoDevice 00118 virtual void setSize(int w, int h); 00119 virtual UDimension getSize() const; 00120 00121 virtual void setLocation(int x, int y); 00122 virtual UPoint getLocation() const; 00123 00124 virtual void setTitle(const std::string & title); 00125 virtual std::string getTitle() const; 00126 00127 virtual void setDepth(int depth); 00128 virtual int getDepth() const; 00129 00130 virtual void swapBuffers(); 00131 virtual void makeContextCurrent(); 00132 00133 virtual bool show(); 00134 virtual void hide(); 00135 00136 virtual void setFrameStyle(uint32_t frameStyle); 00137 virtual uint32_t getFrameStyle() const; 00138 00139 virtual void setInitialFrameState(uint32_t frameState); 00140 virtual uint32_t getFrameState() const; 00141 00142 virtual void setFrame(UXFrame * frame); 00143 virtual void notify(uint32_t type, int arg1, int arg2, int arg3, int arg4); 00144 public: 00145 virtual UXFrame * getFrame() const; 00146 bool setupPixelFormat(unsigned char layer_type); 00147 HWND getWindow() { return m_window; } 00148 HDC getDC(); 00149 HGLRC getGLContext() { return m_glContext; } 00150 00151 void setDecorations(); 00152 void setSizeHints(); 00153 void setWMHints(); 00154 protected: 00155 int getAttribute(int key); 00156 void setAttribute(int key, int value); 00157 00158 private: // Private attributes 00159 UXWGLDriver * m_wglDriver; 00160 HWND m_window; 00161 HDC m_dc; 00162 HGLRC m_glContext; 00163 UXFrame * m_frame; 00164 UDimension m_size; 00165 UPoint m_pos; 00166 bool m_isVisible; 00167 uint32_t m_frameStyle; 00168 uint32_t m_frameState; 00169 int m_depth; 00170 std::string m_title; 00171 std::map<int, int> m_attributes; 00172 }; 00173 00174 } // namespace ufo 00175 00176 #endif // UXWGLDRIVER_HPP

The libUFO Project - written by Johannes Schmidt