Files
XCEngine/tests/OpenGL/OpenGLShader.h
ssdfasd 170df5506b Add OpenGLShader class
- Created OpenGLShader class for shader compilation
- Supports compiling from file or source code
- Provides uniform setting methods (SetInt, SetFloat, SetVec3, SetMat4)
- Integrated with GLAD for OpenGL function loading
2026-03-16 16:09:09 +08:00

35 lines
950 B
C++

#pragma once
#include <string>
#include <GLFW/glfw3.h>
namespace XCEngine {
namespace RHI {
class OpenGLShader {
public:
OpenGLShader();
~OpenGLShader();
bool CompileFromFile(const char* vertexPath, const char* fragmentPath);
bool Compile(const char* vertexSource, const char* fragmentSource);
void Shutdown();
void Use() const;
void SetInt(const std::string& name, int value) const;
void SetFloat(const std::string& name, float value) 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 SetMat4(const std::string& name, const float* value) const;
unsigned int GetID() const { return m_program; }
private:
unsigned int m_program;
bool CheckCompileErrors(unsigned int shader, const char* type);
bool CheckLinkErrors(unsigned int program);
};
} // namespace RHI
} // namespace XCEngine