Sun, 08 May 2016 15:26:58 +0300
- Refactoring...
- Camera icons don't have to be heap allocated anymore
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
1014
f0a8ecb6a357
Happy new year 2016!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
986
diff
changeset
|
3 | * Copyright (C) 2013 - 2016 Teemu Piippo |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
740
dbf9f1294d94
- apply #pragma once to glShared.h
Santeri Piippo <crimsondusk64@gmail.com>
parents:
739
diff
changeset
|
19 | #pragma once |
856
6bdc03091441
- and fixed compilation on linux systems too
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
20 | |
1023
9450ac3cd930
Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1014
diff
changeset
|
21 | #include "basics.h" |
856
6bdc03091441
- and fixed compilation on linux systems too
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
22 | #ifdef USE_QT5 |
6bdc03091441
- and fixed compilation on linux systems too
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
23 | # include <QOpenGLFunctions> |
6bdc03091441
- and fixed compilation on linux systems too
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
24 | #endif |
6bdc03091441
- and fixed compilation on linux systems too
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
25 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | class LDObject; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | struct LDPolygon |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | char num; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | Vertex vertices[4]; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | int id; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | int color; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | inline int numVertices() const |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | return (num == 5) ? 4 : num; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | }; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
41 | enum SurfaceVboType |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
43 | LinesVbo, |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
44 | TrianglesVbo, |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
45 | QuadsVbo, |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
46 | ConditionalLinesVbo, |
762
d259256e1394
- added a macro for adding operator++ and operator-- to enums, less cast hell this way
Santeri Piippo <crimsondusk64@gmail.com>
parents:
740
diff
changeset
|
47 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
48 | NumSurfaceVbos, |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
49 | FirstSurfaceVbo = LinesVbo |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | }; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | |
1033 | 52 | MAKE_ITERABLE_ENUM (SurfaceVboType, LinesVbo, ConditionalLinesVbo) |
53 | ||
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
54 | enum ComplementVboType |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
56 | SurfacesVboComplement, |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
57 | NormalColorsVboComplement, |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
58 | PickColorsVboComplement, |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
59 | BfcFrontColorsVboComplement, |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
60 | BfcBackColorsVboComplement, |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
61 | RandomColorsVboComplement, |
762
d259256e1394
- added a macro for adding operator++ and operator-- to enums, less cast hell this way
Santeri Piippo <crimsondusk64@gmail.com>
parents:
740
diff
changeset
|
62 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
63 | NumVboComplements, |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
64 | FirstVboComplement = SurfacesVboComplement |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | }; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | |
1033 | 67 | MAKE_ITERABLE_ENUM (ComplementVboType, SurfacesVboComplement, RandomColorsVboComplement) |
68 | ||
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
69 | enum |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
70 | { |
1033 | 71 | NumVbos = EnumLimits::SurfaceVboType::Count * EnumLimits::ComplementVboType::Count, |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
72 | }; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
73 | |
856
6bdc03091441
- and fixed compilation on linux systems too
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
74 | #ifndef USE_QT5 |
6bdc03091441
- and fixed compilation on linux systems too
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
75 | // Placeholder QOpenGLFunctions for Qt 4.x support |
6bdc03091441
- and fixed compilation on linux systems too
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
76 | struct QOpenGLFunctions |
6bdc03091441
- and fixed compilation on linux systems too
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
77 | { |
6bdc03091441
- and fixed compilation on linux systems too
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
78 | void initializeOpenGLFunctions() {} |
6bdc03091441
- and fixed compilation on linux systems too
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
79 | }; |
6bdc03091441
- and fixed compilation on linux systems too
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
80 | |
6bdc03091441
- and fixed compilation on linux systems too
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
81 | #endif |
6bdc03091441
- and fixed compilation on linux systems too
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
82 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | // KDevelop doesn't seem to understand some VBO stuff |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | #ifdef IN_IDE_PARSER |
708
3155f2c05f89
- more debugging...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
706
diff
changeset
|
85 | using GLint = int; |
3155f2c05f89
- more debugging...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
706
diff
changeset
|
86 | using GLsizei = int; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | using GLenum = unsigned int; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | using GLuint = unsigned int; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | void glBindBuffer (GLenum, GLuint); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | void glGenBuffers (GLuint, GLuint*); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
91 | void glDeleteBuffers (GLuint, GLuint*); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | void glBufferData (GLuint, GLuint, void*, GLuint); |
708
3155f2c05f89
- more debugging...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
706
diff
changeset
|
93 | void glBufferSubData (GLenum, GLint, GLsizei, void*); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | #endif |