MCPcopy
hub / github.com/ManimCommunity/manim / construct

Method construct

example_scenes/opengl.py:289–363  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

287
288class InlineShaderExample(Scene):
289 def construct(self):
290 config["background_color"] = "#333333"
291
292 c = Circle(fill_opacity=0.7).shift(UL)
293 self.add(c)
294
295 shader = Shader(
296 self.renderer.context,
297 source={
298 "vertex_shader": """
299 #version 330
300
301 in vec4 in_vert;
302 in vec4 in_color;
303 out vec4 v_color;
304 uniform mat4 u_model_view_matrix;
305 uniform mat4 u_projection_matrix;
306
307 void main() {
308 v_color = in_color;
309 vec4 camera_space_vertex = u_model_view_matrix * in_vert;
310 vec4 clip_space_vertex = u_projection_matrix * camera_space_vertex;
311 gl_Position = clip_space_vertex;
312 }
313 """,
314 "fragment_shader": """
315 #version 330
316
317 in vec4 v_color;
318 out vec4 frag_color;
319
320 void main() {
321 frag_color = v_color;
322 }
323 """,
324 },
325 )
326 shader.set_uniform("u_model_view_matrix", opengl.view_matrix())
327 shader.set_uniform(
328 "u_projection_matrix",
329 opengl.orthographic_projection_matrix(),
330 )
331
332 attributes = np.zeros(
333 6,
334 dtype=[
335 ("in_vert", np.float32, (4,)),
336 ("in_color", np.float32, (4,)),
337 ],
338 )
339 attributes["in_vert"] = np.array(
340 [
341 [-1, -1, 0, 1],
342 [-1, 1, 0, 1],
343 [1, 1, 0, 1],
344 [-1, -1, 0, 1],
345 [1, -1, 0, 1],
346 [1, 1, 0, 1],

Callers

nothing calls this directly

Calls 7

set_uniformMethod · 0.95
CircleClass · 0.85
ShaderClass · 0.85
MeshClass · 0.85
waitMethod · 0.80
shiftMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected