From ed62b5b07f17c87f74994a47e43af1e1676b0eb2 Mon Sep 17 00:00:00 2001 From: sagudev <16504129+sagudev@users.noreply.github.com> Date: Wed, 23 Oct 2024 11:39:08 +0200 Subject: [PATCH] Add get_program_validate_status Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --- src/lib.rs | 2 ++ src/native.rs | 7 +++++++ src/web_sys.rs | 15 +++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 3228048..2611386 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -181,6 +181,8 @@ pub trait HasContext: __private::Sealed { unsafe fn get_program_completion_status(&self, program: Self::Program) -> bool; + unsafe fn get_program_validate_status(&self, program: Self::Program) -> bool; + unsafe fn get_program_link_status(&self, program: Self::Program) -> bool; unsafe fn get_program_info_log(&self, program: Self::Program) -> String; diff --git a/src/native.rs b/src/native.rs index a722c4c..cb4d642 100644 --- a/src/native.rs +++ b/src/native.rs @@ -438,6 +438,13 @@ impl HasContext for Context { 1 == status } + unsafe fn get_program_validate_status(&self, program: Self::Program) -> bool { + let gl = &self.raw; + let mut status = 0; + gl.GetProgramiv(program.0.get(), VALIDATE_STATUS, &mut status); + status == 1 + } + unsafe fn get_program_info_log(&self, program: Self::Program) -> String { let gl = &self.raw; let mut length = 0; diff --git a/src/web_sys.rs b/src/web_sys.rs index 188e4a0..65e3f1f 100644 --- a/src/web_sys.rs +++ b/src/web_sys.rs @@ -1946,6 +1946,21 @@ impl HasContext for Context { .unwrap_or(false) } + unsafe fn get_program_validate_status(&self, program: Self::Program) -> bool { + let programs = self.programs.borrow(); + let raw_program = programs.get_unchecked(program); + match self.raw { + RawRenderingContext::WebGl1(ref gl) => { + gl.get_program_parameter(raw_program, VALIDATE_STATUS) + } + RawRenderingContext::WebGl2(ref gl) => { + gl.get_program_parameter(raw_program, VALIDATE_STATUS) + } + } + .as_bool() + .unwrap_or(false) + } + unsafe fn get_program_info_log(&self, program: Self::Program) -> String { let programs = self.programs.borrow(); let raw_program = programs.get_unchecked(program);