55 |
55 |
56 // static QMap<LDObjectPtr, String> g_objectOrigins; |
56 // static QMap<LDObjectPtr, String> g_objectOrigins; |
57 |
57 |
58 // ============================================================================= |
58 // ============================================================================= |
59 // |
59 // |
60 void checkGLError_private (const char* file, int line) |
60 void CheckGLErrorImpl (const char* file, int line) |
61 { |
61 { |
62 QString errmsg; |
62 QString errmsg; |
63 GLenum errnum = glGetError(); |
63 GLenum errnum = glGetError(); |
64 |
64 |
65 if (errnum == GL_NO_ERROR) |
65 if (errnum == GL_NO_ERROR) |
72 errmsg = err.text; |
72 errmsg = err.text; |
73 break; |
73 break; |
74 } |
74 } |
75 } |
75 } |
76 |
76 |
77 print ("OpenGL ERROR: at %1:%2: %3", basename (QString (file)), line, errmsg); |
77 print ("OpenGL ERROR: at %1:%2: %3", Basename (QString (file)), line, errmsg); |
78 } |
78 } |
79 |
79 |
80 // ============================================================================= |
80 // ============================================================================= |
81 // |
81 // |
82 GLCompiler::GLCompiler (GLRenderer* renderer) : |
82 GLCompiler::GLCompiler (GLRenderer* renderer) : |
90 // |
90 // |
91 void GLCompiler::initialize() |
91 void GLCompiler::initialize() |
92 { |
92 { |
93 initializeOpenGLFunctions(); |
93 initializeOpenGLFunctions(); |
94 glGenBuffers (g_numVBOs, &m_vbo[0]); |
94 glGenBuffers (g_numVBOs, &m_vbo[0]); |
95 checkGLError(); |
95 CHECK_GL_ERROR(); |
96 } |
96 } |
97 |
97 |
98 // ============================================================================= |
98 // ============================================================================= |
99 // |
99 // |
100 GLCompiler::~GLCompiler() |
100 GLCompiler::~GLCompiler() |
101 { |
101 { |
102 glDeleteBuffers (g_numVBOs, &m_vbo[0]); |
102 glDeleteBuffers (g_numVBOs, &m_vbo[0]); |
103 checkGLError(); |
103 CHECK_GL_ERROR(); |
104 |
104 |
105 if (m_renderer != null) |
105 if (m_renderer != null) |
106 m_renderer->setCompiler (null); |
106 m_renderer->setCompiler (null); |
107 } |
107 } |
108 |
108 |
157 case VBOCM_RandomColors: |
157 case VBOCM_RandomColors: |
158 qcol = topobj->randomColor(); |
158 qcol = topobj->randomColor(); |
159 break; |
159 break; |
160 |
160 |
161 case VBOCM_NormalColors: |
161 case VBOCM_NormalColors: |
162 if (poly.color == mainColorIndex) |
162 if (poly.color == MainColorIndex) |
163 { |
163 { |
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 elif (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 { |
175 LDColor col = LDColor::fromIndex (poly.color); |
175 LDColor col = LDColor::fromIndex (poly.color); |
176 |
176 |
282 |
282 |
283 for (auto it = m_objectInfo.begin(); it != m_objectInfo.end(); ++it) |
283 for (auto it = m_objectInfo.begin(); it != m_objectInfo.end(); ++it) |
284 { |
284 { |
285 if (it.key() == null) |
285 if (it.key() == null) |
286 it = m_objectInfo.erase (it); |
286 it = m_objectInfo.erase (it); |
287 elif (it.key().toStrongRef()->document() == getCurrentDocument() and not it.key().toStrongRef()->isHidden()) |
287 elif (it.key().toStrongRef()->document() == CurrentDocument() and not it.key().toStrongRef()->isHidden()) |
288 vbodata += it->data[vbonum]; |
288 vbodata += it->data[vbonum]; |
289 } |
289 } |
290 |
290 |
291 glBindBuffer (GL_ARRAY_BUFFER, m_vbo[vbonum]); |
291 glBindBuffer (GL_ARRAY_BUFFER, m_vbo[vbonum]); |
292 glBufferData (GL_ARRAY_BUFFER, vbodata.size() * sizeof(GLfloat), vbodata.constData(), GL_STATIC_DRAW); |
292 glBufferData (GL_ARRAY_BUFFER, vbodata.size() * sizeof(GLfloat), vbodata.constData(), GL_STATIC_DRAW); |
293 glBindBuffer (GL_ARRAY_BUFFER, 0); |
293 glBindBuffer (GL_ARRAY_BUFFER, 0); |
294 checkGLError(); |
294 CHECK_GL_ERROR(); |
295 m_vboChanged[vbonum] = false; |
295 m_vboChanged[vbonum] = false; |
296 m_vboSizes[vbonum] = vbodata.size(); |
296 m_vboSizes[vbonum] = vbodata.size(); |
297 } |
297 } |
298 |
298 |
299 // ============================================================================= |
299 // ============================================================================= |