Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It implements enough WebGL spec to draw a triangle
- Loading branch information
Showing
17 changed files
with
741 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl | ||
use dom::bindings::codegen::Bindings::WebGLBufferBinding; | ||
use dom::bindings::global::GlobalRef; | ||
use dom::bindings::js::{Temporary, JSRef}; | ||
use dom::bindings::utils::{Reflector, reflect_dom_object}; | ||
|
||
#[dom_struct] | ||
pub struct WebGLBuffer { | ||
reflector_: Reflector, | ||
id: u32, | ||
} | ||
|
||
impl WebGLBuffer { | ||
fn new_inherited(id: u32) -> WebGLBuffer { | ||
WebGLBuffer { | ||
reflector_: Reflector::new(), | ||
id: id, | ||
} | ||
} | ||
|
||
pub fn new(global: GlobalRef, id: u32) -> Temporary<WebGLBuffer> { | ||
reflect_dom_object(box WebGLBuffer::new_inherited(id), global, WebGLBufferBinding::Wrap) | ||
} | ||
} | ||
|
||
pub trait WebGLBufferHelpers { | ||
fn get_id(&self) -> u32; | ||
} | ||
|
||
impl<'a> WebGLBufferHelpers for JSRef<'a, WebGLBuffer> { | ||
fn get_id(&self) -> u32 { | ||
self.id | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl | ||
use dom::bindings::codegen::Bindings::WebGLObjectBinding; | ||
use dom::bindings::global::GlobalRef; | ||
use dom::bindings::js::{Temporary}; | ||
use dom::bindings::utils::{Reflector, reflect_dom_object}; | ||
|
||
#[dom_struct] | ||
pub struct WebGLObject { | ||
reflector_: Reflector, | ||
} | ||
|
||
impl WebGLObject { | ||
fn new_inherited() -> WebGLObject { | ||
WebGLObject { | ||
reflector_: Reflector::new(), | ||
} | ||
} | ||
|
||
pub fn new(global: GlobalRef) -> Temporary<WebGLObject> { | ||
reflect_dom_object(box WebGLObject::new_inherited(), global, WebGLObjectBinding::Wrap) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl | ||
use dom::bindings::codegen::Bindings::WebGLProgramBinding; | ||
use dom::bindings::global::GlobalRef; | ||
use dom::bindings::js::{Temporary, JSRef}; | ||
use dom::bindings::utils::{Reflector, reflect_dom_object}; | ||
|
||
#[dom_struct] | ||
pub struct WebGLProgram { | ||
reflector_: Reflector, | ||
id: u32, | ||
} | ||
|
||
impl WebGLProgram { | ||
fn new_inherited(id: u32) -> WebGLProgram { | ||
WebGLProgram { | ||
reflector_: Reflector::new(), | ||
id: id, | ||
} | ||
} | ||
|
||
pub fn new(global: GlobalRef, id: u32) -> Temporary<WebGLProgram> { | ||
reflect_dom_object(box WebGLProgram::new_inherited(id), global, WebGLProgramBinding::Wrap) | ||
} | ||
} | ||
|
||
pub trait WebGLProgramHelpers { | ||
fn get_id(&self) -> u32; | ||
} | ||
|
||
impl<'a> WebGLProgramHelpers for JSRef<'a, WebGLProgram> { | ||
fn get_id(&self) -> u32 { | ||
self.id | ||
} | ||
} |
Oops, something went wrong.