Skip to content

Commit 3dc5e10

Browse files
author
HUGE | Raed Atoui
committed
readme
1 parent 6cf2f4b commit 3dc5e10

File tree

1 file changed

+81
-4
lines changed

1 file changed

+81
-4
lines changed

README.md

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,87 @@
1-
### OpenGL Tutorial in GO
2-
* Based on https://learnopengl.com/
3-
* uses https://github.com/go-gl
1+
### OpenGL Tutorial in Go
2+
* Based on the excellent [tutorial](https://learnopengl.com/) by Joey de Vries
3+
* uses [go-gl](https://github.com/go-gl) for all OpenGL Go bindings
4+
5+
### Installation
6+
7+
This is setup has only been tested on macOS.
8+
I am currently working with the 4.1 core profile on macOS. This is the latest version that [ships](https://support.apple.com/en-us/HT202823) with macOS and I didn't want to delve upgrading that manually. You need
9+
10+
I figured I would get linux machine at a later if I need to use newer features in the API.
11+
The nice about go-gl is that you can install multiple profiles and write different programs targeting different version of OpenGL.
12+
13+
#### go-gl packages
14+
15+
1- **[gl](https://github.com/go-gl/gl)** - OpenGL core profile v4.1
16+
`go get -u github.com/go-gl/v4.1-core/gl`
17+
18+
2- [**Glow**](https://github.com/go-gl/glow) - Go binding generator for OpenGL
19+
20+
```bash
21+
go get github.com/go-gl/glow
22+
cd $GOPATH/src/github.com/go-gl/glow
23+
go build
24+
./glow download
25+
./glow generate -api=gl -version=4.1 -profile=core -remext=GL_ARB_cl_event
26+
go install ./gl-core/3.3/gl
27+
```
28+
29+
3- [**GLFW 3.2**](https://github.com/go-gl/glfw) - Go bindings for GLFW 3
30+
`go get -u github.com/go-gl/glfw/v3.2/glfw`
31+
32+
4- [**MathGL**](https://github.com/go-gl/mathgl) - A pure Go 3D math library
33+
`go get github.com/go-gl/mathgl`
34+
35+
To test that the installation is working, try the examples from go-gl.
36+
37+
`go get github.com/go-gl/examples`
38+
39+
Run the `gl41core-cube` example by executing `go run cube.go`
40+
41+
### learnopengl.com tutorial
42+
43+
1- [**glutils**](https://github.com/raedatoui/glutils)
44+
45+
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](https://github.com/raedatoui/glutils) in the hope of being useful for other projects.
46+
47+
`go get github.com/raedatoui/glutils`
48+
49+
I had to fork 2 libraries and update them to get everything working.
50+
51+
2- [**glfont**](https://github.com/raedatoui/glfont) - A modern opengl text rendering library for golang
52+
53+
`go get github.com/raedatoui/glfont`
54+
55+
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`
56+
57+
Text rendering sucks and is not intended to look good, but good enough and easy to use for the sake of this tutorial.
58+
59+
3- [**assimp**](https://github.com/raedatoui/assimp) - Go wrapper of [Assimp](http://www.assimp.org/)
60+
61+
First, install Assimp on macOS using homebrew `brew install assimp`
62+
63+
`go get github.com/raedatoui/assimp`
64+
65+
I fixed some minor bugs and changed the cgo directives for linking assimp. Intead of using `LDFLAGS` and other windows specific flags, I used the `pkg-config` flag.
66+
67+
### Run
68+
69+
`go run tutorial.go` and you should see this screen
70+
71+
Use the left and arrows to go navigate through the tutorials.
72+
73+
Use the num keys to jump between sections.
74+
75+
![](/Users/ratoui/Desktop/Screen Shot 2017-02-11 at 12.21.47 AM.png)
76+
77+
478

579
### Notes
80+
81+
When configuring vertex attribute arrays, the stride is calculated using the size of
82+
a float32 type.
683
* sizeof(GLfloat) is 4 , float32
784
* size of uint32 - 4
885

9-
no need to disable 3d depth when drawing 2D shapes
86+
1087

0 commit comments

Comments
 (0)