This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
YASMIN/ui/map/3D/gl/GL.h
2016-09-28 12:16:45 +02:00

83 lines
2.9 KiB
C

#ifndef HELPER_GL_H
#define HELPER_GL_H
#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLBuffer>
#include <QOpenGLTexture>
struct Vert {
QVector3D vert;
Vert(QVector3D vert) : vert(vert) {;}
int getVertOffset() const {return 0;}
bool operator == (const Vert& o) const {return (vert == o.vert);}
};
struct VertColor {
QVector3D vert;
QVector3D color;
VertColor(QVector3D vert, QVector3D color) : vert(vert), color(color) {;}
int getVertOffset() const {return 0;}
int getColorOffset() const {return sizeof(QVector3D);}
int getTanOffset() const {throw "error";}
int getNormOffset() const {throw "error";}
int getTexOffset() const {throw "error";}
bool operator == (const VertColor& o) const {return (vert == o.vert) && (color == o.color);}
static bool hasTangent() {return false;}
static bool hasColor() {return true;}
static bool hasNormal() {return false;}
static bool hasTexCoord() {return false;}
};
struct VertNorm {
QVector3D vert;
QVector3D norm;
VertNorm(QVector3D vert, QVector3D norm) : vert(vert), norm(norm) {;}
int getVertOffset() const {return 0;}
int getNormOffset() const {return sizeof(QVector3D);}
int getTanOffset() const {throw "error";}
int getColorOffset() const {throw "error";}
bool operator == (const VertNorm& o) const {return (vert == o.vert) && (norm == o.norm);}
static bool hasTangent() {return false;}
static bool hasNormal() {return true;}
static bool hasTexCoord() {return false;}
static bool hasColor() {return false;}
};
struct VertNormTex {
QVector3D vert;
QVector3D norm;
QVector2D tex;
VertNormTex(QVector3D vert, QVector3D norm, QVector3D tex) : vert(vert), norm(norm), tex(tex) {;}
int getVertOffset() const {return 0;}
int getNormOffset() const {return sizeof(QVector3D);}
int getTexOffset() const {return sizeof(QVector3D)*2;}
int getTanOffset() const {throw "error";}
int getColorOffset() const {throw "error";}
bool operator == (const VertNormTex& o) const {return (vert == o.vert) && (norm == o.norm) && (tex == o.tex);}
static bool hasTangent() {return false;}
static bool hasNormal() {return true;}
static bool hasTexCoord() {return true;}
static bool hasColor() {return false;}
};
struct VertNormTexTan {
QVector3D vert;
QVector3D norm;
QVector2D tex;
QVector3D tan;
VertNormTexTan(QVector3D vert, QVector3D norm, QVector3D tex, QVector3D tan) : vert(vert), norm(norm), tex(tex), tan(tan) {;}
int getVertOffset() const {return 0;}
int getNormOffset() const {return sizeof(QVector3D);}
int getTexOffset() const {return sizeof(QVector3D)*2;}
int getTanOffset() const {return sizeof(QVector3D)*2 + sizeof(QVector2D);}
int getColorOffset() const {throw "error";}
bool operator == (const VertNormTexTan& o) const {return (vert == o.vert) && (norm == o.norm) && (tex == o.tex) && (tan == o.tan);}
static bool hasTangent() {return true;}
static bool hasNormal() {return true;}
static bool hasTexCoord() {return true;}
static bool hasColor() {return false;}
};
#endif // HELPER_GL_H