Skip to content
Daniel Salvadori edited this page May 26, 2022 · 38 revisions

Introduction

G3N Banner

G3N (pronounced "gen") is an OpenGL 3D Game Engine written in Go. It can be used to write cross-platform Go applications that show rich and dynamic 3D representations - not just games. A basic integrated GUI framework is provided, and 3D spatial audio is supported through OpenAL. You can evaluate most of the features by installing and executing G3ND - the G3N demo.

Dependencies

Go 1.8+ is required. The engine also requires the system to have an OpenGL driver and a GCC-compatible C compiler.

On Unix-based systems the engine depends on some C libraries that can be installed using the appropriate distribution package manager. See below for OS specific requirements.

Ubuntu/Debian-like

$ sudo apt-get install xorg-dev libgl1-mesa-dev libopenal1 libopenal-dev libvorbis0a libvorbis-dev libvorbisfile3

Fedora

$ sudo dnf -y install xorg-x11-proto-devel mesa-libGL mesa-libGL-devel openal-soft openal-soft-devel libvorbis libvorbis-devel glfw-devel libXi-devel

CentOS 7

Enable the EPEL repository:

$ sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

Then install the same packages as for Fedora - remember to use yum instead of dnf for the package installation command.

Windows

The necessary audio libraries sources and DLLs are supplied but they need to be installed manually. Please see Audio libraries for Windows for details. We tested the Windows build using the mingw-w64 toolchain (you can download this file in particular).

macOS

Install the development files of OpenAL and Vorbis using Homebrew:

brew install libvorbis openal-soft

Installation

The following command will download and install the engine along with all its Go dependencies:

go get -u github.com/g3n/engine/...

Hello G3N

The code below is a basic "hello world" application (hellog3n) that shows a blue torus. You can download and install hellog3n via:

go get -u github.com/g3n/demos/hellog3n

For more complex demos please see the G3N demo program.

package main

import (
    "github.com/g3n/engine/util/application"
    "github.com/g3n/engine/geometry"
    "github.com/g3n/engine/material"
    "github.com/g3n/engine/math32"
    "github.com/g3n/engine/graphic"
    "github.com/g3n/engine/light"
)

func main() {

    app, _ := application.Create(application.Options{
        Title:  "Hello G3N",
        Width:  800,
        Height: 600,
    })

    // Create a blue torus and add it to the scene
    geom := geometry.NewTorus(1, .4, 12, 32, math32.Pi*2)
    mat := material.NewPhong(math32.NewColor("DarkBlue"))
    torusMesh := graphic.NewMesh(geom, mat)
    app.Scene().Add(torusMesh)

    // Add lights to the scene
    ambientLight := light.NewAmbient(&math32.Color{1.0, 1.0, 1.0}, 0.8)
    app.Scene().Add(ambientLight)
    pointLight := light.NewPoint(&math32.Color{1, 1, 1}, 5.0)
    pointLight.SetPosition(1, 0, 2)
    app.Scene().Add(pointLight)

    // Add an axis helper to the scene
    axis := graphic.NewAxisHelper(0.5)
    app.Scene().Add(axis)

    app.CameraPersp().SetPosition(0, 0, 3)
    app.Run()
}

hellog3n Screenshot

Documentation

The complete engine API reference can be found here: GoDoc.

There is also the beginning of a Getting Started Guide, and a newly created list of Guides and Tutorials:

Along with those, a good way to learn how to use the engine is to see the source code of G3ND - the G3N demo.

We intend in the future to write/update/complete the following topics to build a user guide: