summaryrefslogtreecommitdiff
path: root/webhogg/wasm/src/context/webgl.rs
diff options
context:
space:
mode:
Diffstat (limited to 'webhogg/wasm/src/context/webgl.rs')
-rw-r--r--webhogg/wasm/src/context/webgl.rs26
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);
+ }
+}