xcal
基于 C++23 的现代图形渲染引擎
载入中...
搜索中...
未找到
shaderprogram.hpp
浏览该文件的文档.
1#pragma once
2#include <xcal/public.h>
3
4#include <memory>
5#include <string_view>
7#include <xcmath/xcmath.hpp>
10 friend class Object;
11
12 private:
13 gl::GLuint program_{};
14
15 private:
16 ShaderProgram(const ShaderProgram &) = delete;
17 ShaderProgram(ShaderProgram &&o) { _STD swap(program_, o.program_); }
18 ShaderProgram &operator=(const ShaderProgram &) = delete;
19 ShaderProgram &operator=(ShaderProgram &&o) {
20 _STD swap(program_, o.program_);
21 return *this;
22 }
23
24 public:
26 ~ShaderProgram() { destroy(); };
27
28 public:
29 public:
30 bool is_valid() const { return program_ != 0; };
31 void atttach_shader(const Shader &shader);
32 void use() const;
33 void uniform(const char *name,
34 const xcmath::mat<gl::GLfloat, 4, 4> &mat) const;
35 void uniform(const char *name,
36 const xcmath::mat<gl::GLfloat, 3, 3> &mat) const;
37 void uniform(const char *name,
38 const xcmath::vec<gl::GLfloat, 3> &vec) const;
39 void uniform(const char *name,
40 const xcmath::vec<gl::GLfloat, 4> &vec) const;
41
42 public:
43 static std::shared_ptr<ShaderProgram> from_file(
44 std::string_view vertex_file, std::string_view fragment_file);
45
46 public:
47 void swap(ShaderProgram &o) { _STD swap(program_, o.program_); }
48 void link();
49 void destroy();
50};
51} // namespace xcal::render::opengl::GL
Matrix class template
Definition mat.hpp:27
Vector class template
Definition vec.hpp:206
unsigned int GLuint
Definition typedef.hpp:21
#define _STD
Definition public.h:32
#define XCAL_API
Definition public.h:69