Wed, 05 Nov 2014 02:07:38 +0200
- merged bfc with default
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 |
844
11587d419d2f
- changed copyright lines to use my legal name instead of my nickname
Teemu Piippo <crimsondusk64@gmail.com>
parents:
840
diff
changeset
|
3 | * Copyright (C) 2013, 2014 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 "ldObject.h" |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include "colors.h" |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | #include "ldDocument.h" |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | #include "miscallenous.h" |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | #include "glRenderer.h" |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | #include "dialogs.h" |
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 | struct GLErrorInfo |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | GLenum value; |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
786
diff
changeset
|
33 | QString text; |
706
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 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | static const GLErrorInfo g_GLErrors[] = |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | { GL_NO_ERROR, "No error" }, |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | { GL_INVALID_ENUM, "Unacceptable enumerator passed" }, |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | { GL_INVALID_VALUE, "Numeric argument out of range" }, |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | { 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
|
42 | { GL_INVALID_FRAMEBUFFER_OPERATION, "Framebuffer object is not complete"}, |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | { GL_OUT_OF_MEMORY, "Out of memory" }, |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | { GL_STACK_UNDERFLOW, "The operation would have caused an underflow" }, |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | { GL_STACK_OVERFLOW, "The operation would have caused an overflow" }, |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | }; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | |
850
a3d72b0e916d
- changed configuration entry name from minuscule camelCase to majuscule CamelCase. reasoning for this being that these variables are globals.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
844
diff
changeset
|
48 | CFGENTRY (String, SelectColorBlend, "#0080FF") |
852
cbd89b33f70d
- down with all these unnecessary semicolons!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
850
diff
changeset
|
49 | EXTERN_CFGENTRY (Bool, BlackEdges) |
cbd89b33f70d
- down with all these unnecessary semicolons!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
850
diff
changeset
|
50 | EXTERN_CFGENTRY (String, BackgroundColor) |
717
fdc285e5952f
- reimplemented vertex snapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
716
diff
changeset
|
51 | |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
762
diff
changeset
|
52 | // static QMap<LDObjectPtr, String> g_objectOrigins; |
721
4cf0f6c9082d
- now works with selection subfiling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
53 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
54 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
55 | // |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
56 | void CheckGLErrorImpl (const char* file, int line) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
57 | { |
789
4b7306f52bb5
- String -> QString
Santeri Piippo <crimsondusk64@gmail.com>
parents:
786
diff
changeset
|
58 | QString errmsg; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | GLenum errnum = glGetError(); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | if (errnum == GL_NO_ERROR) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | return; |
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 | for (const GLErrorInfo& err : g_GLErrors) |
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 | if (err.value == errnum) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | errmsg = err.text; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | break; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
73 | 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
|
74 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | // |
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
|
78 | GLCompiler::GLCompiler (GLRenderer* renderer) : |
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
|
79 | m_renderer (renderer) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
81 | needMerge(); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
82 | memset (m_vboSizes, 0, sizeof m_vboSizes); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | // |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | void GLCompiler::initialize() |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | { |
855
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
852
diff
changeset
|
89 | initializeOpenGLFunctions(); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | glGenBuffers (g_numVBOs, &m_vbo[0]); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
91 | CHECK_GL_ERROR(); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
93 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | // |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | GLCompiler::~GLCompiler() |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
98 | glDeleteBuffers (g_numVBOs, &m_vbo[0]); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
99 | CHECK_GL_ERROR(); |
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
|
100 | |
e62983881460
- fixed crash-on-exit (simply by not running full destruction processing during program termination)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
101 | if (m_renderer != null) |
e62983881460
- fixed crash-on-exit (simply by not running full destruction processing during program termination)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
102 | m_renderer->setCompiler (null); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
105 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | // |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | uint32 GLCompiler::colorToRGB (const QColor& color) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
109 | return |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
110 | (color.red() & 0xFF) << 0x00 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
111 | (color.green() & 0xFF) << 0x08 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
112 | (color.blue() & 0xFF) << 0x10 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
113 | (color.alpha() & 0xFF) << 0x18; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
117 | // |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
118 | QColor GLCompiler::indexColorForID (int id) const |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
119 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
120 | // Calculate a color based from this index. This method caters for |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
121 | // 16777216 objects. I don't think that will be exceeded anytime soon. :) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | int r = (id / 0x10000) % 0x100, |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
123 | g = (id / 0x100) % 0x100, |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
124 | b = id % 0x100; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
125 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
126 | return QColor (r, g, b); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
128 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
129 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
130 | // |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
762
diff
changeset
|
131 | QColor GLCompiler::getColorForPolygon (LDPolygon& poly, LDObjectPtr topobj, |
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
|
132 | EVBOComplement complement) const |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
133 | { |
891
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
134 | static const QColor bfcFrontColor (64, 192, 80); |
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
135 | static const QColor bfcBackColor (208, 64, 64); |
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
136 | static const QColor bfcDisabledColor (64, 64, 208); |
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
137 | static QList<int> warnedcolors; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
138 | QColor qcol; |
891
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
139 | print ("Winding of %1 is %2", poly.id, (int) poly.winding); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
140 | |
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 | switch (complement) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
142 | { |
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
|
143 | case VBOCM_Surfaces: |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
144 | case VBOCM_NumComplements: |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
145 | return QColor(); |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
146 | |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
147 | case VBOCM_BFCFrontColors: |
891
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
148 | qcol = (poly.winding != Winding::None) ? bfcFrontColor : bfcDisabledColor; |
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
|
149 | 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
|
150 | |
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 | case VBOCM_BFCBackColors: |
891
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
152 | qcol = (poly.winding != Winding::None) ? bfcBackColor : bfcDisabledColor; |
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
|
153 | 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
|
154 | |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
155 | case VBOCM_PickColors: |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
156 | return indexColorForID (topobj->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
|
157 | |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
158 | case VBOCM_RandomColors: |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
159 | qcol = topobj->randomColor(); |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
160 | break; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
161 | |
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
|
162 | case VBOCM_NormalColors: |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
163 | if (poly.color == MainColorIndex) |
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
|
164 | { |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
165 | if (topobj->color() == MainColor()) |
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
|
166 | qcol = GLRenderer::getMainColor(); |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
167 | else |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
168 | qcol = topobj->color().faceColor(); |
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
|
169 | } |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
170 | elif (poly.color == EdgeColorIndex) |
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
|
171 | { |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
172 | qcol = Luma (QColor (cfg::BackgroundColor)) > 40 ? Qt::black : Qt::white; |
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
|
173 | } |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
174 | 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
|
175 | { |
795
195fa1fff9c3
- changed all color usage to use LDColor classes instead of color indices. Added support for direct colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
176 | LDColor col = LDColor::fromIndex (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
|
177 | |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
178 | if (col) |
806
4240f47aa2d4
- moved most of LDColorData API into LDColor
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
179 | qcol = col.faceColor(); |
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
|
180 | } |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
181 | break; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
182 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
183 | |
717
fdc285e5952f
- reimplemented vertex snapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
716
diff
changeset
|
184 | if (not qcol.isValid()) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
185 | { |
717
fdc285e5952f
- reimplemented vertex snapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
716
diff
changeset
|
186 | // 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
|
187 | // not appear pitch-black. |
891
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
188 | qcol = (poly.num != 2 and poly.num != 5) ? GLRenderer::getMainColor() : Qt::black; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
189 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
190 | // Warn about the unknown color, but only once. |
891
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
191 | if (not warnedcolors.contains (poly.color)) |
706
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 | print ("Unknown color %1!\n", poly.color); |
891
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
194 | warnedcolors << poly.color; |
706
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 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
197 | return qcol; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
198 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
199 | |
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
|
200 | double blendAlpha = 0.0; |
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
|
201 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
202 | if (topobj->isSelected()) |
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
|
203 | blendAlpha = 1.0; |
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
|
204 | elif (topobj == m_renderer->objectAtCursor()) |
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
|
205 | blendAlpha = 0.5; |
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
|
206 | |
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
|
207 | if (blendAlpha != 0.0) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
208 | { |
850
a3d72b0e916d
- changed configuration entry name from minuscule camelCase to majuscule CamelCase. reasoning for this being that these variables are globals.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
844
diff
changeset
|
209 | QColor selcolor (cfg::SelectColorBlend); |
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
|
210 | double denom = blendAlpha + 1.0; |
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
|
211 | qcol.setRed ((qcol.red() + (selcolor.red() * blendAlpha)) / denom); |
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
|
212 | qcol.setGreen ((qcol.green() + (selcolor.green() * blendAlpha)) / denom); |
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
|
213 | qcol.setBlue ((qcol.blue() + (selcolor.blue() * blendAlpha)) / denom); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
214 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
215 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
216 | return qcol; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
217 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
218 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
219 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
220 | // |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
221 | void GLCompiler::needMerge() |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
222 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
223 | for (int i = 0; i < countof (m_vboChanged); ++i) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
224 | m_vboChanged[i] = true; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
225 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
226 | |
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 | // |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
762
diff
changeset
|
229 | void GLCompiler::stageForCompilation (LDObjectPtr obj) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
230 | { |
721
4cf0f6c9082d
- now works with selection subfiling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
231 | /* |
4cf0f6c9082d
- now works with selection subfiling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
232 | g_objectOrigins[obj] = format ("%1:%2 (%3)", |
4cf0f6c9082d
- now works with selection subfiling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
233 | obj->document()->getDisplayName(), obj->lineNumber(), obj->typeName()); |
4cf0f6c9082d
- now works with selection subfiling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
234 | */ |
4cf0f6c9082d
- now works with selection subfiling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
235 | |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
762
diff
changeset
|
236 | m_staged << LDObjectWeakPtr (obj); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
237 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
238 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
239 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
240 | // |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
762
diff
changeset
|
241 | void GLCompiler::unstage (LDObjectPtr obj) |
721
4cf0f6c9082d
- now works with selection subfiling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
242 | { |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
762
diff
changeset
|
243 | m_staged.removeOne (LDObjectWeakPtr (obj)); |
721
4cf0f6c9082d
- now works with selection subfiling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
244 | } |
4cf0f6c9082d
- now works with selection subfiling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
245 | |
4cf0f6c9082d
- now works with selection subfiling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
246 | // ============================================================================= |
4cf0f6c9082d
- now works with selection subfiling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
247 | // |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
772
diff
changeset
|
248 | void GLCompiler::compileDocument (LDDocumentPtr doc) |
706
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 | if (doc == null) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
251 | return; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
252 | |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
762
diff
changeset
|
253 | for (LDObjectPtr obj : doc->objects()) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
254 | compileObject (obj); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
255 | } |
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 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
258 | // |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
259 | void GLCompiler::compileStaged() |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
260 | { |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
261 | RemoveDuplicates (m_staged); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
262 | |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
762
diff
changeset
|
263 | for (LDObjectPtr obj : m_staged) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
264 | compileObject (obj); |
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 | m_staged.clear(); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
267 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
268 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
269 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
270 | // |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
271 | void GLCompiler::prepareVBO (int vbonum) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
272 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
273 | // Compile anything that still awaits it |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
274 | compileStaged(); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
275 | |
716
639a900999bc
- removed the debug code
Santeri Piippo <crimsondusk64@gmail.com>
parents:
715
diff
changeset
|
276 | if (not m_vboChanged[vbonum]) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
277 | return; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
278 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
279 | QVector<GLfloat> vbodata; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
280 | |
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
|
281 | for (auto it = m_objectInfo.begin(); it != m_objectInfo.end();) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
282 | { |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
772
diff
changeset
|
283 | if (it.key() == null) |
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
|
284 | { |
784
f82ab4d3c7b4
- made LDDocument use shared pointers, this eliminates a lot of document-related crashes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
772
diff
changeset
|
285 | it = m_objectInfo.erase (it); |
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
|
286 | } |
891
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
287 | elif (it.key().toStrongRef()->document() == CurrentDocument() |
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
|
288 | and not it.key().toStrongRef()->isHidden()) |
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
|
289 | { |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
290 | vbodata += it->data[vbonum]; |
891
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
291 | ++it; |
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
|
292 | } |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
293 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
294 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
295 | glBindBuffer (GL_ARRAY_BUFFER, m_vbo[vbonum]); |
708
3155f2c05f89
- more debugging...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
706
diff
changeset
|
296 | glBufferData (GL_ARRAY_BUFFER, vbodata.size() * sizeof(GLfloat), vbodata.constData(), GL_STATIC_DRAW); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
297 | glBindBuffer (GL_ARRAY_BUFFER, 0); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
857
diff
changeset
|
298 | CHECK_GL_ERROR(); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
299 | m_vboChanged[vbonum] = false; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
300 | m_vboSizes[vbonum] = vbodata.size(); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
301 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
302 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
303 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
304 | // |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
762
diff
changeset
|
305 | void GLCompiler::dropObject (LDObjectPtr obj) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
306 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
307 | auto it = m_objectInfo.find (obj); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
308 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
309 | if (it != m_objectInfo.end()) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
310 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
311 | m_objectInfo.erase (it); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
312 | needMerge(); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
313 | } |
721
4cf0f6c9082d
- now works with selection subfiling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
314 | |
4cf0f6c9082d
- now works with selection subfiling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
315 | unstage (obj); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
316 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
317 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
318 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
319 | // |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
762
diff
changeset
|
320 | void GLCompiler::compileObject (LDObjectPtr obj) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
321 | { |
721
4cf0f6c9082d
- now works with selection subfiling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
322 | // print ("Compile %1\n", g_objectOrigins[obj]); |
4cf0f6c9082d
- now works with selection subfiling
Santeri Piippo <crimsondusk64@gmail.com>
parents:
717
diff
changeset
|
323 | |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
806
diff
changeset
|
324 | if (obj == null or obj->document() == null or obj->document().toStrongRef()->isImplicit()) |
708
3155f2c05f89
- more debugging...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
706
diff
changeset
|
325 | return; |
3155f2c05f89
- more debugging...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
706
diff
changeset
|
326 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
327 | ObjectVBOInfo info; |
713
46377d340c23
- more debug stuff....
Santeri Piippo <crimsondusk64@gmail.com>
parents:
708
diff
changeset
|
328 | info.isChanged = true; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
329 | dropObject (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
|
330 | |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
331 | 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
|
332 | { |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
333 | // Note: We cannot split quads into triangles here, it would mess up the |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
334 | // wireframe view. Quads must go into separate vbos. |
786
71d786ce0dcc
- LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents:
784
diff
changeset
|
335 | case OBJ_Triangle: |
71d786ce0dcc
- LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents:
784
diff
changeset
|
336 | case OBJ_Quad: |
71d786ce0dcc
- LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents:
784
diff
changeset
|
337 | case OBJ_Line: |
71d786ce0dcc
- LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents:
784
diff
changeset
|
338 | 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
|
339 | { |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
340 | 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
|
341 | 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
|
342 | 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
|
343 | 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
|
344 | 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
|
345 | } |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
346 | |
786
71d786ce0dcc
- LDObject::Type moved back to global namespace
Santeri Piippo <crimsondusk64@gmail.com>
parents:
784
diff
changeset
|
347 | case OBJ_Subfile: |
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
|
348 | { |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
762
diff
changeset
|
349 | LDSubfilePtr ref = obj.staticCast<LDSubfile>(); |
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
|
350 | 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
|
351 | |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
352 | 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
|
353 | { |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
354 | 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
|
355 | 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
|
356 | } |
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 | 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
|
358 | } |
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 | |
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 | default: |
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 | 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
|
362 | } |
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 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
364 | m_objectInfo[obj] = info; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
365 | needMerge(); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
366 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
367 | |
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 | // |
768
29e6c5552388
- initial overhaul with smart pointers
Santeri Piippo <crimsondusk64@gmail.com>
parents:
762
diff
changeset
|
370 | void GLCompiler::compilePolygon (LDPolygon& poly, LDObjectPtr topobj, ObjectVBOInfo* objinfo) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
371 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
372 | EVBOSurface surface; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
373 | int numverts; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
374 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
375 | switch (poly.num) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
376 | { |
713
46377d340c23
- more debug stuff....
Santeri Piippo <crimsondusk64@gmail.com>
parents:
708
diff
changeset
|
377 | case 2: surface = VBOSF_Lines; numverts = 2; break; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
378 | case 3: surface = VBOSF_Triangles; numverts = 3; break; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
379 | case 4: surface = VBOSF_Quads; numverts = 4; break; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
380 | case 5: surface = VBOSF_CondLines; numverts = 2; break; |
717
fdc285e5952f
- reimplemented vertex snapping
Santeri Piippo <crimsondusk64@gmail.com>
parents:
716
diff
changeset
|
381 | default: return; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
382 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
383 | |
762
d259256e1394
- added a macro for adding operator++ and operator-- to enums, less cast hell this way
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
384 | for (EVBOComplement complement = VBOCM_First; complement < VBOCM_NumComplements; ++complement) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
385 | { |
762
d259256e1394
- added a macro for adding operator++ and operator-- to enums, less cast hell this way
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
386 | const int vbonum = vboNumber (surface, complement); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
387 | QVector<GLfloat>& vbodata = objinfo->data[vbonum]; |
762
d259256e1394
- added a macro for adding operator++ and operator-- to enums, less cast hell this way
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
388 | const QColor color = getColorForPolygon (poly, topobj, complement); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
389 | |
891
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
390 | bool inverted = (poly.winding != Winding::CCW); |
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
391 | |
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
392 | auto func = [&](int vert) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
393 | { |
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
|
394 | if (complement == VBOCM_Surfaces) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
395 | { |
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
|
396 | // 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
|
397 | 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
|
398 | << -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
|
399 | << -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
|
400 | } |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
401 | 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
|
402 | { |
9a53d9a379de
- refactored the gl compiler a tad, made selection blend work with BFC/random colors
Santeri Piippo <crimsondusk64@gmail.com>
parents:
725
diff
changeset
|
403 | 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
|
404 | << ((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
|
405 | << ((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
|
406 | << ((GLfloat) color.alpha()) / 255.0f; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
407 | } |
891
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
408 | }; |
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
409 | |
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
410 | if (not inverted) |
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
411 | { |
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
412 | for (int vert = 0; vert < numverts; ++vert) |
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
413 | func (vert); |
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
414 | } |
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
415 | else |
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
416 | { |
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
417 | for (int vert = numverts - 1; vert >= 0; --vert) |
00d76b281021
- re-committed bfc work (this makes 903ec1e46298 a suitable common ancestor for experimental branch features)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
890
diff
changeset
|
418 | func (vert); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
419 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
420 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
421 | } |
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
|
422 | |
e62983881460
- fixed crash-on-exit (simply by not running full destruction processing during program termination)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
423 | 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
|
424 | { |
e62983881460
- fixed crash-on-exit (simply by not running full destruction processing during program termination)
Teemu Piippo <crimsondusk64@gmail.com>
parents:
855
diff
changeset
|
425 | 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
|
426 | } |