Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/zacharycarter/zengine

2D | 3D Game development library
https://github.com/zacharycarter/zengine

2d 3d game-development game-engine nim

Last synced: 2 months ago
JSON representation

2D | 3D Game development library

Lists

README

        

# zengine
2D | 3D Game development library

NOTE - Please run examples from root directory for now

Progress -

![3D Skeletal Animation](https://media.giphy.com/media/l1J3tQly5PfRKtMUo/giphy.gif)
![Lit Model](http://i.imgur.com/YIQutvx.png)
![Model Loading](http://i.imgur.com/fKbrXPi.png)
![FPS Camera](https://media.giphy.com/media/xUA7aSrJzGLbB0x5hS/giphy.gif)
![2D & 3D Primitive Rendering](http://i.imgur.com/m5gWahM.png)

Dependencies:
[Assimp](https://github.com/assimp/assimp)

```nim
import zengine, sdl2, opengl

type
LightKind = enum
Point, Directional, Spot

Light = ref object
id: int
enabled: bool
kind: LightKind
position: Vector3
target: Vector3
radius: float
diffuse: ZColor
intensity: float
coneAngle: float

const
WIDTH = 960
HEIGHT = 540
MAX_LIGHTS = 8

var lights: array[MAX_LIGHTS, Light]
var lightsCount = 0
var lightsLocs: array[MAX_LIGHTS, array[8, int]]

proc createLight(kind: LightKind, position: Vector3, diffuse: ZColor): Light =
result = nil

if lightsCount < MAX_LIGHTS:
result = Light(
id: lightsCount,
kind: kind,
enabled: true,
position: position,
target: vectorZero(),
intensity: 1.0,
diffuse: diffuse
)

lights[lightsCount] = result

inc(lightsCount)
else:
result = lights[lightsCount]

proc setShaderLightsValues(shader: Shader) =
var tempInt: array[8, GLint]
var tempFloat: array[8, GLfloat]

for i in 0..