Copy a texture to screen

For our sparse voxel octree renderer we’re going to bypass almost the entire GPU rendering pipeline and use a compute shader instead. ‘Almost’, because the pipeline is the only method to render onto the screen. In this post I’ll describe how to create a texture and copy that texture onto the screen. I also wanted to show how to use bindless textures, but unfortunately my GPU doesn’t support those. Continue reading

Creating an OpenGL 4.5 context using SDL2 and Glad

In this post I’ll describe how to set up an OpenGL 4.5 context. In my previous post, I decided that I’m going to use GLM, SDL2 and Glad for that. Glad is a loader generator, so head over there and choose API: gl version 4.5, Profile: core, Extensions: GL_ARB_bindless_texture, GL_ARB_sparse_buffer, GL_ARB_sparse_texture, Options: uncheck ‘generate a loader’. Click generate; download the zip-file and unpack glad.h and glad.c into a folder named glad in your source directory. The package also contains a file khrplatform.h, which you don’t need if you remove the line #include <KHR/khrplatform.h> from glad.h. Furthermore, because you put glad.c and glad.h in the same folder, you should change glad.c to replace #include <glad/glad.h> with #include "glad.h".

Yes, I said I wanted to avoid extensions, however, those three are part of AZDO (approaching zero driver overhead) OpenGL, so I want to be able to explain their use as well. I also plan on using the sparse buffers in my voxel-engine.

Continue reading

Starting with OpenGL 4.5

When I started 3D programming, OpenGL 2 did not yet exist. I grew up using glBegin and glEnd, but quickly learned that you needed to use vertex arrays to get any decent performance. Since OpenGL 3.3 core profile, both are gone and you need to use buffer objects to send a list of vertices to your GPU. However, the biggest change is that the fixed pipeline is gone, which means that you’re forced to use shaders.

During my master in computer science and engineering, I did get some experience in using shaders and their programming language GLSL. However, I used Qt4 which provided a very nice class for dealing with shader programs. So, I have no experience with compiling shader programs and binding data using the OpenGL API. Furthermore, the GLSL language itself has also changed quite a lot. Basically, I have to learn OpenGL from scratch again.

There are also big differences between minor OpenGL 4 versions. While no functionality is removed, the added functionality is sometimes a huge improvement over the functionality it seeks to replace, for example: the debug output added in 4.3. I will be using OpenGL 4.5, for the sole reason that my GPU claims to support it.
Continue reading