engine

module
v0.0.0-...-f342b60 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2018 License: BSD-2-Clause

README

G3N Banner

Godoc Go Report Card

G3N - Go 3D Game Engine

G3N (pronounced "gen") is a cross-platform OpenGL 3D game engine written in Go.

To see G3N in action try the G3N demo or the Gokoban award winning game.

G3ND In Action

Highlighted Projects

Gokoban - 3D Puzzle Game (1st place in the 2017 Gopher Game Jam)

Dependencies

G3N requires Go 1.8+

The engine requires an OpenGL driver and a GCC-compatible C compiler to be installed.

On Unix-based systems the engine depends on some C libraries that can be installed using the appropriate distribution package manager.

  • For Ubuntu/Debian-like Linux distributions, install the following packages:
    • xorg-dev
    • libgl1-mesa-dev
    • libopenal1
    • libopenal-dev
    • libvorbis0a
    • libvorbis-dev
    • libvorbisfile3
  • For CentOS/Fedora-like Linux distributions, install the following packages:
    • xorg-x11-devel.x86_64
    • mesa-libGL.x86_64
    • mesa-libGL-devel.x86_64
    • openal-soft.x86_64
    • openal-soft-devel.x86_64
    • libvorbis.x86_64
    • libvorbis-devel.x86_64
  • For 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.
  • For macOS, you should install the development files of OpenAL and Vorbis. If you are using Homebrew as your package manager, run: brew install libvorbis openal-soft

Installation

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

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

Features

  • Cross-platform: Windows, Linux, and macOS
  • Integrated GUI (graphical user interface) with many widgets
  • Hierarchical scene graph - nodes can contain other nodes
  • 3D spatial audio via OpenAL (.wav, .ogg)
  • Real-time lighting: ambient, directional, point, and spot lights
  • Physically-based rendering: fresnel reflectance, geometric occlusion, microfacet distribution
  • Model loaders: glTF (.gltf, .glb), Wavefront OBJ (.obj), and COLLADA (.dae)
  • Geometry generators: box, sphere, cylinder, torus, etc...
  • Geometries support morph targets and multimaterials
  • Support for animated sprites based on sprite sheets
  • Perspective and ortographic cameras
  • Text image generation and support for TrueType fonts
  • Image textures can be loaded from GIF, PNG or JPEG files
  • Animation framework for position, rotation, and scale of objects
  • Support for user-created GLSL shaders: vertex, fragment, and geometry shaders
  • Integrated basic physics engine (experimental/incomplete)
  • Support for HiDPI displays

G3N Banner

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

For the engine API reference, please see GoDoc.

Currently, the best way to learn how to use G3N is to look at the source code of the demos from G3ND. In the future we would like to have a "Getting Started" guide along with tutorials in the wiki.

Contributing

If you find a bug or create a new feature you are encouraged to send pull requests!

Community

Join our channel on Gophers Slack (Click here to register for Gophers Slack). It's a great way to have your questions answered quickly by the G3N community.

Directories

Path Synopsis
Package animation
Package animation
Package audio contains sub packages for binding to external audio libraries and implements a spatial audio player.
Package audio contains sub packages for binding to external audio libraries and implements a spatial audio player.
al
Package al implements the Go bindings of a subset of the functions of the OpenAL C library.
Package al implements the Go bindings of a subset of the functions of the OpenAL C library.
ov
Package ov implements the Go bindings of a subset of the functions of the Ogg Vorbis File C library.
Package ov implements the Go bindings of a subset of the functions of the Ogg Vorbis File C library.
vorbis
Package vorbis implements the Go bindings of a subset (only one function) of the functions of the libvorbis library See API reference at: https://xiph.org/vorbis/doc/libvorbis/reference.html
Package vorbis implements the Go bindings of a subset (only one function) of the functions of the libvorbis library See API reference at: https://xiph.org/vorbis/doc/libvorbis/reference.html
Package camera contains common camera types used for rendering 3D scenes.
Package camera contains common camera types used for rendering 3D scenes.
control
Package control implements controllers for cameras
Package control implements controllers for cameras
Package core implements some basic types used by other packages.
Package core implements some basic types used by other packages.
experimental
collision
Package collision implements collision related algorithms and data structures.
Package collision implements collision related algorithms and data structures.
physics
Package collision implements collision related algorithms and data structures.
Package collision implements collision related algorithms and data structures.
physics/constraint
Package constraint implements physics constraints.
Package constraint implements physics constraints.
physics/equation
Package equation implements SPOOK equations based on the 2007 PhD thesis of Claude Lacoursière titled "Ghosts and Machines: Regularized Variational Methods for Interactive Simulations of Multibodies with Dry Frictional Contacts"
Package equation implements SPOOK equations based on the 2007 PhD thesis of Claude Lacoursière titled "Ghosts and Machines: Regularized Variational Methods for Interactive Simulations of Multibodies with Dry Frictional Contacts"
physics/solver
Package physics implements a basic physics engine.
Package physics implements a basic physics engine.
Package geometry implements several primitive geometry generators.
Package geometry implements several primitive geometry generators.
gls
Package gls implements a loader of OpenGL functions for the platform and a Go binding for selected OpenGL functions.
Package gls implements a loader of OpenGL functions for the platform and a Go binding for selected OpenGL functions.
Package graphic implements scene objects which have a graphic representation.
Package graphic implements scene objects which have a graphic representation.
gui
Package gui implements the GUI infraestructure and several widgets.
Package gui implements the GUI infraestructure and several widgets.
assets
Code generated by go-bindata.
Code generated by go-bindata.
Package light contains common light types which can be add to a 3D scene to illuminate it.
Package light contains common light types which can be add to a 3D scene to illuminate it.
loader
collada
Package collada
Package collada
gltf
Package gltf
Package gltf
obj
Package obj
Package obj
Package material contains several types of materials which can be used to set the appearance of graphic object
Package material contains several types of materials which can be used to set the appearance of graphic object
Package math32 implements basic math functions which operate directly on float32 numbers without casting and contains types of common entities used in 3D Graphics such as vectors, matrices, quaternions and others.
Package math32 implements basic math functions which operate directly on float32 numbers without casting and contains types of common entities used in 3D Graphics such as vectors, matrices, quaternions and others.
Package renderer implements the scene renderer.
Package renderer implements the scene renderer.
shaders
Package shaders contains the several shaders used by the engine
Package shaders contains the several shaders used by the engine
Package text implements text font support.
Package text implements text font support.
Package texture contains several types of textures which can be added to materials.
Package texture contains several types of textures which can be added to materials.
tools
g3nshaders
g3nshaders reads shaders files with ".glsl" extensions and generates a Go file containing strings with the content of these files.
g3nshaders reads shaders files with ".glsl" extensions and generates a Go file containing strings with the content of these files.
util
logger
Package logger implements an hierarchical logger used by other packages.
Package logger implements an hierarchical logger used by other packages.
Package window abstracts the OpenGL Window manager Currently only "glfw" is supported
Package window abstracts the OpenGL Window manager Currently only "glfw" is supported

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL