Brunot
Loading...
Searching...
No Matches
Shader.h
Go to the documentation of this file.
1// File: Shader.h
2// Description: Loads and handles shaers in OpenGL programs
3// Author(s): Aidan Hartman (aidan.hartman@digipen.edu) Pair progamming with Ori
4// Ori Balashov (ori.balashov@digipen.edu) Pair progamming with Aidan
5// Marcelo Escamilla (marcelo.escamilla@digipen.edu) JSON serialization
6// 2025 / 10 / 03
7// (C) Digipen 2025
8// ____ __ __ __
9// /\__ _\/\ \ /\ \/\ \
10// \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
11// \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
12// \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
13// \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
14// \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
15#pragma once
16#include <string>
17#include "System/json.h"
18
19using GLuint = unsigned int;
20using Stream = sys::Json; // replace with whatever stream we are using
21namespace gfx
22{
23
24class Shader
25{
26
27public:
28 Shader();
29 Shader(const std::string& vertexFile, const std::string& fragmentFile);
30 ~Shader();
31
32 Shader(const Shader& other);
33 Shader(Shader&& other) noexcept;
34 auto operator=(const Shader& other) -> Shader&;
35 auto operator=(Shader&& other) noexcept -> Shader&;
36
37 auto activate() const -> void;
38 auto deactivate() const -> void;
39
44 auto setCamera() const -> void;
45
46 auto ID() const -> GLuint
47 {
48 return shaderID;
49 }
50
51 auto loadFile(const std::string& vertexFile, const std::string& fragmentFile) -> void;
52
53 auto load(const Stream& stream) -> void;
54 auto save(Stream& stream) const -> void;
55
60 [[nodiscard]] auto name() const -> const std::string&
61 {
62 return _name;
63 }
64
69 auto name(const std::string& name) -> void
70 {
71 this->_name = name;
72 }
73
74 friend auto to_json(json& j, const Shader& a) -> void;
75 friend auto from_json(const json& j, Shader& a) -> void;
76
77private:
78 std::string _name;
79 std::string vertexPath;
80 std::string fragmentPath;
82};
83}
sys::Json Stream
Definition AudioObject.h:20
unsigned int GLuint
Definition IndexBuffer.h:17
nlohmann::json json
Definition Json.cpp:19
Definition Shader.h:25
Shader()
Definition Shader.cpp:40
std::string vertexPath
Definition Shader.h:79
GLuint shaderID
Definition Shader.h:81
~Shader()
Definition Shader.cpp:51
auto operator=(const Shader &other) -> Shader &
Definition Shader.cpp:80
std::string fragmentPath
Definition Shader.h:80
auto ID() const -> GLuint
Definition Shader.h:46
auto name(const std::string &name) -> void
Definition Shader.h:69
auto deactivate() const -> void
Definition Shader.cpp:115
friend auto to_json(json &j, const Shader &a) -> void
Definition Shader.cpp:280
std::string _name
Definition Shader.h:78
auto load(const Stream &stream) -> void
Definition Shader.cpp:270
auto save(Stream &stream) const -> void
Definition Shader.cpp:275
auto activate() const -> void
Definition Shader.cpp:109
auto setCamera() const -> void
Sets the view and projection transforms for the shader The shader to be set must be currently loaded.
Definition Shader.cpp:121
auto loadFile(const std::string &vertexFile, const std::string &fragmentFile) -> void
Definition Shader.cpp:126
auto name() const -> const std::string &
Definition Shader.h:60
friend auto from_json(const json &j, Shader &a) -> void
Definition Shader.cpp:290
Definition Json.h:32
Definition Sprite.h:25