small refactoring
This commit is contained in:
@@ -86,12 +86,6 @@ QVector<QVector3D> loadFileHDR(const QString & path, QSize * size) {
|
||||
}
|
||||
|
||||
|
||||
//#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
|
||||
//#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
|
||||
//#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
|
||||
//#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
|
||||
//#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
|
||||
//#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
|
||||
QVector<QVector3D> faceHDR(const QVector<QVector3D> & data, QSize sz, QSize & fsz, int face) {
|
||||
QVector<QVector3D> ret;
|
||||
if (data.isEmpty() || sz.isNull()) return ret;
|
||||
@@ -175,13 +169,6 @@ bool CubeTexture::init() {
|
||||
f->glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||
f->glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
f->glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
//glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
|
||||
//glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, format_, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
||||
//glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, format_, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
||||
//glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, format_, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
||||
//glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, format_, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
||||
//glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, format_, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
||||
//glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, format_, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
||||
changed_ = false;
|
||||
return id_ > 0;
|
||||
}
|
||||
@@ -213,7 +200,6 @@ void CubeTexture::loadHDR(const QVector<QVector3D> & data, QSize sz) {
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
fd = faceHDR(data, sz, fsz, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i);
|
||||
//qDebug() << "load cube" << fd[0];
|
||||
//f->glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
f->glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, format_, fsz.width(), fsz.height(), 0, GL_RGB, GL_FLOAT, fd.isEmpty() ? 0 : fd.constData());
|
||||
//qDebug() << QString::number(GetLastError(), 16);
|
||||
}
|
||||
@@ -245,37 +231,3 @@ void CubeTexture::load() {
|
||||
changed_ = false;
|
||||
}
|
||||
|
||||
/*
|
||||
void CubeTexture::load() {
|
||||
if (isEmpty()) return;
|
||||
create();
|
||||
if (!path(0).isEmpty()) loadFront(path(0));
|
||||
if (!path(1).isEmpty()) loadBack(path(1));
|
||||
if (!path(2).isEmpty()) loadLeft(path(2));
|
||||
if (!path(3).isEmpty()) loadRight(path(3));
|
||||
if (!path(4).isEmpty()) loadTop(path(4));
|
||||
if (!path(5).isEmpty()) loadBottom(path(5));
|
||||
}
|
||||
|
||||
|
||||
void CubeTexture::loadFromDirectory(const QString & dir) {
|
||||
QDir d(dir); QFileInfoList sl;
|
||||
sl = d.entryInfoList(QStringList("front.*"), QDir::Files | QDir::NoDotAndDotDot); if (!sl.isEmpty()) loadFront(sl[0].absoluteFilePath());
|
||||
sl = d.entryInfoList(QStringList("back.*"), QDir::Files | QDir::NoDotAndDotDot); if (!sl.isEmpty()) loadBack(sl[0].absoluteFilePath());
|
||||
sl = d.entryInfoList(QStringList("left.*"), QDir::Files | QDir::NoDotAndDotDot); if (!sl.isEmpty()) loadLeft(sl[0].absoluteFilePath());
|
||||
sl = d.entryInfoList(QStringList("right.*"), QDir::Files | QDir::NoDotAndDotDot); if (!sl.isEmpty()) loadRight(sl[0].absoluteFilePath());
|
||||
sl = d.entryInfoList(QStringList("top.*"), QDir::Files | QDir::NoDotAndDotDot); if (!sl.isEmpty()) loadTop(sl[0].absoluteFilePath());
|
||||
sl = d.entryInfoList(QStringList("bottom.*"), QDir::Files | QDir::NoDotAndDotDot); if (!sl.isEmpty()) loadBottom(sl[0].absoluteFilePath());
|
||||
}
|
||||
|
||||
|
||||
void CubeTexture::loadPathesFromDirectory(const QString & dir) {
|
||||
QDir d(dir); QFileInfoList sl;
|
||||
sl = d.entryInfoList(QStringList("front.*"), QDir::Files | QDir::NoDotAndDotDot); if (!sl.isEmpty()) pathes[0] = sl[0].absoluteFilePath();
|
||||
sl = d.entryInfoList(QStringList("back.*"), QDir::Files | QDir::NoDotAndDotDot); if (!sl.isEmpty()) pathes[1] = sl[0].absoluteFilePath();
|
||||
sl = d.entryInfoList(QStringList("left.*"), QDir::Files | QDir::NoDotAndDotDot); if (!sl.isEmpty()) pathes[2] = sl[0].absoluteFilePath();
|
||||
sl = d.entryInfoList(QStringList("right.*"), QDir::Files | QDir::NoDotAndDotDot); if (!sl.isEmpty()) pathes[3] = sl[0].absoluteFilePath();
|
||||
sl = d.entryInfoList(QStringList("top.*"), QDir::Files | QDir::NoDotAndDotDot); if (!sl.isEmpty()) pathes[4] = sl[0].absoluteFilePath();
|
||||
sl = d.entryInfoList(QStringList("bottom.*"), QDir::Files | QDir::NoDotAndDotDot); if (!sl.isEmpty()) pathes[5] = sl[0].absoluteFilePath();
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -35,22 +35,10 @@ public:
|
||||
void loadHDR(const QVector<QVector3D> & data, QSize sz);
|
||||
void setFileHDR(const QString & path);
|
||||
QString fileHDR() const {return hdr_path;}
|
||||
//void loadFromDirectory(const QString & dir);
|
||||
//void loadFront(const QString & path) {bind(); pathes[0] = path; createGLTexture(id_, rotateQImageLeft(QImage(path)).scaled(size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), format_, GL_TEXTURE_CUBE_MAP_POSITIVE_X);}
|
||||
//void loadBack(const QString & path) {bind(); pathes[1] = path; createGLTexture(id_, rotateQImageRight(QImage(path)).scaled(size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), format_, GL_TEXTURE_CUBE_MAP_NEGATIVE_X);}
|
||||
//void loadLeft(const QString & path) {bind(); pathes[2] = path; createGLTexture(id_, QImage(path).scaled(size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), format_, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y);}
|
||||
//void loadRight(const QString & path) {bind(); pathes[3] = path; createGLTexture(id_, rotateQImage180(QImage(path)).scaled(size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), format_, GL_TEXTURE_CUBE_MAP_POSITIVE_Y);}
|
||||
//void loadTop(const QString & path) {bind(); pathes[4] = path; createGLTexture(id_, rotateQImageLeft(QImage(path)).scaled(size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), format_, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);}
|
||||
//void loadBottom(const QString & path) {bind(); pathes[5] = path; createGLTexture(id_, rotateQImageLeft(QImage(path)).scaled(size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), format_, GL_TEXTURE_CUBE_MAP_POSITIVE_Z);}
|
||||
//void load();
|
||||
//bool isEmpty() const {foreach (const QString & i, pathes) if (!i.isEmpty()) return false; return true;}
|
||||
GLenum format() const {return format_;}
|
||||
void setFormat(GLenum f) {format_ = f; changed_ = true;}
|
||||
GLuint id() const {return id_;}
|
||||
bool isInit() const {return id_ != 0;}
|
||||
//const QString & path(int side) const {return pathes[side];}
|
||||
//void setPath(int side, const QString & p) {pathes[side] = p;}
|
||||
//void loadPathesFromDirectory(const QString & dir);
|
||||
void load();
|
||||
private:
|
||||
|
||||
@@ -60,7 +48,6 @@ private:
|
||||
GLenum format_;
|
||||
GLuint id_;
|
||||
QString hdr_path;
|
||||
//QVector<QString> pathes;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#include <QTime>
|
||||
|
||||
|
||||
Framebuffer::Framebuffer(QOpenGLExtraFunctions * f_, int colorAttachments_, bool withDepth, GLenum colorFormat_, GLenum _target): f(f_),
|
||||
pbo(GL_PIXEL_PACK_BUFFER, GL_STREAM_DRAW) {
|
||||
Framebuffer::Framebuffer(QOpenGLExtraFunctions * f_, int colorAttachments_, bool withDepth, GLenum colorFormat_, GLenum _target)
|
||||
: f(f_), pbo(GL_PIXEL_PACK_BUFFER, GL_STREAM_DRAW) {
|
||||
is_depth = withDepth;
|
||||
target_ = _target;
|
||||
color_formats.fill(colorFormat_, colorAttachments_);
|
||||
@@ -35,8 +35,8 @@ Framebuffer::Framebuffer(QOpenGLExtraFunctions * f_, int colorAttachments_, bool
|
||||
}
|
||||
|
||||
|
||||
Framebuffer::Framebuffer(QOpenGLExtraFunctions * f_, QVector<GLenum> colors_, bool withDepth, GLenum _target): f(f_),
|
||||
pbo(GL_PIXEL_PACK_BUFFER, GL_STREAM_DRAW) {
|
||||
Framebuffer::Framebuffer(QOpenGLExtraFunctions * f_, QVector<GLenum> colors_, bool withDepth, GLenum _target)
|
||||
: f(f_), pbo(GL_PIXEL_PACK_BUFFER, GL_STREAM_DRAW) {
|
||||
is_depth = withDepth;
|
||||
target_ = _target;
|
||||
color_formats = colors_;
|
||||
@@ -73,7 +73,6 @@ void Framebuffer::resize(int width, int height, bool force) {
|
||||
f->glTexParameteri(target_, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
f->glTexParameteri(target_, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
f->glTexParameteri(target_, GL_TEXTURE_MAX_LEVEL, 4);
|
||||
//f->glTexParameteri(target_, GL_GENERATE_MIPMAP_SGIS, GL_FALSE);
|
||||
f->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, target_, colors[i], 0);
|
||||
}
|
||||
if (is_depth) {
|
||||
@@ -88,7 +87,6 @@ void Framebuffer::resize(int width, int height, bool force) {
|
||||
f->glTexParameteri(target_, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
f->glTexParameteri(target_, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
f->glTexParameteri(target_, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
//f->glTexParameteri(target_, GL_GENERATE_MIPMAP_SGIS, GL_FALSE);
|
||||
f->glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, target_, tex_d, 0);
|
||||
}
|
||||
f->glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
@@ -289,8 +287,6 @@ void Framebuffer::bindColorTextures() {
|
||||
for (int i = colors.size() - 1; i >= 0; --i) {
|
||||
f->glActiveTexture(GL_TEXTURE0 + i);
|
||||
f->glBindTexture(GL_TEXTURE_2D, colors[i]);
|
||||
//f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
//f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ public:
|
||||
|
||||
GLuint id() const {return fbo;}
|
||||
GLuint colorTexture(int index = 0) const {return colors[index];}
|
||||
//GLenum colorFormat() const {return color_format;}
|
||||
GLuint depthTexture() const {return tex_d;}
|
||||
GLenum target() const {return target_;}
|
||||
bool isInit() const {return fbo != 0;}
|
||||
@@ -61,7 +60,6 @@ public:
|
||||
void setWriteBuffers(const QVector<int> & indeces) {setWriteBuffers(indeces.constData(), indeces.size());}
|
||||
void setWriteBuffers();
|
||||
void unsetWriteBuffers();
|
||||
//void setColorFormat(GLenum format) {color_format = format; is_changed = true;}
|
||||
void enablePixelBuffer();
|
||||
void setColorTextureFiltering(int index, GLenum filter);
|
||||
|
||||
@@ -83,7 +81,6 @@ private:
|
||||
GLenum target_;
|
||||
GLuint fbo, drbo, tex_d;
|
||||
GLint prev_view[4], wid, hei;
|
||||
|
||||
};
|
||||
|
||||
#endif // GLFRAMEBUFFER_H
|
||||
|
||||
@@ -62,7 +62,7 @@ void Map::copyToQGLMap(QGLMap & m) const {
|
||||
|
||||
|
||||
|
||||
Material::Material(const QString _name)/*: map_reflection(512)*/ {
|
||||
Material::Material(const QString _name) {
|
||||
setTypes();
|
||||
name = _name;
|
||||
color_diffuse = Qt::white;
|
||||
|
||||
@@ -70,7 +70,6 @@ public:
|
||||
Map map_relief ;
|
||||
bool _changed;
|
||||
int _index;
|
||||
//GLCubeTexture map_reflection;
|
||||
};
|
||||
|
||||
|
||||
@@ -93,13 +92,10 @@ inline QDataStream & operator <<(QDataStream & s, const Material * m) {
|
||||
cs.add(1, m->name).add(2, m->color_diffuse).add(4, m->color_emission)
|
||||
.add(5, m->transparency).add(6, m->reflectivity).add(7, m->glass).add(8, m->map_diffuse).add(9, m->map_normal)
|
||||
.add(10, m->map_relief).add(11, m->map_metalness).add(12, m->map_roughness).add(13, m->map_emission);
|
||||
s << /*qCompress*/(cs.data()); return s;
|
||||
s << (cs.data()); return s;
|
||||
}
|
||||
inline QDataStream & operator >>(QDataStream & s, Material *& m) {
|
||||
m = new Material();
|
||||
//QByteArray ba;
|
||||
//s >> ba;
|
||||
//ba = qUncompres(ba);
|
||||
ChunkStream cs(s);
|
||||
while (!cs.atEnd()) {
|
||||
switch (cs.read()) {
|
||||
|
||||
@@ -37,7 +37,6 @@ Mesh::Mesh(GLenum geom_type_): geom_type(geom_type_),
|
||||
|
||||
Mesh::~Mesh() {
|
||||
//qDebug() << "~Mesh, now" << --_count;
|
||||
//destroy();
|
||||
}
|
||||
|
||||
|
||||
@@ -401,15 +400,12 @@ QDataStream & operator <<(QDataStream & s, const Mesh * m) {
|
||||
cs.add(1, m->vertices_).add(2, m->normals_).add(3, m->texcoords_)
|
||||
.add(6, m->triangles_).add(7, m->lines_).add(10, int(m->geom_type));
|
||||
//qDebug() << "place VBO done" << cs.data().size() << "...";
|
||||
s << /*qCompress*/(cs.data()); return s;
|
||||
s << cs.data(); return s;
|
||||
}
|
||||
|
||||
|
||||
QDataStream & operator >>(QDataStream & s, Mesh *& m) {
|
||||
m = new Mesh();
|
||||
//QByteArray ba;
|
||||
//s >> ba;
|
||||
//ba = qUncompress(ba);
|
||||
ChunkStream cs(s);
|
||||
while (!cs.atEnd()) {
|
||||
switch (cs.read()) {
|
||||
|
||||
@@ -25,9 +25,6 @@
|
||||
|
||||
class Mesh
|
||||
{
|
||||
friend class ObjectBase;
|
||||
friend class Scene;
|
||||
friend class Renderer;
|
||||
friend QDataStream & operator <<(QDataStream & s, const Mesh * m);
|
||||
friend QDataStream & operator >>(QDataStream & s, Mesh *& m);
|
||||
public:
|
||||
@@ -36,8 +33,6 @@ public:
|
||||
|
||||
Mesh * clone();
|
||||
|
||||
//GLVBO & operator =(const GLVBO & o) {return *this;}
|
||||
|
||||
void init (QOpenGLExtraFunctions * f);
|
||||
void destroy (QOpenGLExtraFunctions * f);
|
||||
bool rebuffer(QOpenGLExtraFunctions * f);
|
||||
@@ -100,7 +95,6 @@ private:
|
||||
mutable bool hash_changed;
|
||||
int vert_count;
|
||||
bool changed;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -248,7 +248,6 @@ Mesh * Primitive::cylinder(int segments, float radius, float height, float end_a
|
||||
if (end_angle < 360.) {
|
||||
Mesh * cap = Primitive::plane(radius, height);
|
||||
cap->rotatePoints(90, 1, 0, 0);
|
||||
//cap->rotatePoints(-90, 0, 0, 1);
|
||||
cap->translatePoints(radius/2, 0, height/2);
|
||||
ret->append(cap);
|
||||
cap->flipNormals();
|
||||
|
||||
@@ -52,53 +52,4 @@ Mesh * coneFrame(int segments, float radius = 1., float height = 1.);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
class GLPrimitivePoint: public GLObjectBase
|
||||
{
|
||||
public:
|
||||
GLPrimitivePoint(double size = 1., QVector3D pos = QVector3D()) {sz = 8.;}
|
||||
virtual void draw(QOpenGLShaderProgram * prog, bool simplest = false);
|
||||
private:
|
||||
double sz;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class GLPrimitiveLine: public GLObjectBase
|
||||
{
|
||||
public:
|
||||
GLPrimitiveLine(QVector3D p0_ = QVector3D(), QVector3D p1_ = QVector3D()) {p0 = p0_; p1 = p1_;}
|
||||
virtual void draw(QOpenGLShaderProgram * prog, bool simplest = false);
|
||||
QVector3D point0() const {return p0;}
|
||||
QVector3D point1() const {return p1;}
|
||||
void setPoint0(const QVector3D & p) {p0 = p;}
|
||||
void setPoint1(const QVector3D & p) {p1 = p;}
|
||||
private:
|
||||
QVector3D p0, p1;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class GLPrimitiveEllipsoid: public GLObjectBase
|
||||
{
|
||||
public:
|
||||
GLPrimitiveEllipsoid(float width = 1., float length = 1., float height = 1., int seg_wl = 10, int seg_h = 10, QVector3D pos = QVector3D());
|
||||
virtual void init();
|
||||
private:
|
||||
void putTriangle(const QVector3D & v0, const QVector3D & v1, const QVector3D & v2);
|
||||
float w, l, h;
|
||||
int swl, sh;
|
||||
};
|
||||
|
||||
|
||||
class GLPrimitiveAxis: public GLObjectBase
|
||||
{
|
||||
public:
|
||||
GLPrimitiveAxis() {accept_fog = accept_light = cast_shadow = rec_shadow = select_ = false;}
|
||||
virtual void draw(QOpenGLShaderProgram * prog, bool simplest = false);
|
||||
};
|
||||
*/
|
||||
|
||||
#endif // GLPRIMITIVE_CUBE_H
|
||||
|
||||
@@ -85,7 +85,6 @@ const char qgl_structs[] =
|
||||
"};\n"
|
||||
"struct QGLMaterial {\n"
|
||||
" vec4 color_diffuse;\n"
|
||||
//" vec4 color_specular;\n"
|
||||
" vec4 color_emission;\n"
|
||||
" float transparency;\n"
|
||||
" float reflectivity;\n"
|
||||
@@ -97,11 +96,6 @@ const char qgl_structs[] =
|
||||
" vec4 color;\n"
|
||||
" vec4 decay_intensity;\n"
|
||||
" vec4 angles;\n"
|
||||
//" sampler2DShadow shadow;\n"
|
||||
//" sampler2D shadowColor\n"
|
||||
//" mat4 shadowMatrix;\n"
|
||||
//" vec4 shadowDir0;\n"
|
||||
//" vec4 shadowDir1;\n"
|
||||
"};\n"
|
||||
"struct QGLLightPosition {\n"
|
||||
" vec4 position;\n"
|
||||
|
||||
@@ -125,8 +125,6 @@ struct QGLLightParameter {
|
||||
QVector4D color;
|
||||
QVector4D decay_intensity; // [^0, ^1, ^2, intensity]
|
||||
QVector4D angles; // [start, cos(start), end, cos(end)]
|
||||
//GLfloat shadow;
|
||||
//GLfloat shadowMatrix[16];
|
||||
};
|
||||
struct QGLLightPosition {
|
||||
QVector4D position;
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
class Texture2DArray
|
||||
{
|
||||
friend class ObjectBase;
|
||||
public:
|
||||
Texture2DArray(bool filter);
|
||||
~Texture2DArray();
|
||||
@@ -49,7 +48,6 @@ private:
|
||||
QSize size_;
|
||||
int layers_;
|
||||
bool filtering_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -398,7 +398,6 @@ QVector3D Transform::fromDirection(QVector3D d, float pitch) {
|
||||
|
||||
|
||||
QVector3D Transform::fromRotationMatrix(const QMatrix3x3 & m) {
|
||||
//return QQuaternion::fromRotationMatrix(m);
|
||||
float sy = sqrt(m(0,0) * m(0,0) + m(1,0) * m(1,0));
|
||||
bool singular = sy < 1.E-6; // If
|
||||
float x, y, z;
|
||||
|
||||
@@ -96,19 +96,9 @@ protected:
|
||||
|
||||
|
||||
inline QDataStream & operator <<(QDataStream & s, const Transform & v) {
|
||||
//ChunkStream cs;
|
||||
//cs.add(1, v.matrix());
|
||||
//s << cs.data(); return s;
|
||||
s << v.matrix(); return s;
|
||||
}
|
||||
inline QDataStream & operator >>(QDataStream & s, Transform & v) {
|
||||
//ChunkStream cs(s);
|
||||
//while (!cs.atEnd()) {
|
||||
// switch (cs.read()) {
|
||||
// case 1: v.setMatrix(cs.getData<QMatrix4x4>()); break;
|
||||
// }
|
||||
//}
|
||||
//return s;
|
||||
QMatrix4x4 m;
|
||||
s >> m;
|
||||
v.setMatrix(m);
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
//__GLWidget__ * currentQGLView;
|
||||
//QMutex globMutex;
|
||||
|
||||
|
||||
QString readCharsUntilNull(QDataStream & s) {
|
||||
QString str;
|
||||
@@ -55,7 +52,6 @@ QString findFile(const QString & file, const QStringList & pathes) {
|
||||
|
||||
|
||||
void glDrawQuad(QOpenGLShaderProgram * prog, QVector4D * corner_dirs, GLfloat x, GLfloat y, GLfloat w, GLfloat h) {
|
||||
//glResetAllTransforms();
|
||||
glSetPolygonMode(GL_FILL);
|
||||
glDisable(GL_LIGHTING);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
@@ -63,7 +59,6 @@ void glDrawQuad(QOpenGLShaderProgram * prog, QVector4D * corner_dirs, GLfloat x,
|
||||
locv = prog ? prog->attributeLocation("qgl_Vertex") : -1,
|
||||
loct = prog ? prog->attributeLocation("qgl_Texture") : -1,
|
||||
locc = prog ? prog->attributeLocation("view_corner") : -1;
|
||||
//if (prog) {qDebug() << locv << loct << locc;}
|
||||
QOpenGLFunctions * glFuncs = QOpenGLContext::currentContext()->functions();
|
||||
if (prog) {
|
||||
static const GLfloat cols [] = {1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f};
|
||||
@@ -137,12 +132,10 @@ void qglMultMatrix(const QMatrix4x4 & m) {
|
||||
|
||||
|
||||
void createGLTexture(QOpenGLExtraFunctions * f, GLuint & tex, int width, int height, const GLenum & format, const GLenum & target) {
|
||||
//glClearError();
|
||||
if (tex == 0) {
|
||||
f->glGenTextures(1, &tex);
|
||||
f->glBindTexture(target, tex);
|
||||
}
|
||||
//glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
if (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_COMPONENT16 || format == GL_DEPTH_COMPONENT24 || format == GL_DEPTH_COMPONENT32)
|
||||
f->glTexImage2D(target, 0, format, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, nullptr);
|
||||
else {
|
||||
@@ -153,7 +146,6 @@ void createGLTexture(QOpenGLExtraFunctions * f, GLuint & tex, int width, int hei
|
||||
if (format == GL_RGB32F || format == GL_RGB16F || format == GL_RGB8 || format == GL_RGB)
|
||||
fmt = GL_RGB;
|
||||
f->glTexImage2D(target, 0, format, width, height, 0, fmt, type, nullptr);
|
||||
//glGenerateMipmap(target);
|
||||
//qDebug() << "glTexImage2D" << width << height << QString::number(t, 16);
|
||||
}
|
||||
//qDebug() << QString::number(glGetError(), 16);
|
||||
@@ -166,7 +158,6 @@ void createGLTexture(QOpenGLExtraFunctions * f, GLuint & tex, const QImage & ima
|
||||
}
|
||||
f->glBindTexture(target, tex);
|
||||
QImage im = image.mirrored(false, true).convertToFormat(QImage::Format_RGBA8888);
|
||||
//const QImage & cim(im);
|
||||
f->glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
f->glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
f->glTexParameteri(target, GL_TEXTURE_WRAP_R, GL_REPEAT);
|
||||
@@ -197,8 +188,8 @@ QMatrix4x4 glMatrixPerspective(float angle, float aspect, float near_) {
|
||||
ret(0, 0) = t;
|
||||
ret(1, 1) = t * aspect;
|
||||
}
|
||||
ret(2, 2) = e - 1.f;//far_ / (far_ - near_) - 1.;
|
||||
ret(2, 3) = (e - 2.f) * near_;//2. * far_ * near_ / (far_ - near_);
|
||||
ret(2, 2) = e - 1.f;
|
||||
ret(2, 3) = (e - 2.f) * near_;
|
||||
ret(3, 2) = -1.f;
|
||||
ret(3, 3) = 0.f;
|
||||
return ret;
|
||||
@@ -294,7 +285,6 @@ Vector3i::Vector3i(const QString & str) {
|
||||
|
||||
void glEnableDepth() {
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
//glDepthFunc(GL_GREATER);
|
||||
glDepthFunc(GL_LESS);
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
@@ -308,7 +298,6 @@ void glDisableDepth() {
|
||||
|
||||
void glClearFramebuffer(const QColor & color, bool depth) {
|
||||
glClearColor(color.redF(), color.greenF(), color.blueF(), color.alphaF());
|
||||
//glClearDepth(0.);
|
||||
if (depth)
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
else
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
class VertexObject
|
||||
{
|
||||
friend class Mesh;
|
||||
public:
|
||||
VertexObject();
|
||||
~VertexObject();
|
||||
@@ -57,7 +56,6 @@ private:
|
||||
GLuint vao_;
|
||||
Buffer buffer_obj, buffer_sel;
|
||||
bool buffers_binded, objects_changed, selected_changed;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user