mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb: Implement WebGL getShaderSource
This commit is contained in:
parent
932a3328a3
commit
2d8b393c76
Notes:
github-actions[bot]
2025-11-01 23:55:28 +00:00
Author: https://github.com/cqundefine
Commit: 2d8b393c76
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6663
Reviewed-by: https://github.com/gmta ✅
5 changed files with 51 additions and 1 deletions
|
|
@ -3078,6 +3078,30 @@ Optional<String> WebGL2RenderingContextImpl::get_shader_info_log(GC::Root<WebGLS
|
|||
return String::from_utf8_without_validation(ReadonlyBytes { info_log.data(), static_cast<size_t>(info_log_length - 1) });
|
||||
}
|
||||
|
||||
Optional<String> WebGL2RenderingContextImpl::get_shader_source(GC::Root<WebGLShader> shader)
|
||||
{
|
||||
m_context->make_current();
|
||||
|
||||
GLuint shader_handle = 0;
|
||||
if (shader) {
|
||||
auto handle_or_error = shader->handle(this);
|
||||
if (handle_or_error.is_error()) {
|
||||
set_error(GL_INVALID_OPERATION);
|
||||
return {};
|
||||
}
|
||||
shader_handle = handle_or_error.release_value();
|
||||
}
|
||||
|
||||
GLint shader_source_length = 0;
|
||||
glGetShaderiv(shader_handle, GL_SHADER_SOURCE_LENGTH, &shader_source_length);
|
||||
if (!shader_source_length)
|
||||
return String {};
|
||||
|
||||
auto shader_source = MUST(ByteBuffer::create_uninitialized(shader_source_length));
|
||||
glGetShaderSource(shader_handle, shader_source_length, nullptr, reinterpret_cast<GLchar*>(shader_source.data()));
|
||||
return String::from_utf8_without_validation(ReadonlyBytes { shader_source.data(), static_cast<size_t>(shader_source_length - 1) });
|
||||
}
|
||||
|
||||
GC::Root<WebGLUniformLocation> WebGL2RenderingContextImpl::get_uniform_location(GC::Root<WebGLProgram> program, String name)
|
||||
{
|
||||
m_context->make_current();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue