Skip to content
Daniel Limberger edited this page Aug 13, 2014 · 47 revisions

Examples

cubescape

cubescape uses a heightmap and cubes/cuboids in combination with instanced drawing to render a tiny landscape. For the input textures, raw texture files are used (created with glraw). The number of cubes per side can be decreased and increased at runtime, thus providing an OpenGL rendering test, that can be arbitrarily scaled for, e.g., performance stress tests.

16² cubes (default) 8² cubes
[[examples/cubescape-16.png alt=cubescape-16]]
64² cubes 2048² cubes
[[examples/cubescape-64.png alt=cubescape-64]]

qt-cubescape

qt-cubescape creates a QMainWindow that embeds a QWindow with an QOpenGLContext and shows a cubescape, using glbinding and the exact rendering code of the cubescape example. Furthermore, it allows for toggling full screen and swap interval modes.

qt-cubescape

compare

The comparison example shows that there is no significant overhead involved in using glbinding over GLEW. It compares the function execution times of identical rendering code, dispatched once with glbinding and once with GLEW. The rendering would yield the following image, but viewport height is not set and swap buffers not called:

compare-behind-the-scenes

Various outputs of compare on different systems:

Windows 8.1, NVIDIA Geforce GTX 680

Intel(R) Xeon(R) CPU W3530 @ 2.8GHz, 12GB RAM, compare.exe (release, x64):

test: initialize bindings ...
      glbinding : 5001.3 us
      glew      : 6941.4 us

OpenGL Version:  4.4
OpenGL Vendor:   NVIDIA Corporation
OpenGL Renderer: GeForce GTX 680/PCIe/SSE2

prep: warm-up ...
      glew
      glbinding

test: average call times for 8192 x 24 calls ...
      glew      : 14.5 us
      glbinding : 14.1 us

test: again, now with error checking ...
      glew      : 15.8 us
      glbinding : 15.6 us

glbinding/glew decrease:                -2.75862%

glbinding/glew decrease (error checks): -1.26582%

finalizing ...
Windows 8.1, AMD Radeon™ HD 8570M

Intel(R) Core(TM) i5-3337U CPU @ 1.8GHz, 6GB RAM, compare.exe (release, x64):

test: initialize bindings ...
      glbinding : 1001.8 us
      glew      : 7005.2 us

OpenGL Version:  4.4
OpenGL Vendor:   ATI Technologies Inc.
OpenGL Renderer: AMD Radeon (TM) HD 8500M/8700M

prep: warm-up ...
      glew
      glbinding

test: average call times for 8192 x 24 calls ...
      glew      : 159.1 us
      glbinding : 159.6 us

test: again, now with error checking ...
      glew      : 159.9 us
      glbinding : 161.3 us

glbinding/glew decrease:                0.314268%

glbinding/glew decrease (error checks): 0.875547%

finalizing ...
Windows 8.1, Intel HD Graphics 4000

Intel(R) Core(TM) i5-3337U CPU @ 1.8GHz, 6GB RAM, compare.exe (release, x64):

test: initialize bindings ...
      glbinding : 1003 us
      glew      : 3002 us

OpenGL Version:  4.0
OpenGL Vendor:   Intel
OpenGL Renderer: Intel(R) HD Graphics 4000

prep: warm-up ...
      glew
      glbinding

test: average call times for 8192 x 24 calls ...
      glew      : 55.8 us
      glbinding : 55.2 us

test: again, now with error checking ...
      glew      : 57.7 us
      glbinding : 58.3 us

glbinding/glew decrease:                -1.07527%

glbinding/glew decrease (error checks):  1.03986%

finalizing ...
Ubuntu 14.4, NVIDIA Quadro 4000

Intel(R) Xeon(R) CPU W3530 @ 2.8GHz, 6GB RAM, compare.exe (release, x64):

test: initialize bindings ...
      glbinding : 2360.39 us
      glew      : 4986.19 us

OpenGL Version:  4.4
OpenGL Vendor:   NVIDIA Corporation
OpenGL Renderer: Quadro 4000/PCIe/SSE2

prep: warm-up ...
      glew      
      glbinding 

test: average call times for 8192 x 24 calls ...
      glew      : 8.661 us
      glbinding : 8.724 us

test: again, now with error checking ...
      glew      : 8.658 us
      glbinding : 8.886 us

glbinding/glew decrease:                0.727399%

glbinding/glew decrease (error checks): 2.6334%

finalizing ...

callbacks

callbacks uses After and ParametersAndReturnValue callbacks for logging every function call while drawing the compare scene. The output is:

