File: moderngl.rst

package info (click to toggle)
python-moderngl 5.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,700 kB
  • sloc: python: 15,758; cpp: 14,665; makefile: 14
file content (244 lines) | stat: -rw-r--r-- 5,546 bytes parent folder | download
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
moderngl
========

.. py:module:: moderngl

.. code-block:: python

    import moderngl

    window = ...
    ctx = moderngl.create_context()
    # store a ref to ctx

The module object itself is responsible for creating a :py:class:`Context` object.

.. py:function:: moderngl.create_context(require: int = 330, standalone: bool = False) -> Context

    Create a ModernGL context by loading OpenGL functions from an existing OpenGL context.
    An OpenGL context must exist. Call this after a window is created or opt for the windowless standalone mode.
    Other backend specific settings are passed as keyword arguments.

    Context sharing is known to not work properly, please avoid using it.
    There is a paramter `share` for that to attempt to create a shared context.

    :param int require: OpenGL version code
    :param bool standalone: Headless flag

    Example::

        # Accept the current context version
        ctx = moderngl.create_context()

        # Require at least OpenGL 4.3
        ctx = moderngl.create_context(require=430)

        # Create a windowless context
        ctx = moderngl.create_context(standalone=True)

.. py:function:: moderngl.create_standalone_context(...) -> Context

    Deprecated, use :py:func:`moderngl.create_context()` with the standalone parameter set.

.. py:function:: moderngl.get_context() -> Context

    Returns the previously created context object.

    Example::

        # my_app.py

        from moderngl import create_context

        ctx = create_context(...)

        # my_renderer.py

        from moderngl import get_context

        class MyRenderer:
            def __init__(self):
                self.ctx = get_context()
                self.program = ...
                self.vao = ...

Context Flags
-------------

These were moved to :py:class:`Context`.

.. py:attribute:: moderngl.NOTHING

    See :py:attr:`Context.NOTHING`

.. py:attribute:: moderngl.BLEND

    See :py:attr:`Context.BLEND`

.. py:attribute:: moderngl.DEPTH_TEST

    See :py:attr:`Context.DEPTH_TEST`

.. py:attribute:: moderngl.CULL_FACE

    See :py:attr:`Context.CULL_FACE`

.. py:attribute:: moderngl.RASTERIZER_DISCARD

    See :py:attr:`Context.RASTERIZER_DISCARD`

.. py:attribute:: moderngl.PROGRAM_POINT_SIZE

    See :py:attr:`Context.PROGRAM_POINT_SIZE`

.. py:attribute:: moderngl.POINTS

    See :py:attr:`Context.POINTS`

.. py:attribute:: moderngl.LINES

    See :py:attr:`Context.LINES`

.. py:attribute:: moderngl.LINE_LOOP

    See :py:attr:`Context.LINE_LOOP`

.. py:attribute:: moderngl.LINE_STRIP

    See :py:attr:`Context.LINE_STRIP`

.. py:attribute:: moderngl.TRIANGLES

    See :py:attr:`Context.TRIANGLES`

.. py:attribute:: moderngl.TRIANGLE_STRIP

    See :py:attr:`Context.TRIANGLE_STRIP`

.. py:attribute:: moderngl.TRIANGLE_FAN

    See :py:attr:`Context.TRIANGLE_FAN`

.. py:attribute:: moderngl.LINES_ADJACENCY

    See :py:attr:`Context.LINES_ADJACENCY`

.. py:attribute:: moderngl.LINE_STRIP_ADJACENCY

    See :py:attr:`Context.LINE_STRIP_ADJACENCY`

.. py:attribute:: moderngl.TRIANGLES_ADJACENCY

    See :py:attr:`Context.TRIANGLES_ADJACENCY`

.. py:attribute:: moderngl.TRIANGLE_STRIP_ADJACENCY

    See :py:attr:`Context.TRIANGLE_STRIP_ADJACENCY`

.. py:attribute:: moderngl.PATCHES

    See :py:attr:`Context.PATCHES`

.. py:attribute:: moderngl.NEAREST

    See :py:attr:`Context.NEAREST`

.. py:attribute:: moderngl.LINEAR

    See :py:attr:`Context.LINEAR`

.. py:attribute:: moderngl.NEAREST_MIPMAP_NEAREST

    See :py:attr:`Context.NEAREST_MIPMAP_NEAREST`

.. py:attribute:: moderngl.LINEAR_MIPMAP_NEAREST

    See :py:attr:`Context.LINEAR_MIPMAP_NEAREST`

.. py:attribute:: moderngl.NEAREST_MIPMAP_LINEAR

    See :py:attr:`Context.NEAREST_MIPMAP_LINEAR`

.. py:attribute:: moderngl.LINEAR_MIPMAP_LINEAR

    See :py:attr:`Context.LINEAR_MIPMAP_LINEAR`

.. py:attribute:: moderngl.ZERO

    See :py:attr:`Context.ZERO`

.. py:attribute:: moderngl.ONE

    See :py:attr:`Context.ONE`

.. py:attribute:: moderngl.SRC_COLOR

    See :py:attr:`Context.SRC_COLOR`

.. py:attribute:: moderngl.ONE_MINUS_SRC_COLOR

    See :py:attr:`Context.ONE_MINUS_SRC_COLOR`

.. py:attribute:: moderngl.SRC_ALPHA

    See :py:attr:`Context.SRC_ALPHA`

.. py:attribute:: moderngl.ONE_MINUS_SRC_ALPHA

    See :py:attr:`Context.ONE_MINUS_SRC_ALPHA`

.. py:attribute:: moderngl.DST_ALPHA

    See :py:attr:`Context.DST_ALPHA`

.. py:attribute:: moderngl.ONE_MINUS_DST_ALPHA

    See :py:attr:`Context.ONE_MINUS_DST_ALPHA`

.. py:attribute:: moderngl.DST_COLOR

    See :py:attr:`Context.DST_COLOR`

.. py:attribute:: moderngl.ONE_MINUS_DST_COLOR

    See :py:attr:`Context.ONE_MINUS_DST_COLOR`

.. py:attribute:: moderngl.DEFAULT_BLENDING

    See :py:attr:`Context.DEFAULT_BLENDING`

.. py:attribute:: moderngl.ADDITIVE_BLENDING

    See :py:attr:`Context.ADDITIVE_BLENDING`

.. py:attribute:: moderngl.PREMULTIPLIED_ALPHA

    See :py:attr:`Context.PREMULTIPLIED_ALPHA`

.. py:attribute:: moderngl.FUNC_ADD

    See :py:attr:`Context.FUNC_ADD`

.. py:attribute:: moderngl.FUNC_SUBTRACT

    See :py:attr:`Context.FUNC_SUBTRACT`

.. py:attribute:: moderngl.FUNC_REVERSE_SUBTRACT

    See :py:attr:`Context.FUNC_REVERSE_SUBTRACT`

.. py:attribute:: moderngl.MIN

    See :py:attr:`Context.MIN`

.. py:attribute:: moderngl.MAX

    See :py:attr:`Context.MAX`

.. py:attribute:: moderngl.FIRST_VERTEX_CONVENTION

    See :py:attr:`Context.FIRST_VERTEX_CONVENTION`

.. py:attribute:: moderngl.LAST_VERTEX_CONVENTION

    See :py:attr:`Context.LAST_VERTEX_CONVENTION`