git-svn-id: svn://db.shs.com.ru/libs@286 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -41,9 +41,14 @@
|
||||
# define CC_VC
|
||||
#endif
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#if QT_VERSION < 0x050600
|
||||
# define GL_GLEXT_PROTOTYPES
|
||||
#endif
|
||||
#include <QObject>
|
||||
#ifdef WINDOWS
|
||||
# include "GLee.h"
|
||||
# if QT_VERSION < 0x050600
|
||||
# include "GLee.h"
|
||||
# endif
|
||||
#else
|
||||
# ifdef MAC
|
||||
# include <OpenGL/gl.h>
|
||||
@@ -55,12 +60,16 @@
|
||||
# include <GL/glu.h>
|
||||
# endif
|
||||
#endif
|
||||
#include <qgl.h>
|
||||
#if QT_VERSION < 0x050600
|
||||
# include <qgl.h>
|
||||
#else
|
||||
//# include "GLee.h"
|
||||
# include <QOpenGLExtraFunctions>
|
||||
#endif
|
||||
#include <cmath>
|
||||
#include <float.h>
|
||||
//#include <limits>
|
||||
#include <QMatrix4x4>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QDataStream>
|
||||
#include <QColor>
|
||||
@@ -70,7 +79,6 @@
|
||||
#include <QMutex>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QGLShaderProgram>
|
||||
#ifndef QNX
|
||||
# include <cmath>
|
||||
# include <complex>
|
||||
@@ -79,6 +87,23 @@
|
||||
# include <complex.h>
|
||||
#endif
|
||||
#include <iostream>
|
||||
#if QT_VERSION >= 0x050400
|
||||
# include <QOpenGLWidget>
|
||||
# include <QOpenGLShader>
|
||||
# include <QOpenGLShaderProgram>
|
||||
typedef QOpenGLWidget __GLWidget__;
|
||||
typedef QOpenGLContext __GLContext__;
|
||||
typedef QOpenGLShader __GLShader__;
|
||||
typedef QOpenGLShaderProgram __GLShaderProgram__;
|
||||
#else
|
||||
# include <QGLWidget>
|
||||
# include <QGLShader>
|
||||
# include <QGLShaderProgram>
|
||||
typedef QGLWidget __GLWidget__;
|
||||
typedef QGLContext __GLContext__;
|
||||
typedef QGLShader __GLShader__;
|
||||
typedef QGLShaderProgram __GLShaderProgram__;
|
||||
#endif
|
||||
|
||||
#ifdef WINDOWS
|
||||
# define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
|
||||
@@ -140,31 +165,50 @@ QString findFile(const QString & file, const QStringList & pathes);
|
||||
inline QColor operator *(const QColor & c, double v) {return QColor(c.red() * v, c.green() * v, c.blue() * v, c.alpha() * v);}
|
||||
inline QColor operator /(const QColor & c, double v) {return QColor(c.red() / v, c.green() / v, c.blue() / v, c.alpha() / v);}
|
||||
|
||||
extern __GLWidget__ * currentQGLView;
|
||||
extern QMutex globMutex;
|
||||
|
||||
inline void qglColor(const QColor & c) {glColor4f(c.redF(), c.greenF(), c.blueF(), c.alphaF());}
|
||||
void qglMultMatrix(const QMatrix4x4 & m);
|
||||
void glEnableDepth();
|
||||
void glDisableDepth();
|
||||
inline void glActiveTextureChannel(int channel) {glActiveTexture(GL_TEXTURE0 + channel); glClientActiveTexture(GL_TEXTURE0 + channel);}
|
||||
inline void glResetAllTransforms() {glMatrixMode(GL_TEXTURE); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity();}
|
||||
inline void glClearError() {int c = 100; while (glGetError() != GL_NO_ERROR && --c > 0) glGetError();}
|
||||
inline void glClearAccumulation(const QColor & color = Qt::black) {glClearAccum(color.redF(), color.greenF(), color.blueF(), color.alphaF()); glClear(GL_ACCUM_BUFFER_BIT);}
|
||||
void glClearFramebuffer(const QColor & color = Qt::black, bool depth = true);
|
||||
inline void glReleaseTextures(int channels = 8) {for (int i = channels - 1; i >= 0; --i) {glActiveTextureChannel(i); glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_CUBE_MAP, 0);}}
|
||||
inline void glReleaseFramebuffer() {glBindFramebuffer(GL_FRAMEBUFFER, 0);}
|
||||
inline void glDisableTextures(int channels = 8) {for (int i = channels - 1; i >= 0; --i) {glActiveTextureChannel(i); glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_CUBE_MAP);}}
|
||||
inline void glReleaseShaders() {glUseProgram(0);}
|
||||
inline void glSetCapEnabled(GLenum cap, bool on = true) {if (on) glEnable(cap); else glDisable(cap);}
|
||||
inline void glSetLightEnabled(bool on) {if (on) glEnable(GL_LIGHTING); else glDisable(GL_LIGHTING);}
|
||||
inline void glSetFogEnabled(bool on) {if (on) glEnable(GL_FOG); else glDisable(GL_FOG);}
|
||||
inline void glSetPolygonMode(GLenum mode) {glPolygonMode(GL_FRONT_AND_BACK, mode);}
|
||||
void glDrawQuad(QGLShaderProgram * prog = 0, QVector4D * corner_dirs = 0, GLfloat x = -1.f, GLfloat y = -1.f, GLfloat w = 2.f, GLfloat h = 2.f);
|
||||
void glDrawQuad(__GLShaderProgram__ * prog = 0, QVector4D * corner_dirs = 0, GLfloat x = -1.f, GLfloat y = -1.f, GLfloat w = 2.f, GLfloat h = 2.f);
|
||||
QMatrix4x4 getGLMatrix(GLenum matrix);
|
||||
void setGLMatrix(QMatrix4x4 matrix);
|
||||
inline void deleteGLTexture(GLuint & tex) {if (tex != 0) glDeleteTextures(1, &tex); tex = 0;}
|
||||
#if QT_VERSION >= 0x050600
|
||||
# define QGLCI QOpenGLExtraFunctions gf(QOpenGLContext::currentContext());
|
||||
# define QGLC gf.
|
||||
inline void glActiveTextureChannel(int channel) {QGLCI gf.glActiveTexture(GL_TEXTURE0 + channel);}
|
||||
inline void glDisableTextures(int channels = 8) {QGLCI for (int i = channels - 1; i >= 0; --i) {glActiveTextureChannel(i); glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_CUBE_MAP);}}
|
||||
inline void glReleaseTextures(int channels = 8) {QGLCI for (int i = channels - 1; i >= 0; --i) {glActiveTextureChannel(i); glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_CUBE_MAP, 0);}}
|
||||
inline void glReleaseFramebuffer() {QGLCI gf.glBindFramebuffer(GL_FRAMEBUFFER, 0);}
|
||||
inline void glReleaseShaders() {QGLCI gf.glUseProgram(0);}
|
||||
inline void deleteGLFramebuffer(GLuint & fbo) {QGLCI if (fbo != 0) gf.glDeleteFramebuffers(1, &fbo); fbo = 0;}
|
||||
inline void deleteGLRenderbuffer(GLuint & drbo) {QGLCI if (drbo != 0) gf.glDeleteRenderbuffers(1, &drbo); drbo = 0;}
|
||||
inline void deleteGLBuffer(GLuint & bo) {QGLCI if (bo != 0) gf.glDeleteBuffers(1, &bo); bo = 0;}
|
||||
inline void deleteGLVertexArray(GLuint & va) {QGLCI if (va != 0) gf.glDeleteVertexArrays(1, &va); va = 0;}
|
||||
#else
|
||||
# define QGLCI
|
||||
# define QGLC
|
||||
inline void glActiveTextureChannel(int channel) {glActiveTexture(GL_TEXTURE0 + channel); glClientActiveTexture(GL_TEXTURE0 + channel);}
|
||||
inline void glDisableTextures(int channels = 8) {for (int i = channels - 1; i >= 0; --i) {glActiveTextureChannel(i); glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_CUBE_MAP);}}
|
||||
inline void glReleaseTextures(int channels = 8) {for (int i = channels - 1; i >= 0; --i) {glActiveTextureChannel(i); glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_CUBE_MAP, 0);}}
|
||||
inline void glReleaseFramebuffer() {glBindFramebuffer(GL_FRAMEBUFFER, 0);}
|
||||
inline void glReleaseShaders() {glUseProgram(0);}
|
||||
inline void deleteGLFramebuffer(GLuint & fbo) {if (fbo != 0) glDeleteFramebuffers(1, &fbo); fbo = 0;}
|
||||
inline void deleteGLRenderbuffer(GLuint & drbo) {if (drbo != 0) glDeleteRenderbuffers(1, &drbo); drbo = 0;}
|
||||
inline void deleteGLBuffer(GLuint & bo) {if (bo != 0) glDeleteBuffers(1, &bo); bo = 0;}
|
||||
inline void deleteGLVertexArray(GLuint & va) {if (va != 0) glDeleteVertexArrays(1, &va); va = 0;}
|
||||
#endif
|
||||
void createGLTexture(GLuint & tex, int width, int height, const GLenum & format = GL_RGBA8, const GLenum & target = GL_TEXTURE_2D);
|
||||
void createGLTexture(GLuint & tex, const QImage & image, const GLenum & format = GL_RGBA8, const GLenum & target = GL_TEXTURE_2D);
|
||||
inline void qglTranslate(const QVector3D & v) {glTranslated(v.x(), v.y(), v.z());}
|
||||
@@ -176,9 +220,6 @@ inline QImage rotateQImage180(const QImage & im) {return im.mirrored(true, true)
|
||||
//const double deg2rad = atan(1.) / 45.;
|
||||
//const double rad2deg = 45. / atan(1.);
|
||||
|
||||
extern QGLWidget * currentQGLView;
|
||||
extern QMutex globMutex;
|
||||
|
||||
struct Box3D {
|
||||
GLfloat x;
|
||||
GLfloat y;
|
||||
|
||||
Reference in New Issue
Block a user