Giter VIP home page Giter VIP logo

learn-opengl-golang's Introduction

OpenGL Tutorial in Go

  • Based on the excellent tutorial by Joey de Vries
  • uses go-gl for all OpenGL Go bindings

Installation

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.

go-gl packages

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

learnopengl.com tutorial

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.

Run

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.

Alt text

Notes

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

learn-opengl-golang's People

Contributors

bramp avatar raedatoui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

learn-opengl-golang's Issues

Get material color form .mtl

Hi, I've tried different methods to get material colors defined in mtl such as ka, kd and ks via your assimp pkg but all failed.
I checked the c pkg of assimp and found the Get() method of aiMaterial is defined for that, would you please tell me which methods shall I use in your pkg? And if you can give me some examples for that. Thank you! @raedatoui

Windows OS Setup

Hi,

I'm trying to run the project on a Windows 10 Pro OS. I have already pulled everything and installed pkg-config and assimp(through the Windows installer). However, whenever I run the project I get the errors below.

capture

I am able to run the examples on https://github.com/go-gl/example without any issue.

I know this project was only tested on an OS X but is there a chance you can point me to the right direction to get it running on Windows?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.