hyporo-cpp/source/hpr/gpu/depth_buffer.hpp
2023-03-13 22:27:09 +05:00

85 lines
1.1 KiB
C++

#pragma once
#ifndef __gl_h_
#include <glad/glad.h>
#endif
namespace hpr::gpu
{
class DepthBuffer
{
protected:
bool p_enabled;
bool p_binded;
public:
inline
DepthBuffer() :
p_enabled {true},
p_binded {false}
{}
inline
DepthBuffer(bool enabled) :
p_enabled {enabled},
p_binded {false}
{}
virtual
~DepthBuffer() = default;
inline
void bind()
{
p_binded = true;
glEnable(GL_DEPTH_TEST);
}
inline
void unbind()
{
p_binded = false;
glDisable(GL_DEPTH_TEST);
}
inline
bool binded() const
{
return p_binded;
}
inline
void enable()
{
p_enabled = true;
glDepthMask(GL_TRUE);
}
inline
void disable()
{
p_enabled = false;
glDepthMask(GL_FALSE);
}
[[nodiscard]]
inline
bool enabled() const
{
return p_enabled;
}
inline
void clear() const
{
glClear(GL_DEPTH_BUFFER_BIT);
}
};
}