Added ReadPixel method to framebuffers

This commit is contained in:
Antoine Pilote
2023-07-06 18:10:14 -04:00
parent e632c4b8d3
commit 3b6eac356b
2 changed files with 10 additions and 0 deletions

View File

@@ -126,6 +126,14 @@ namespace Nuake
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
}
int FrameBuffer::ReadPixel(uint32_t attachment, const Vector2 coords)
{
glReadBuffer(GL_COLOR_ATTACHMENT0 + attachment);
int pixelData;
glReadPixels((int)coords.x, (int)coords.y, 1, 1, GL_RED_INTEGER, GL_INT, &pixelData);
return pixelData;
}
void FrameBuffer::SetDrawBuffer(GLenum draw)
{
Bind();

View File

@@ -38,6 +38,8 @@ namespace Nuake
void SetSize(const Vector2& size) { m_Size = size; }
void UpdateSize(Vector2 size);
int ReadPixel(uint32_t attachment, const Vector2 coords);
void SetDrawBuffer(GLenum draw);
void SetReadBuffer(GLenum read);
};