mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibGL: Implement glShaderSource
This commit is contained in:
parent
962d088e4e
commit
d5277ecdfe
Notes:
sideshowbarker
2024-07-17 06:40:21 +09:00
Author: https://github.com/sunverwerth Commit: https://github.com/SerenityOS/serenity/commit/d5277ecdfe Pull-request: https://github.com/SerenityOS/serenity/pull/16225 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/gmta ✅ Reviewed-by: https://github.com/supercomputer7
1 changed files with 18 additions and 2 deletions
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibGL/GLContext.h>
|
||||
|
||||
namespace GL {
|
||||
|
@ -40,8 +41,23 @@ void GLContext::gl_delete_shader(GLuint shader)
|
|||
|
||||
void GLContext::gl_shader_source(GLuint shader, GLsizei count, GLchar const** string, GLint const* length)
|
||||
{
|
||||
dbgln("gl_shader_source({}, {}, {#x}, {#x}) unimplemented ", shader, count, string, length);
|
||||
TODO();
|
||||
auto it = m_allocated_shaders.find(shader);
|
||||
// FIXME: implement check "GL_INVALID_VALUE is generated if shader is not a value generated by OpenGL."
|
||||
RETURN_WITH_ERROR_IF(it == m_allocated_shaders.end(), GL_INVALID_OPERATION);
|
||||
RETURN_WITH_ERROR_IF(count < 0, GL_INVALID_VALUE);
|
||||
|
||||
it->value->clear_sources();
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (length == nullptr || length[i] < 0) {
|
||||
auto result = it->value->add_source(StringView(string[i], strlen(string[i])));
|
||||
RETURN_WITH_ERROR_IF(result.is_error() && result.error().is_errno() && result.error().code() == ENOMEM, GL_OUT_OF_MEMORY);
|
||||
RETURN_WITH_ERROR_IF(result.is_error(), GL_INVALID_OPERATION);
|
||||
} else {
|
||||
auto result = it->value->add_source(StringView(string[i], length[i]));
|
||||
RETURN_WITH_ERROR_IF(result.is_error() && result.error().is_errno() && result.error().code() == ENOMEM, GL_OUT_OF_MEMORY);
|
||||
RETURN_WITH_ERROR_IF(result.is_error(), GL_INVALID_OPERATION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GLContext::gl_compile_shader(GLuint shader)
|
||||
|
|
Loading…
Reference in a new issue