Enhance OpenGLShader with comprehensive shader support
This commit is contained in:
@@ -2,27 +2,55 @@
|
||||
|
||||
#include <string>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
enum class ShaderType {
|
||||
Vertex,
|
||||
Fragment,
|
||||
Geometry,
|
||||
Compute,
|
||||
TessControl,
|
||||
TessEvaluation
|
||||
};
|
||||
|
||||
class OpenGLShader {
|
||||
public:
|
||||
OpenGLShader();
|
||||
~OpenGLShader();
|
||||
|
||||
bool CompileFromFile(const char* vertexPath, const char* fragmentPath);
|
||||
bool CompileFromFile(const char* vertexPath, const char* fragmentPath, const char* geometryPath);
|
||||
bool Compile(const char* vertexSource, const char* fragmentSource);
|
||||
bool Compile(const char* vertexSource, const char* fragmentSource, const char* geometrySource);
|
||||
bool CompileCompute(const char* computeSource);
|
||||
bool Compile(const char* source, ShaderType type);
|
||||
void Shutdown();
|
||||
|
||||
void Use() const;
|
||||
void Bind() const { Use(); }
|
||||
void Unbind() const;
|
||||
|
||||
void SetInt(const std::string& name, int value) const;
|
||||
void SetIntArray(const std::string& name, const int* values, unsigned int count) const;
|
||||
void SetFloat(const std::string& name, float value) const;
|
||||
void SetFloatArray(const std::string& name, const float* values, unsigned int count) const;
|
||||
void SetVec2(const std::string& name, float x, float y) const;
|
||||
void SetVec2(const std::string& name, const float* values) const;
|
||||
void SetVec3(const std::string& name, float x, float y, float z) const;
|
||||
void SetVec3(const std::string& name, const float* values) const;
|
||||
void SetVec4(const std::string& name, float x, float y, float z, float w) const;
|
||||
void SetVec4(const std::string& name, const float* values) const;
|
||||
void SetMat2(const std::string& name, const float* value) const;
|
||||
void SetMat3(const std::string& name, const float* value) const;
|
||||
void SetMat4(const std::string& name, const float* value) const;
|
||||
void SetMat4Array(const std::string& name, const float* values, unsigned int count) const;
|
||||
|
||||
int GetUniformLocation(const std::string& name) const;
|
||||
unsigned int GetID() const { return m_program; }
|
||||
bool IsValid() const { return m_program != 0; }
|
||||
|
||||
private:
|
||||
unsigned int m_program;
|
||||
|
||||
Reference in New Issue
Block a user