Fix gl.getShaderSource and gl.getShaderInfoLog

It only returns null if there was an error, and the only error isn't
implemented yet.
This commit is contained in:
Anthony Ramine 2018-07-07 21:52:10 +02:00
parent 0e93f06d8d
commit 6996d1ce36
3 changed files with 13 additions and 29 deletions

View file

@ -35,8 +35,8 @@ pub struct WebGLShader {
webgl_object: WebGLObject,
id: WebGLShaderId,
gl_type: u32,
source: DomRefCell<Option<DOMString>>,
info_log: DomRefCell<Option<String>>,
source: DomRefCell<DOMString>,
info_log: DomRefCell<DOMString>,
is_deleted: Cell<bool>,
attached_counter: Cell<u32>,
compilation_status: Cell<ShaderCompilationStatus>,
@ -56,8 +56,8 @@ impl WebGLShader {
webgl_object: WebGLObject::new_inherited(),
id: id,
gl_type: shader_type,
source: DomRefCell::new(None),
info_log: DomRefCell::new(None),
source: Default::default(),
info_log: Default::default(),
is_deleted: Cell::new(false),
attached_counter: Cell::new(0),
compilation_status: Cell::new(ShaderCompilationStatus::NotCompiled),
@ -113,10 +113,6 @@ impl WebGLShader {
}
let source = self.source.borrow();
let source = match source.as_ref() {
Some(source) => source,
None => return Ok(()),
};
let params = BuiltInResources {
MaxVertexAttribs: limits.max_vertex_attribs as c_int,
@ -166,7 +162,7 @@ impl WebGLShader {
},
};
match validator.compile_and_translate(&[source]) {
match validator.compile_and_translate(&[&source]) {
Ok(translated_source) => {
debug!("Shader translated: {}", translated_source);
// NOTE: At this point we should be pretty sure that the compilation in the paint thread
@ -182,7 +178,7 @@ impl WebGLShader {
},
}
*self.info_log.borrow_mut() = Some(validator.info_log());
*self.info_log.borrow_mut() = validator.info_log().into();
// TODO(emilio): More data (like uniform data) should be collected
// here to properly validate uniforms.
@ -220,18 +216,18 @@ impl WebGLShader {
}
/// glGetShaderInfoLog
pub fn info_log(&self) -> Option<String> {
pub fn info_log(&self) -> DOMString {
self.info_log.borrow().clone()
}
/// Get the shader source
pub fn source(&self) -> Option<DOMString> {
pub fn source(&self) -> DOMString {
self.source.borrow().clone()
}
/// glShaderSource
pub fn set_source(&self, source: DOMString) {
*self.source.borrow_mut() = Some(source);
*self.source.borrow_mut() = source;
}
pub fn successfully_compiled(&self) -> bool {