]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/glcanvas/msw/myglcanvas.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxGLCanvas, for using OpenGL with wxWindows under Windows
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma interface "glcanvas.h"
16 #ifndef _WX_GLCANVAS_H_
17 #define _WX_GLCANVAS_H_
21 #define wxUSE_GLCANVAS 1
23 #include <wx/palette.h>
24 #include <wx/scrolwin.h>
27 #include "wx/msw/winundef.h"
31 //---------------------------------------------------------------------------
32 // Constants for attriblist
33 //---------------------------------------------------------------------------
35 // The generic GL implementation doesn't support most of these options,
36 // such as stereo, auxiliary buffers, alpha channel, and accum buffer.
37 // Other implementations may actually support them.
41 WX_GL_RGBA
=1, /* use true color palette */
42 WX_GL_BUFFER_SIZE
, /* bits for buffer if not WX_GL_RGBA */
43 WX_GL_LEVEL
, /* 0 for main buffer, >0 for overlay, <0 for underlay */
44 WX_GL_DOUBLEBUFFER
, /* use doublebuffer */
45 WX_GL_STEREO
, /* use stereoscopic display */
46 WX_GL_AUX_BUFFERS
, /* number of auxiliary buffers */
47 WX_GL_MIN_RED
, /* use red buffer with most bits (> MIN_RED bits) */
48 WX_GL_MIN_GREEN
, /* use green buffer with most bits (> MIN_GREEN bits) */
49 WX_GL_MIN_BLUE
, /* use blue buffer with most bits (> MIN_BLUE bits) */
50 WX_GL_MIN_ALPHA
, /* use blue buffer with most bits (> MIN_ALPHA bits) */
51 WX_GL_DEPTH_SIZE
, /* bits for Z-buffer (0,16,32) */
52 WX_GL_STENCIL_SIZE
, /* bits for stencil buffer */
53 WX_GL_MIN_ACCUM_RED
, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */
54 WX_GL_MIN_ACCUM_GREEN
, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */
55 WX_GL_MIN_ACCUM_BLUE
, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */
56 WX_GL_MIN_ACCUM_ALPHA
/* use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */
59 class wxGLCanvas
; /* forward reference */
61 class wxGLContext
: public wxObject
64 wxGLContext(bool isRGB
, wxGLCanvas
*win
, const wxPalette
& palette
= wxNullPalette
);
66 bool isRGB
, wxGLCanvas
*win
,
67 const wxPalette
& WXUNUSED(palette
),
68 const wxGLContext
*other
/* for sharing display lists */
73 void SetColour(const wxChar
*colour
);
77 inline wxWindow
* GetWindow() const { return m_window
; }
78 inline WXHDC
GetHDC() const { return m_hDC
; }
79 inline HGLRC
GetGLRC() const { return m_glContext
; }
88 extern const wxChar
* wxGLCanvasName
;
91 class wxGLCanvas
: public wxWindow
93 DECLARE_CLASS(wxGLCanvas
)
95 wxGLCanvas(wxWindow
*parent
, wxWindowID id
= -1, const wxPoint
& pos
= wxDefaultPosition
,
96 const wxSize
& size
= wxDefaultSize
, long style
= 0,
97 const wxString
& name
= wxGLCanvasName
, int *attribList
= 0, const wxPalette
& palette
= wxNullPalette
);
98 wxGLCanvas( wxWindow
*parent
, const wxGLContext
*shared
= (wxGLContext
*)NULL
,
99 wxWindowID id
= -1, const wxPoint
& pos
= wxDefaultPosition
,
100 const wxSize
& size
= wxDefaultSize
, long style
= 0, const wxString
&
101 name
= wxGLCanvasName
,
102 int *attribList
= (int*) NULL
, const wxPalette
& palette
= wxNullPalette
);
104 wxGLCanvas( wxWindow
*parent
, const wxGLCanvas
*shared
= (wxGLCanvas
*)NULL
, wxWindowID id
= -1,
105 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& size
= wxDefaultSize
, long style
= 0,
106 const wxString
& name
= wxGLCanvasName
, int *attribList
= 0, const wxPalette
& palette
= wxNullPalette
);
110 // Replaces wxWindow::Create functionality, since we need to use a different window class
111 bool Create(wxWindow
*parent
, wxWindowID id
,
112 const wxPoint
& pos
, const wxSize
& size
, long style
, const wxString
& name
);
115 void SetColour(const wxChar
*colour
);
118 void OnSize(wxSizeEvent
& event
);
120 void OnQueryNewPalette(wxQueryNewPaletteEvent
& event
);
121 void OnPaletteChanged(wxPaletteChangedEvent
& event
);
123 inline wxGLContext
* GetContext() const { return m_glContext
; }
125 inline WXHDC
GetHDC() const { return m_hDC
; }
126 void SetupPixelFormat(int *attribList
= (int*) NULL
);
127 void SetupPalette(const wxPalette
& palette
);
128 wxPalette
CreateDefaultPalette();
130 inline wxPalette
* GetPalette() const { return (wxPalette
*) & m_palette
; }
133 wxGLContext
* m_glContext
; // this is typedef-ed ptr, in fact
137 DECLARE_EVENT_TABLE()
142 class wxGLApp
: public wxApp
145 wxGLApp() : wxApp() { }
148 // use this in the constructor of the user-derived wxGLApp class to
149 // determine if an OpenGL rendering context with these attributes
150 // is available - returns TRUE if so, FALSE if not.
151 bool InitGLVisual(int *attribList
);
154 DECLARE_DYNAMIC_CLASS(wxGLApp
)