mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
webgl: Check shader compilation status on use_program.
This commit is contained in:
parent
cf479a2b4f
commit
4092ffd245
3 changed files with 20 additions and 3 deletions
|
@ -73,8 +73,19 @@ impl WebGLProgram {
|
|||
}
|
||||
|
||||
/// glUseProgram
|
||||
pub fn use_program(&self) {
|
||||
pub fn use_program(&self) -> WebGLResult<()> {
|
||||
match self.fragment_shader.get() {
|
||||
Some(ref shader) if shader.successfully_compiled() => {},
|
||||
_ => return Err(WebGLError::InvalidOperation),
|
||||
}
|
||||
|
||||
match self.vertex_shader.get() {
|
||||
Some(ref shader) if shader.successfully_compiled() => {},
|
||||
_ => return Err(WebGLError::InvalidOperation),
|
||||
}
|
||||
|
||||
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::UseProgram(self.id))).unwrap();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// glAttachShader
|
||||
|
|
|
@ -1004,8 +1004,10 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
|
||||
fn UseProgram(&self, program: Option<&WebGLProgram>) {
|
||||
if let Some(program) = program {
|
||||
program.use_program();
|
||||
self.current_program.set(Some(program));
|
||||
match program.use_program() {
|
||||
Ok(()) => self.current_program.set(Some(program)),
|
||||
Err(e) => self.webgl_error(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -147,6 +147,10 @@ impl WebGLShader {
|
|||
pub fn set_source(&self, source: DOMString) {
|
||||
*self.source.borrow_mut() = Some(source);
|
||||
}
|
||||
|
||||
pub fn successfully_compiled(&self) -> bool {
|
||||
self.compilation_status.get() == ShaderCompilationStatus::Succeeded
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for WebGLShader {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue