From 69f3ecefddf6d3d4b6d7be91bc224788c528df79 Mon Sep 17 00:00:00 2001 From: "re.kovalev" Date: Sun, 15 Jan 2023 01:01:47 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9C=D0=BE=D0=B4=D0=B8=D1=84=D0=B8=D0=BA?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B0?= =?UTF-8?q?=20=D1=82=D0=B5=D0=BA=D1=81=D1=82=D1=83=D1=80=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/Texture.h | 1 + src/Texture.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/Texture.h b/include/Texture.h index bbbf12a..17d30cc 100644 --- a/include/Texture.h +++ b/include/Texture.h @@ -35,6 +35,7 @@ class Texture : public BaseTexture public: Texture(GLuint type = TEX_AVAILABLE_COUNT, const std::string& filename = ""); // Загрузка текстуры с диска или использование "пустой" Texture(GLuint width, GLuint height, GLuint attachment, GLuint texType = TEX_DIFFUSE, GLint internalformat = GL_RGBA, GLint format = GL_RGBA, GLenum dataType = GL_FLOAT); // Конструктор текстуры заданного размера для использования в буфере + Texture(GLuint width, GLuint height, void* data, GLuint texType = TEX_DIFFUSE, GLint internalformat = GL_RGBA, GLint format = GL_RGBA, GLenum dataType = GL_FLOAT); // Конструктор текстуры заданного размера без привязки к буферу с загрузкой пикселей по указателю Texture(const Texture& other); // Конструктор копирования Texture& operator=(const Texture& other); // Оператор присваивания diff --git a/src/Texture.cpp b/src/Texture.cpp index 9837bb7..a120992 100644 --- a/src/Texture.cpp +++ b/src/Texture.cpp @@ -78,6 +78,21 @@ Texture::Texture(GLuint width, GLuint height, GLuint attachment, GLuint texType, handler_count[handler] = 1; } +// Конструктор текстуры заданного размера без привязки к буферу с загрузкой пикселей по указателю +Texture::Texture(GLuint width, GLuint height, void* data, 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, data); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + // Создаем счетчик использований дескриптора + handler_count[handler] = 1; +} + // Конструктор копирования Texture::Texture(const Texture& other) {