git-svn-id: svn://db.shs.com.ru/libs@286 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2017-10-03 12:20:32 +00:00
parent b46b9329f3
commit 7ad19d72c5
40 changed files with 320 additions and 712 deletions

View File

@@ -19,7 +19,7 @@
#include "glcamera.h"
#include "qglview.h"
QGLWidget * currentQGLView;
__GLWidget__ * currentQGLView;
QMutex globMutex;
@@ -51,7 +51,8 @@ QString findFile(const QString & file, const QStringList & pathes) {
}
void glDrawQuad(QGLShaderProgram * prog, QVector4D * corner_dirs, GLfloat x, GLfloat y, GLfloat w, GLfloat h) {
void glDrawQuad(__GLShaderProgram__ * prog, QVector4D * corner_dirs, GLfloat x, GLfloat y, GLfloat w, GLfloat h) {
QGLCI
glResetAllTransforms();
glSetPolygonMode(GL_FILL);
int loc = prog ? prog->attributeLocation("qgl_Color") : 0,
@@ -59,11 +60,11 @@ void glDrawQuad(QGLShaderProgram * prog, QVector4D * corner_dirs, GLfloat x, GLf
loct = prog ? prog->attributeLocation("qgl_Texture") : 0,
locc = prog ? prog->attributeLocation("view_corner") : 0;
glBegin(GL_QUADS);
if (prog) glVertexAttrib3f(loc, 1.f, 1.f, 1.f); glColor3f(1.f, 1.f, 1.f);
if (prog) {if (corner_dirs) prog->setAttributeValue(locc, corner_dirs[0]); glVertexAttrib2f(loct, 0.f, 0.f); glVertexAttrib2f(locv, x, y);} glTexCoord2f(0.f, 0.f); glVertex2f(x, y);
if (prog) {if (corner_dirs) prog->setAttributeValue(locc, corner_dirs[1]); glVertexAttrib2f(loct, 1.f, 0.f); glVertexAttrib2f(locv, x + w, y);} glTexCoord2f(1.f, 0.f); glVertex2f(x + w, y);
if (prog) {if (corner_dirs) prog->setAttributeValue(locc, corner_dirs[2]); glVertexAttrib2f(loct, 1.f, 1.f); glVertexAttrib2f(locv, x + w, y + h);} glTexCoord2f(1.f, 1.f); glVertex2f(x + w, y + h);
if (prog) {if (corner_dirs) prog->setAttributeValue(locc, corner_dirs[3]); glVertexAttrib2f(loct, 0.f, 1.f); glVertexAttrib2f(locv, x, y + h);} glTexCoord2f(0.f, 1.f); glVertex2f(x, y + h);
if (prog) {QGLC glVertexAttrib3f(loc, 1.f, 1.f, 1.f);} glColor3f(1.f, 1.f, 1.f);
if (prog) {if (corner_dirs) prog->setAttributeValue(locc, corner_dirs[0]); QGLC glVertexAttrib2f(loct, 0.f, 0.f); QGLC glVertexAttrib2f(locv, x, y);} glTexCoord2f(0.f, 0.f); glVertex2f(x, y);
if (prog) {if (corner_dirs) prog->setAttributeValue(locc, corner_dirs[1]); QGLC glVertexAttrib2f(loct, 1.f, 0.f); QGLC glVertexAttrib2f(locv, x + w, y);} glTexCoord2f(1.f, 0.f); glVertex2f(x + w, y);
if (prog) {if (corner_dirs) prog->setAttributeValue(locc, corner_dirs[2]); QGLC glVertexAttrib2f(loct, 1.f, 1.f); QGLC glVertexAttrib2f(locv, x + w, y + h);} glTexCoord2f(1.f, 1.f); glVertex2f(x + w, y + h);
if (prog) {if (corner_dirs) prog->setAttributeValue(locc, corner_dirs[3]); QGLC glVertexAttrib2f(loct, 0.f, 1.f); QGLC glVertexAttrib2f(locv, x, y + h);} glTexCoord2f(0.f, 1.f); glVertex2f(x, y + h);
glEnd();
}
@@ -71,7 +72,12 @@ void glDrawQuad(QGLShaderProgram * prog, QVector4D * corner_dirs, GLfloat x, GLf
QMatrix4x4 getGLMatrix(GLenum matrix) {
GLdouble gm[16];
glGetDoublev(matrix, gm);
qreal qm[16];
#if QT_VERSION < 0x050600
qreal
#else
float
#endif
qm[16];
for (int i = 0; i < 16; ++i)
qm[i] = gm[i];
return QMatrix4x4(qm).transposed();
@@ -80,7 +86,12 @@ QMatrix4x4 getGLMatrix(GLenum matrix) {
void setGLMatrix(QMatrix4x4 matrix) {
GLdouble gm[16];
qreal qm[16];
#if QT_VERSION < 0x050600
qreal
#else
float
#endif
qm[16];
matrix.transposed().copyDataTo(qm);
for (int i = 0; i < 16; ++i)
gm[i] = qm[i];
@@ -90,7 +101,12 @@ void setGLMatrix(QMatrix4x4 matrix) {
void qglMultMatrix(const QMatrix4x4 & m) {
GLdouble gm[16];
qreal qm[16];
#if QT_VERSION < 0x050600
qreal
#else
float
#endif
qm[16];
m.transposed().copyDataTo(qm);
for (int i = 0; i < 16; ++i)
gm[i] = qm[i];
@@ -127,7 +143,7 @@ void createGLTexture(GLuint & tex, const QImage & image, const GLenum & format,
glGenTextures(1, &tex);
glBindTexture(target, tex);
}
QImage im = QGLWidget::convertToGLFormat(image);
QImage im = image;///__GLWidget__::convertToGLFormat(image);
//const QImage & cim(im);
//glClearError();
//glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
@@ -139,7 +155,7 @@ void createGLTexture(GLuint & tex, const QImage & image, const GLenum & format,
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(target, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
}
glTexImage2D(target, 0, format, im.width(), im.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, im.bits());
glTexImage2D(target, 0, format, im.width(), im.height(), 0, GL_BGRA, GL_UNSIGNED_BYTE, im.bits());
//qDebug() << tex << im.width() << im.height() << im.bits() << glGetError();
}