Skip to content

Commit 83688d0

Browse files
committed
Docs: More BaseProject docs
1 parent 669adf0 commit 83688d0

File tree

2 files changed

+71
-15
lines changed

2 files changed

+71
-15
lines changed

demosys/project/base.py

+54-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,60 @@
99

1010

1111
class BaseProject:
12-
"""The Project"""
13-
effect_packages = []
14-
resources = []
15-
override_resources = {}
12+
"""
13+
The base project class we extend when creating a project configuration
14+
15+
The minimal implementation::
16+
17+
from demosys.project.base import BaseProject
18+
from demosys.resources.meta import ProgramDescription, TextureDescription
19+
20+
class Project(BaseProject):
21+
# The effect packages to import using full python path
22+
effect_packages = [
23+
'myproject.efect_package1',
24+
'myproject.efect_package2',
25+
'myproject.efect_package2',
26+
]
27+
# Resource description for global project resources (not loaded by effect packages)
28+
resources = [
29+
ProgramDescription(label='cube_textured', path="cube_textured.glsl'),
30+
TextureDescription(label='wood', path="wood.png', mipmap=True),
31+
]
32+
33+
def create_resources(self):
34+
# Override the method adding additional resources
35+
36+
# Create some shared fbo
37+
size = (256, 256)
38+
self.shared_framebuffer = self.ctx.framebuffer(
39+
color_attachments=self.ctx.texture(size, 4),
40+
depth_attachement=self.ctx.depth_texture(size)
41+
)
42+
43+
return self.resources
44+
45+
def create_effect_instances(self):
46+
# Create and register instances of an effect class we loaded from the effect packages
47+
self.create_effect('cube1', 'CubeEffect')
48+
49+
# Using full path to class
50+
self.create_effect('cube2', 'myproject.efect_package1.CubeEffect')
51+
52+
# Passing variables to initializer
53+
self.create_effect('cube3', 'CubeEffect', texture=self.get_texture('wood'))
54+
55+
# Assign resources manually
56+
cube = self.create_effect('cube1', 'CubeEffect')
57+
cube.program = self.get_program('cube_textured')
58+
cube.texture = self.get_texture('wood')
59+
cube.fbo = self.shared_framebuffer
60+
61+
These effects instances can then be obtained by the configured timeline class deciding
62+
when they should be rendered.
63+
"""
64+
effect_packages = [] #: The effect packages to load
65+
resources = [] #: Global project resource descriptions
1666

1767
def __init__(self):
1868
self._effects = {}

docs/reference/baseproject.rst

+17-11
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,36 @@ BaseProject
88
.. autodata:: BaseProject
99
:annotation:
1010

11-
Methods
12-
-------
11+
Create Methods
12+
--------------
1313

14-
.. automethod:: BaseProject.get_default_effect
14+
.. automethod:: BaseProject.create_effect
1515
.. automethod:: BaseProject.create_effect_classes
16-
.. automethod:: BaseProject.create_external_resources
1716
.. automethod:: BaseProject.create_resources
17+
.. automethod:: BaseProject.create_external_resources
1818
.. automethod:: BaseProject.create_effect_instances
19-
.. automethod:: BaseProject.create_effect
20-
.. automethod:: BaseProject.post_load
21-
.. automethod:: BaseProject.load
22-
.. automethod:: BaseProject.reload_programs
19+
20+
Resource Methods
21+
----------------
22+
2323
.. automethod:: BaseProject.get_effect
2424
.. automethod:: BaseProject.get_effect_class
2525
.. automethod:: BaseProject.get_scene
2626
.. automethod:: BaseProject.get_program
2727
.. automethod:: BaseProject.get_texture
2828
.. automethod:: BaseProject.get_data
29+
30+
Other Methods
31+
-------------
32+
33+
.. automethod:: BaseProject.load
34+
.. automethod:: BaseProject.post_load
35+
.. automethod:: BaseProject.reload_programs
2936
.. automethod:: BaseProject.get_runnable_effects
30-
.. automethod:: BaseProject.
31-
.. automethod:: BaseProject.
32-
.. automethod:: BaseProject.
3337

3438
Attributes
3539
----------
3640

41+
.. autoattribute:: BaseProject.effect_packages
42+
.. autoattribute:: BaseProject.resources
3743
.. autoattribute:: BaseProject.ctx

0 commit comments

Comments
 (0)