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) {