Implement new WebGL interfaces and methods

This commit implements:
* WebGLFramebuffer
* WebGLRenderbuffer
* WebGLTexture

And adds the following methods to `WebGLRenderingContext`:
* create{Texture,Framebuffer,Renderbuffer}
* bind{Texture,Framebuffer,Renderbuffer}
* destroy{Buffer,Texture,Framebuffer,Renderbuffer}

Fixes:
* WebGLUniform location shouldn't inherit from WebGLObject.

Known Issues:
* WebGL objects have to be destroyed on drop, we may want to keep a reference to the context, or maybe a clone of the renderer to achieve this

Also refactors a huge part of the current implementation, to allow
failing on creation of different WebGL objects.

Blocked on https://github.com/servo/gleam/pull/22

A reftest for most of the added functionality is not doable right now,
we need a few more functions in order to upload a texture, for example.
This commit is contained in:
ecoal95 2015-06-05 15:44:03 +02:00
parent ad5846f2e1
commit 9f94d39c9e
14 changed files with 469 additions and 102 deletions

View file

@ -4,6 +4,8 @@
#![crate_name = "canvas_traits"]
#![crate_type = "rlib"]
#![feature(core)]
extern crate core;
extern crate azure;
extern crate geom;
extern crate cssparser;
@ -24,6 +26,7 @@ use gfx_traits::color;
use std::sync::mpsc::{Sender};
use layers::platform::surface::NativeSurface;
use offscreen_gl_context::GLContextAttributes;
use core::nonzero::NonZero;
#[derive(Clone)]
pub enum CanvasMsg {
@ -70,23 +73,35 @@ pub enum Canvas2dMsg {
pub enum CanvasWebGLMsg {
GetContextAttributes(Sender<GLContextAttributes>),
AttachShader(u32, u32),
BindBuffer(u32, u32),
BufferData(u32, Vec<f32>, u32),
Clear(u32),
ClearColor(f32, f32, f32, f32),
CompileShader(u32),
CreateBuffer(Sender<u32>),
CreateProgram(Sender<u32>),
CreateShader(u32, Sender<u32>),
CreateBuffer(Sender<Option<NonZero<u32>>>),
CreateFramebuffer(Sender<Option<NonZero<u32>>>),
CreateRenderbuffer(Sender<Option<NonZero<u32>>>),
CreateTexture(Sender<Option<NonZero<u32>>>),
CreateProgram(Sender<Option<NonZero<u32>>>),
CreateShader(u32, Sender<Option<NonZero<u32>>>),
DeleteBuffer(u32),
DeleteFramebuffer(u32),
DeleteRenderbuffer(u32),
DeleteTexture(u32),
DeleteProgram(u32),
DeleteShader(u32),
BindBuffer(u32, u32),
BindFramebuffer(u32, u32),
BindRenderbuffer(u32, u32),
BindTexture(u32, u32),
DrawArrays(u32, i32, i32),
EnableVertexAttribArray(u32),
GetAttribLocation(u32, String, Sender<i32>),
GetShaderInfoLog(u32, Sender<String>),
GetShaderParameter(u32, u32, Sender<i32>),
GetUniformLocation(u32, String, Sender<u32>),
GetUniformLocation(u32, String, Sender<Option<i32>>),
LinkProgram(u32),
ShaderSource(u32, Vec<String>),
Uniform4fv(u32, Vec<f32>),
ShaderSource(u32, String),
Uniform4fv(i32, Vec<f32>),
UseProgram(u32),
VertexAttribPointer2f(u32, i32, bool, i32, i64),
Viewport(i32, i32, i32, i32),