diff options
author | natrixaeria <janng@gmx.de> | 2019-06-14 00:13:15 +0200 |
---|---|---|
committer | natrixaeria <janng@gmx.de> | 2019-06-14 00:13:15 +0200 |
commit | b75597c140e9b4758a1ad803044dda96b403e1a5 (patch) | |
tree | d61eb5116cd45cd411b5e079d09fd07540c09042 /webhogg/wasm/src/context/webgl.rs | |
parent | 03cedca74429c326fcca176576702873e32a8455 (diff) |
Wrap WebGl2
Diffstat (limited to 'webhogg/wasm/src/context/webgl.rs')
-rw-r--r-- | webhogg/wasm/src/context/webgl.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/webhogg/wasm/src/context/webgl.rs b/webhogg/wasm/src/context/webgl.rs new file mode 100644 index 0000000..abecc6e --- /dev/null +++ b/webhogg/wasm/src/context/webgl.rs @@ -0,0 +1,26 @@ +use web_sys::WebGl2RenderingContext as GlContext; + +pub struct Color4(f32, f32, f32, f32); + +impl Color4 { + pub fn new(r: f32, g: f32, b: f32, a: f32) -> Color4 { + Color4(r, g, b, a) + } +} + +pub struct WebGl2 { + gl: GlContext, +} + +impl WebGl2 { + pub fn from_context(context: GlContext) -> Self { + WebGl2 { + gl: context, + } + } + + pub fn clear(&self, color: Color4) { + self.gl.clear_color(color.0, color.1, color.2, color.3); + self.gl.clear(GlContext::COLOR_BUFFER_BIT); + } +} |