]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/glcanvas.tex
don't make read-only text controls editable when enabled
[wxWidgets.git] / docs / latex / wx / glcanvas.tex
... / ...
CommitLineData
1\section{\class{wxGLCanvas}}\label{wxglcanvas}
2
3wxGLCanvas is a class for displaying OpenGL graphics. It is always used in
4conjunction with \helpref{wxGLContext}{wxglcontext} as the context can only be
5be made current (i.e. active for the OpenGL commands) when it is associated to
6a wxGLCanvas.
7
8More precisely, you first need to create a wxGLCanvas window and then create an
9instance of a \helpref{wxGLContext}{wxglcontext} that is initialized with this
10wxGLCanvas and then later use either \helpref{wxGLCanvas::SetCurrent}{wxglcanvassetcurrent}
11with the instance of the \helpref{wxGLContext}{wxglcontext} or
12\helpref{wxGLContext::SetCurrent}{wxglcontextsetcurrent} with the instance of
13the \helpref{wxGLCanvas}{wxglcanvas} (which might be not the same as was used
14for the creation of the context) to bind the OpenGL state that is represented
15by the rendering context to the canvas, and then finally call
16\helpref{wxGLCanvas::SwapBuffers}{wxglcanvasswapbuffers} to swap the buffers of
17the OpenGL canvas and thus show your current output.
18
19Notice that previous versions of wxWidgets used to implicitly create a
20wxGLContext inside wxGLCanvas itself. This is still supported in the current
21version but is deprecated now and will be removed in the future, please update
22your code to create the rendering contexts explicitly.
23
24To set up the attributes for the canvas (number of bits for the depth buffer,
25number of bits for the stencil buffer and so on) you should set up the correct values of
26the {\it attribList} parameter. The values that should be set up and their meanings will be described below.
27
28Notice that OpenGL is not enabled by default. To switch it on, you need to edit
29setup.h under Windows and set {\tt wxUSE\_GLCANVAS} to $1$ (you may also need
30to have to add {\tt opengl32.lib} and {\tt glu32.lib} to the list of libraries
31your program is linked with). On Unix, pass {\tt --with-opengl} to configure.
32
33\wxheading{Derived from}
34
35\helpref{wxWindow}{wxwindow}\\
36\helpref{wxEvtHandler}{wxevthandler}\\
37\helpref{wxObject}{wxobject}
38
39\wxheading{Include files}
40
41<wx/glcanvas.h>
42
43\wxheading{Window styles}
44
45There are no specific window styles for this class.
46
47See also \helpref{window styles overview}{windowstyles}.
48
49\wxheading{Constants}
50
51The generic GL implementation doesn't support many of these options, such as stereo, auxiliary buffers,
52alpha channel, and accum buffer. Other implementations may support them.
53
54\twocolwidtha{5cm}
55\begin{twocollist}\itemsep=0pt
56\twocolitem{\windowstyle{WX\_GL\_RGBA}}{Use true colour}
57\twocolitem{\windowstyle{WX\_GL\_BUFFER\_SIZE}}{Bits for buffer if not WX\_GL\_RGBA}
58\twocolitem{\windowstyle{WX\_GL\_LEVEL}}{0 for main buffer, >0 for overlay, <0 for underlay}
59\twocolitem{\windowstyle{WX\_GL\_DOUBLEBUFFER}}{Use doublebuffer}
60\twocolitem{\windowstyle{WX\_GL\_STEREO}}{Use stereoscopic display}
61\twocolitem{\windowstyle{WX\_GL\_AUX\_BUFFERS}}{Number of auxiliary buffers (not all implementation support this option)}
62\twocolitem{\windowstyle{WX\_GL\_MIN\_RED}}{Use red buffer with most bits (> MIN\_RED bits)}
63\twocolitem{\windowstyle{WX\_GL\_MIN\_GREEN}}{Use green buffer with most bits (> MIN\_GREEN bits) }
64\twocolitem{\windowstyle{WX\_GL\_MIN\_BLUE}}{Use blue buffer with most bits (> MIN\_BLUE bits) }
65\twocolitem{\windowstyle{WX\_GL\_MIN\_ALPHA}}{Use alpha buffer with most bits (> MIN\_ALPHA bits)}
66\twocolitem{\windowstyle{WX\_GL\_DEPTH\_SIZE}}{Bits for Z-buffer (0,16,32)}
67\twocolitem{\windowstyle{WX\_GL\_STENCIL\_SIZE}}{Bits for stencil buffer}
68\twocolitem{\windowstyle{WX\_GL\_MIN\_ACCUM\_RED}}{Use red accum buffer with most bits (> MIN\_ACCUM\_RED bits)}
69\twocolitem{\windowstyle{WX\_GL\_MIN\_ACCUM\_GREEN}}{Use green buffer with most bits (> MIN\_ACCUM\_GREEN bits)}
70\twocolitem{\windowstyle{WX\_GL\_MIN\_ACCUM\_BLUE}}{Use blue buffer with most bits (> MIN\_ACCUM\_BLUE bits)}
71\twocolitem{\windowstyle{WX\_GL\_MIN\_ACCUM\_ALPHA}}{Use blue buffer with most bits (> MIN\_ACCUM\_ALPHA bits)}
72\end{twocollist}
73
74\wxheading{See also}
75
76\helpref{wxGLContext}{wxglcontext}
77
78\latexignore{\rtfignore{\wxheading{Members}}}
79
80
81\membersection{wxGLCanvas::wxGLCanvas}\label{wxglcanvasconstr}
82
83\func{void}{wxGLCanvas}{\param{wxWindow* }{parent}, \param{wxWindowID}{ id = wxID\_ANY},
84 \param{const int*}{ attribList = NULL},
85 \param{const wxPoint\&}{ pos = wxDefaultPosition}, \param{const wxSize\&}{ size = wxDefaultSize},
86 \param{long}{ style=0}, \param{const wxString\& }{name="GLCanvas"},
87 \param{const wxPalette\&}{ palette = wxNullPalette}}
88
89Creates a window with the given parameters. Notice that you need to create and
90use a \helpref{wxGLContext}{wxglcontext} to output to this window.
91
92If \arg{attribList} is not specified, double buffered RGBA mode is used.
93
94\docparam{parent}{Pointer to a parent window.}
95
96\docparam{id}{Window identifier. If -1, will automatically create an identifier.}
97
98\docparam{pos}{Window position. wxDefaultPosition is (-1, -1) which indicates that wxWidgets
99should generate a default position for the window.}
100
101\docparam{size}{Window size. wxDefaultSize is (-1, -1) which indicates that wxWidgets should
102generate 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.}
103
104\docparam{style}{Window style.}
105
106\docparam{name}{Window name.}
107
108\docparam{attribList}{Array of integers. With this parameter you can set the device context attributes associated to this window.
109This array is zero-terminated: it should be set up with constants described in the table above.
110If a constant should be followed by a value, put it in the next array position.
111For example, the WX\_GL\_DEPTH\_SIZE should be followed by the value that indicates the number of
112bits for the depth buffer, so:}
113
114\begin{verbatim}
115attribList[index] = WX_GL_DEPTH_SIZE;
116attribList[index+1] = 32;
117and so on.
118\end{verbatim}
119
120\docparam{palette}{Palette for indexed colour (i.e. non WX\_GL\_RGBA) mode.
121Ignored under most platforms.}
122
123
124\membersection{wxGLCanvas::SetCurrent}\label{wxglcanvassetcurrent}
125
126\func{void}{SetCurrent}{ \param{const wxGLContext&}{ context} }
127
128Makes the OpenGL state that is represented by the OpenGL rendering context
129\arg{context} current, i.e. it will be used by all subsequent OpenGL calls.
130
131This is equivalent to \helpref{wxGLContext::SetCurrent}{wxglcontextsetcurrent}
132called with this window as parameter.
133
134Note that this function may only be called when the window is shown on screen,
135in particular it can't usually be called from the constructor as the window
136isn't yet shown at this moment.
137
138
139\membersection{wxGLCanvas::SetColour}\label{wxglcanvassetcolour}
140
141\func{void}{SetColour}{\param{const char*}{ colour}}
142
143Sets the current colour for this window (using \texttt{glcolor3f()}), using the
144wxWidgets colour database to find a named colour.
145
146
147\membersection{wxGLCanvas::SwapBuffers}\label{wxglcanvasswapbuffers}
148
149\func{void}{SwapBuffers}{\void}
150
151Swaps the double-buffer of this window, making the back-buffer the front-buffer and vice versa,
152so that the output of the previous OpenGL commands is displayed on the window.
153