OpenGL 4.x Examples
OpenGL is a cross-platform API for 2D and 3D graphics on desktop devices.
Beginner | Intermediate | Advanced
Beginner
-
Draw a triangle to the screen using hardware acceleration.
Description:
A basic tutorial that guides the user, step-by-step, through the process of initializing a window using :API:, drawing a triangle in it using hardware acceleration, and then terminating the window.
Controls:
Esc : Close the application
Links:
-
This training course introduces the PVRShell library.
Description:
This demo deals with the PVRShell library. The PowerVR shell handles all OS specific initialisation code, and has several built in command line features which allow for the specifying of attributes. The library is constructed around a 'PVRShell' base class, and object of which is constructed and returned from a 'NewDemo' function.
Controls:
Esc : Close the application
Links:
-
This training course demonstrates how to apply a texture to a polygon in :API:.
Description:
This training course demonstrates how to apply a texture to a polygon in :API:. The texture is generated procedurally during initialisation and then loaded into :API:. The triangle is then drawn with UV values so that the texture can be applied to it.
Controls:
Esc : Close the application
Links:
-
This training course introduces the PVRTools libraries.
Description:
This training course introduces the PVRTools libraries. These libraries provide various modules to help developers perform many of the common tasks associated with hardware accelerated graphics rendering.
Controls:
Esc : Close the application
Links:
-
This training course introduces the Print3D class featured within the PVRTools library.
Description:
This training course introduces the Print3D class from the PVRTools library. Print3D can be used to display text in both 2D and 3D modes. The default projection mode is 2D but supplying a modelview and projection matrices allow the user to render the text in 3D. Text in different colours is also possible.
Controls:
Links:
-
This training course introduces the PowerVR Object Data (.pod) format.
Description:
This training course introduces the PowerVR Object Data (.pod) format. It goes into detail on how to open .pod files, load any .pfx and .pvr files that have been referenced, and set up the cameras and lights from the .pod file.
Controls:
Esc : Close the application
Links:
-
This training course demonstrates how to use the PVRTools library to load and use .pfx files.
Description:
This training course demonstrates how to use the PVRTools library to load and use .pfx files. PFX is both a file format and an API, and stands for PowerVR Effects.
Controls:
Esc : Close the application
Links:
Intermediate
-
This training course illustrates how transparency effects can be achieved with blending and the use of some common blending modes.
Description:
Blending is a fragment operation that combines the colour value of fragments as they are drawn with values that are already present in the colour buffer. This allows transparent objects to be simulated. This training course shows how to draw blended geometry using four different types of blending modes set with glBlendFunc().
Controls:
Esc : Close the application
Links:
-
This training course illustrates how to perform alpha testing and provides a visual comparison between alpha blending and alpha testing.
Description:
Alpha testing is a technique through which a test is conducted on a per-fragment basis to determine whether that fragment should be discarded and not contribute to the final scene. This can allow complex shapes to be drawn using very simple geometries, but often at the price of hardware optimisations in the graphics pipeline. In programmable graphics pipelines supporting GLSL this is done through the use of the 'discard' keyword in the fragment shader while in the fixed function pipeline API OpenGL ES 1.x this is performed by calling either glEnable(GL_BLEND) or glEnable(GL_ALPHA_TEST).
Controls:
Esc : Close the application
Links:
-
In this training course two techniques are shown for generating an anisotropic lighting effect, one technique using per vertex/pixel calculations, and the other using a texture lookup.
Description:
In this training course two techniques are shown for generating an anisotropic lighting effect (the effect of surface grain on materials such as brushed metal, velvet etc.). The first technique uses per vertex and pixel calculations to calculate the shading and thus generate the effect on the fly. The second technique uses a texture lookup to determine the shading and would be useful in situations where bandwidth was more readily available than processing time.
Controls:
Left/Right Arrow : Toggle effect
Esc : Close application
Links:
-
This training course demonstrates a simple implementation of a 'bloom' effect.
Description:
This training course demonstrates a simple implementation of a 'bloom' post processing effect. The bright parts of the picture are extracted in a post processing step, blurred and added over the final image to create a glow around the object's borders.
Controls:
Up/Down : Toggle the bloom effect On/Off
Esc : Close the application
Links:
-
This training course demonstrates an example of using a normal map to implement bump mapping.
Description:
Bump mapping is a technique for simulating bumps and wrinkles on the surface of an object. This is achieved by perturbing the surface normals of the object and using the perturbed normal during the illumination calculations. The result is an apparently bumpy surface rather than a perfectly smooth surface although the surface of the underlying object is not actually changed. This technique is used extensively in graphics applications to add perceived detail to models without adding further geometry.
Controls:
Esc : Close the application
Links:
-
This training course demonstrates how to implement cell shading.
Description:
This training course demonstrates how to implement cell shading. Cell-shaded animation (also known as Cell shading or Toon shading) is a type of non-photorealistic rendering designed to make computer graphics appear to be hand-drawn. Cell-shading is often used to mimic the style of a comic book or cartoon and is predominantly used in video games.
Controls:
Esc : Close the application
Links:
-
This training course demonstrates how to implement complex lighting techniques.
Description:
This training course demonstrates how to implement various forms of more complex lighting techniques than the basic lighting training courses. Specifically, it shows how to implement directional, point and spot lighting with a diffuse and a specular component using branching in the vertex shader.
Controls:
Left/Right : Cycle through the available modes
Esc : Close the application
Links:
-
Shows how to use cube shadow maps for point light sources.
Description:
Shows how to dynamically update the cube shadow map for a point light source and cast shadows using that cube shadow map. Shadow Mapping is a process by which shadows are added to 3D computer graphics by testing whether a pixel is visible from the light source, and comparing it to a z-buffer or depth image of the light source's view.
Controls:
Links:
-
This training course demonstrates displacement mapping using a texture read from the vertex shader.
Description:
Displacement mapping is an alternative to bump mapping, normal mapping, and parallax mapping, that causes the actual geometric position of points over a textured surface to be displaced, often along the local surface normal, according to the value the texture function evaluates to at each point on the surface.
Controls:
Esc : Close the application
Links:
-
This training course serves as an example of a fast transformation and lighting vertex shader.
Description:
This training course shows how to use a fast transformation and lighting vertex shader. This technique is appropriate for situations when a high performance shader is required.
Controls:
Esc : Close the application
Links:
-
This training course demonstrates how to create a fog effect using shaders.
Description:
This training course demonstrates how to create a fog effect using shaders. Fog is used to help with the perception of distance in a 3D world - objects that are further way are increasingly coloured with a fog colour.
Controls:
Left/Right : Cycle fog mode
Esc : Close the application
Links:
-
This training course demonstrates an implementation of Fresnel reflection.
Description:
This training course demonstrates an implementation of Fresnel reflection. The Fresnel equations (or Fresnel conditions) describe the behaviour of light when moving between media of differing refractive indices. The reflection of light that the equations predict is known as Fresnel reflection.
Controls:
Up/Down : Increase/Decrease the refractive index of the surface material
Esc : Close the application
Links:
-
This training course demonstrates how to implement an iridescence effect.
Description:
This training course demonstrates how to implement an iridescence effect. Iridescence (also known as goniochromism) is generally known as the property of certain surfaces which appear to change colour as the angle of view or the angle of illumination changes. Iridescence is commonly seen in items such as soap bubbles, butterfly wings, and sea shells. The effect demonstrated in this training course mimics the behaviour of light reflecting off a surface covered by a translucent film of variable thickness.
Controls:
Up/Down : Increase/Decrease the maximum variation
Left/Right : Decrease/Increase the maximum thickness
Esc : Close the application
Links:
-
This training course demonstrates a switch in the detail of an object based on its distance from the camera.
Description:
This training course demonstrates a switch in the detail of an object based on its distance from the camera. The vertex and fragment shaders implement two techniques for reflections. Which technique is used depends on the value of bHighDetail (which varies based on distance). If bHighDetail is true the method described in OGLES2PerturbedUVs is used; if bHighDetail is false the method described in OGLES2Reflections is used. Additionally, when the training course is in 'low detail' mode it uses a different mesh, this mesh contains only 7% of the original meshes vertices.
Controls:
Esc : Close the application
Links:
-
This training course shows how to use light maps.
Description:
This training course demonstrates how to use light mapping to project a shadow texture from an arbitrary point, in an arbitrary direction, onto a model which has a base and reflection texture.
Controls:
Esc : Close the application
Links:
-
Shows how to use multiple render targets to output data to several different surfaces within a single pass.
Description:
Multiple Render Targets is a technique utilised in modern graphics processing that allows the rendering of multiple images to multiple render targets simultaneously. These textures can then be used as texture maps applied to 3D models, or as inputs for other shaders.
Controls:
Links:
-
This training course demonstrates the use of environment mapping with perturbed UVs.
Description:
This training course demonstrates the use of environment mapping with perturbed UVs. For any given surface on the object a normal map value is read, an angle of reflection between that normal and the eye direction is used to generate a new UV co-ordinate and finally, this UV co-ordinate is used to find the correct colour to reflect from the environment map.
Controls:
Esc : Close the application
Links:
-
This training course demonstrates the creation of a reflection effect from a 2D map and a cube map.
Description:
This training course demonstrates the creation of a reflection effect from a 2D map and a cube map. This technique is also known as environment mapping in that the environment around an object is rendered into a texture (in this case as a pre-baked step) and then this environment is sampled per fragment in order to simulate the effect of light from the environment being reflected from the object. Two variations on the technique are shown using either a 2D map or a cube map.
Controls:
Left/Right : Swap mapping type
Esc : Close the application
Links:
-
This training course demonstrates a simulation of glass-like materials.
Description:
This training course combines an object with a background in order to achieve a refraction effect. The background texture is applied to the model but the sample coordinates are affected by the normals of the geometry in order to simulate how light would be bent through a material with differing refractive index to the air around it.
Controls:
Left/Right : Cycle Specular reflection on or off
Esc : Close the application
Links:
-
This training course demonstrates the use of rendering to a texture.
Description:
This training course demonstrates rendering a scene to a pBuffer surface or FBO, then binding and applying that render to an object in an additional render pass.
Controls:
Left : Toggles multisampling of the FBOs
Esc : Close the application
Links:
-
This training course demonstrates a shadow mapping technique.
Description:
This training course demonstrates a shadow mapping technique. This technique begins by determining whether a given area can be seen from the light. Each fragment that is not visible is marked in one render pass and used to create a texture. In a second render pass this texture is applied to the scene to create the shadow effect.
Controls:
Esc : Close the application
Links:
-
This training course demonstrates how to use the PVRTools libraries to create and use shadow volumes.
Description:
This training course demonstrates how to use the PVRTools library to create and use shadow volumes. The process for using this technique involves updating dynamic shadow volumes before drawing the fully lit scene. After that, the stencil test must be enabled, and the shadow volumes must be drawn to fill the stencil buffer. Then draw a full screen quad that will only appear where the stencil buffer is not zero, and finally disable the stencil test.
Controls:
1 : Toggle display of shadow volumes
Esc : Close the application
Links:
-
This training course demonstrates how to implement hardware accelerated skinning using .pod files.
Description:
This training course demonstrates how to implement hardware accelerated skinning using the .pod file loading tools found in the PVRTools library.
Controls:
Left/Right : Rotate model clockwise/anti-clockwise
Up/Down : Zoom out/in
Esc : Close the application
Links:
-
This training course demonstrates how to use the stencil buffer to mask areas of the screen when rendering.
Description:
This training course demonstrates how to use the stencil buffer to mask areas of the screen when rendering. A sphere and a cylinder are drawn intersecting. The sphere is drawn first, then a stencil test performed using the cylinder. This test is used to determine what colour should be drawn for a given area of the sphere.
Controls:
Esc : Close the application
Links:
-
Shows how to use transform feedback to implement a simple particle system.
Description:
Shows how to use the transform feedback functionality to implement a simple particle system. The particles are animated within a vertex shader and written out to a buffer object. This buffer object is then used to render the particles and used as input for the next frame's animation.
Controls:
Links:
-
Shows how to use uniform buffer objects.
Description:
This demonstration shows how to use uniform buffer objects to set the values of several shader uniforms at once. A uniform buffer object stores uniform data for a shader program, and is often used becuase switching between uniform buffer bindings is faster than swithcing several uniforms in a program.
Controls:
Links:
Advanced
-
A demonstration of drawing a fractal using render to texture.
Description:
A recursive fractal effect is demonstrated here using the render to texture technique. This technique is a useful method to create a variety of effects. Basically, a scene is rendered as usual, but in a texture for future reuse.
Controls:
Esc : Close the application
Links:
-
Implementation of John Conway's Game of Life using OpenCL.
Description:
This demo utilises OpenCL to take advantage of the GPU computation available in PowerVR Series6 to implement John Conway's Game of Life simulation, updating every aspect of the grid where all the particles are stored. OpenGL then retrieves the result of that computation and presents it on the screen.
Controls:
Left and right arrows : Switch between evolution functions.
Up : Pause simulation.
Down : Generate new population.
Links:
-
Demonstrates the use of PVRScope and the example graphing code.
Description:
This demo shows the use of PVRScope and the example graphing code that allows an application to return performance statistics from the GPU in real time. For further details, refer to the PVRScope User Manual.
Controls:
Links:
-
Demonstrates the use of PVRScope's remote communication features.
Description:
This example shows how to use the editable data and custom mark functionality of PVRScope. PVRTune must be running and connected to an instance of PVRPerfServer running on the target device for this demo to function.
Controls:
Links:
-
Shows how to implement a simple particle system using OpenCL and the GPU.
Description:
The demo utilises OpenCL to implement a particle system. Particle systems are techniques that use a large amount of sprites to simulate phenomena that would be difficult to reproduce with conventional rendering techniques. Furthermore, it also highlights the interaction between OpenCL and OpenGL (plus OpenGL ES 2).
- left and right arrows - Decrease and increase number of particles
- up and down arrows - Switch between OpenCL and CPU Particle System implementation.
Controls:
Links:







