mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:27:45 +00:00
LibGL: Implement glAttachShader
This commit is contained in:
parent
42ef5c9e12
commit
7f062e35a4
4 changed files with 43 additions and 4 deletions
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibGL/GL/gl.h>
|
||||
#include <LibGL/Shaders/Program.h>
|
||||
|
||||
namespace GL {
|
||||
|
@ -13,9 +14,36 @@ NonnullRefPtr<Program> Program::create()
|
|||
return adopt_ref(*new Program());
|
||||
}
|
||||
|
||||
ErrorOr<void> Program::attach_shader(Shader&)
|
||||
bool Program::is_shader_attached(Shader const& shader) const
|
||||
{
|
||||
TODO();
|
||||
switch (shader.type()) {
|
||||
case GL_VERTEX_SHADER:
|
||||
return m_vertex_shaders.contains_slow(shader);
|
||||
case GL_FRAGMENT_SHADER:
|
||||
return m_fragment_shaders.contains_slow(shader);
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
ErrorOr<void> Program::attach_shader(Shader& shader)
|
||||
{
|
||||
if (is_shader_attached(shader))
|
||||
return Error::from_string_literal("Trying to attach a shader that is already attached");
|
||||
|
||||
switch (shader.type()) {
|
||||
case GL_VERTEX_SHADER:
|
||||
TRY(m_vertex_shaders.try_append(shader));
|
||||
break;
|
||||
|
||||
case GL_FRAGMENT_SHADER:
|
||||
TRY(m_fragment_shaders.try_append(shader));
|
||||
break;
|
||||
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Error.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/Vector.h>
|
||||
|
@ -17,6 +18,7 @@ class Program final : public RefCounted<Program> {
|
|||
public:
|
||||
static NonnullRefPtr<Program> create();
|
||||
|
||||
bool is_shader_attached(Shader const&) const;
|
||||
ErrorOr<void> attach_shader(Shader&);
|
||||
ErrorOr<void> link();
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/Error.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/String.h>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue