Shader.h 875 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Error.h>
  8. #include <AK/RefCounted.h>
  9. #include <AK/RefPtr.h>
  10. #include <AK/String.h>
  11. #include <AK/StringView.h>
  12. #include <AK/Vector.h>
  13. #include <LibGL/GL/glplatform.h>
  14. namespace GL {
  15. class Shader final : public RefCounted<Shader> {
  16. public:
  17. static NonnullRefPtr<Shader> create(GLenum shader_type);
  18. void clear_sources() { m_sources.clear(); }
  19. ErrorOr<void> add_source(StringView source_code);
  20. ErrorOr<void> compile();
  21. GLenum type() const { return m_type; }
  22. bool compile_status() const { return m_compile_status; }
  23. private:
  24. explicit Shader(GLenum shader_type)
  25. : m_type { shader_type }
  26. {
  27. }
  28. Vector<String> m_sources;
  29. GLenum m_type;
  30. bool m_compile_status { false };
  31. };
  32. }