Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/schwalbe-t/obem

A Gera library for 3D browser games.
https://github.com/schwalbe-t/obem

3d-audio 3d-games 3d-graphics game-dev game-development game-framework game-library games

Last synced: 3 days ago
JSON representation

A Gera library for 3D browser games.

Awesome Lists containing this project

README

        

# Obem
*A Gera library for 3D browser games.*

This library aims provides simple and easy-to-use bindings for WebGL and the Web Audio API for games written in [the Gera programming language](https://github.com/geralang).

### Example

Below is a simple triangle example, and what it looks like when viewed in a web browser:

```
mod example

use obem::gfx::(Mesh, Shader, Surface)

proc main() {
obem::on_init(start)
}

proc start() {
var triangle = Mesh::new([
-0.5, -0.5, 0.0, 1.0, 0.2, 0.2,
0.0, 0.5, 0.0, 0.2, 1.0, 0.2,
0.5, -0.5, 0.0, 0.2, 0.2, 1.0
], [0, 1, 2])
var shader = Shader::new("
attribute vec3 coords;
attribute vec3 color;
varying vec3 fcolor;

void main(void) {
gl_Position = vec4(coords, 1.0);
fcolor = color;
}
", "
precision highp float;
varying vec3 fcolor;

void main(void) {
gl_FragColor = vec4(fcolor, 1.0);
}
")
obem::on_frame(|| {
Surface::main()
.> clear_color(1.0, 1.0, 1.0, 1.0)
.> draw_mesh(triangle, [3, 3], shader, false)
})
}
```
```html



Obem Example



```
![Output Screenshot](triangle.png)