git-svn-id: svn://db.shs.com.ru/libs@536 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -41,15 +41,9 @@
|
||||
# define CC_VC
|
||||
#endif
|
||||
|
||||
#if QT_VERSION < 0x050600
|
||||
# define GL_GLEXT_PROTOTYPES
|
||||
#endif
|
||||
|
||||
#include <QObject>
|
||||
#ifdef WINDOWS
|
||||
# if QT_VERSION < 0x050600
|
||||
# include "GLee.h"
|
||||
# endif
|
||||
#else
|
||||
#ifndef WINDOWS
|
||||
# ifdef MAC
|
||||
# include <OpenGL/gl.h>
|
||||
# include <OpenGL/glu.h>
|
||||
@@ -60,15 +54,12 @@
|
||||
# include <GL/glu.h>
|
||||
# endif
|
||||
#endif
|
||||
#if QT_VERSION < 0x050600
|
||||
# include <qgl.h>
|
||||
#else
|
||||
//# include "GLee.h"
|
||||
# include <QOpenGLExtraFunctions>
|
||||
#endif
|
||||
#include <QOpenGLExtraFunctions>
|
||||
#include <QOpenGLWidget>
|
||||
#include <QOpenGLShader>
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <cmath>
|
||||
#include <float.h>
|
||||
//#include <limits>
|
||||
#include <QMatrix4x4>
|
||||
#include <QDebug>
|
||||
#include <QDataStream>
|
||||
@@ -87,23 +78,7 @@
|
||||
# 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
|
||||
@@ -169,8 +144,7 @@ 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;
|
||||
//extern __GLWidget__ * currentQGLView;
|
||||
|
||||
inline void qglColor(const QColor & c) {glColor4f(c.redF(), c.greenF(), c.blueF(), c.alphaF());}
|
||||
void qglMultMatrix(const QMatrix4x4 & m);
|
||||
@@ -184,11 +158,10 @@ inline void glSetCapEnabled(GLenum cap, bool on = true) {if (on) glEnable(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(__GLShaderProgram__ * prog = 0, QVector4D * corner_dirs = 0, GLfloat x = -1.f, GLfloat y = -1.f, GLfloat w = 2.f, GLfloat h = 2.f);
|
||||
void glDrawQuad(QOpenGLShaderProgram * 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 if (!QOpenGLContext::currentContext()) return; QOpenGLExtraFunctions gf(QOpenGLContext::currentContext());
|
||||
# define QGLC gf.
|
||||
inline void glActiveTextureChannel(int channel) {QGLCI gf.glActiveTexture(GL_TEXTURE0 + channel);}
|
||||
@@ -200,19 +173,6 @@ inline void deleteGLFramebuffer(GLuint & fbo) {QGLCI if (fbo != 0) gf.glDeleteFr
|
||||
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());}
|
||||
@@ -367,6 +327,7 @@ class GLObjectBase;
|
||||
class QGLView;
|
||||
class Light;
|
||||
class Camera;
|
||||
class GLTextureManagerBase;
|
||||
|
||||
class QGLViewBase
|
||||
{
|
||||
@@ -376,9 +337,11 @@ public:
|
||||
Camera & camera();
|
||||
const Camera & camera() const;
|
||||
void setCamera(const Camera & camera);
|
||||
GLTextureManagerBase * textureManager();
|
||||
protected:
|
||||
virtual void collectLights() = 0;
|
||||
Camera * camera_;
|
||||
GLTextureManagerBase * m_texture_manager;
|
||||
};
|
||||
|
||||
#endif // GLTYPES_H
|
||||
|
||||
Reference in New Issue
Block a user