<commit_before>#include <glow/FrameBufferObject.h>
#include <glow/Log.h>

#include <sstream>

using namespace glow;

ColorAttachment::ColorAttachment(GLenum attachment)
: _attachment(attachment)
{
}

GLenum ColorAttachment::attachment() const
{
	return _attachment;
}

TextureAttachment::TextureAttachment(Texture* texture, GLenum attachment)
: ColorAttachment(attachment)
, _texture(texture)
{
}

RenderBufferAttachment::RenderBufferAttachment(RenderBufferObject* renderBuffer, GLenum attachment)
: ColorAttachment(attachment)
, _renderBuffer(renderBuffer)
{
}


FrameBufferObject::FrameBufferObject()
: Object(genFrameBuffer())
, _target(GL_FRAMEBUFFER)
{
}

FrameBufferObject::~FrameBufferObject()
{
	if (_id) glDeleteFramebuffers(1, &_id);
}

GLuint FrameBufferObject::genFrameBuffer()
{
	GLuint id = 0;
	glGenFramebuffers(1, &id);
	return id;
}

void FrameBufferObject::bind()
{
	glBindFramebuffer(_target, _id);
}

void FrameBufferObject::bind(GLenum target)
{
	_target = target;
	glBindFramebuffer(target, _id);
}

void FrameBufferObject::unbind()
{
	glBindFramebuffer(_target, 0);
}

void FrameBufferObject::setParameter(GLenum pname, GLint param)
{
	bind();
	glFramebufferParameteri(_target, pname, param);
}

void FrameBufferObject::attachTexture(GLenum attachment, Texture* texture, GLint level)
{
	bind();
	glFramebufferTexture(_target, attachment, texture->id(), level);
	attach(new TextureAttachment(texture, attachment));
}

void FrameBufferObject::attachTexture1D(GLenum attachment, Texture* texture, GLint level)
{
	bind();
	glFramebufferTexture1D(_target, attachment, texture->target(), texture->id(), level);
	attach(new TextureAttachment(texture, attachment));
}

void FrameBufferObject::attachTexture2D(GLenum attachment, Texture* texture, GLint level)
{
	bind();
	glFramebufferTexture2D(_target, attachment, texture->target(), texture->id(), level);
	attach(new TextureAttachment(texture, attachment));
}

void FrameBufferObject::attachTextureLayer(GLenum attachment, Texture* texture, GLint level, GLint layer)
{
	bind();
	glFramebufferTextureLayer(_target, attachment, texture->id(), level, layer);
	attach(new TextureAttachment(texture, attachment));
}

void FrameBufferObject::attachRenderBuffer(GLenum attachment, RenderBufferObject* renderBuffer)
{
	bind();<commit_msg>bind render buffer when attached to framebufferobject<commit_after>#include <glow/FrameBufferObject.h>
#include <glow/Log.h>

#include <sstream>

using namespace glow;

ColorAttachment::ColorAttachment(GLenum attachment)
: _attachment(attachment)
{
}

GLenum ColorAttachment::attachment() const
{
	return _attachment;
}

TextureAttachment::TextureAttachment(Texture* texture, GLenum attachment)
: ColorAttachment(attachment)
, _texture(texture)
{
}

RenderBufferAttachment::RenderBufferAttachment(RenderBufferObject* renderBuffer, GLenum attachment)
: ColorAttachment(attachment)
, _renderBuffer(renderBuffer)
{
}


FrameBufferObject::FrameBufferObject()
: Object(genFrameBuffer())
, _target(GL_FRAMEBUFFER)
{
}

FrameBufferObject::~FrameBufferObject()
{
	if (_id) glDeleteFramebuffers(1, &_id);
}

GLuint FrameBufferObject::genFrameBuffer()
{
	GLuint id = 0;
	glGenFramebuffers(1, &id);
	return id;
}

void FrameBufferObject::bind()
{
	glBindFramebuffer(_target, _id);
}

void FrameBufferObject::bind(GLenum target)
{
	_target = target;
	glBindFramebuffer(target, _id);
}

void FrameBufferObject::unbind()
{
	glBindFramebuffer(_target, 0);
}

void FrameBufferObject::setParameter(GLenum pname, GLint param)
{
	bind();
	glFramebufferParameteri(_target, pname, param);
}

void FrameBufferObject::attachTexture(GLenum attachment, Texture* texture, GLint level)
{
	bind();
	glFramebufferTexture(_target, attachment, texture->id(), level);
	attach(new TextureAttachment(texture, attachment));
}

void FrameBufferObject::attachTexture1D(GLenum attachment, Texture* texture, GLint level)
{
	bind();
	glFramebufferTexture1D(_target, attachment, texture->target(), texture->id(), level);
	attach(new TextureAttachment(texture, attachment));
}

void FrameBufferObject::attachTexture2D(GLenum attachment, Texture* texture, GLint level)
{
	bind();
	glFramebufferTexture2D(_target, attachment, texture->target(), texture->id(), level);
	attach(new TextureAttachment(texture, attachment));
}

void FrameBufferObject::attachTextureLayer(GLenum attachment, Texture* texture, GLint level, GLint layer)
{
	bind();
	glFramebufferTextureLayer(_target, attachment, texture->id(), level, layer);
	attach(new TextureAttachment(texture, attachment));
}

void FrameBufferObject::attachRenderBuffer(GLenum attachment, RenderBufferObject* renderBuffer)
{
	bind();
	renderBuffer->bind();
{'fraction_non_alphanumeric': 0.12304058406699592, 'fraction_numerical': 0.003435688211294825, 'mean_word_length': 8.785714285714286, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7433524', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1431, 'n_words': 288}