| 1 |
#pragma once |
| 2 |
|
| 3 |
#ifndef DOXYGEN_GENERATING_OUTPUT |
| 4 |
#define NCINE_INCLUDE_OPENGL |
| 5 |
#include "../../../CommonHeaders.h" |
| 6 |
#endif |
| 7 |
|
| 8 |
#include <Containers/StringView.h> |
| 9 |
|
| 10 |
using namespace Death::Containers; |
| 11 |
|
| 12 |
namespace nCine::RHI::GL |
| 13 |
{ |
| 14 |
/** |
| 15 |
@brief Wraps an OpenGL renderbuffer object |
| 16 |
|
| 17 |
Manages the lifetime of a single OpenGL renderbuffer object and allocates its storage on |
| 18 |
construction with the given internal format and dimensions. Binding to `GL_RENDERBUFFER` is cached |
| 19 |
so that redundant `glBindRenderbuffer()` calls are skipped. Typically attached to a @ref GLFramebuffer. |
| 20 |
*/ |
| 21 |
class GLRenderbuffer |
| 22 |
{ |
| 23 |
friend class GLFramebuffer; |
| 24 |
|
| 25 |
public: |
| 26 |
GLRenderbuffer(GLenum internalFormat, GLsizei width, GLsizei height); |
| 27 |
~GLRenderbuffer(); |
| 28 |
|
| 29 |
GLRenderbuffer(const GLRenderbuffer&) = delete; |
| 30 |
GLRenderbuffer& operator=(const GLRenderbuffer&) = delete; |
| 31 |
|
| 32 |
/** @brief Returns the OpenGL handle of the renderbuffer object */ |
| 33 |
inline GLuint GetGLHandle() const { |
| 34 |
return _glHandle; |
| 35 |
} |
| 36 |
|
| 37 |
/** @brief Sets the framebuffer attachment point this renderbuffer is associated with */ |
| 38 |
inline void SetAttachment(GLenum attachment) { |
| 39 |
_attachment = attachment; |
| 40 |
} |
| 41 |
/** @brief Returns the framebuffer attachment point this renderbuffer is associated with */ |
| 42 |
inline GLenum GetAttachment() const { |
| 43 |
return _attachment; |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* @brief Binds the renderbuffer to `GL_RENDERBUFFER` |
| 48 |
* |
| 49 |
* @return `true` if a `glBindRenderbuffer()` call was issued, `false` if it was already bound |
| 50 |
*/ |
| 51 |
bool Bind() const; |
| 52 |
/** |
| 53 |
* @brief Unbinds any renderbuffer from `GL_RENDERBUFFER` |
| 54 |
* |
| 55 |
* @return `true` if a `glBindRenderbuffer()` call was issued, `false` if nothing was bound |
| 56 |
*/ |
| 57 |
static bool Unbind(); |
| 58 |
|
| 59 |
/** @brief Sets an OpenGL object label for the renderbuffer, for debugging */ |
| 60 |
void SetObjectLabel(StringView label); |
| 61 |
|
| 62 |
private: |
| 63 |
static GLuint _boundBuffer; |
| 64 |
|
| 65 |
GLuint _glHandle; |
| 66 |
GLenum _attachment; |
| 67 |
|
| 68 |
void Storage(GLenum internalFormat, GLsizei width, GLsizei height); |
| 69 |
}; |
| 70 |
|
| 71 |
} |