src/GLShared.h

Mon, 10 Mar 2014 14:12:28 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Mon, 10 Mar 2014 14:12:28 +0200
changeset 698
16e6d7d87982
parent 681
c1cc036c6e1f
child 703
ce2a76cebdbb
permissions
-rw-r--r--

- refactor

674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2013, 2014 Santeri Piippo
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #ifndef LDFORGE_GLSHARED_H
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #define LDFORGE_GLSHARED_H
681
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
21 #include <QString>
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22
681
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
23 class LDObject;
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
24
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
25 struct LDPolygon
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 {
681
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
27 char num;
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
28 Vertex vertices[4];
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
29 int id;
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
30 int color;
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
31 QString origin;
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
32
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
33 inline int numVertices() const
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
34 {
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
35 return (num == 5) ? 4 : num;
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
36 }
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 };
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38
681
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
39 enum EVBOSurface
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
40 {
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
41 vboLines,
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
42 vboTriangles,
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
43 vboQuads,
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
44 vboCondLines,
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
45 vboNumSurfaces
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
46 };
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
47
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
48 enum EVBOComplement
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
49 {
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
50 vboSurfaces,
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
51 vboNormalColors,
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
52 vboPickColors,
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
53 vboBFCFrontColors,
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
54 vboBFCBackColors,
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
55 vboNumComplements
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
56 };
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
57
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
58 // KDevelop doesn't seem to understand some VBO stuff
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
59 #ifdef IN_IDE_PARSER
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
60 using GLenum = unsigned int;
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
61 using GLuint = unsigned int;
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
62 void glBindBuffer (GLenum, GLuint);
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
63 void glGenBuffers (GLuint, GLuint*);
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
64 void glDeleteBuffers (GLuint, GLuint*);
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
65 void glBufferData (GLuint, GLuint, void*, GLuint);
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
66 #endif
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
67
698
16e6d7d87982 - refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 681
diff changeset
68 static const int g_numVBOs = vboNumSurfaces * vboNumComplements;
681
c1cc036c6e1f - work on improved rendering performance
Santeri Piippo <crimsondusk64@gmail.com>
parents: 676
diff changeset
69
674
3d8ab0f89102 - refactoring
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 #endif // LDFORGE_GLSHARED_H

mercurial