00001 #ifndef __OPENGLDEVICEC_H__
00002 #define __OPENGLDEVICEC_H__
00003
00004 #define WIN32_LEAN_AND_MEAN
00005 #include <windows.h>
00006 #include <gl\gl.h>
00007
00008
00009
00010 namespace PajaSystem {
00011 class OpenGLDeviceC;
00012 };
00013
00014 #include "PajaTypes.h"
00015 #include "BBox2C.h"
00016 #include "ColorC.h"
00017 #include "Vector2C.h"
00018 #include "DeviceInterfaceI.h"
00019 #include "GraphicsDeviceI.h"
00020 #include "OpenGLViewportC.h"
00021 #include "OpenGLGUIDrawInterfaceC.h"
00022 #include "DeviceFeedbackC.h"
00023 #include "OpenGLBufferC.h"
00024
00025
00026 namespace PajaSystem {
00027
00029
00030
00031
00032
00033 const PluginClass::ClassIdC CLASS_OPENGL_DEVICEDRIVER = PluginClass::ClassIdC( 0, 10000 );
00034
00035
00036 class OpenGLDeviceC : public GraphicsDeviceI
00037 {
00038 public:
00039 static OpenGLDeviceC* create_new();
00040 virtual Edit::DataBlockI* create();
00041 virtual PluginClass::ClassIdC get_class_id() const;
00042 virtual const char* get_class_name();
00043 virtual DeviceInterfaceI* query_interface( const PluginClass::SuperClassIdC& rSuperClassId );
00044 virtual PajaTypes::uint32 save( FileIO::SaveC* pSave );
00045 virtual PajaTypes::uint32 load( FileIO::LoadC* pLoad );
00046
00047 virtual bool init( HINSTANCE hInstance, HWND hParent, PajaTypes::int32 i32ID, PajaTypes::uint32 ui32Flags,
00048 PajaTypes::uint32 ui32Width = 0, PajaTypes::uint32 ui32Height = 0, PajaTypes::uint32 ui32BPP = 0,
00049 PajaSystem::DeviceFeedbackC* pFeedback = 0 );
00050 virtual void destroy();
00051 virtual void flush();
00052 virtual void activate();
00053 virtual HWND get_hwnd();
00054 virtual bool configure();
00055
00056 virtual bool set_fullscreen( PajaTypes::uint32 ui32Width, PajaTypes::uint32 ui32Height,
00057 PajaTypes::uint32 ui32BPP = 0 );
00058 virtual bool set_windowed();
00059
00060 virtual void set_size( PajaTypes::int32 int32X, PajaTypes::int32 int32Y,
00061 PajaTypes::int32 i32Width, PajaTypes::int32 i32Height );
00062
00063
00064 virtual void clear_device( PajaTypes::uint32 ui32Flags, const PajaTypes::ColorC& rColor = PajaTypes::ColorC(),
00065 PajaTypes::float32 f32Depth = 1.0f, PajaTypes::int32 i32Stencil = 0 );
00066
00067 virtual void begin_draw();
00068 virtual void end_draw();
00069
00070
00071 virtual void begin_effects();
00072 virtual void end_effects();
00073
00075 virtual GraphicsBufferI* create_graphicsbuffer();
00077 virtual GraphicsBufferI* set_render_target( GraphicsBufferI* pBuffer );
00078
00079 virtual HDC get_hdc();
00080 virtual HGLRC get_glrc();
00081
00082 private:
00083
00084 OpenGLDeviceC();
00085 virtual ~OpenGLDeviceC();
00086
00087
00088 void choose_resolution( PajaTypes::uint32& ui32Width, PajaTypes::uint32& ui32Height );
00089
00090 static bool set_pixelformat( HDC hDC );
00091
00092 static LRESULT CALLBACK stub_window_proc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
00093
00094 HWND m_hWnd;
00095 HDC m_hDC;
00096 HGLRC m_hGLRC;
00097
00098 LONG m_lSavedWindowStyle;
00099 LONG m_lSavedExWindowStyle;
00100 PajaTypes::uint32 m_ui32SavedCreateFlags;
00101 HWND m_hSavedParent;
00102 RECT m_rSavedWindowRect;
00103 PajaTypes::BBox2C m_rSavedViewport;
00104
00105 PajaTypes::uint32 m_ui32CreateFlags;
00106
00107 bool m_bResolutionChanged;
00108
00109 OpenGLViewportC* m_pInterface;
00110 OpenGLGUIDrawInterfaceC* m_pGUIDrawInterface;
00111 DeviceFeedbackC* m_pFeedback;
00112 OpenGLBufferC* m_pCurrentBuffer;
00113
00114 static HGLRC m_hMainGLRC;
00115 static PajaTypes::int32 m_i32RefCount;
00116 static bool m_bClassCreated;
00117 static PajaTypes::int32 m_i32InstCount;
00118 };
00119
00120 };
00121
00122 #endif // __OPENGLDEVICEC_H__