This is setup has only been tested on macOS. I am currently working with the 4.1 core profile on macOS, which is the latest version that ships with it. I didn't want to delve into upgrading that manually.
I figured I would get linux machine at a later time if I needed to use newer features in the API. The nice thing about go-gl is that you can install multiple profiles and write different programs targeting different version of OpenGL.
1- gl - OpenGL core profile v4.1
go get -u github.com/go-gl/gl/v4.1-core/gl
2- Glow - Go binding generator for OpenGL
go get github.com/go-gl/glow
cd $GOPATH/src/github.com/go-gl/glow
go build
./glow download
./glow generate -api=gl -version=4.1 -profile=core -remext=GL_ARB_cl_event
# the profile is now installed in a gl directory
go install ./gl
3- GLFW 3.2 - Go bindings for GLFW 3
go get -u github.com/go-gl/glfw/v3.2/glfw
4- MathGL - A pure Go 3D math library
go get github.com/go-gl/mathgl/...
This package is the equivalent of the GLM library and probably has all the functionality but after some differences. I didnt dive too deep into it, but I am getting different matrices when running the same sample in C++ with glm vs Go with mgl32.
To test that the installation is working, try the examples from go-gl.
go get github.com/go-gl/example
cd $GOPATH/src/github.com/go-gl/example
go run gl41core-cube/cube.go
1- assimp - Go wrapper of Assimp
First, install Assimp on macOS using homebrew brew install assimp
Then install wrapper, go get github.com/raedatoui/assimp
2- glutils
Some of the utllities developed throughout the tutorials like shader compilation and linking, camera, loading textures, loading models from assimp, other redundant GL commands,etc were packaged together. Initially, these lived within the tutorial repo as the utils
package and we later moved to a dedicated repo in the hope of being useful for other projects.
go get github.com/raedatoui/glutils
3- glfont - A modern opengl text rendering library for golang
go get github.com/raedatoui/glfont
I made minor changes to this package where I use the shader functions from the glutils
package and I explicitly set the profile version in the imports to 4.1
intead of all-core
Text rendering sucks and is not intended to look good, but good enough and easy to use for the sake of this tutorial.
go get github.com/raedatoui/learn-opengl-golang
cd $GOPATH/src/github.com/raedatoui/learn-opengl-golang
go run tutorial.go
and you should see this screen
Use the right and left arrow keys to navigate through the tutorials.
Use the num keys to jump between sections.
When configuring vertex attribute arrays, the stride is calculated using the size of a float32 type.
- sizeof(GLfloat) is 4 , float32
- size of uint32 - 4