Skip to content
Tobias1595 edited this page Sep 6, 2018 · 47 revisions

Note: this requires OPTION_BUILD_EXAMPLES=On.

Brief overview of the following glbinding examples:

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)

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 source image

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 ...

Please Note: even when there are differences keep in mind that this example measures the pure CPU time of a function call which, most of the time, is the time required to insert the OpenGL command into the queue. The actual execution time of OpenGL commands is usually driver and GPU bound.

cubescape

cubescape uses a height map 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
cubescape-16 source image cubescape-8 source image
64² cubes 2048² cubes
cubescape-64 source image cubescape-2048 source image

cubescape-qt

cubescape-qt creates a QMainWindow that embeds a QWindow with a 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 source image