]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/glcanvas.tex
define _HPUX_SOURCE under HP-UX, otherwise many things are not defined in standard...
[wxWidgets.git] / docs / latex / wx / glcanvas.tex
CommitLineData
8b089c5e
JS
1\section{\class{wxGLCanvas}}\label{wxglcanvas}
2
3wxGLCanvas is a class for displaying OpenGL graphics. There are
4wrappers for OpenGL on Windows, and GTK+ and Motif.
5
6To use this class, create a wxGLCanvas window, call \helpref{wxGLCanvas::SetCurrent}{wxglcanvassetcurrent}
7to direct normal OpenGL commands to the window, and then call \helpref{wxGLCanvas::SwapBuffers}{wxglcanvasswapbuffers}
8to show the OpenGL buffer on the window.
9
dd27a3bd
JS
10To set up the attributes for the rendering context (number of bits for the depth buffer,
11number of bits for the stencil buffer and so on) you should set up the correct values of
12the {\it attribList} parameter. The values that should be set up and their meanings will be described below.
13
1162d0a2
VZ
14To switch wxGLCanvas support on under Windows, edit setup.h and set
15{\tt wxUSE\_GLCANVAS} to $1$. You may also need to have to add
16{\tt opengl32.lib} to the list of libraries your program is linked with. On
17Unix, pass {\tt --with-opengl} to configure to compile using OpenGL or Mesa.
8b089c5e
JS
18
19\wxheading{Derived from}
20
8b089c5e
JS
21\helpref{wxWindow}{wxwindow}\\
22\helpref{wxEvtHandler}{wxevthandler}\\
23\helpref{wxObject}{wxobject}
24
25\wxheading{Include files}
26
27<wx/glcanvas.h>
28
29\wxheading{Window styles}
30
31There are no specific window styles for this class.
32
33See also \helpref{window styles overview}{windowstyles}.
34
dd27a3bd
JS
35\wxheading{Constants}
36
37The generic GL implementation doesn't support many of these options, such as stereo, auxiliary buffers,
38alpha channel, and accum buffer. Other implementations may support them.
39
40\twocolwidtha{5cm}
41\begin{twocollist}\itemsep=0pt
42\twocolitem{\windowstyle{WX\_GL\_RGBA}}{Use true colour}
43\twocolitem{\windowstyle{WX\_GL\_BUFFER\_SIZE}}{Bits for buffer if not WX\_GL\_RGBA}
44\twocolitem{\windowstyle{WX\_GL\_LEVEL}}{0 for main buffer, >0 for overlay, <0 for underlay}
45\twocolitem{\windowstyle{WX\_GL\_DOUBLEBUFFER}}{Use doublebuffer}
46\twocolitem{\windowstyle{WX\_GL\_STEREO}}{Use stereoscopic display}
47\twocolitem{\windowstyle{WX\_GL\_AUX\_BUFFERS}}{Number of auxiliary buffers (not all implementation support this option)}
48\twocolitem{\windowstyle{WX\_GL\_MIN\_RED}}{Use red buffer with most bits (> MIN\_RED bits)}
49\twocolitem{\windowstyle{WX\_GL\_MIN\_GREEN}}{Use green buffer with most bits (> MIN\_GREEN bits) }
50\twocolitem{\windowstyle{WX\_GL\_MIN\_BLUE}}{Use blue buffer with most bits (> MIN\_BLUE bits) }
51\twocolitem{\windowstyle{WX\_GL\_MIN\_ALPHA}}{Use alpha buffer with most bits (> MIN\_ALPHA bits)}
52\twocolitem{\windowstyle{WX\_GL\_DEPTH\_SIZE}}{Bits for Z-buffer (0,16,32)}
53\twocolitem{\windowstyle{WX\_GL\_STENCIL\_SIZE}}{Bits for stencil buffer}
54\twocolitem{\windowstyle{WX\_GL\_MIN\_ACCUM\_RED}}{Use red accum buffer with most bits (> MIN\_ACCUM\_RED bits)}
55\twocolitem{\windowstyle{WX\_GL\_MIN\_ACCUM\_GREEN}}{Use green buffer with most bits (> MIN\_ACCUM\_GREEN bits)}
56\twocolitem{\windowstyle{WX\_GL\_MIN\_ACCUM\_BLUE}}{Use blue buffer with most bits (> MIN\_ACCUM\_BLUE bits)}
57\twocolitem{\windowstyle{WX\_GL\_MIN\_ACCUM\_ALPHA}}{Use blue buffer with most bits (> MIN\_ACCUM\_ALPHA bits)}
58\end{twocollist}
59
f2ac0386 60\wxheading{See also}
38fc80ae
RN
61
62\helpref{wxGLContext}{wxglcontext}
63
8b089c5e
JS
64\latexignore{\rtfignore{\wxheading{Members}}}
65
2d918775 66
8b089c5e
JS
67\membersection{wxGLCanvas::wxGLCanvas}\label{wxglcanvasconstr}
68
b636c599
MR
69\func{void}{wxGLCanvas}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id = -1},
70 \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},
71 \param{long}{ style=0}, \param{const wxString\& }{name="GLCanvas"},
8b089c5e
JS
72 \param{int*}{ attribList = 0}, \param{const wxPalette\&}{ palette = wxNullPalette}}
73
b636c599
MR
74\func{void}{wxGLCanvas}{\param{wxWindow* }{parent}, \param{wxGLContext* }{sharedContext}, \param{wxWindowID}{ id = -1},
75 \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},
76 \param{long}{ style=0}, \param{const wxString\& }{name="GLCanvas"},
8b089c5e
JS
77 \param{int*}{ attribList = 0}, \param{const wxPalette\&}{ palette = wxNullPalette}}
78
b636c599
MR
79\func{void}{wxGLCanvas}{\param{wxWindow* }{parent}, \param{wxGLCanvas* }{sharedCanvas}, \param{wxWindowID}{ id = -1},
80 \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},
81 \param{long}{ style=0}, \param{const wxString\& }{name="GLCanvas"},
8b089c5e
JS
82 \param{int*}{ attribList = 0}, \param{const wxPalette\&}{ palette = wxNullPalette}}
83
84Constructor.
85
dd27a3bd
JS
86\docparam{parent}{Pointer to a parent window.}
87
b636c599
MR
88\docparam{sharedContext}{Context to share object resources with.}
89
90%TODO document sharedCanvas meaning
01168e95 91
dd27a3bd
JS
92\docparam{id}{Window identifier. If -1, will automatically create an identifier.}
93
fc2171bd 94\docparam{pos}{Window position. wxDefaultPosition is (-1, -1) which indicates that wxWidgets
dd27a3bd
JS
95should generate a default position for the window.}
96
fc2171bd 97\docparam{size}{Window size. wxDefaultSize is (-1, -1) which indicates that wxWidgets should
dd27a3bd
JS
98generate a default size for the window. If no suitable size can be found, the window will be sized to 20x20 pixels so that the window is visible but obviously not correctly sized.}
99
100\docparam{style}{Window style.}
101
102\docparam{name}{Window name.}
103
104\docparam{attribList}{Array of int. With this parameter you can set the device context attributes associated to this window.
105This array is zero-terminated: it should be set up with constants described in the table above.
106If a constant should be followed by a value, put it in the next array position.
107For example, the WX\_GL\_DEPTH\_SIZE should be followed by the value that indicates the number of
e119d049 108bits for the depth buffer, so:}
dd27a3bd
JS
109
110\begin{verbatim}
111attribList[index]= WX_GL_DEPTH_SIZE;
112attribList[index+1]=32;
113and so on.
114\end{verbatim}
dd27a3bd
JS
115
116\docparam{palette}{If the window has the palette, it should by pass this value.
117Note: palette and WX\_GL\_RGBA are mutually exclusive.}
118
2d918775 119
01168e95
RN
120\membersection{wxGLCanvas::GetContext}\label{wxglcanvasgetcontext}
121
122\func{wxGLContext*}{GetContext}{\void}
123
124Obtains the context that is associated with this canvas.
125
2d918775 126
8b089c5e
JS
127\membersection{wxGLCanvas::SetCurrent}\label{wxglcanvassetcurrent}
128
129\func{void}{SetCurrent}{\void}
130
131Sets this canvas as the current recipient of OpenGL calls.
38fc80ae 132Each canvas contains an OpenGL device context that has been created during
dd27a3bd
JS
133the creation of this window. So this call sets the current device context
134as the target device context for OpenGL operations.
8b089c5e 135
2d918775
VZ
136Note that this function may only be called after the window has been shown.
137
138
8b089c5e
JS
139\membersection{wxGLCanvas::SetColour}\label{wxglcanvassetcolour}
140
141\func{void}{SetColour}{\param{const char*}{ colour}}
142
fc2171bd 143Sets the current colour for this window, using the wxWidgets colour database to find a named colour.
8b089c5e 144
2d918775 145
8b089c5e
JS
146\membersection{wxGLCanvas::SwapBuffers}\label{wxglcanvasswapbuffers}
147
148\func{void}{SwapBuffers}{\void}
149
150Displays the previous OpenGL commands on the window.
151