src/glCompiler.cpp

changeset 941
f895379d7fab
parent 931
85080f7a1c20
equal deleted inserted replaced
940:edc716c1d8e1 941:f895379d7fab
25 #include "ldDocument.h" 25 #include "ldDocument.h"
26 #include "miscallenous.h" 26 #include "miscallenous.h"
27 #include "glRenderer.h" 27 #include "glRenderer.h"
28 #include "dialogs.h" 28 #include "dialogs.h"
29 29
30 struct GLErrorInfo 30 struct GlErrorInfo
31 { 31 {
32 GLenum value; 32 GLenum value;
33 QString text; 33 QString text;
34 }; 34 };
35 35
36 static const GLErrorInfo g_GLErrors[] = 36 static const GlErrorInfo GlErrorMessages[] =
37 { 37 {
38 { GL_NO_ERROR, "No error" }, 38 { GL_NO_ERROR, "No error" },
39 { GL_INVALID_ENUM, "Unacceptable enumerator passed" }, 39 { GL_INVALID_ENUM, "Unacceptable enumerator passed" },
40 { GL_INVALID_VALUE, "Numeric argument out of range" }, 40 { GL_INVALID_VALUE, "Numeric argument out of range" },
41 { GL_INVALID_OPERATION, "The operation is not allowed to be done in this state" }, 41 { GL_INVALID_OPERATION, "The operation is not allowed to be done in this state" },
63 GLenum errnum = glGetError(); 63 GLenum errnum = glGetError();
64 64
65 if (errnum == GL_NO_ERROR) 65 if (errnum == GL_NO_ERROR)
66 return; 66 return;
67 67
68 for (const GLErrorInfo& err : g_GLErrors) 68 for (const GlErrorInfo& err : GlErrorMessages)
69 { 69 {
70 if (err.value == errnum) 70 if (err.value == errnum)
71 { 71 {
72 errmsg = err.text; 72 errmsg = err.text;
73 break; 73 break;
100 GLCompiler::~GLCompiler() 100 GLCompiler::~GLCompiler()
101 { 101 {
102 glDeleteBuffers (g_numVBOs, &m_vbo[0]); 102 glDeleteBuffers (g_numVBOs, &m_vbo[0]);
103 CHECK_GL_ERROR(); 103 CHECK_GL_ERROR();
104 104
105 if (m_renderer != null) 105 if (m_renderer != nullptr)
106 m_renderer->setCompiler (null); 106 m_renderer->setCompiler (nullptr);
107 } 107 }
108 108
109 // ============================================================================= 109 // =============================================================================
110 // 110 //
111 uint32 GLCompiler::colorToRGB (const QColor& color) 111 uint32 GLCompiler::colorToRGB (const QColor& color)
164 if (topobj->color() == MainColor()) 164 if (topobj->color() == MainColor())
165 qcol = GLRenderer::getMainColor(); 165 qcol = GLRenderer::getMainColor();
166 else 166 else
167 qcol = topobj->color().faceColor(); 167 qcol = topobj->color().faceColor();
168 } 168 }
169 elif (poly.color == EdgeColorIndex) 169 else if (poly.color == EdgeColorIndex)
170 { 170 {
171 qcol = Luma (QColor (cfg::BackgroundColor)) > 40 ? Qt::black : Qt::white; 171 qcol = Luma (QColor (cfg::BackgroundColor)) > 40 ? Qt::black : Qt::white;
172 } 172 }
173 else 173 else
174 { 174 {
201 201
202 double blendAlpha = 0.0; 202 double blendAlpha = 0.0;
203 203
204 if (topobj->isSelected()) 204 if (topobj->isSelected())
205 blendAlpha = 1.0; 205 blendAlpha = 1.0;
206 elif (topobj == m_renderer->objectAtCursor()) 206 else if (topobj == m_renderer->objectAtCursor())
207 blendAlpha = 0.5; 207 blendAlpha = 0.5;
208 208
209 if (blendAlpha != 0.0) 209 if (blendAlpha != 0.0)
210 { 210 {
211 QColor selcolor (cfg::SelectColorBlend); 211 QColor selcolor (cfg::SelectColorBlend);
247 247
248 // ============================================================================= 248 // =============================================================================
249 // 249 //
250 void GLCompiler::compileDocument (LDDocumentPtr doc) 250 void GLCompiler::compileDocument (LDDocumentPtr doc)
251 { 251 {
252 if (doc == null) 252 if (doc == nullptr)
253 return; 253 return;
254 254
255 for (LDObjectPtr obj : doc->objects()) 255 for (LDObjectPtr obj : doc->objects())
256 compileObject (obj); 256 compileObject (obj);
257 } 257 }
258 258
259 // ============================================================================= 259 // =============================================================================
260 // 260 //
261 void GLCompiler::compileStaged() 261 void GLCompiler::compileStaged()
262 { 262 {
263 RemoveDuplicates (m_staged); 263 removeDuplicates (m_staged);
264 264
265 for (auto it = m_staged.begin(); it != m_staged.end(); ++it) 265 for (auto it = m_staged.begin(); it != m_staged.end(); ++it)
266 { 266 {
267 if (*it == null) 267 if (*it == nullptr)
268 continue; 268 continue;
269 269
270 compileObject (*it); 270 compileObject (*it);
271 } 271 }
272 272
285 285
286 QVector<GLfloat> vbodata; 286 QVector<GLfloat> vbodata;
287 287
288 for (auto it = m_objectInfo.begin(); it != m_objectInfo.end();) 288 for (auto it = m_objectInfo.begin(); it != m_objectInfo.end();)
289 { 289 {
290 if (it.key() == null) 290 if (it.key() == nullptr)
291 { 291 {
292 it = m_objectInfo.erase (it); 292 it = m_objectInfo.erase (it);
293 continue; 293 continue;
294 } 294 }
295 295
329 // 329 //
330 void GLCompiler::compileObject (LDObjectPtr obj) 330 void GLCompiler::compileObject (LDObjectPtr obj)
331 { 331 {
332 // print ("Compile %1\n", g_objectOrigins[obj]); 332 // print ("Compile %1\n", g_objectOrigins[obj]);
333 333
334 if (obj == null or obj->document() == null or obj->document().toStrongRef()->isImplicit()) 334 if (obj == nullptr or obj->document() == nullptr or obj->document().toStrongRef()->isImplicit())
335 return; 335 return;
336 336
337 ObjectVBOInfo info; 337 ObjectVBOInfo info;
338 info.isChanged = true; 338 info.isChanged = true;
339 dropObject (obj); 339 dropObject (obj);

mercurial