Glumpy comes with a lot of examples that aim at illustrating the main features. You'll find below a list organized around several sections.
glumpy.app is responsible for opening a window, handling events
(mouse, keyboard and user event). It also provides convenient interfaces to
parse command line options and configure the GL context.
This example shows how to change the backend programmatically.
Note that if the backend is set, the
--backendcommand line option has not effect.
This example shows how to choose and use a specific GL configuration (GL version & profile, depth buffer size, stencil, ...).
This example shows how to run manually the event loop. It might come handy if you want to integrate a glumpy program into another application.
This example exhibits all available events and display them when triggered.
Note that the idle event is commented out because it generates far too many messages.
This example runs in interactive mode where python console is reactive.
This examples takes a single screenshot and immeditaley exit.
You can also take a screenshot anytime using the
F10key. The screenshot will be named after the example filename.
This is the most simple glumpy example that display a black window and wait for the user to exit the application
You can exit any glumpy program by closing the window or pressing the
ESCkey. If you want to disable the
ESCbehavior, you'll have to connect to the key press event and override behavior.
This example creates a window and closes it after 5 seconds.
This example opens two windows, one should be black, the other white.
This example displays two points (square), one blue, one red, using two shader programs. This example also serves as a test for checking glumpy is running properly.
glumpy.gloo is the heart of glumpy and is responsible for talking to the GPU throught buffers, textures and programs. This is done quite transparently thanks to the numpy interface (and the GPU data object which is a subclassed numpy array).
This example shows stroke, filled and outline antialiased shader.
This example shows antialiased arrows using points.
This example illustrates the atlas object that allow to store different texture into a single one.
This example show an animated 3d scatter plots made of a million antialiased points. It should run smoothly on any recent hardware.
This is a failsafe debug console that should never fails...
This example shows a rotating, colored & outlined cube. It uses transformation matrices to translate, rotate and finally project the cube on the window framebuffer. Note that there are easier way to do the same with glumpy (transforms).
This examples shows how to display an image, without control of the aspect ratio though.
This examples shows a scatter plot which is zoomed dynamically around the mouse pointer.
This example show various antialiased markers. The anti-aliasing is computed by the GPU using signed-distance functions that describe the mathematical shape. This makes the display very fast (it is possible to display a million points this way, provided they're not too big in terms of pixels area).
This example shows an animated colored quad made of two triangles in orthographic mode.
This example simulates rain drops using growing and fading circles and shows how to update a vertex buffer.
This example shows how to manipulate 1-dimensional textures.
This example shows how to manipulate 2-dimensional textures.
This example display a bunch of signals that slowly fades out. The tick is to not clear the framebuffer but to draw a almost transparent quad over the scene, making older signals to slowly vanish.
This example show mouse trails using growing and fadind discs. It illustrate how to use mouse interation to update a vertex buffer.
Simple computation can be directly written using the GPU (no Cuda, no OpenCL):
This is the Game Of Life computed on the GPU (very fast).
This is a Grayscott Reaction-Diffusion system.
This is smoke simulation ported from the little grasshopper.
Post-processing filters are easily implemented using the Filter object. You
draw tour scene normally but the draw calls are surrounded by a
Filter(shader) where the shader transform the otuput.
Pixelating filter with pixelation level controlled by mouse scroll.
Simple 2D Gaussian blur using two 1D kernels.
This example show how to compose filters together.
- 2D plots on regular grid
- 3D plots on regular grid
- Arbitrary viewports
Transforms are snippets that can be attached to events (resize, mouse_scroll, etc.) and inserted into other shader code using hooks.
The panzoom transform allow to translate and scale an object in the window space coordinate (2D).
The trackball transform simulates a virtual trackball (3D) that can rotate around the origin using intuitive mouse gestures.
Projection / Model / View transform (equivalen to the deprecated GL api)
The orthographic projection can be combined with the panzoom tranform.
Simple linear scale that maps point from a domain to a given range.
Power scales are similar to linear scales, except there's an exponential transform that is applied to the input domain value before the output range value is computed.
Log scales are similar to linear scales, except there's a logarithmic transform that is applied to the input domain value before the output range value is computed.
This example show how to use different scales on x, y, or z.
Simple polar projection.
Simple composition of a polar projection and a log scale on the radius.
- Spiral galaxy
- Quiver plot
- Realtime signals
- Antialiased solid lines
- Antialiased dashed lines
- Read movie
- Write movie
- Antialiased grids
- High-frequency signal
- Image spatial interpolations