src/glCompiler.h

Sat, 06 Jan 2018 17:57:03 +0200

author
Santeri Piippo
date
Sat, 06 Jan 2018 17:57:03 +0200
changeset 1225
ffcbdce88978
parent 1222
34def2630300
child 1231
ce0c9f2e6b9c
permissions
-rw-r--r--

simplify

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
1222
34def2630300 happy new year 2018
Santeri Piippo
parents: 1217
diff changeset
3 * Copyright (C) 2013 - 2018 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
736
0446af72b2ee - use #pragma once for the gl compiler header
Santeri Piippo <crimsondusk64@gmail.com>
parents: 726
diff changeset
19 #pragma once
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include "main.h"
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include "glRenderer.h"
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include "glShared.h"
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 #include <QMap>
978
4603d8fd063e Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents: 970
diff changeset
24 #include <QSet>
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 // =============================================================================
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 //
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
28 class GLCompiler : public HierarchyElement, protected QOpenGLFunctions
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 {
713
46377d340c23 - more debug stuff....
Santeri Piippo <crimsondusk64@gmail.com>
parents: 706
diff changeset
30 public:
46377d340c23 - more debug stuff....
Santeri Piippo <crimsondusk64@gmail.com>
parents: 706
diff changeset
31 struct ObjectVBOInfo
46377d340c23 - more debug stuff....
Santeri Piippo <crimsondusk64@gmail.com>
parents: 706
diff changeset
32 {
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
33 QVector<GLfloat> data[NumVbos];
713
46377d340c23 - more debug stuff....
Santeri Piippo <crimsondusk64@gmail.com>
parents: 706
diff changeset
34 bool isChanged;
46377d340c23 - more debug stuff....
Santeri Piippo <crimsondusk64@gmail.com>
parents: 706
diff changeset
35 };
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
36
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 986
diff changeset
37 GLCompiler(GLRenderer* renderer);
713
46377d340c23 - more debug stuff....
Santeri Piippo <crimsondusk64@gmail.com>
parents: 706
diff changeset
38 ~GLCompiler();
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 986
diff changeset
39 void compileDocument(LDDocument* doc);
314e12e23c3a fix paren style
Santeri Piippo
parents: 986
diff changeset
40 void dropObjectInfo(LDObject* obj);
314e12e23c3a fix paren style
Santeri Piippo
parents: 986
diff changeset
41 QColor getColorForPolygon(LDPolygon& poly, LDObject* topobj, ComplementVboType complement) const;
314e12e23c3a fix paren style
Santeri Piippo
parents: 986
diff changeset
42 QColor indexColorForID(int id) const;
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
43 void initialize();
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
44 void needMerge();
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 986
diff changeset
45 void prepareVBO(int vbonum);
314e12e23c3a fix paren style
Santeri Piippo
parents: 986
diff changeset
46 void setRenderer(GLRenderer* compiler);
314e12e23c3a fix paren style
Santeri Piippo
parents: 986
diff changeset
47 void stageForCompilation(LDObject* obj);
314e12e23c3a fix paren style
Santeri Piippo
parents: 986
diff changeset
48 void unstage(LDObject* obj);
314e12e23c3a fix paren style
Santeri Piippo
parents: 986
diff changeset
49 GLuint vbo(int vbonum) const;
314e12e23c3a fix paren style
Santeri Piippo
parents: 986
diff changeset
50 int vboSize(int vbonum) const;
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 986
diff changeset
52 static int vboNumber(SurfaceVboType surface, ComplementVboType complement);
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53
713
46377d340c23 - more debug stuff....
Santeri Piippo <crimsondusk64@gmail.com>
parents: 706
diff changeset
54 private:
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
55 void compileStaged();
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 986
diff changeset
56 void compileObject(LDObject* obj);
314e12e23c3a fix paren style
Santeri Piippo
parents: 986
diff changeset
57 void compilePolygon(LDPolygon& poly, LDObject* topobj, ObjectVBOInfo* objinfo);
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58
945
c310073e4f22 More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents: 944
diff changeset
59 QMap<LDObject*, ObjectVBOInfo> m_objectInfo;
986
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
60 QSet<LDObject*> m_staged; // Objects that need to be compiled
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
61 GLuint m_vbo[NumVbos];
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
62 bool m_vboChanged[NumVbos];
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
63 int m_vboSizes[NumVbos];
525921eae58c Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents: 978
diff changeset
64 GLRenderer* m_renderer;
706
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 };
d79083b9f74d Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
66
1217
314e12e23c3a fix paren style
Santeri Piippo
parents: 986
diff changeset
67 #define CHECK_GL_ERROR() { CheckGLErrorImpl(__FILE__, __LINE__); }
314e12e23c3a fix paren style
Santeri Piippo
parents: 986
diff changeset
68 void CheckGLErrorImpl(const char* file, int line);

mercurial