https://github.com/galaco/gosigl
Slightly opinionated Go module wrapper to simplify basic OpenGL usage
https://github.com/galaco/gosigl
golang opengl texture2d wrapper
Last synced: 12 months ago
JSON representation
Slightly opinionated Go module wrapper to simplify basic OpenGL usage
- Host: GitHub
- URL: https://github.com/galaco/gosigl
- Owner: Galaco
- License: unlicense
- Created: 2018-12-28T17:32:26.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-05-21T12:19:25.000Z (about 2 years ago)
- Last Synced: 2024-06-21T03:33:44.977Z (about 2 years ago)
- Topics: golang, opengl, texture2d, wrapper
- Language: Go
- Size: 20.5 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Gosigl
Gosigl (Go SImple openGL) is an somewhat opinionated Go wrapper for OpenGL with emphasis on simple. It's purpose is to make creating simple OpenGL programs really goddamn
easy. It doesn't provide a whole lot of functionality, but it's really quick and simple to get a basic renderable
world up and running.
It provides simplified functions for creating textures, VAO and VBOs, and shader objects.
#### Texture
Provides functions for creating and binding Texture2D and Cube_Map_Textures.
Creating and binding a Texture2D can be done as follows:
```go
buf := gosigl.CreateTexture2D(
gosigl.TextureSlot(0), // Assign texture slot
width, // texture width
height, // texture height
pixelData, // []byte raw colour data
gosigl.RGB, // colour data format
false) // true = clamp to edge, false = repeat
gosigl.BindTexture2D(gosigl.TextureSlot(0), buf)
```
Cubemaps are very similar:
```go
buf := gosigl.CreateTextureCubemap(
gosigl.TextureSlot(0), // Assign texture slot
width, // texture width
height, // texture height
pixelData, // [6][]byte raw colour data
gosigl.RGB, // colour data format
true)
gosigl.BindTextureCubemap(gosigl.TextureSlot(0), buf)
```
#### Mesh
Simple methods are available for VBO and VAO generation, as follows:
```go
mesh := gosigl.NewMesh(vertices) // vertices = []float32
gosigl.CreateVertexAttribute(mesh, uvs, 2) // uvs = []float32, 2 = numPerVertex
gosigl.CreateVertexAttribute(mesh, normals, 3)
gosigl.FinishMesh()
```
To draw:
```go
gosigl.BindMesh(mesh) // bind vbo
gosigl.DrawArray(offset, length) // draw from bound
```
To delete:
```go
gosigl.DeleteMesh(mesh)
```
#### Shader
@Incomplete