view Package

glyph Module

class gloopy.view.glyph.Glyph(num_verts, verts, colors, normals, indices)[source]

Bases: object

Passed iterables of vertex positions, colors, normals and indices, converts them into ctypes arrays, stores them in a VBO, and then creates a VAO that can be used to bind them later for rendering.

__init__(num_verts, verts, colors, normals, indices)[source]
shader = None
gloopy.view.glyph.get_index_type(num_verts)[source]

Return the unsigned integer data type required to store the given number. e.g. 255 can be stored in a GLubyte, whereas 256 rrequires a GLushort.

gloopy.view.glyph.glarray(gltype, seq, length)[source]

Convert a list of lists into a flattened ctypes array, eg: [ (1, 2, 3), (4, 5, 6) ] -> (GLfloat*6)(1, 2, 3, 4, 5, 6)

modelview Module

class gloopy.view.modelview.ModelView(camera)[source]

Bases: object

Manage modelview matrix.

Presumably this class will go away in future releases of Gloopy as we use a more OpenGL3 style.

__init__(camera)[source]

camera must have .position and .look_at attributes. A GameItem instance would make a good camera.

set_identity()[source]
set_world()[source]

Set the OpenGL modelview matrix to account for the camera’s position and orientation.

projection Module

class gloopy.view.projection.Projection(window)[source]

Bases: object

Manage projection matrix.

Presumably this class will go away, or be severely modified, in some future release of Gloopy which may use a more OpenGL3 style.

resize_window(width, height)[source]

Handler for window resize events TODO: do we also need to set clipping?

set_ortho(scale)[source]

Set OpenGL projection matrix to Ortho2D, such that the screen’s shortest dimension (height on a landscape monitor or window) will show exactly scale of the world from the center of the screen to each edge, regardless of screen resolution or window size.

set_perspective(fovy)[source]

Set OpenGL projection matrix to a 3D perspective projection, with the given field of view, in degrees.

set_screen()[source]

Set OpenGL projection matrix to Ortho2D, showing world space coords 0 <= x < WIDTH, and 0 <= y < HEIGHT.

render Module

class gloopy.view.render.Render(world, window, camera, options)[source]

Bases: object

Render class does all the OpenGL rendering

__init__(window, camera, options)[source]

world: instance of World.

window: instance of pyglet Window class

camera: gloopy camera (might be a GameItem instance)

options: instance of Options.

backface_culling

Boolean property to get or set backface culling.

clear_window(color)[source]

Clear window color and depth buffers, using the given color

draw_hud()[source]

Draw any display items overlaid on the world, such as FPS counter

draw_window()[source]

Redraw the whole window

draw_world_items()[source]

Draw all items that have been added to the world

init()[source]

Set all initial OpenGL state, such as enabling DEPTH_TEST. Also loads a the lighting shader.

gloopy.view.render.log_opengl_version()[source]

Send OpenGL version and driver info to logfile

shader Module

class gloopy.view.shader.Shader(vert_filename, frag_filename, attribs)[source]

Bases: object

Wraps PyOpenGL’s shader compile and link functions

__init__(vertex, fragment, attributes)[source]

vertex: filename of vertex shader source code

fragment: filename of fragment shader source code

attribs: a list of attribute names

Compiles and links the shader. For each attribute_name in attribs, looks up the attribute location, and stores it in self.attrib[attribute_name].

Can be bound and unbound by use as a context-manager:

shader = Shader('vert.glsl', 'frag.glsl', [])
with shader:
    # draw calls
use()[source]

Use the linked shader program

gloopy.view.shader.read_shader_file(filename)[source]

Table Of Contents

Previous topic

util Package

This Page