149 lines
3.5 KiB
C++
149 lines
3.5 KiB
C++
/*
|
|
QGLView
|
|
Copyright (C) 2019 Ivan Pelipenko peri4ko@yandex.ru
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef GLSHADERS_TYPES_H
|
|
#define GLSHADERS_TYPES_H
|
|
|
|
#include "gltypes.h"
|
|
|
|
namespace QGLEngineShaders {
|
|
|
|
|
|
/// VBO
|
|
|
|
// geometry
|
|
const GLsizei pos_offset = 0;
|
|
const GLsizei normal_offset = sizeof(QVector3D) + pos_offset ;
|
|
const GLsizei tangent_offset = sizeof(QVector3D) + normal_offset ;
|
|
const GLsizei bitangent_offset = sizeof(QVector3D) + tangent_offset ;
|
|
const GLsizei tex_offset = sizeof(QVector3D) + bitangent_offset;
|
|
|
|
// object
|
|
const GLsizei material_offset = 0;
|
|
const GLsizei object_id_offset = sizeof(GLuint ) + material_offset ;
|
|
const GLsizei color_offset = sizeof(GLuint ) + object_id_offset ;
|
|
const GLsizei modelmatrix_offset = sizeof(QVector4D) + color_offset;
|
|
|
|
const GLsizei is_selected_offset = 0;
|
|
|
|
const GLuint pos_loc = 1 ; // qgl_Vertex
|
|
const GLuint normal_loc = 2 ; // qgl_Normal
|
|
const GLuint tangent_loc = 3 ; // qgl_Tangent
|
|
const GLuint bitangent_loc = 4 ; // qgl_Bitangent
|
|
const GLuint tex_loc = 5 ; // qgl_Texture
|
|
|
|
const GLuint material_loc = 6 ; // qgl_Material
|
|
const GLuint object_id_loc = 8 ; // qgl_ObjectID
|
|
const GLuint color_loc = 9 ; // qgl_ObjectColor
|
|
const GLuint modelmatrix_loc = 10; // qgl_ModelViewProjectionMatrix
|
|
|
|
const GLuint is_selected_loc = 7 ; // qgl_ObjectSelected
|
|
|
|
#pragma pack(push, 1)
|
|
struct Vertex {
|
|
QVector3D pos;
|
|
QVector3D normal;
|
|
QVector3D tangent;
|
|
QVector3D bitangent;
|
|
QVector2D tex;
|
|
};
|
|
struct Object {
|
|
Object() {
|
|
material = object_id = 0;
|
|
color = QVector4D(1,1,1,1);
|
|
QMatrix4x4().copyDataTo(modelmatrix);
|
|
}
|
|
GLuint material;
|
|
GLuint object_id;
|
|
QVector4D color;
|
|
GLfloat modelmatrix[16];
|
|
};
|
|
#pragma pack(pop)
|
|
|
|
|
|
/// UBO
|
|
|
|
enum BindingPoints {
|
|
bpMaterials,
|
|
bpLightParameters,
|
|
bpLightPositions,
|
|
};
|
|
|
|
enum MapType {
|
|
mtDiffuse = 0,
|
|
mtNormal = 1,
|
|
mtSpecular = 2,
|
|
mtRoughness = 3,
|
|
mtEmission = 4,
|
|
mtRelief = 5,
|
|
};
|
|
enum TextureArrayRole {
|
|
tarEmpty = 0,
|
|
tarMaps = 1,
|
|
};
|
|
enum EmptyMapRole {
|
|
emrWhite = 0,
|
|
emrBlue = 1,
|
|
};
|
|
#define QGL_MAPS_COUNT 6
|
|
#pragma pack(push, 1)
|
|
struct QGLMap {
|
|
QGLMap();
|
|
GLfloat offset;
|
|
GLfloat amount;
|
|
QVector2D scale;
|
|
GLuint array_index;
|
|
GLuint map_index;
|
|
GLfloat __res_2[2];
|
|
};
|
|
struct QGLMaterial {
|
|
QGLMaterial();
|
|
QVector4D color_diffuse;
|
|
QVector4D color_specular;
|
|
QVector4D color_emission;
|
|
GLfloat transparency;
|
|
GLfloat reflectivity;
|
|
GLfloat iof;
|
|
GLfloat dispersion;
|
|
QGLMap map[QGL_MAPS_COUNT];
|
|
};
|
|
struct QGLLightParameter {
|
|
QVector4D color;
|
|
//QVector4D shadowColor;
|
|
GLfloat intensity;
|
|
GLfloat startAngle;
|
|
GLfloat startAngleCos;
|
|
GLfloat endAngle;
|
|
GLfloat endAngleCos;
|
|
GLfloat constantAttenuation;
|
|
GLfloat linearAttenuation;
|
|
GLfloat quadraticAttenuation;
|
|
//GLfloat shadow;
|
|
//GLfloat shadowMatrix[16];
|
|
};
|
|
struct QGLLightPosition {
|
|
QVector4D position;
|
|
QVector4D direction;
|
|
};
|
|
#pragma pack(pop)
|
|
|
|
|
|
}
|
|
|
|
#endif // GLSHADERS_TYPES_H
|