00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
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:
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:
00081 HINSTANCE getInstance()
const;
00082
UXContext * getContextFromWindow(HWND window);
00083
UXWGLDevice * getDeviceFromWindow(HWND window);
00084
00085
public:
00086
void initKeymap();
00087
00088 LRESULT windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
00089 UMod_t mapWin32Button(
int msg);
00090
00091
public:
00092
static UPluginBase * createPlugin();
00093
static void destroyPlugin(
UPluginBase * plugin);
00094
00095
private:
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
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:
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:
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 }
00175
00176
#endif // UXWGLDRIVER_HPP