OpenGL Version:  4.0
OpenGL Vendor:   Intel
OpenGL Renderer: Intel(R) HD Graphics 4000
OpenGL Revision: 27590 (gl.xml)

glViewport(0, 0, 320, 240)
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT)
glGenVertexArrays(1, 0000000140013B0C)
glGenBuffers(1, 0000000140013B08)
glCreateProgram() -> 1
glCreateShader(GL_VERTEX_SHADER) -> 2
glShaderSource(2, 1, 0000000140013020, 0000000000000000)
glCompileShader(2)
glCreateShader(GL_FRAGMENT_SHADER) -> 3
glShaderSource(3, 1, 0000000140013028, 0000000000000000)
glCompileShader(3)
glAttachShader(1, 2)
glAttachShader(1, 3)
glLinkProgram(1)
glBindBuffer(GL_ARRAY_BUFFER, 1)
glBufferData(GL_ARRAY_BUFFER, 32, 000000014000D478, GL_STATIC_DRAW)
glBindVertexArray(1)
glGetAttribLocation(1, "a_vertex") -> 0
glEnableVertexAttribArray(0)
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0000000000000000)
glUseProgram(1)
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)
glDeleteProgram(1)
glDeleteBuffers(1, 0000000140013B08)
glDeleteVertexArrays(1, 0000000140013B0C)

functions

This example lists all extensions along with their associated functions. For every function and extension the support status is shown, and the supported version are summarized (similar to the OpenGL Extensions Viewer). Shortened example output:

[-.- EXTENSIONS]

GL_3DFX_multisample

GL_3DFX_tbuffer
	(0x0000000000000000) glTbufferMask3DFX

...

GL_ARB_map_buffer_range (supported)
	(0x000000005FBA5010) glMapBufferRange
	(0x000000005FB93E10) glFlushMappedBufferRange

...

[4.3 EXTENSIONS]

GL_ARB_ES3_compatibility (supported)

GL_ARB_arrays_of_arrays (supported)

GL_ARB_clear_buffer_object (supported)
	(0x000000005FB869D0) glClearBufferData
	(0x000000005FB86A50) glClearBufferSubData

...

[EXTENSIONS NOT COVERED BY GLBINDING]

GL_EXTX_framebuffer_mixed_formats
GL_EXT_Cg_shader
GL_EXT_import_sync_object
GL_EXT_texture_compression_dxt1
GL_EXT_texture_edge_clamp
GL_EXT_texture_lod
GL_EXT_texture_storage
GL_EXT_transform_feedback2
GL_KTX_buffer_region
GL_NVX_nvenc_interop
GL_NV_ES1_1_compatibility
GL_NV_gpu_program4_1
GL_NV_gpu_program_fp64
GL_WIN_swap_hint
WGL_EXT_swap_control


[NON-EXTENSION OR NOT-COVERED-EXTENSION FUNCTIONS]

	(0x00007FFF57922BF0) glStencilMask
	(0x000000005FBCB050) glVertexAttrib1f
	(0x00007FFF57922C50) glDepthMask
	(0x000000005FBCF450) glVertexAttribI4sv
	...

[SUMMARY]

# Functions:     2128 of 2773 resolved (645 unresolved)
                 2139 assigned to extensions.

# Extensions:    312 of 520 supported (17 of which are unknown to glbinding)
  # -.- assoc.:  177 / 384
  # 3.0 assoc.:  22 / 22
  # 3.1 assoc.:  6 / 6
  # 3.2 assoc.:  10 / 10
  # 3.3 assoc.:  9 / 9
  # 4.0 assoc.:  13 / 13
  # 4.1 assoc.:  6 / 6
  # 4.2 assoc.:  12 / 12
  # 4.3 assoc.:  22 / 22
  # 4.4 assoc.:  8 / 8
  # 4.5 assoc.:  10 / 11

OpenGL Version:  4.5
OpenGL Vendor:   NVIDIA Corporation
OpenGL Renderer: GeForce GTX 680/PCIe/SSE2
OpenGL Revision: 27693 (gl.xml)

meta

meta gathers list of string for versions, enums, and extensions and converts them to their associated OpenGL symbols:

[VERSIONS]

# Versions: 17

1.0
1.1

...

[ENUMS]

# Enums: 3352

 (0x00040b) GL_AUX2
 (0x008cda) GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT
 
...

[EXTENSIONS]

 # Extensions: 486

 GL_3DFX_multisample 
 GL_3DFX_tbuffer 
 
...

OpenGL Revision: 27590 (gl.xml)
Clone this wiki locally