summaryrefslogtreecommitdiff
path: root/lib/wx/doc/src/wxGLCanvas.xml
blob: 2ccfb6e137bb1559c41d5eeb2420f53c6220b656 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">

<!-- THIS FILE IS GENERATED DO NOT EDIT -->


<erlref>
<header>
  <copyright>
    <year>2020</year><year>2021</year>
    <holder>wxWidgets team.</holder></copyright>
  <legalnotice>Licensed under the wxWindows Free Documentation Licence, Version 3
  </legalnotice>
  <title>wxGLCanvas</title>
</header>
<module>wxGLCanvas</module>
<modulesummary>Functions for wxGLCanvas class</modulesummary>
<description><p><seeerl marker="wxGLCanvas"><c>wxGLCanvas</c></seeerl> is a class for displaying OpenGL graphics. It is always used in conjunction with <seeerl marker="wxGLContext"><c>wxGLContext</c></seeerl> as the context can only be made current (i.e. active for the OpenGL commands) when it is associated to a <seeerl marker="wxGLCanvas"><c>wxGLCanvas</c></seeerl>.
      </p><p>More precisely, you first need to create a <seeerl marker="wxGLCanvas"><c>wxGLCanvas</c></seeerl> window and then create an instance of a <seeerl marker="wxGLContext"><c>wxGLContext</c></seeerl> that is initialized with this <seeerl marker="wxGLCanvas"><c>wxGLCanvas</c></seeerl> and then later use either <seemfa marker="#setCurrent/2"><c>setCurrent/2</c></seemfa> with the instance of the <seeerl marker="wxGLContext"><c>wxGLContext</c></seeerl> or <seemfa marker="wxGLContext#setCurrent/2"><c>wxGLContext:setCurrent/2</c></seemfa> with the instance of the <seeerl marker="wxGLCanvas"><c>wxGLCanvas</c></seeerl> (which might be not the same as was used for the creation of the context) to bind the OpenGL state that is represented by the rendering context to the canvas, and then finally call <seemfa marker="#swapBuffers/1"><c>swapBuffers/1</c></seemfa> to swap the buffers of the OpenGL canvas and thus show your current output.
      </p><p>Please note that <seeerl marker="wxGLContext"><c>wxGLContext</c></seeerl> always uses physical pixels, even on the platforms where <seeerl marker="wxWindow"><c>wxWindow</c></seeerl> uses logical pixels, affected by the coordinate scaling, on high DPI displays. Thus, if you want to set the OpenGL view port to the size of entire window, you must multiply the result returned by <seemfa marker="wxWindow#getClientSize/1"><c>wxWindow:getClientSize/1</c></seemfa> by <seemfa marker="wxWindow#getContentScaleFactor/1"><c>wxWindow:getContentScaleFactor/1</c></seemfa> before passing it to <c>glViewport()</c>. Same considerations apply to other OpenGL functions and other coordinates, notably those retrieved from <seeerl marker="wxMouseEvent"><c>wxMouseEvent</c></seeerl> in the event handlers.
      </p><p>Notice that versions of wxWidgets previous to 2.9 used to implicitly create a <seeerl marker="wxGLContext"><c>wxGLContext</c></seeerl> inside <seeerl marker="wxGLCanvas"><c>wxGLCanvas</c></seeerl> itself. This is still supported in the current version but is deprecated now and will be removed in the future, please update your code to create the rendering contexts explicitly.
      </p><p>To set up the attributes for the canvas (number of bits for the depth buffer, number of bits for the stencil buffer and so on) you pass them in the constructor using a <c>wxGLAttributes</c> (not implemented in wx) instance. You can still use the way before 3.1.0 (setting up the correct values of the <c>attribList</c> parameter) but it's discouraged.
      </p><p>Note: On those platforms which use a configure script (e.g. Linux and macOS) OpenGL support is automatically enabled if the relative headers and libraries are found. To switch it on under the other platforms (e.g. Windows), you need to edit the <c>setup.h</c> file and set <c>wxUSE_GLCANVAS</c> to <c>1</c> and then also pass <c>USE_OPENGL=1</c> to the make utility. You may also need to add <c>opengl32.lib</c> (and <c>glu32.lib</c> for old OpenGL versions) to the list of the libraries your program is linked with.
      </p><p>See: <seeerl marker="wxGLContext"><c>wxGLContext</c></seeerl>, <c>wxGLAttributes</c> (not implemented in wx), <c>wxGLContextAttrs</c> (not implemented in wx)
      </p>
  <p>This class is derived (and can use functions) from: 
    <seeerl marker="wxWindow"><c>wxWindow</c></seeerl> <seeerl marker="wxEvtHandler"><c>wxEvtHandler</c></seeerl></p>
  
  <p>wxWidgets docs: <url href="https://docs.wxwidgets.org/3.1/classwx_g_l_canvas.html">wxGLCanvas</url></p>
  </description>
<datatypes><datatype><name name="wxGLCanvas"/></datatype></datatypes>

<funcs>
  <func>
    <name name="new" arity="1" clause_i="1" since=""/>
    <fsummary>See: <c>new/2</c></fsummary>
  </func>
  
  <func>
    <name name="new" arity="2" clause_i="1" since=""/>
    <fsummary>This constructor is still available only for compatibility reasons. </fsummary>
    <desc><p>This constructor is still available only for compatibility reasons. 
      </p><p>Please use the constructor with <c>wxGLAttributes</c> (not implemented in wx) instead.
      </p><p>If <c>attribList</c> is not specified, <c>wxGLAttributes::PlatformDefaults()</c> (not implemented in wx) is used, plus some other attributes (see below).
      </p></desc>
  </func>
  
  <func>
    <name name="setCurrent" arity="2" clause_i="1" since=""/>
    <fsummary>Makes the OpenGL state that is represented by the OpenGL rendering context <c>context</c> current, i.e. </fsummary>
    <desc><p>Makes the OpenGL state that is represented by the OpenGL rendering context <c>context</c> current, i.e. 
      </p><p>it will be used by all subsequent OpenGL calls.
      </p><p>This is equivalent to <seemfa marker="wxGLContext#setCurrent/2"><c>wxGLContext:setCurrent/2</c></seemfa> called with this window as parameter.
      </p><p>Note: This function may only be called when the window is shown on screen, in particular it can't usually be called from the constructor as the window isn't yet shown at this moment.
      </p><p>Return: false if an error occurred. 
      </p></desc>
  </func>
  
  <func>
    <name name="swapBuffers" arity="1" clause_i="1" since=""/>
    <fsummary>Swaps the double-buffer of this window, making the back-buffer the front-buffer and vice versa, so that the output of the previous OpenGL commands is displayed on the window. </fsummary>
    <desc><p>Swaps the double-buffer of this window, making the back-buffer the front-buffer and vice versa, so that the output of the previous OpenGL commands is displayed on the window. 
      </p><p>Return: false if an error occurred. 
      </p></desc>
  </func>
  
  <func>
    <name name="destroy" arity="1" clause_i="1" since=""/>
    <fsummary>Destructor</fsummary>
    <desc><p>Destroys the object.</p></desc>
  </func>
  </funcs>
</erlref>