code format
This commit is contained in:
@@ -1,36 +1,36 @@
|
||||
/*
|
||||
QGL Texture2DArray
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
QGL Texture2DArray
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <QOpenGLExtraFunctions>
|
||||
#include "gltexturearray.h"
|
||||
|
||||
#include <QOpenGLExtraFunctions>
|
||||
|
||||
|
||||
Texture2DArray::Texture2DArray(bool filter) {
|
||||
target_ = GL_TEXTURE_2D_ARRAY;
|
||||
texture_ = 0;
|
||||
layers_ = 0;
|
||||
target_ = GL_TEXTURE_2D_ARRAY;
|
||||
texture_ = 0;
|
||||
layers_ = 0;
|
||||
filtering_ = filter;
|
||||
}
|
||||
|
||||
|
||||
Texture2DArray::~Texture2DArray() {
|
||||
}
|
||||
Texture2DArray::~Texture2DArray() {}
|
||||
|
||||
|
||||
void Texture2DArray::init(QOpenGLExtraFunctions * f) {
|
||||
@@ -50,7 +50,7 @@ void Texture2DArray::destroy(QOpenGLExtraFunctions * f) {
|
||||
|
||||
void Texture2DArray::reinit() {
|
||||
texture_ = 0;
|
||||
layers_ = 0;
|
||||
layers_ = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ void Texture2DArray::release(QOpenGLExtraFunctions * f) {
|
||||
bool Texture2DArray::resize(QOpenGLExtraFunctions * f, QSize new_size, int layers_count) {
|
||||
if (new_size.isNull() || layers_count <= 0) return false;
|
||||
if ((size_ == new_size) && (layers_ >= layers_count)) return false;
|
||||
size_ = new_size;
|
||||
size_ = new_size;
|
||||
layers_ = layers_count;
|
||||
f->glBindTexture(target_, texture_);
|
||||
f->glTexParameteri(target_, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
@@ -88,10 +88,9 @@ bool Texture2DArray::resize(QOpenGLExtraFunctions * f, QSize new_size, int layer
|
||||
|
||||
void Texture2DArray::load(QOpenGLExtraFunctions * f, const QImage & image, int layer) {
|
||||
if (image.isNull() || size_.isNull() || layer < 0 || layer >= layers_) return;
|
||||
QImage im = image.mirrored(false, true)
|
||||
.scaled(size_, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)
|
||||
.convertToFormat(QImage::Format_RGBA8888);
|
||||
//qDebug() << "Texture2DArray::load image" << image.size() << "to layer" << layer;
|
||||
QImage im =
|
||||
image.mirrored(false, true).scaled(size_, Qt::IgnoreAspectRatio, Qt::SmoothTransformation).convertToFormat(QImage::Format_RGBA8888);
|
||||
// qDebug() << "Texture2DArray::load image" << image.size() << "to layer" << layer;
|
||||
f->glTexSubImage3D(target_, 0, 0, 0, layer, size_.width(), size_.height(), 1, GL_RGBA, GL_UNSIGNED_BYTE, im.constBits());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user