Skip to content

Commit 4c8901b

Browse files
committed
Doc cleanup
1 parent 41886ee commit 4c8901b

File tree

17 files changed

+74
-27
lines changed

17 files changed

+74
-27
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Running tests:
8989
pytest
9090
```
9191

92-
Bulding docs:
92+
Building docs:
9393

9494
```bash
9595
python setup.py build_sphinx

demosys/effects/effect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def bind_target(func):
1616
"""
1717
Decorator auto binding and releasing the incoming FBO in ``draw()``.
1818
19-
literal blocks::
19+
example::
2020
2121
@bind_target
2222
def draw(...):

demosys/opengl/fbo.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ def mglo(cls):
3131

3232

3333
class FBO:
34-
"""Frame buffer object"""
34+
"""
35+
A framebuffer object is a collection of buffers that can be used as the destination for rendering.
36+
The buffers for framebuffer objects reference images from either textures.
37+
38+
A typical FBO has one or multiple color layers and a depth. Shaders can write to these buffers
39+
when activated.
40+
"""
3541
_stack = []
3642

3743
def __init__(self):
@@ -47,7 +53,7 @@ def create_from_textures(color_buffers: List[Texture2D], depth_buffer: DepthText
4753
:param color_buffers: List of textures
4854
:param depth_buffer: Depth texture
4955
50-
:return: FBO instance
56+
:return: A new :py:class:`FBO`
5157
"""
5258
instance = FBO()
5359
instance.color_buffers = color_buffers
@@ -70,8 +76,7 @@ def create(size, components=4, depth=False, dtype='f1', layers=1) -> 'FBO':
7076
:param depth: (bool) Create a depth attachment
7177
:param dtype: (string) data type per r, g, b, a ...
7278
:param layers: (int) number of color attachments
73-
74-
:return: A new FBO
79+
:return: A new :py:class:`FBO`
7580
"""
7681
instance = FBO()
7782

@@ -150,6 +155,12 @@ def __exit__(self, exc_type, exc_val, exc_tb):
150155
def use(self, stack=True):
151156
"""
152157
Bind FBO adding it to the stack.
158+
Optionally a context manager can be used:
159+
160+
optonally a context manager can be used::
161+
162+
with fbo:
163+
# draw stuff
153164
154165
:param stack: (bool) If the bind should push the current FBO on the stack.
155166
"""

demosys/opengl/texture/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from .texture import Texture2D
2-
from .array import TextureArray
3-
from .depth import DepthTexture
1+
from .texture import Texture2D # noqa
2+
from .array import TextureArray # noqa
3+
from .depth import DepthTexture # noqa

demosys/opengl/texture/array.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@
66

77

88
class TextureArray(BaseTexture):
9-
"""This is the class docstring"""
9+
"""
10+
A TextureArray is a texture where each mipmap level contains an array of
11+
images of the same size. Array textures may have Mipmaps, but each mipmap
12+
in the texture has the same number of levels.
13+
14+
The image data size must exactly match (width, height * layers)
15+
"""
1016

1117
def __init__(self, path: str=None, mipmap: bool=False, layers=0, **kwargs) -> 'TextureArray':
1218
"""
@@ -35,6 +41,7 @@ def create(cls, size, components=4, data=None, alignment=1, dtype='f1', mipmap=F
3541
:param alignment: The byte alignment 1, 2, 4 or 8
3642
:param dtype: (str) The data type
3743
:param mipmap: (bool) Generate mipmaps
44+
:returns: :py:class:`TextureArray` object
3845
"""
3946
texture = TextureArray("create", mipmap=False, layers=size[2])
4047
texture.mglo = context.ctx().texture_array(
@@ -50,6 +57,7 @@ def create(cls, size, components=4, data=None, alignment=1, dtype='f1', mipmap=F
5057
def set_image(self, image, flip=True):
5158
"""
5259
Set pixel data using a image file with PIL/Pillow.
60+
The image size must exactly match (width, height * layers)
5361
5462
:param image: The PIL/Pillow image object
5563
:param flip: Flip the image top to bottom

demosys/opengl/texture/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def __init__(self):
1414

1515
def use(self, location=0):
1616
"""
17-
Bind the texture.
17+
Bind the texture to a channel/location.
1818
1919
:param location: The texture location. (GL_TEXTURE0 + location)
2020
"""

demosys/opengl/texture/depth.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55

66

77
class DepthTexture(BaseTexture):
8-
"""Depth Texture"""
8+
"""
9+
A DepthTexture is a texture for storing depth information during rendering.
10+
They are attachments to :py:class:`demosys.opengl.FBO`.
11+
"""
912

1013
# Class attributes for drawing the texture
1114
quad = None
1215
shader = None
1316
sampler = None
1417

15-
def __init__(self, size, data=None, samples=0, alignment=8):
18+
def __init__(self, size, data=None, samples=0, alignment=4):
1619
"""
1720
Create a depth texture
1821
@@ -27,12 +30,24 @@ def __init__(self, size, data=None, samples=0, alignment=8):
2730
_init_depth_texture_draw()
2831

2932
@classmethod
30-
def create(cls, size, data=None, samples=0, alignment=8) -> 'DepthTexture':
33+
def create(cls, size, data=None, samples=0, alignment=4) -> 'DepthTexture':
34+
"""
35+
Creates a :py:class:`DepthTexture` object
36+
37+
:param size: (tuple) The width and height of the texture.
38+
:param data: (bytes) Content of the texture.
39+
:param samples: The number of samples. Value 0 means no multisample format.
40+
:param alignment: The byte alignment 1, 2, 4 or 8.
41+
:return: :py:class:`DepthTexture` object
42+
"""
3143
return cls(size, data=data, samples=samples, alignment=alignment)
3244

3345
def draw(self, near, far, pos=(0.0, 0.0), scale=(1.0, 1.0)):
3446
"""
3547
Draw depth buffer linearized.
48+
By default this will draw the texture as a full screen quad.
49+
A sampler will be used to ensure the right conditions to draw the depth buffer.
50+
3651
:param near: Near plane in projection
3752
:param far: Far plane in projection
3853
:param pos: (tuple) offset x, y

demosys/opengl/texture/texture.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77

88

99
class Texture2D(BaseTexture):
10-
"""2D Texture"""
10+
"""
11+
A Texture is an OpenGL object that contains one or more images that all
12+
have the same image format. A texture can be used in two ways. It can
13+
be the source of a texture access from a Shader, or it can be used
14+
as a render target.
15+
"""
1116

1217
# Class attributes for drawing the texture
1318
quad = None
@@ -43,7 +48,7 @@ def create(cls, size, components=4, data=None, samples=0, alignment=1, dtype='f1
4348
:param alignment: Data alignment (1, 2, 4 or 8)
4449
:param dtype: Datatype for each component
4550
:param mipmap: Generate mipmaps
46-
:return: Texture object
51+
:return: :py:class:`Texture2D` object
4752
"""
4853
texture = Texture2D(path="dynamic", mipmap=mipmap)
4954

@@ -69,7 +74,7 @@ def from_image(cls, path, image=None, **kwargs):
6974
7075
:param path: The path to the file
7176
:param image: The PIL/Pillow image object (Can be None)
72-
:return: Texture object
77+
:return: :py:class:`Texture2D` object
7378
"""
7479
texture = Texture2D(path=path, **kwargs)
7580
if image:
@@ -97,7 +102,8 @@ def set_image(self, image, flip=True):
97102

98103
def draw(self, pos=(0.0, 0.0), scale=(1.0, 1.0)):
99104
"""
100-
Draw texture
105+
Draw texture using a fullscreen quad.
106+
By default this will conver the entire screen.
101107
102108
:param pos: (tuple) offset x, y
103109
:param scale: (tuple) scale x, y

demosys/scene/loaders/wavefront.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from pywavefront import cache
66
from pywavefront.obj import ObjParser
77

8-
from demosys import context
98
from demosys.opengl import VAO
109
from demosys.resources import textures
1110
from demosys.scene import Material, MaterialTexture, Mesh, Node

demosys/scene/scene.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(self, name, loader=None, mesh_shaders=None, **kwargs):
3333
self.bbox_vao = geometry.bbox()
3434
self.bbox_shader = shaders.get('scene_default/bbox.glsl', create=True)
3535

36-
self._view_matrix = matrix44.create_identity()
36+
self._view_matrix = matrix44.create_identity()
3737

3838
@property
3939
def view_matrix(self):

0 commit comments

Comments
 (0)