1#![recursion_limit = "512"]
2
3#[cfg(not(target_arch = "wasm32"))]
4extern crate gl;
5
6#[cfg(target_arch = "wasm32")]
7#[path = "webgl.rs"]
8pub mod webgl;
9
10#[cfg(not(target_arch = "wasm32"))]
11#[path = "webgl_native.rs"]
12mod webgl;
13
14#[cfg(not(target_arch = "wasm32"))]
15pub const IS_GL_ES: bool = false;
17
18#[cfg(target_arch = "wasm32")]
19pub const IS_GL_ES: bool = true;
20
21mod glenum;
22
23pub use glenum::*;
24pub use webgl::{GLContext, WebGLContext};
25
26pub mod common {
27 use std::ops::{Deref, DerefMut};
28
29 type Reference = super::webgl::Reference;
30 type GLContext = super::GLContext;
31
32 #[derive(Debug, Clone)]
33 pub struct WebGLRenderingContext {
35 pub common: GLContext,
36 }
37
38 impl Deref for WebGLRenderingContext {
39 type Target = GLContext;
40 fn deref(&self) -> &GLContext {
41 &self.common
42 }
43 }
44
45 impl DerefMut for WebGLRenderingContext {
46 fn deref_mut(&mut self) -> &mut GLContext {
47 &mut self.common
48 }
49 }
50
51 #[derive(Debug)]
52 pub struct WebGLBuffer(pub Reference);
57
58 impl Deref for WebGLBuffer {
59 type Target = Reference;
60 fn deref(&self) -> &Self::Target {
61 &self.0
62 }
63 }
64
65 #[derive(Debug)]
66 pub struct WebGLShader(pub Reference);
68 impl Deref for WebGLShader {
69 type Target = Reference;
70 fn deref(&self) -> &Self::Target {
71 &self.0
72 }
73 }
74
75 #[derive(Debug, PartialEq)]
76 pub struct WebGLProgram(pub Reference);
80 impl Deref for WebGLProgram {
81 type Target = Reference;
82 fn deref(&self) -> &Self::Target {
83 &self.0
84 }
85 }
86
87 #[derive(Debug, PartialEq)]
88 pub struct WebGLTexture(pub Reference);
92 impl Deref for WebGLTexture {
93 type Target = Reference;
94 fn deref(&self) -> &Self::Target {
95 &self.0
96 }
97 }
98
99 #[derive(Debug)]
100 pub struct WebGLVertexArray(pub Reference);
104 impl Deref for WebGLVertexArray {
105 type Target = Reference;
106 fn deref(&self) -> &Self::Target {
107 &self.0
108 }
109 }
110
111 #[derive(Debug, PartialEq)]
112 pub struct WebGLUniformLocation {
114 pub reference: Reference,
115 pub name: String,
116 }
117 impl Deref for WebGLUniformLocation {
118 type Target = Reference;
119 fn deref(&self) -> &Reference {
120 &self.reference
121 }
122 }
123
124 #[derive(Debug)]
125 pub struct WebGLFrameBuffer(pub Reference);
129 impl Deref for WebGLFrameBuffer {
130 type Target = Reference;
131 fn deref(&self) -> &Self::Target {
132 &self.0
133 }
134 }
135
136 pub fn print(s: &str) {
138 GLContext::print(s);
139 }
140}
141
142pub use self::common::*;