Thu, 09 Feb 2017 20:44:36 +0200
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
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 |
1072 | 3 | * Copyright (C) 2013 - 2017 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 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #define GL_GLEXT_PROTOTYPES |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include <GL/glu.h> |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | #include <GL/glext.h> |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include "glCompiler.h" |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include "miscallenous.h" |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
24 | #include "guiutilities.h" |
1012 | 25 | #include "documentmanager.h" |
1023
9450ac3cd930
Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
26 | #include "grid.h" |
706
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 GLErrorInfo |
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 | GLenum value; |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
786
diff
changeset
|
31 | QString text; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | }; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | static const GLErrorInfo g_GLErrors[] = |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | { GL_NO_ERROR, "No error" }, |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | { GL_INVALID_ENUM, "Unacceptable enumerator passed" }, |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | { GL_INVALID_VALUE, "Numeric argument out of range" }, |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | { GL_INVALID_OPERATION, "The operation is not allowed to be done in this state" }, |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | { GL_INVALID_FRAMEBUFFER_OPERATION, "Framebuffer object is not complete"}, |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | { GL_OUT_OF_MEMORY, "Out of memory" }, |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | { GL_STACK_UNDERFLOW, "The operation would have caused an underflow" }, |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | { GL_STACK_OVERFLOW, "The operation would have caused an overflow" }, |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | }; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | |
970
c8aae45afd85
Commit configuration rework (doesn't work yet, more than most probably doesn't compile either)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
968
diff
changeset
|
46 | ConfigOption (QString SelectColorBlend = "#0080FF") |
717
fdc285e5952f
- reimplemented vertex snapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
716
diff
changeset
|
47 | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
48 | void CheckGLErrorImpl (const char* file, int line) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
49 | { |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
786
diff
changeset
|
50 | QString errmsg; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | GLenum errnum = glGetError(); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | if (errnum == GL_NO_ERROR) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | return; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
56 | for (const GLErrorInfo& err : g_GLErrors) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | if (err.value == errnum) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | errmsg = err.text; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | break; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
65 | print ("OpenGL ERROR: at %1:%2: %3", Basename (QString (file)), line, errmsg); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
68 | |
759
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
69 | GLCompiler::GLCompiler (GLRenderer* renderer) : |
971
c00f9665a9f8
Now compiles and links but crashes shortly after startup.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
970
diff
changeset
|
70 | HierarchyElement (renderer), |
759
038985b4a154
- added a selection hover effect to the renderer. selecting objects just became a lot more convenient...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
757
diff
changeset
|
71 | m_renderer (renderer) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | { |
1113
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
73 | connect(renderer->model(), SIGNAL(objectAdded(LDObject*)), this, SLOT(compileObject(LDObject*))); |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
74 | connect(renderer->model(), SIGNAL(objectModified(LDObject*)), this, SLOT(compileObject(LDObject*))); |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
75 | connect(renderer->model(), SIGNAL(aboutToRemoveObject(LDObject*)), this, SLOT(forgetObject(LDObject*)), Qt::DirectConnection); |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
76 | connect(renderer, SIGNAL(objectHighlightingChanged(LDObject*)), this, SLOT(compileObject(LDObject*))); |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
77 | connect(m_window, SIGNAL(gridChanged()), this, SLOT(recompile())); |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
78 | |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
79 | for (LDObject* object : renderer->model()->objects()) |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
80 | stageForCompilation(object); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
81 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
82 | |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
83 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | void GLCompiler::initialize() |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | { |
855
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
852
diff
changeset
|
86 | initializeOpenGLFunctions(); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
87 | glGenBuffers (NumVbos, &m_vbo[0]); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
88 | CHECK_GL_ERROR(); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
91 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | GLCompiler::~GLCompiler() |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
93 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
94 | glDeleteBuffers (NumVbos, &m_vbo[0]); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
95 | CHECK_GL_ERROR(); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
98 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
99 | QColor GLCompiler::indexColorForID (int id) const |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
100 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | // Calculate a color based from this index. This method caters for |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | // 16777216 objects. I don't think that will be exceeded anytime soon. :) |
1113
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
103 | int r = (id / 0x10000) % 0x100; |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
104 | int g = (id / 0x100) % 0x100; |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
105 | int b = id % 0x100; |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
106 | return {r, g, b}; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
109 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
110 | QColor GLCompiler::getColorForPolygon (LDPolygon& poly, LDObject* topobj, ComplementVboType complement) const |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
112 | QColor qcol; |
1113
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
113 | static const QColor bfcFrontColor {64, 192, 80}; |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
114 | static const QColor bfcBackColor {208, 64, 64}; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | |
726
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
116 | switch (complement) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
117 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
118 | case SurfacesVboComplement: |
1113
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
119 | return {}; |
726
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
120 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
121 | case BfcFrontColorsVboComplement: |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
122 | qcol = bfcFrontColor; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
123 | break; |
726
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
124 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
125 | case BfcBackColorsVboComplement: |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
126 | qcol = bfcBackColor; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
127 | break; |
726
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
128 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
129 | case PickColorsVboComplement: |
1113
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
130 | return indexColorForID(topobj->id()); |
726
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
131 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
132 | case RandomColorsVboComplement: |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
133 | qcol = topobj->randomColor(); |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
134 | break; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
135 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
136 | case NormalColorsVboComplement: |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
137 | if (poly.color == MainColor) |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
138 | { |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
139 | if (topobj->color() == MainColor) |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
140 | qcol = guiUtilities()->mainColorRepresentation(); |
726
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
141 | else |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
142 | qcol = topobj->color().faceColor(); |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
143 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
144 | else if (poly.color == EdgeColor) |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
145 | { |
1113
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
146 | qcol = luma(QColor (m_config->backgroundColor())) > 40 ? Qt::black : Qt::white; |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
147 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
148 | else |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
149 | { |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
150 | LDColor col = poly.color; |
726
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
151 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
152 | if (col.isValid()) |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
153 | qcol = col.faceColor(); |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
154 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
155 | break; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
156 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
157 | |
1113
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
158 | if (qcol.isValid()) |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
159 | { |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
160 | double blendAlpha = 0.0; |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
161 | |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
162 | if (topobj->isSelected()) |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
163 | blendAlpha = 1.0; |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
164 | else if (topobj == m_renderer->objectAtCursor()) |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
165 | blendAlpha = 0.5; |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
166 | |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
167 | if (blendAlpha != 0.0) |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
168 | { |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
169 | QColor selectedColor = m_config->selectColorBlend(); |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
170 | double denom = blendAlpha + 1.0; |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
171 | qcol.setRed((qcol.red() + (selectedColor.red() * blendAlpha)) / denom); |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
172 | qcol.setGreen((qcol.green() + (selectedColor.green() * blendAlpha)) / denom); |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
173 | qcol.setBlue((qcol.blue() + (selectedColor.blue() * blendAlpha)) / denom); |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
174 | } |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
175 | } |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
176 | else |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
177 | { |
717
fdc285e5952f
- reimplemented vertex snapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
716
diff
changeset
|
178 | // The color was unknown. Use main color to make the polygon at least |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
179 | // not appear pitch-black. |
890
903ec1e46298
- backed out work done on bfc (re-committing later)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
889
diff
changeset
|
180 | if (poly.num != 2 and poly.num != 5) |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
181 | qcol = guiUtilities()->mainColorRepresentation(); |
890
903ec1e46298
- backed out work done on bfc (re-committing later)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
889
diff
changeset
|
182 | else |
903ec1e46298
- backed out work done on bfc (re-committing later)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
889
diff
changeset
|
183 | qcol = Qt::black; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
184 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
185 | // Warn about the unknown color, but only once. |
1113
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
186 | static QSet<int> warnedColors; |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
187 | if (not warnedColors.contains(poly.color)) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
188 | { |
1113
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
189 | print("Unknown color %1!\n", poly.color); |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
190 | warnedColors.insert(poly.color); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
191 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
192 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
193 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
194 | return qcol; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
195 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
196 | |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
197 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
198 | void GLCompiler::needMerge() |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
199 | { |
1065
c8ecddbd99e9
Actually, let's call it countof(). Makes more sense.
Teemu Piippo <teemu@hecknology.net>
parents:
1063
diff
changeset
|
200 | for (int i = 0; i < countof (m_vboChanged); ++i) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
201 | m_vboChanged[i] = true; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
202 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
203 | |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
204 | |
944 | 205 | void GLCompiler::stageForCompilation (LDObject* obj) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
206 | { |
943
af81220741d9
Commit work done on code cleanup
Teemu Piippo <crimsondusk64@gmail.com>
parents:
920
diff
changeset
|
207 | m_staged << obj; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
208 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
209 | |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
210 | |
944 | 211 | void GLCompiler::unstage (LDObject* obj) |
721
4cf0f6c9082d
- now works with selection subfiling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
212 | { |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
213 | m_staged.remove (obj); |
721
4cf0f6c9082d
- now works with selection subfiling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
214 | } |
4cf0f6c9082d
- now works with selection subfiling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
215 | |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
216 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
217 | void GLCompiler::compileStaged() |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
218 | { |
1113
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
219 | for (LDObject* object : m_staged) |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
220 | compileObject(object); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
221 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
222 | m_staged.clear(); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
223 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
224 | |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
225 | |
1098
0b837bed121d
LDGLData merged into GLRenderer since it only deals with one document now. GLRenderer generalised from rendering documents to models.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
226 | void GLCompiler::prepareVBO (int vbonum, Model* model) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
227 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
228 | // Compile anything that still awaits it |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
229 | compileStaged(); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
230 | |
716
639a900999bc
- removed the debug code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
715
diff
changeset
|
231 | if (not m_vboChanged[vbonum]) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
232 | return; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
233 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
234 | QVector<GLfloat> vbodata; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
235 | |
883
69b8adc9a669
- fixed: due to a shared pointer called via reference called dismiss() in LDDocument::closeInitialFile, this could cause LDDocuments to delete themselves in setImplicit(true) as no shared pointers were left inside closeInitialFile to keep the refcount up.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
236 | for (auto it = m_objectInfo.begin(); it != m_objectInfo.end();) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
237 | { |
984 | 238 | if (it.key() == nullptr) |
883
69b8adc9a669
- fixed: due to a shared pointer called via reference called dismiss() in LDDocument::closeInitialFile, this could cause LDDocuments to delete themselves in setImplicit(true) as no shared pointers were left inside closeInitialFile to keep the refcount up.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
239 | { |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
772
diff
changeset
|
240 | it = m_objectInfo.erase (it); |
886
3c83fe3486b1
- fixed endless loop in prepareVBO due to badly incremented iterator
Teemu Piippo <crimsondusk64@gmail.com>
parents:
883
diff
changeset
|
241 | continue; |
883
69b8adc9a669
- fixed: due to a shared pointer called via reference called dismiss() in LDDocument::closeInitialFile, this could cause LDDocuments to delete themselves in setImplicit(true) as no shared pointers were left inside closeInitialFile to keep the refcount up.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
861
diff
changeset
|
242 | } |
886
3c83fe3486b1
- fixed endless loop in prepareVBO due to badly incremented iterator
Teemu Piippo <crimsondusk64@gmail.com>
parents:
883
diff
changeset
|
243 | |
1098
0b837bed121d
LDGLData merged into GLRenderer since it only deals with one document now. GLRenderer generalised from rendering documents to models.
Teemu Piippo <teemu@hecknology.net>
parents:
1086
diff
changeset
|
244 | if (it.key()->model() == model and not it.key()->isHidden()) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
245 | vbodata += it->data[vbonum]; |
886
3c83fe3486b1
- fixed endless loop in prepareVBO due to badly incremented iterator
Teemu Piippo <crimsondusk64@gmail.com>
parents:
883
diff
changeset
|
246 | |
3c83fe3486b1
- fixed endless loop in prepareVBO due to badly incremented iterator
Teemu Piippo <crimsondusk64@gmail.com>
parents:
883
diff
changeset
|
247 | ++it; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
248 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
249 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
250 | glBindBuffer (GL_ARRAY_BUFFER, m_vbo[vbonum]); |
1065
c8ecddbd99e9
Actually, let's call it countof(). Makes more sense.
Teemu Piippo <teemu@hecknology.net>
parents:
1063
diff
changeset
|
251 | glBufferData (GL_ARRAY_BUFFER, countof(vbodata) * sizeof(GLfloat), vbodata.constData(), GL_STATIC_DRAW); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
252 | glBindBuffer (GL_ARRAY_BUFFER, 0); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
253 | CHECK_GL_ERROR(); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
254 | m_vboChanged[vbonum] = false; |
1065
c8ecddbd99e9
Actually, let's call it countof(). Makes more sense.
Teemu Piippo <teemu@hecknology.net>
parents:
1063
diff
changeset
|
255 | m_vboSizes[vbonum] = countof(vbodata); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
256 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
257 | |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
258 | |
1113
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
259 | void GLCompiler::dropObjectInfo(LDObject* object) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
260 | { |
1113
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
261 | if (m_objectInfo.contains(object)) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
262 | { |
1113
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
263 | m_objectInfo.remove(object); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
264 | needMerge(); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
265 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
266 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
267 | |
1113
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
268 | void GLCompiler::forgetObject(LDObject* object) |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
269 | { |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
270 | dropObjectInfo(object); |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
271 | m_staged.remove(object); |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
272 | } |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
273 | |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
274 | |
944 | 275 | void GLCompiler::compileObject (LDObject* obj) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
276 | { |
1073
a0a0d581309b
Major overhaul of object→document relationship: added the Model class which models the object buffer. Each object is to be included in a model (an invariant that currently does not hold). A document is a subclass of a model. The LDObject is also now agnostic about selection, and the selection is now a set. A lot of things are probably broken now but it's a major step forward.
Teemu Piippo <teemu@hecknology.net>
parents:
1072
diff
changeset
|
277 | if (obj == nullptr) |
708
3155f2c05f89
- more debugging...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
706
diff
changeset
|
278 | return; |
3155f2c05f89
- more debugging...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
706
diff
changeset
|
279 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
280 | ObjectVBOInfo info; |
713
46377d340c23
- more debug stuff....
Santeri Piippo <crimsondusk64@gmail.com>
parents:
708
diff
changeset
|
281 | info.isChanged = true; |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
971
diff
changeset
|
282 | dropObjectInfo (obj); |
726
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
283 | |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
284 | switch (obj->type()) |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
285 | { |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
286 | // Note: We cannot split quads into triangles here, it would mess up the wireframe view. |
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
287 | // Quads must go into separate vbos. |
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
288 | case OBJ_Triangle: |
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
289 | case OBJ_Quad: |
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
290 | case OBJ_Line: |
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
291 | case OBJ_CondLine: |
726
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
292 | { |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
293 | LDPolygon* poly = obj->getPolygon(); |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
294 | poly->id = obj->id(); |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
295 | compilePolygon (*poly, obj, &info); |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
296 | delete poly; |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
297 | break; |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
298 | } |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
299 | |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
300 | case OBJ_SubfileReference: |
726
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
301 | { |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
302 | LDSubfileReference* ref = static_cast<LDSubfileReference*> (obj); |
726
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
303 | auto data = ref->inlinePolygons(); |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
304 | |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
305 | for (LDPolygon& poly : data) |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
306 | { |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
307 | poly.id = obj->id(); |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
308 | compilePolygon (poly, obj, &info); |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
309 | } |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
310 | break; |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
311 | } |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
312 | |
1004
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
998
diff
changeset
|
313 | case OBJ_BezierCurve: |
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
998
diff
changeset
|
314 | { |
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
998
diff
changeset
|
315 | LDBezierCurve* curve = static_cast<LDBezierCurve*> (obj); |
1023
9450ac3cd930
Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
316 | for (LDPolygon& polygon : curve->rasterizePolygons(grid()->bezierCurveSegments())) |
1004
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
998
diff
changeset
|
317 | { |
1023
9450ac3cd930
Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
318 | polygon.id = obj->id(); |
9450ac3cd930
Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
319 | compilePolygon (polygon, obj, &info); |
1004
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
998
diff
changeset
|
320 | } |
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
998
diff
changeset
|
321 | } |
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
998
diff
changeset
|
322 | break; |
ba4200437179
Bézier curves now render in 3D
Teemu Piippo <crimsondusk64@gmail.com>
parents:
998
diff
changeset
|
323 | |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
324 | default: |
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
325 | break; |
726
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
326 | } |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
327 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
328 | m_objectInfo[obj] = info; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
329 | needMerge(); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
330 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
331 | |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
332 | |
944 | 333 | void GLCompiler::compilePolygon (LDPolygon& poly, LDObject* topobj, ObjectVBOInfo* objinfo) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
334 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
335 | SurfaceVboType surface; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
336 | int numverts; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
337 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
338 | switch (poly.num) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
339 | { |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
340 | case 2: surface = LinesVbo; numverts = 2; break; |
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
341 | case 3: surface = TrianglesVbo; numverts = 3; break; |
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
342 | case 4: surface = QuadsVbo; numverts = 4; break; |
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
343 | case 5: surface = ConditionalLinesVbo; numverts = 2; break; |
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
344 | default: return; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
345 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
346 | |
1036
993c46d7eb75
Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents:
1035
diff
changeset
|
347 | for (ComplementVboType complement : iterateEnum<ComplementVboType>()) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
348 | { |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
349 | const int vbonum = vboNumber (surface, complement); |
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
350 | QVector<GLfloat>& vbodata = objinfo->data[vbonum]; |
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
351 | const QColor color = getColorForPolygon (poly, topobj, complement); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
352 | |
890
903ec1e46298
- backed out work done on bfc (re-committing later)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
889
diff
changeset
|
353 | for (int vert = 0; vert < numverts; ++vert) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
354 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
355 | if (complement == SurfacesVboComplement) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
356 | { |
726
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
357 | // Write coordinates. Apparently Z must be flipped too? |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
358 | vbodata << poly.vertices[vert].x() |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
359 | << -poly.vertices[vert].y() |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
360 | << -poly.vertices[vert].z(); |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
361 | } |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
362 | else |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
363 | { |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
364 | vbodata << ((GLfloat) color.red()) / 255.0f |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
365 | << ((GLfloat) color.green()) / 255.0f |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
366 | << ((GLfloat) color.blue()) / 255.0f |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
367 | << ((GLfloat) color.alpha()) / 255.0f; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
368 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
369 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
370 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
371 | } |
857
e62983881460
- fixed crash-on-exit (simply by not running full destruction processing during program termination)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
372 | |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
373 | |
857
e62983881460
- fixed crash-on-exit (simply by not running full destruction processing during program termination)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
374 | void GLCompiler::setRenderer (GLRenderer* renderer) |
e62983881460
- fixed crash-on-exit (simply by not running full destruction processing during program termination)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
375 | { |
e62983881460
- fixed crash-on-exit (simply by not running full destruction processing during program termination)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
376 | m_renderer = renderer; |
e62983881460
- fixed crash-on-exit (simply by not running full destruction processing during program termination)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
377 | } |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
378 | |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
379 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
380 | int GLCompiler::vboNumber (SurfaceVboType surface, ComplementVboType complement) |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
381 | { |
1036
993c46d7eb75
Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents:
1035
diff
changeset
|
382 | return (surface * EnumLimits<ComplementVboType>::Count) + complement; |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
383 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
384 | |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
385 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
386 | GLuint GLCompiler::vbo (int vbonum) const |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
387 | { |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
388 | return m_vbo[vbonum]; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
389 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
390 | |
1011
4fdd74a04790
Rename LDSubfile to LDSubfileReference
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1006
diff
changeset
|
391 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
392 | int GLCompiler::vboSize (int vbonum) const |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
393 | { |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
394 | return m_vboSizes[vbonum]; |
1113
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
395 | } |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
396 | |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
397 | |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
398 | void GLCompiler::recompile() |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
399 | { |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
400 | for (LDObject* object : m_renderer->model()->objects()) |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
401 | compileObject(object); |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1098
diff
changeset
|
402 | } |