Текстура для буфера кадра

This commit is contained in:
2022-11-23 14:23:44 +03:00
parent 6de0a3af8d
commit d6c8e22205
2 changed files with 25 additions and 0 deletions

View File

@@ -59,6 +59,23 @@ Texture::Texture(GLuint t, const std::string& filename) : type(t)
handler_count[handler]++;
}
// Конструктор текстуры заданного размера для использования в буфере
Texture::Texture(GLuint width, GLuint height, GLuint attachment, GLuint texType, GLint internalformat, GLint format, GLenum dataType) : type(texType)
{
// Генерация текстуры заданного размера
glGenTextures(1, &handler);
glBindTexture(GL_TEXTURE_2D, handler);
glTexImage2D(GL_TEXTURE_2D, 0, internalformat, width, height, 0, format, dataType, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
// Привязка к буферу кадра
glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, handler, 0);
// Создаем счетчик использований дескриптора
handler_count[handler] = 1;
}
// Конструктор копирования
Texture::Texture(const Texture& other) : handler(other.handler), type(other.type)
{
@@ -117,3 +134,9 @@ GLuint Texture::getType()
{
return type;
}
// Задает тип текстуры
void Texture::setType(GLuint type)
{
this->type = type;
}