Fri, 03 Mar 2017 23:08:04 +0200
At long last, the grid is finally now rendered onto the viewport. Woop!
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
1072 | 3 | * Copyright (C) 2013 - 2017 Teemu Piippo |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
19 | #define GL_GLEXT_PROTOTYPES |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
20 | #include <GL/glu.h> |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
21 | #include <GL/glext.h> |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include <QContextMenuEvent> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include <QToolTip> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include <QTimer> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | #include <GL/glu.h> |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | #include "main.h" |
1145
02264bf0108d
Renamed ldDocument.cpp → lddocument.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1144
diff
changeset
|
27 | #include "lddocument.h" |
1144
4f226fd97826
Renamed glRenderer.cpp → glrenderer.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1135
diff
changeset
|
28 | #include "glrenderer.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | #include "colors.h" |
962
a4b463a7ee82
Rename MainWindow files
Teemu Piippo <crimsondusk64@gmail.com>
parents:
958
diff
changeset
|
30 | #include "mainwindow.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | #include "miscallenous.h" |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | #include "editHistory.h" |
1146
bb728c124d47
Renamed glCompiler.cpp → glcompiler.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1145
diff
changeset
|
33 | #include "glcompiler.h" |
827 | 34 | #include "primitives.h" |
998 | 35 | #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
|
36 | #include "grid.h" |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | |
1106
7541b0209057
Moved more methods only used by canvas code from GLRenderer to Canvas. Thin border pen is now a static constant.
Teemu Piippo <teemu@hecknology.net>
parents:
1105
diff
changeset
|
38 | const QPen GLRenderer::thinBorderPen {QColor {0, 0, 0, 208}, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin}; |
7541b0209057
Moved more methods only used by canvas code from GLRenderer to Canvas. Thin border pen is now a static constant.
Teemu Piippo <teemu@hecknology.net>
parents:
1105
diff
changeset
|
39 | |
1151
0eddb5bcf25b
Made fixed cameras matrix-based. This simplifies some math.
Teemu Piippo <teemu@hecknology.net>
parents:
1146
diff
changeset
|
40 | // Transformation matrices for the fixed cameras. |
0eddb5bcf25b
Made fixed cameras matrix-based. This simplifies some math.
Teemu Piippo <teemu@hecknology.net>
parents:
1146
diff
changeset
|
41 | const GLRotationMatrix GLRenderer::topCameraMatrix = GLRotationMatrix {}; |
1177
8661b9237ed5
Added support for ideal co-ordinates, which should make writing editing tools a lot easier. For some reason they don't yet work with the back and right cameras.
Teemu Piippo <teemu@hecknology.net>
parents:
1173
diff
changeset
|
42 | const GLRotationMatrix GLRenderer::frontCameraMatrix = {1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1}; |
8661b9237ed5
Added support for ideal co-ordinates, which should make writing editing tools a lot easier. For some reason they don't yet work with the back and right cameras.
Teemu Piippo <teemu@hecknology.net>
parents:
1173
diff
changeset
|
43 | const GLRotationMatrix GLRenderer::leftCameraMatrix = {0, -1, 0, 0, 0, 0, 1, 0, -1, 0, 0, 0, 0, 0, 0, 1}; |
8661b9237ed5
Added support for ideal co-ordinates, which should make writing editing tools a lot easier. For some reason they don't yet work with the back and right cameras.
Teemu Piippo <teemu@hecknology.net>
parents:
1173
diff
changeset
|
44 | const GLRotationMatrix GLRenderer::bottomCameraMatrix = {1, 0, 0, 0, 0, -1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1}; |
8661b9237ed5
Added support for ideal co-ordinates, which should make writing editing tools a lot easier. For some reason they don't yet work with the back and right cameras.
Teemu Piippo <teemu@hecknology.net>
parents:
1173
diff
changeset
|
45 | const GLRotationMatrix GLRenderer::backCameraMatrix = {-1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1}; |
8661b9237ed5
Added support for ideal co-ordinates, which should make writing editing tools a lot easier. For some reason they don't yet work with the back and right cameras.
Teemu Piippo <teemu@hecknology.net>
parents:
1173
diff
changeset
|
46 | const GLRotationMatrix GLRenderer::rightCameraMatrix = {0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1}; |
1151
0eddb5bcf25b
Made fixed cameras matrix-based. This simplifies some math.
Teemu Piippo <teemu@hecknology.net>
parents:
1146
diff
changeset
|
47 | |
0eddb5bcf25b
Made fixed cameras matrix-based. This simplifies some math.
Teemu Piippo <teemu@hecknology.net>
parents:
1146
diff
changeset
|
48 | // Conversion matrix from LDraw to OpenGL coordinates. |
1177
8661b9237ed5
Added support for ideal co-ordinates, which should make writing editing tools a lot easier. For some reason they don't yet work with the back and right cameras.
Teemu Piippo <teemu@hecknology.net>
parents:
1173
diff
changeset
|
49 | const GLRotationMatrix GLRenderer::ldrawToGLAdapterMatrix = {1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1}; |
1151
0eddb5bcf25b
Made fixed cameras matrix-based. This simplifies some math.
Teemu Piippo <teemu@hecknology.net>
parents:
1146
diff
changeset
|
50 | |
1133
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
51 | /* |
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
52 | * Constructs a GL renderer. |
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
53 | */ |
1109
a55b2608a395
Made GLRenderer's Model pointer const
Teemu Piippo <teemu@hecknology.net>
parents:
1108
diff
changeset
|
54 | GLRenderer::GLRenderer(const Model* model, QWidget* parent) : |
1097
9a9e6ce0c5dc
Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents:
1096
diff
changeset
|
55 | QGLWidget {parent}, |
9a9e6ce0c5dc
Made a new renderer be created for each document, instead of reusing the same renderer for all documents.
Teemu Piippo <teemu@hecknology.net>
parents:
1096
diff
changeset
|
56 | HierarchyElement {parent}, |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
57 | m_model {model}, |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
58 | m_cameras { |
1151
0eddb5bcf25b
Made fixed cameras matrix-based. This simplifies some math.
Teemu Piippo <teemu@hecknology.net>
parents:
1146
diff
changeset
|
59 | {"Top camera", {topCameraMatrix, X, Z, false, false, false}}, // top |
0eddb5bcf25b
Made fixed cameras matrix-based. This simplifies some math.
Teemu Piippo <teemu@hecknology.net>
parents:
1146
diff
changeset
|
60 | {"Front camera", {frontCameraMatrix, X, Y, false, true, false}}, // front |
0eddb5bcf25b
Made fixed cameras matrix-based. This simplifies some math.
Teemu Piippo <teemu@hecknology.net>
parents:
1146
diff
changeset
|
61 | {"Left camera", {leftCameraMatrix, Z, Y, true, true, false}}, // left |
0eddb5bcf25b
Made fixed cameras matrix-based. This simplifies some math.
Teemu Piippo <teemu@hecknology.net>
parents:
1146
diff
changeset
|
62 | {"Bottom camera", {bottomCameraMatrix, X, Z, false, true, true}}, // bottom |
0eddb5bcf25b
Made fixed cameras matrix-based. This simplifies some math.
Teemu Piippo <teemu@hecknology.net>
parents:
1146
diff
changeset
|
63 | {"Back camera", {backCameraMatrix, X, Y, true, true, true}}, // back |
0eddb5bcf25b
Made fixed cameras matrix-based. This simplifies some math.
Teemu Piippo <teemu@hecknology.net>
parents:
1146
diff
changeset
|
64 | {"Right camera", {rightCameraMatrix, Z, Y, false, true, true}}, // right |
1130
17f92eb2a30c
Moved camera names to GLCamera, other adjustments
Teemu Piippo <teemu@hecknology.net>
parents:
1129
diff
changeset
|
65 | {"Free camera", GLCamera::FreeCamera}, // free |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
66 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | { |
1033 | 68 | m_camera = (Camera) m_config->camera(); |
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 | m_compiler = new GLCompiler (this); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | m_toolTipTimer = new QTimer (this); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | m_toolTipTimer->setSingleShot (true); |
790
fe1b83f6ba82
- added primitives toolbox
Santeri Piippo <crimsondusk64@gmail.com>
parents:
789
diff
changeset
|
72 | setAcceptDrops (true); |
1131
03aa7091cb4a
Simplified camera tooltip code.
Teemu Piippo <teemu@hecknology.net>
parents:
1130
diff
changeset
|
73 | connect (m_toolTipTimer, SIGNAL (timeout()), this, SLOT (showCameraIconTooltip())); |
1158
35ceb74fe53e
Made the GL renderer recieve information of object deletion via signals.
Teemu Piippo <teemu@hecknology.net>
parents:
1157
diff
changeset
|
74 | connect(model, SIGNAL(aboutToRemoveObject(LDObject*)), this, SLOT(removeObject(LDObject*))); |
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:
1097
diff
changeset
|
75 | resetAllAngles(); |
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:
1097
diff
changeset
|
76 | m_needZoomToFit = true; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | // Init camera icons |
1036
993c46d7eb75
Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents:
1035
diff
changeset
|
79 | for (Camera camera : iterateEnum<Camera>()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | { |
1036
993c46d7eb75
Replaced the ugly for_enum macro with a generator class
Teemu Piippo <teemu@compsta2.com>
parents:
1035
diff
changeset
|
81 | const char* cameraIconNames[EnumLimits<Camera>::Count] = |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
82 | { |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
83 | "camera-top", "camera-front", "camera-left", |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
84 | "camera-bottom", "camera-back", "camera-right", |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
85 | "camera-free" |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
86 | }; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
87 | |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1121
diff
changeset
|
88 | CameraIcon* info = &m_cameraIcons[static_cast<int>(camera)]; |
1157
1d6d244bdabd
Moved GetIcon and makeSettings into the MainWindow namespace as static methods.
Teemu Piippo <teemu@hecknology.net>
parents:
1151
diff
changeset
|
89 | info->image = MainWindow::getIcon (cameraIconNames[static_cast<int>(camera)]); |
1035
8a60250175ba
Further improved enum handling
Teemu Piippo <teemu@compsta2.com>
parents:
1034
diff
changeset
|
90 | info->camera = camera; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
91 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
93 | calcCameraIcons(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | |
1133
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
96 | /* |
1169
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
97 | * Destructs the GL renderer. |
1133
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
98 | */ |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
99 | GLRenderer::~GLRenderer() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
100 | { |
1169
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
101 | freeAxes(); |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
102 | } |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
103 | |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
104 | /* |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
105 | * Deletes the axes VBOs |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
106 | */ |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
107 | void GLRenderer::freeAxes() |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
108 | { |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
109 | if (m_axesInitialized) |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
110 | { |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
111 | glDeleteBuffers(1, &m_axesVbo); |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
112 | glDeleteBuffers(1, &m_axesColorVbo); |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
113 | m_axesInitialized = false; |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
114 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | |
1133
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
117 | /* |
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
118 | * Calculates the camera icon locations. |
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
119 | */ |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
120 | void GLRenderer::calcCameraIcons() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
121 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | int i = 0; |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
123 | const int columns = 3; |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
124 | const int firstAtLastRow = countof(m_cameras) - (countof(m_cameras) % columns); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
125 | |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
126 | for (CameraIcon& cameraIcon : m_cameraIcons) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | { |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
128 | int row = i / columns; |
1132
825dd975588d
Fixed the free camera icon not showing up anymore.
Teemu Piippo <teemu@hecknology.net>
parents:
1131
diff
changeset
|
129 | int column = i % columns; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
130 | |
1133
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
131 | // Do right-justifying on the last row. |
1132
825dd975588d
Fixed the free camera icon not showing up anymore.
Teemu Piippo <teemu@hecknology.net>
parents:
1131
diff
changeset
|
132 | if (i >= firstAtLastRow) |
825dd975588d
Fixed the free camera icon not showing up anymore.
Teemu Piippo <teemu@hecknology.net>
parents:
1131
diff
changeset
|
133 | column += columns - (countof(m_cameras) % columns); |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
134 | |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
135 | int x1 = width() - 48 + (column * 16) - 1; |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
136 | int y1 = (row * 16) + 1; |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
137 | |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
138 | cameraIcon.sourceRect = {0, 0, 16, 16}; |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
139 | cameraIcon.targetRect = {x1, y1, 16, 16}; |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
140 | cameraIcon.hitRect = { |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
141 | cameraIcon.targetRect.x(), |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
142 | cameraIcon.targetRect.y(), |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
143 | cameraIcon.targetRect.width() + 1, |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
144 | cameraIcon.targetRect.height() + 1 |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
145 | }; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
147 | ++i; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
148 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
150 | |
1133
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
151 | /* |
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
152 | * Returns the camera currently in use. |
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
153 | */ |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
154 | GLCamera& GLRenderer::currentCamera() |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
155 | { |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
156 | return m_cameras[static_cast<int>(camera())]; |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
157 | } |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
158 | |
1133
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
159 | /* |
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
160 | * Returns the camera currently in use. |
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
161 | */ |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
162 | const GLCamera& GLRenderer::currentCamera() const |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
163 | { |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
164 | return m_cameras[static_cast<int>(camera())]; |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
165 | } |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
166 | |
1133
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
167 | /* |
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
168 | * Prepares the GL context for rendering. |
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
169 | */ |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
170 | void GLRenderer::initGLData() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
171 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
172 | glEnable (GL_BLEND); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
173 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
174 | glEnable (GL_POLYGON_OFFSET_FILL); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
175 | glPolygonOffset (1.0f, 1.0f); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
176 | glEnable (GL_DEPTH_TEST); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
177 | glShadeModel (GL_SMOOTH); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
178 | glEnable (GL_MULTISAMPLE); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
179 | |
1017
fc1c13db9618
Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1015
diff
changeset
|
180 | if (m_config->antiAliasedLines()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
181 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
182 | glEnable (GL_LINE_SMOOTH); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
183 | glEnable (GL_POLYGON_SMOOTH); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
184 | glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
185 | glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
186 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
187 | else |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
188 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
189 | glDisable (GL_LINE_SMOOTH); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
190 | glDisable (GL_POLYGON_SMOOTH); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
191 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
192 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
193 | |
1133
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
194 | /* |
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
195 | * Returns the object currently highlighted by the cursor. |
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
196 | */ |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
197 | LDObject* GLRenderer::objectAtCursor() const |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
198 | { |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
199 | return m_objectAtCursor; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
200 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
201 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
202 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
203 | // |
738
16b63398aa1f
- resetAngles still needs to request a zoom to fit or the ctrl-0 action doesn't zoom to fit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
737
diff
changeset
|
204 | void GLRenderer::needZoomToFit() |
16b63398aa1f
- resetAngles still needs to request a zoom to fit or the ctrl-0 action doesn't zoom to fit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
737
diff
changeset
|
205 | { |
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:
1097
diff
changeset
|
206 | m_needZoomToFit = true; |
738
16b63398aa1f
- resetAngles still needs to request a zoom to fit or the ctrl-0 action doesn't zoom to fit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
737
diff
changeset
|
207 | } |
16b63398aa1f
- resetAngles still needs to request a zoom to fit or the ctrl-0 action doesn't zoom to fit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
737
diff
changeset
|
208 | |
16b63398aa1f
- resetAngles still needs to request a zoom to fit or the ctrl-0 action doesn't zoom to fit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
737
diff
changeset
|
209 | // ============================================================================= |
16b63398aa1f
- resetAngles still needs to request a zoom to fit or the ctrl-0 action doesn't zoom to fit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
737
diff
changeset
|
210 | // |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
211 | void GLRenderer::resetAngles() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
212 | { |
1095
cb58a160bed3
- Use a QGenericMatrix to store the matrix, instead of a C array
Teemu Piippo <teemu@hecknology.net>
parents:
1094
diff
changeset
|
213 | if (m_initialized) |
cb58a160bed3
- Use a QGenericMatrix to store the matrix, instead of a C array
Teemu Piippo <teemu@hecknology.net>
parents:
1094
diff
changeset
|
214 | { |
cb58a160bed3
- Use a QGenericMatrix to store the matrix, instead of a C array
Teemu Piippo <teemu@hecknology.net>
parents:
1094
diff
changeset
|
215 | // Why did I even bother trying to compute this by pen and paper? Let GL figure it out... |
cb58a160bed3
- Use a QGenericMatrix to store the matrix, instead of a C array
Teemu Piippo <teemu@hecknology.net>
parents:
1094
diff
changeset
|
216 | glMatrixMode(GL_MODELVIEW); |
cb58a160bed3
- Use a QGenericMatrix to store the matrix, instead of a C array
Teemu Piippo <teemu@hecknology.net>
parents:
1094
diff
changeset
|
217 | glPushMatrix(); |
cb58a160bed3
- Use a QGenericMatrix to store the matrix, instead of a C array
Teemu Piippo <teemu@hecknology.net>
parents:
1094
diff
changeset
|
218 | glLoadIdentity(); |
cb58a160bed3
- Use a QGenericMatrix to store the matrix, instead of a C array
Teemu Piippo <teemu@hecknology.net>
parents:
1094
diff
changeset
|
219 | glRotatef(30, 1, 0, 0); |
cb58a160bed3
- Use a QGenericMatrix to store the matrix, instead of a C array
Teemu Piippo <teemu@hecknology.net>
parents:
1094
diff
changeset
|
220 | glRotatef(330, 0, 1, 0); |
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:
1097
diff
changeset
|
221 | glGetFloatv(GL_MODELVIEW_MATRIX, m_rotationMatrix.data()); |
1095
cb58a160bed3
- Use a QGenericMatrix to store the matrix, instead of a C array
Teemu Piippo <teemu@hecknology.net>
parents:
1094
diff
changeset
|
222 | glPopMatrix(); |
cb58a160bed3
- Use a QGenericMatrix to store the matrix, instead of a C array
Teemu Piippo <teemu@hecknology.net>
parents:
1094
diff
changeset
|
223 | } |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
224 | currentCamera().setPanning(0, 0); |
738
16b63398aa1f
- resetAngles still needs to request a zoom to fit or the ctrl-0 action doesn't zoom to fit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
737
diff
changeset
|
225 | needZoomToFit(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
226 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
227 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
228 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
229 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
230 | void GLRenderer::resetAllAngles() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
231 | { |
1167
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
232 | Camera oldCamera = camera(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
233 | |
1167
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
234 | for (Camera camera : iterateEnum<Camera>()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
235 | { |
1167
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
236 | setCamera(camera); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
237 | resetAngles(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
238 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
239 | |
1167
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
240 | setCamera(oldCamera); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
241 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
242 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
243 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
244 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
245 | void GLRenderer::initializeGL() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
246 | { |
855
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
851
diff
changeset
|
247 | initializeOpenGLFunctions(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
248 | setBackground(); |
1017
fc1c13db9618
Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1015
diff
changeset
|
249 | glLineWidth (m_config->lineThickness()); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
250 | glLineStipple (1, 0x6666); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
251 | setAutoFillBackground (false); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
252 | setMouseTracking (true); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
253 | setFocusPolicy (Qt::WheelFocus); |
1133
47f6db5ea24d
Some documentation and cleanup in GLRenderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1132
diff
changeset
|
254 | m_compiler->initialize(); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
255 | initializeAxes(); |
1119
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
256 | initializeLighting(); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
257 | m_initialized = true; |
1095
cb58a160bed3
- Use a QGenericMatrix to store the matrix, instead of a C array
Teemu Piippo <teemu@hecknology.net>
parents:
1094
diff
changeset
|
258 | // Now that GL is initialized, we can reset angles. |
cb58a160bed3
- Use a QGenericMatrix to store the matrix, instead of a C array
Teemu Piippo <teemu@hecknology.net>
parents:
1094
diff
changeset
|
259 | resetAllAngles(); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
260 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
261 | |
1119
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
262 | void GLRenderer::initializeLighting() |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
263 | { |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
264 | GLfloat materialShininess[] = {5.0}; |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
265 | GLfloat lightPosition[] = {1.0, 1.0, 1.0, 0.0}; |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
266 | GLfloat ambientLightingLevel[] = {0.8, 0.8, 0.8, 1.0}; |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
267 | glShadeModel(GL_SMOOTH); |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
268 | glMaterialfv(GL_FRONT, GL_SHININESS, materialShininess); |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
269 | glMaterialfv(GL_FRONT, GL_AMBIENT, ambientLightingLevel); |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
270 | glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
271 | glEnable(GL_LIGHTING); |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
272 | glEnable(GL_LIGHT0); |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
273 | glEnable(GL_COLOR_MATERIAL); |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
274 | glEnable(GL_DEPTH_TEST); |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
275 | } |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
276 | |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
277 | // ============================================================================= |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
278 | // |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
279 | void GLRenderer::initializeAxes() |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
280 | { |
1169
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
281 | freeAxes(); |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
282 | float axisVertexData[3][6]; |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
283 | float axisColorData[3][6]; |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
284 | |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
285 | auto compileAxis = [&](Axis axis, QColor color, Vertex extrema) |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
286 | { |
1169
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
287 | axisVertexData[axis][0] = extrema[X]; |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
288 | axisVertexData[axis][1] = extrema[Y]; |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
289 | axisVertexData[axis][2] = extrema[Z]; |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
290 | axisVertexData[axis][3] = -extrema[X]; |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
291 | axisVertexData[axis][4] = -extrema[Y]; |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
292 | axisVertexData[axis][5] = -extrema[Z]; |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
293 | axisColorData[axis][0] = axisColorData[axis][3] = color.red(); |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
294 | axisColorData[axis][1] = axisColorData[axis][4] = color.green(); |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
295 | axisColorData[axis][2] = axisColorData[axis][5] = color.blue(); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
296 | }; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
297 | |
1169
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
298 | compileAxis(X, {192, 96, 96}, {10000, 0, 0}); |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
299 | compileAxis(Y, {48, 192, 48}, {0, 10000, 0}); |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
300 | compileAxis(Z, {48, 112, 192}, {0, 0, 10000}); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
301 | |
1169
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
302 | glGenBuffers(1, &m_axesVbo); |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
303 | glBindBuffer(GL_ARRAY_BUFFER, m_axesVbo); |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
304 | glBufferData(GL_ARRAY_BUFFER, sizeof axisVertexData, axisVertexData, GL_STATIC_DRAW); |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
305 | glGenBuffers(1, &m_axesColorVbo); |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
306 | glBindBuffer(GL_ARRAY_BUFFER, m_axesColorVbo); |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
307 | glBufferData(GL_ARRAY_BUFFER, sizeof axisColorData, axisColorData, GL_STATIC_DRAW); |
3da9287b4aff
Cleanup GLRenderer::initializeAxes()
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
308 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
309 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
310 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
311 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
312 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
313 | void GLRenderer::setBackground() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
314 | { |
1061 | 315 | if (not m_isDrawingSelectionScene) |
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
|
316 | { |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
317 | // Otherwise use the background that the user wants. |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
318 | QColor color = m_config->backgroundColor(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
319 | |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
320 | if (color.isValid()) |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
321 | { |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
322 | color.setAlpha(255); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
323 | m_useDarkBackground = luma(color) < 80; |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
324 | m_backgroundColor = color; |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
325 | qglClearColor(color); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
326 | } |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
327 | } |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
328 | else |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
329 | { |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
330 | // The picking scene requires a black background. |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
331 | glClearColor(0.0f, 0.0f, 0.0f, 1.0f); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
332 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
333 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
334 | |
1106
7541b0209057
Moved more methods only used by canvas code from GLRenderer to Canvas. Thin border pen is now a static constant.
Teemu Piippo <teemu@hecknology.net>
parents:
1105
diff
changeset
|
335 | QColor GLRenderer::backgroundColor() const |
7541b0209057
Moved more methods only used by canvas code from GLRenderer to Canvas. Thin border pen is now a static constant.
Teemu Piippo <teemu@hecknology.net>
parents:
1105
diff
changeset
|
336 | { |
7541b0209057
Moved more methods only used by canvas code from GLRenderer to Canvas. Thin border pen is now a static constant.
Teemu Piippo <teemu@hecknology.net>
parents:
1105
diff
changeset
|
337 | return m_backgroundColor; |
7541b0209057
Moved more methods only used by canvas code from GLRenderer to Canvas. Thin border pen is now a static constant.
Teemu Piippo <teemu@hecknology.net>
parents:
1105
diff
changeset
|
338 | } |
7541b0209057
Moved more methods only used by canvas code from GLRenderer to Canvas. Thin border pen is now a static constant.
Teemu Piippo <teemu@hecknology.net>
parents:
1105
diff
changeset
|
339 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
340 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
341 | // |
1111
471572db2fe1
Replaced GLRenderer::m_width and GLRenderer::m_height with width() and height() calls.
Teemu Piippo <teemu@hecknology.net>
parents:
1110
diff
changeset
|
342 | void GLRenderer::resizeGL (int width, int height) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
343 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
344 | calcCameraIcons(); |
1111
471572db2fe1
Replaced GLRenderer::m_width and GLRenderer::m_height with width() and height() calls.
Teemu Piippo <teemu@hecknology.net>
parents:
1110
diff
changeset
|
345 | glViewport (0, 0, width, height); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
346 | glMatrixMode (GL_PROJECTION); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
347 | glLoadIdentity(); |
1111
471572db2fe1
Replaced GLRenderer::m_width and GLRenderer::m_height with width() and height() calls.
Teemu Piippo <teemu@hecknology.net>
parents:
1110
diff
changeset
|
348 | gluPerspective (45.0f, (double) width / (double) height, 1.0f, 10000.0f); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
349 | glMatrixMode (GL_MODELVIEW); |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
350 | |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
351 | // Unfortunately Qt does not provide a resized() signal so we have to manually feed the information. |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
352 | for (GLCamera& camera : m_cameras) |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
353 | camera.rendererResized(width, height); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
354 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
355 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
356 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
357 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
358 | void GLRenderer::drawGLScene() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
359 | { |
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:
1097
diff
changeset
|
360 | if (m_needZoomToFit) |
737
e58bdb21cc54
- more elegant version of ded0a9b, do not zoom to fit in setDocument, instead zoom to fit before rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
733
diff
changeset
|
361 | { |
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:
1097
diff
changeset
|
362 | m_needZoomToFit = false; |
737
e58bdb21cc54
- more elegant version of ded0a9b, do not zoom to fit in setDocument, instead zoom to fit before rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
733
diff
changeset
|
363 | zoomAllToFit(); |
e58bdb21cc54
- more elegant version of ded0a9b, do not zoom to fit in setDocument, instead zoom to fit before rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
733
diff
changeset
|
364 | } |
e58bdb21cc54
- more elegant version of ded0a9b, do not zoom to fit in setDocument, instead zoom to fit before rendering
Santeri Piippo <crimsondusk64@gmail.com>
parents:
733
diff
changeset
|
365 | |
1061 | 366 | if (m_config->drawWireframe() and not m_isDrawingSelectionScene) |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
367 | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
368 | |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
369 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
370 | glEnable(GL_DEPTH_TEST); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
371 | |
1119
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
372 | if (m_config->lighting()) |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
373 | glEnable(GL_LIGHTING); |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
374 | else |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
375 | glDisable(GL_LIGHTING); |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
376 | |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1121
diff
changeset
|
377 | if (camera() != Camera::Free) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
378 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
379 | glMatrixMode (GL_PROJECTION); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
380 | glPushMatrix(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
381 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
382 | glLoadIdentity(); |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
383 | const QSizeF& virtualSize = currentCamera().virtualSize(); |
1178
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
384 | glOrtho(-virtualSize.width(), virtualSize.width(), -virtualSize.height(), virtualSize.height(), -1000.0f, 1000.0f); |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
385 | glTranslatef(panning (X), panning (Y), 0.0f); |
1151
0eddb5bcf25b
Made fixed cameras matrix-based. This simplifies some math.
Teemu Piippo <teemu@hecknology.net>
parents:
1146
diff
changeset
|
386 | glMultMatrixf(currentCamera().transformationMatrix()); |
0eddb5bcf25b
Made fixed cameras matrix-based. This simplifies some math.
Teemu Piippo <teemu@hecknology.net>
parents:
1146
diff
changeset
|
387 | glMultMatrixf(ldrawToGLAdapterMatrix); |
1178
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
388 | drawFixedCameraBackdrop(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
389 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
390 | else |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
391 | { |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
392 | glMatrixMode(GL_MODELVIEW); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
393 | glPushMatrix(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
394 | glLoadIdentity(); |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
395 | glTranslatef(0.0f, 0.0f, -2.0f); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
396 | glTranslatef(panning (X), panning (Y), -zoom()); |
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:
1097
diff
changeset
|
397 | glMultMatrixf(m_rotationMatrix.constData()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
398 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
399 | |
1119
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
400 | glEnableClientState (GL_NORMAL_ARRAY); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
401 | glEnableClientState (GL_VERTEX_ARRAY); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
402 | glEnableClientState (GL_COLOR_ARRAY); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
403 | |
1061 | 404 | if (m_isDrawingSelectionScene) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
405 | { |
1167
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
406 | drawVbos (VboClass::Triangles, VboSubclass::PickColors); |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
407 | drawVbos (VboClass::Quads, VboSubclass::PickColors); |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
408 | drawVbos (VboClass::Lines, VboSubclass::PickColors); |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
409 | drawVbos (VboClass::ConditionalLines, VboSubclass::PickColors); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
410 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
411 | else |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
412 | { |
1017
fc1c13db9618
Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1015
diff
changeset
|
413 | if (m_config->bfcRedGreenView()) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
414 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
415 | glEnable (GL_CULL_FACE); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
416 | glCullFace (GL_BACK); |
1167
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
417 | drawVbos (VboClass::Triangles, VboSubclass::BfcFrontColors); |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
418 | drawVbos (VboClass::Quads, VboSubclass::BfcFrontColors); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
419 | glCullFace (GL_FRONT); |
1167
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
420 | drawVbos (VboClass::Triangles, VboSubclass::BfcBackColors); |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
421 | drawVbos (VboClass::Quads, VboSubclass::BfcBackColors); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
422 | glDisable (GL_CULL_FACE); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
423 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
424 | else |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
425 | { |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1121
diff
changeset
|
426 | VboSubclass colors; |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
427 | |
1017
fc1c13db9618
Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1015
diff
changeset
|
428 | if (m_config->randomColors()) |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1121
diff
changeset
|
429 | colors = VboSubclass::RandomColors; |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
430 | else |
1173
6cd85b28f43b
Cleanup ColorSelector::colorButtonClicked()
Teemu Piippo <teemu@hecknology.net>
parents:
1172
diff
changeset
|
431 | colors = VboSubclass::RegularColors; |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
432 | |
1167
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
433 | drawVbos (VboClass::Triangles, colors); |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
434 | drawVbos (VboClass::Quads, colors); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
435 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
436 | |
1173
6cd85b28f43b
Cleanup ColorSelector::colorButtonClicked()
Teemu Piippo <teemu@hecknology.net>
parents:
1172
diff
changeset
|
437 | drawVbos (VboClass::Lines, VboSubclass::RegularColors); |
722
61e2d0ca0018
- conditional lines are now rendered with stippled lines again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
720
diff
changeset
|
438 | glEnable (GL_LINE_STIPPLE); |
1173
6cd85b28f43b
Cleanup ColorSelector::colorButtonClicked()
Teemu Piippo <teemu@hecknology.net>
parents:
1172
diff
changeset
|
439 | drawVbos (VboClass::ConditionalLines, VboSubclass::RegularColors); |
722
61e2d0ca0018
- conditional lines are now rendered with stippled lines again
Santeri Piippo <crimsondusk64@gmail.com>
parents:
720
diff
changeset
|
440 | glDisable (GL_LINE_STIPPLE); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
441 | |
1017
fc1c13db9618
Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1015
diff
changeset
|
442 | if (m_config->drawAxes()) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
443 | { |
1120
c3f07620494e
Axes are not rendered with normals so the normals client state has to be disabled when drawing them.
Teemu Piippo <teemu@hecknology.net>
parents:
1119
diff
changeset
|
444 | glDisableClientState (GL_NORMAL_ARRAY); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
445 | glBindBuffer (GL_ARRAY_BUFFER, m_axesVbo); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
446 | glVertexPointer (3, GL_FLOAT, 0, NULL); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
447 | glBindBuffer (GL_ARRAY_BUFFER, m_axesVbo); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
448 | glColorPointer (3, GL_FLOAT, 0, NULL); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
449 | glDrawArrays (GL_LINES, 0, 6); |
1120
c3f07620494e
Axes are not rendered with normals so the normals client state has to be disabled when drawing them.
Teemu Piippo <teemu@hecknology.net>
parents:
1119
diff
changeset
|
450 | glEnableClientState (GL_NORMAL_ARRAY); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
859
diff
changeset
|
451 | CHECK_GL_ERROR(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
452 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
453 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
454 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
455 | glPopMatrix(); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
456 | glBindBuffer (GL_ARRAY_BUFFER, 0); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
457 | glDisableClientState (GL_VERTEX_ARRAY); |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
458 | glDisableClientState (GL_COLOR_ARRAY); |
1119
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
459 | glDisableClientState (GL_NORMAL_ARRAY); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
859
diff
changeset
|
460 | CHECK_GL_ERROR(); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
461 | glDisable (GL_CULL_FACE); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
462 | glMatrixMode (GL_MODELVIEW); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
463 | glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
464 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
465 | |
1167
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
466 | /* |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
467 | * Draws a set of VBOs onto the scene. Renders surfaces with appropriate normals and colors. |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
468 | * |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
469 | * Parameters: |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
470 | * - surface determines what kind of surface to draw (triangles, quadrilaterals, edges or conditional edges) |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
471 | * - colors determines what VBO subclass to use for colors |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
472 | */ |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
473 | void GLRenderer::drawVbos(VboClass surface, VboSubclass colors) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
474 | { |
815
efe34366e56a
- added ability to filter out surfaces/edgelines/condlines from the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
475 | // Filter this through some configuration options |
1167
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
476 | if ((isOneOf(surface, VboClass::Quads, VboClass::Triangles) and m_config->drawSurfaces() == false) |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1121
diff
changeset
|
477 | or (surface == VboClass::Lines and m_config->drawEdgeLines() == false) |
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1121
diff
changeset
|
478 | or (surface == VboClass::ConditionalLines and m_config->drawConditionalLines() == false)) |
815
efe34366e56a
- added ability to filter out surfaces/edgelines/condlines from the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
479 | { |
efe34366e56a
- added ability to filter out surfaces/edgelines/condlines from the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
480 | return; |
efe34366e56a
- added ability to filter out surfaces/edgelines/condlines from the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
481 | } |
efe34366e56a
- added ability to filter out surfaces/edgelines/condlines from the viewport
Santeri Piippo <crimsondusk64@gmail.com>
parents:
795
diff
changeset
|
482 | |
1167
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
483 | GLenum type; |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
484 | |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
485 | switch (surface) |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
486 | { |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
487 | case VboClass::_End: |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
488 | case VboClass::Lines: |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
489 | case VboClass::ConditionalLines: |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
490 | type = GL_LINES; |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
491 | break; |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
492 | |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
493 | case VboClass::Triangles: |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
494 | type = GL_TRIANGLES; |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
495 | break; |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
496 | |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
497 | case VboClass::Quads: |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
498 | type = GL_QUADS; |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
499 | break; |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
500 | } |
a348cee365e3
GLRenderer::drawVbos no longer needs to be told the GL type
Teemu Piippo <teemu@hecknology.net>
parents:
1161
diff
changeset
|
501 | |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1121
diff
changeset
|
502 | int surfaceVboNumber = m_compiler->vboNumber(surface, VboSubclass::Surfaces); |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
503 | int colorVboNumber = m_compiler->vboNumber(surface, colors); |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1121
diff
changeset
|
504 | int normalVboNumber = m_compiler->vboNumber(surface, VboSubclass::Normals); |
1173
6cd85b28f43b
Cleanup ColorSelector::colorButtonClicked()
Teemu Piippo <teemu@hecknology.net>
parents:
1172
diff
changeset
|
505 | m_compiler->prepareVBO(surfaceVboNumber); |
6cd85b28f43b
Cleanup ColorSelector::colorButtonClicked()
Teemu Piippo <teemu@hecknology.net>
parents:
1172
diff
changeset
|
506 | m_compiler->prepareVBO(colorVboNumber); |
6cd85b28f43b
Cleanup ColorSelector::colorButtonClicked()
Teemu Piippo <teemu@hecknology.net>
parents:
1172
diff
changeset
|
507 | m_compiler->prepareVBO(normalVboNumber); |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
508 | GLuint surfaceVbo = m_compiler->vbo(surfaceVboNumber); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
509 | GLuint colorVbo = m_compiler->vbo(colorVboNumber); |
1119
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
510 | GLuint normalVbo = m_compiler->vbo(normalVboNumber); |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
511 | GLsizei count = m_compiler->vboSize(surfaceVboNumber) / 3; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
512 | |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
513 | if (count > 0) |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
514 | { |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
515 | glBindBuffer(GL_ARRAY_BUFFER, surfaceVbo); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
516 | glVertexPointer(3, GL_FLOAT, 0, nullptr); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
859
diff
changeset
|
517 | CHECK_GL_ERROR(); |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
518 | glBindBuffer(GL_ARRAY_BUFFER, colorVbo); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
519 | glColorPointer(4, GL_FLOAT, 0, nullptr); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
859
diff
changeset
|
520 | CHECK_GL_ERROR(); |
1119
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
521 | glBindBuffer(GL_ARRAY_BUFFER, normalVbo); |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
522 | glNormalPointer(GL_FLOAT, 0, nullptr); |
749fdf61b5cd
Implemented lighting. Yay! Unfortunately, faces that show up the wrong way around in BFC red/green mode also show up with inverted lighting here.
Teemu Piippo <teemu@hecknology.net>
parents:
1116
diff
changeset
|
523 | CHECK_GL_ERROR(); |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
524 | glDrawArrays(type, 0, count); |
861
83426c5fa732
- major identifier renaming
Teemu Piippo <crimsondusk64@gmail.com>
parents:
859
diff
changeset
|
525 | CHECK_GL_ERROR(); |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
526 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
527 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
528 | |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
529 | QPen GLRenderer::textPen() const |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
530 | { |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
531 | return {m_useDarkBackground ? Qt::white : Qt::black}; |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
532 | } |
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
533 | |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
534 | bool GLRenderer::freeCameraAllowed() const |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
535 | { |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
536 | return true; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
537 | } |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
538 | |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
539 | void GLRenderer::paintEvent(QPaintEvent*) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
540 | { |
1013
fa025ba493d8
Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1012
diff
changeset
|
541 | makeCurrent(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
542 | initGLData(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
543 | drawGLScene(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
544 | |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
545 | if (isDrawingSelectionScene()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
546 | return; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
547 | |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
548 | QPainter painter {this}; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
549 | painter.setRenderHint(QPainter::Antialiasing); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
550 | overpaint(painter); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
551 | } |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
552 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
553 | void GLRenderer::overpaint(QPainter &painter) |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
554 | { |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
555 | // Draw a background for the selected camera |
1106
7541b0209057
Moved more methods only used by canvas code from GLRenderer to Canvas. Thin border pen is now a static constant.
Teemu Piippo <teemu@hecknology.net>
parents:
1105
diff
changeset
|
556 | painter.setPen(thinBorderPen); |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
557 | painter.setBrush(QBrush {QColor {0, 128, 160, 128}}); |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1121
diff
changeset
|
558 | painter.drawRect(m_cameraIcons[static_cast<int>(camera())].hitRect); |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
559 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
560 | // Draw the camera icons |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
561 | for (const CameraIcon& info : m_cameraIcons) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
562 | { |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
563 | // Don't draw the free camera icon when we can't use the free camera |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1121
diff
changeset
|
564 | if (info.camera == Camera::Free and not freeCameraAllowed()) |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
565 | continue; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
566 | |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
567 | painter.drawPixmap(info.targetRect, info.image, info.sourceRect); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
568 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
569 | |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
570 | // Draw a label for the current camera in the bottom left corner |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
571 | { |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
572 | QFontMetrics metrics {QFont {}}; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
573 | int margin = 4; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
574 | painter.setPen(textPen()); |
1130
17f92eb2a30c
Moved camera names to GLCamera, other adjustments
Teemu Piippo <teemu@hecknology.net>
parents:
1129
diff
changeset
|
575 | painter.drawText(QPoint {margin, height() - margin - metrics.descent()}, currentCamera().name()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
576 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
577 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
578 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
579 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
580 | // |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
581 | void GLRenderer::mouseReleaseEvent(QMouseEvent* event) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
582 | { |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
583 | bool wasLeft = (m_lastButtons & Qt::LeftButton) and not (event->buttons() & Qt::LeftButton); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
584 | m_panning = false; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
585 | |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
586 | // Check if we selected a camera icon |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
587 | if (wasLeft and not mouseHasMoved()) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
588 | { |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
589 | for (CameraIcon& info : m_cameraIcons) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
590 | { |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
591 | if (info.targetRect.contains (event->pos())) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
592 | { |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
593 | setCamera (info.camera); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
594 | break; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
595 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
596 | } |
827 | 597 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
598 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
599 | update(); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
600 | m_totalMouseMove = 0; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
601 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
602 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
603 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
604 | // |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
605 | void GLRenderer::mousePressEvent(QMouseEvent* event) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
606 | { |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
607 | m_lastButtons = event->buttons(); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
608 | m_totalMouseMove = 0; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
609 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
610 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
611 | // ============================================================================= |
825
f7649c9bfd9a
- more work on edit modes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
824
diff
changeset
|
612 | // |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
613 | void GLRenderer::mouseMoveEvent(QMouseEvent* event) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
614 | { |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
615 | int xMove = event->x() - m_mousePosition.x(); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
616 | int yMove = event->y() - m_mousePosition.y(); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
617 | m_totalMouseMove += qAbs(xMove) + qAbs(yMove); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
618 | m_isCameraMoving = false; |
828
7dd8f19159f7
- and now it works fine too
Santeri Piippo <crimsondusk64@gmail.com>
parents:
827
diff
changeset
|
619 | |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
620 | bool left = event->buttons() & Qt::LeftButton; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
621 | bool mid = event->buttons() & Qt::MidButton; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
622 | bool shift = event->modifiers() & Qt::ShiftModifier; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
623 | |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
624 | if (mid or (left and shift)) |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
625 | { |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
626 | currentCamera().pan(xMove, yMove); |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
627 | m_panning = true; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
628 | m_isCameraMoving = true; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
629 | } |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1121
diff
changeset
|
630 | else if (left and camera() == Camera::Free and (xMove != 0 or yMove != 0)) |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
631 | { |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
632 | // Apply current rotation input to the rotation matrix |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
633 | // ref: https://forums.ldraw.org/thread-22006-post-24426.html#pid24426 |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
634 | glPushMatrix(); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
635 | glLoadIdentity(); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
636 | // 0.6 is an arbitrary rotation sensitivity scalar |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
637 | glRotatef(0.6 * hypot(xMove, yMove), yMove, xMove, 0); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
638 | glMultMatrixf(m_rotationMatrix.constData()); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
639 | glGetFloatv(GL_MODELVIEW_MATRIX, m_rotationMatrix.data()); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
640 | glPopMatrix(); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
641 | m_isCameraMoving = true; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
642 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
643 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
644 | // Start the tool tip timer |
1131
03aa7091cb4a
Simplified camera tooltip code.
Teemu Piippo <teemu@hecknology.net>
parents:
1130
diff
changeset
|
645 | m_toolTipTimer->start (500); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
646 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
647 | // Update 2d position |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
648 | m_mousePosition = event->pos(); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
649 | m_globalpos = event->globalPos(); |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
650 | m_mousePositionF = event->localPos(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
651 | |
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
|
652 | highlightCursorObject(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
653 | update(); |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
654 | event->accept(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
655 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
656 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
657 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
658 | // |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
659 | void GLRenderer::keyPressEvent(QKeyEvent* event) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
660 | { |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
661 | m_currentKeyboardModifiers = event->modifiers(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
662 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
663 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
664 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
665 | // |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
666 | void GLRenderer::keyReleaseEvent(QKeyEvent* event) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
667 | { |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
668 | m_currentKeyboardModifiers = event->modifiers(); |
875
ce8e9b37d44f
- finished line loop mode
Teemu Piippo <crimsondusk64@gmail.com>
parents:
869
diff
changeset
|
669 | update(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
670 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
671 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
672 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
673 | // |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
674 | void GLRenderer::wheelEvent(QWheelEvent* ev) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
675 | { |
1013
fa025ba493d8
Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1012
diff
changeset
|
676 | makeCurrent(); |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
677 | currentCamera().zoomNotch(ev->delta() > 0); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
678 | m_isCameraMoving = true; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
679 | update(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
680 | ev->accept(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
681 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
682 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
683 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
684 | // |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
685 | void GLRenderer::leaveEvent(QEvent*) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
686 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
687 | m_toolTipTimer->stop(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
688 | update(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
689 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
690 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
691 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
692 | // |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
693 | void GLRenderer::setCamera(Camera camera) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
694 | { |
823
1a2f593f0c02
- saving work done on edit mode revamp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
821
diff
changeset
|
695 | // The edit mode may forbid the free camera. |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1121
diff
changeset
|
696 | if (freeCameraAllowed() or camera != Camera::Free) |
1023
9450ac3cd930
Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
697 | { |
9450ac3cd930
Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
698 | m_camera = camera; |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1121
diff
changeset
|
699 | m_config->setCamera(static_cast<int>(camera)); |
1023
9450ac3cd930
Split grid stuff into a new class Grid in grid.cpp/grid.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1017
diff
changeset
|
700 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
701 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
702 | |
1110
ec3ee7da7806
Moved more business logic out of GLRenderer into Canvas. GLRenderer::pick(const QRange&) now returns a set of LDObjects without modifying them. Replaced the GLRenderer::pick(int, int) overload with GLRenderer::pickOneObject.
Teemu Piippo <teemu@hecknology.net>
parents:
1109
diff
changeset
|
703 | /* |
ec3ee7da7806
Moved more business logic out of GLRenderer into Canvas. GLRenderer::pick(const QRange&) now returns a set of LDObjects without modifying them. Replaced the GLRenderer::pick(int, int) overload with GLRenderer::pickOneObject.
Teemu Piippo <teemu@hecknology.net>
parents:
1109
diff
changeset
|
704 | * Returns the set of objects found in the specified pixel area. |
ec3ee7da7806
Moved more business logic out of GLRenderer into Canvas. GLRenderer::pick(const QRange&) now returns a set of LDObjects without modifying them. Replaced the GLRenderer::pick(int, int) overload with GLRenderer::pickOneObject.
Teemu Piippo <teemu@hecknology.net>
parents:
1109
diff
changeset
|
705 | */ |
ec3ee7da7806
Moved more business logic out of GLRenderer into Canvas. GLRenderer::pick(const QRange&) now returns a set of LDObjects without modifying them. Replaced the GLRenderer::pick(int, int) overload with GLRenderer::pickOneObject.
Teemu Piippo <teemu@hecknology.net>
parents:
1109
diff
changeset
|
706 | QSet<LDObject*> GLRenderer::pick(const QRect& range) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
707 | { |
1013
fa025ba493d8
Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1012
diff
changeset
|
708 | makeCurrent(); |
1057
3c7782ec3753
Fixed additive range selection not working properly.
Teemu Piippo <teemu@hecknology.net>
parents:
1056
diff
changeset
|
709 | QSet<LDObject*> newSelection; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
710 | |
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
|
711 | // Paint the picking scene |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
712 | setPicking(true); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
713 | drawGLScene(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
714 | |
827 | 715 | int x0 = range.left(); |
716 | int y0 = range.top(); | |
828
7dd8f19159f7
- and now it works fine too
Santeri Piippo <crimsondusk64@gmail.com>
parents:
827
diff
changeset
|
717 | int x1 = x0 + range.width(); |
7dd8f19159f7
- and now it works fine too
Santeri Piippo <crimsondusk64@gmail.com>
parents:
827
diff
changeset
|
718 | int y1 = y0 + range.height(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
719 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
720 | // Clamp the values to ensure they're within bounds |
966
a834e43a57da
Replaced Min/Max/Clamp/Abs with use of Qt versions of them.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
962
diff
changeset
|
721 | x0 = qMax (0, x0); |
a834e43a57da
Replaced Min/Max/Clamp/Abs with use of Qt versions of them.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
962
diff
changeset
|
722 | y0 = qMax (0, y0); |
1111
471572db2fe1
Replaced GLRenderer::m_width and GLRenderer::m_height with width() and height() calls.
Teemu Piippo <teemu@hecknology.net>
parents:
1110
diff
changeset
|
723 | x1 = qMin (x1, width()); |
471572db2fe1
Replaced GLRenderer::m_width and GLRenderer::m_height with width() and height() calls.
Teemu Piippo <teemu@hecknology.net>
parents:
1110
diff
changeset
|
724 | y1 = qMin (y1, height()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
725 | const int areawidth = (x1 - x0); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
726 | const int areaheight = (y1 - y0); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
727 | const qint32 numpixels = areawidth * areaheight; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
728 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
729 | // Allocate space for the pixel data. |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
730 | QVector<unsigned char> pixelData; |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
731 | pixelData.resize(4 * numpixels); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
732 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
733 | // Read pixels from the color buffer. |
1111
471572db2fe1
Replaced GLRenderer::m_width and GLRenderer::m_height with width() and height() calls.
Teemu Piippo <teemu@hecknology.net>
parents:
1110
diff
changeset
|
734 | glReadPixels(x0, height() - y1, areawidth, areaheight, GL_RGBA, GL_UNSIGNED_BYTE, pixelData.data()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
735 | |
1135
8e0691be0b6f
Removed the intXX type aliases and removed uses of intXX_t in favor of qintXX
Teemu Piippo <teemu@hecknology.net>
parents:
1134
diff
changeset
|
736 | QSet<qint32> indices; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
737 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
738 | // Go through each pixel read and add them to the selection. |
1057
3c7782ec3753
Fixed additive range selection not working properly.
Teemu Piippo <teemu@hecknology.net>
parents:
1056
diff
changeset
|
739 | // Each pixel maps to an LDObject index injectively. |
753 | 740 | // Note: black is background, those indices are skipped. |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
741 | for (unsigned char *pixelCursor = pixelData.begin(); pixelCursor < pixelData.end(); pixelCursor += 4) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
742 | { |
1135
8e0691be0b6f
Removed the intXX type aliases and removed uses of intXX_t in favor of qintXX
Teemu Piippo <teemu@hecknology.net>
parents:
1134
diff
changeset
|
743 | qint32 index = pixelCursor[0] * 0x10000 + pixelCursor[1] * 0x100 + pixelCursor[2] * 0x1; |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
744 | if (index != 0) |
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
745 | indices.insert(index); |
752
b80ccc2a24e4
- optimized picking, black is background now in pick scenes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
742
diff
changeset
|
746 | } |
b80ccc2a24e4
- optimized picking, black is background now in pick scenes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
742
diff
changeset
|
747 | |
1057
3c7782ec3753
Fixed additive range selection not working properly.
Teemu Piippo <teemu@hecknology.net>
parents:
1056
diff
changeset
|
748 | // For each index read, resolve the LDObject behind it and add it to the selection. |
1135
8e0691be0b6f
Removed the intXX type aliases and removed uses of intXX_t in favor of qintXX
Teemu Piippo <teemu@hecknology.net>
parents:
1134
diff
changeset
|
749 | for (qint32 index : indices) |
752
b80ccc2a24e4
- optimized picking, black is background now in pick scenes
Santeri Piippo <crimsondusk64@gmail.com>
parents:
742
diff
changeset
|
750 | { |
1057
3c7782ec3753
Fixed additive range selection not working properly.
Teemu Piippo <teemu@hecknology.net>
parents:
1056
diff
changeset
|
751 | LDObject* object = LDObject::fromID(index); |
958
1dc890c73e01
Removed all asserts from the code. Removed assert handling and the bomb box dialog.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
952
diff
changeset
|
752 | |
1057
3c7782ec3753
Fixed additive range selection not working properly.
Teemu Piippo <teemu@hecknology.net>
parents:
1056
diff
changeset
|
753 | if (object != nullptr) |
1110
ec3ee7da7806
Moved more business logic out of GLRenderer into Canvas. GLRenderer::pick(const QRange&) now returns a set of LDObjects without modifying them. Replaced the GLRenderer::pick(int, int) overload with GLRenderer::pickOneObject.
Teemu Piippo <teemu@hecknology.net>
parents:
1109
diff
changeset
|
754 | newSelection.insert(object); |
1057
3c7782ec3753
Fixed additive range selection not working properly.
Teemu Piippo <teemu@hecknology.net>
parents:
1056
diff
changeset
|
755 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
756 | |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
757 | setPicking(false); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
758 | repaint(); |
1110
ec3ee7da7806
Moved more business logic out of GLRenderer into Canvas. GLRenderer::pick(const QRange&) now returns a set of LDObjects without modifying them. Replaced the GLRenderer::pick(int, int) overload with GLRenderer::pickOneObject.
Teemu Piippo <teemu@hecknology.net>
parents:
1109
diff
changeset
|
759 | return newSelection; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
760 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
761 | |
1110
ec3ee7da7806
Moved more business logic out of GLRenderer into Canvas. GLRenderer::pick(const QRange&) now returns a set of LDObjects without modifying them. Replaced the GLRenderer::pick(int, int) overload with GLRenderer::pickOneObject.
Teemu Piippo <teemu@hecknology.net>
parents:
1109
diff
changeset
|
762 | /* |
ec3ee7da7806
Moved more business logic out of GLRenderer into Canvas. GLRenderer::pick(const QRange&) now returns a set of LDObjects without modifying them. Replaced the GLRenderer::pick(int, int) overload with GLRenderer::pickOneObject.
Teemu Piippo <teemu@hecknology.net>
parents:
1109
diff
changeset
|
763 | * Simpler version of GLRenderer::pick which simply picks whatever object on the cursor |
ec3ee7da7806
Moved more business logic out of GLRenderer into Canvas. GLRenderer::pick(const QRange&) now returns a set of LDObjects without modifying them. Replaced the GLRenderer::pick(int, int) overload with GLRenderer::pickOneObject.
Teemu Piippo <teemu@hecknology.net>
parents:
1109
diff
changeset
|
764 | */ |
ec3ee7da7806
Moved more business logic out of GLRenderer into Canvas. GLRenderer::pick(const QRange&) now returns a set of LDObjects without modifying them. Replaced the GLRenderer::pick(int, int) overload with GLRenderer::pickOneObject.
Teemu Piippo <teemu@hecknology.net>
parents:
1109
diff
changeset
|
765 | LDObject* GLRenderer::pick(int mouseX, int mouseY) |
818
748ba8818af8
- added the magic wand tool
Santeri Piippo <crimsondusk64@gmail.com>
parents:
816
diff
changeset
|
766 | { |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
767 | unsigned char pixel[4]; |
1013
fa025ba493d8
Cleanup miscallenous.cpp/.h
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1012
diff
changeset
|
768 | makeCurrent(); |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
769 | setPicking(true); |
818
748ba8818af8
- added the magic wand tool
Santeri Piippo <crimsondusk64@gmail.com>
parents:
816
diff
changeset
|
770 | drawGLScene(); |
1111
471572db2fe1
Replaced GLRenderer::m_width and GLRenderer::m_height with width() and height() calls.
Teemu Piippo <teemu@hecknology.net>
parents:
1110
diff
changeset
|
771 | glReadPixels(mouseX, height() - mouseY, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel); |
1110
ec3ee7da7806
Moved more business logic out of GLRenderer into Canvas. GLRenderer::pick(const QRange&) now returns a set of LDObjects without modifying them. Replaced the GLRenderer::pick(int, int) overload with GLRenderer::pickOneObject.
Teemu Piippo <teemu@hecknology.net>
parents:
1109
diff
changeset
|
772 | LDObject* object = LDObject::fromID(pixel[0] * 0x10000 + pixel[1] * 0x100 + pixel[2]); |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
773 | setPicking(false); |
818
748ba8818af8
- added the magic wand tool
Santeri Piippo <crimsondusk64@gmail.com>
parents:
816
diff
changeset
|
774 | repaint(); |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
775 | return object; |
818
748ba8818af8
- added the magic wand tool
Santeri Piippo <crimsondusk64@gmail.com>
parents:
816
diff
changeset
|
776 | } |
748ba8818af8
- added the magic wand tool
Santeri Piippo <crimsondusk64@gmail.com>
parents:
816
diff
changeset
|
777 | |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
778 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
779 | // |
1170
2045a395213a
Hardened the GLRenderer interface, made methods more private.
Teemu Piippo <teemu@hecknology.net>
parents:
1169
diff
changeset
|
780 | void GLRenderer::setPicking(bool picking) |
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
|
781 | { |
1170
2045a395213a
Hardened the GLRenderer interface, made methods more private.
Teemu Piippo <teemu@hecknology.net>
parents:
1169
diff
changeset
|
782 | m_isDrawingSelectionScene = picking; |
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
|
783 | setBackground(); |
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
|
784 | |
1061 | 785 | if (m_isDrawingSelectionScene) |
772
e117509e1b51
- make pick scenes always use particularly thick lines so that the line picking behavior is relayed to the mouse-over highlight
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
786 | { |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
787 | glDisable(GL_DITHER); |
772
e117509e1b51
- make pick scenes always use particularly thick lines so that the line picking behavior is relayed to the mouse-over highlight
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
788 | |
e117509e1b51
- make pick scenes always use particularly thick lines so that the line picking behavior is relayed to the mouse-over highlight
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
789 | // Use particularly thick lines while picking ease up selecting lines. |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
790 | glLineWidth(qMax<double>(m_config->lineThickness(), 6.5)); |
772
e117509e1b51
- make pick scenes always use particularly thick lines so that the line picking behavior is relayed to the mouse-over highlight
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
791 | } |
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
|
792 | else |
772
e117509e1b51
- make pick scenes always use particularly thick lines so that the line picking behavior is relayed to the mouse-over highlight
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
793 | { |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
794 | glEnable(GL_DITHER); |
772
e117509e1b51
- make pick scenes always use particularly thick lines so that the line picking behavior is relayed to the mouse-over highlight
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
795 | |
e117509e1b51
- make pick scenes always use particularly thick lines so that the line picking behavior is relayed to the mouse-over highlight
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
796 | // Restore line thickness |
1056
27b7991b3bea
Cleanup in GL renderer...
Teemu Piippo <teemu@hecknology.net>
parents:
1049
diff
changeset
|
797 | glLineWidth(m_config->lineThickness()); |
772
e117509e1b51
- make pick scenes always use particularly thick lines so that the line picking behavior is relayed to the mouse-over highlight
Santeri Piippo <crimsondusk64@gmail.com>
parents:
768
diff
changeset
|
798 | } |
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
|
799 | } |
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
|
800 | |
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
|
801 | // ============================================================================= |
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
|
802 | // |
1158
35ceb74fe53e
Made the GL renderer recieve information of object deletion via signals.
Teemu Piippo <teemu@hecknology.net>
parents:
1157
diff
changeset
|
803 | void GLRenderer::removeObject(LDObject* object) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
804 | { |
1158
35ceb74fe53e
Made the GL renderer recieve information of object deletion via signals.
Teemu Piippo <teemu@hecknology.net>
parents:
1157
diff
changeset
|
805 | if (m_objectAtCursor == object) |
978
4603d8fd063e
Make documents members of the main window
Teemu Piippo <crimsondusk64@gmail.com>
parents:
973
diff
changeset
|
806 | m_objectAtCursor = nullptr; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
807 | } |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
808 | |
1171
430ffa371d2a
Turned GLRenderer::pixelCapture to GLRenderer::screenCapture() which encapsulates screen capturing properly and returns a ready image.
Teemu Piippo <teemu@hecknology.net>
parents:
1170
diff
changeset
|
809 | /* |
430ffa371d2a
Turned GLRenderer::pixelCapture to GLRenderer::screenCapture() which encapsulates screen capturing properly and returns a ready image.
Teemu Piippo <teemu@hecknology.net>
parents:
1170
diff
changeset
|
810 | * Returns an image containing the current render of the scene. |
430ffa371d2a
Turned GLRenderer::pixelCapture to GLRenderer::screenCapture() which encapsulates screen capturing properly and returns a ready image.
Teemu Piippo <teemu@hecknology.net>
parents:
1170
diff
changeset
|
811 | */ |
430ffa371d2a
Turned GLRenderer::pixelCapture to GLRenderer::screenCapture() which encapsulates screen capturing properly and returns a ready image.
Teemu Piippo <teemu@hecknology.net>
parents:
1170
diff
changeset
|
812 | QImage GLRenderer::screenCapture() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
813 | { |
1171
430ffa371d2a
Turned GLRenderer::pixelCapture to GLRenderer::screenCapture() which encapsulates screen capturing properly and returns a ready image.
Teemu Piippo <teemu@hecknology.net>
parents:
1170
diff
changeset
|
814 | // Read the current render to a buffer of pixels. We use RGBA format even though the image should be fully opaque at all times. |
430ffa371d2a
Turned GLRenderer::pixelCapture to GLRenderer::screenCapture() which encapsulates screen capturing properly and returns a ready image.
Teemu Piippo <teemu@hecknology.net>
parents:
1170
diff
changeset
|
815 | // This is because apparently GL_RGBA/GL_UNSIGNED_BYTE is the only setting pair that is guaranteed to actually work! |
430ffa371d2a
Turned GLRenderer::pixelCapture to GLRenderer::screenCapture() which encapsulates screen capturing properly and returns a ready image.
Teemu Piippo <teemu@hecknology.net>
parents:
1170
diff
changeset
|
816 | // ref: https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glReadPixels.xml |
1172
3defab8cfd93
Changed QByteArray to QVector to avoid that ugly reinterpret_cast.
Teemu Piippo <teemu@hecknology.net>
parents:
1171
diff
changeset
|
817 | QVector<unsigned char> pixelData; |
1171
430ffa371d2a
Turned GLRenderer::pixelCapture to GLRenderer::screenCapture() which encapsulates screen capturing properly and returns a ready image.
Teemu Piippo <teemu@hecknology.net>
parents:
1170
diff
changeset
|
818 | pixelData.resize(4 * width() * height()); |
430ffa371d2a
Turned GLRenderer::pixelCapture to GLRenderer::screenCapture() which encapsulates screen capturing properly and returns a ready image.
Teemu Piippo <teemu@hecknology.net>
parents:
1170
diff
changeset
|
819 | glReadPixels(0, 0, width(), height(), GL_RGBA, GL_UNSIGNED_BYTE, pixelData.data()); |
430ffa371d2a
Turned GLRenderer::pixelCapture to GLRenderer::screenCapture() which encapsulates screen capturing properly and returns a ready image.
Teemu Piippo <teemu@hecknology.net>
parents:
1170
diff
changeset
|
820 | |
430ffa371d2a
Turned GLRenderer::pixelCapture to GLRenderer::screenCapture() which encapsulates screen capturing properly and returns a ready image.
Teemu Piippo <teemu@hecknology.net>
parents:
1170
diff
changeset
|
821 | // Prepare the image and return it. It appears that GL and Qt formats have red and blue swapped and the Y axis flipped. |
1172
3defab8cfd93
Changed QByteArray to QVector to avoid that ugly reinterpret_cast.
Teemu Piippo <teemu@hecknology.net>
parents:
1171
diff
changeset
|
822 | QImage image {pixelData.constData(), width(), height(), QImage::Format_ARGB32}; |
1171
430ffa371d2a
Turned GLRenderer::pixelCapture to GLRenderer::screenCapture() which encapsulates screen capturing properly and returns a ready image.
Teemu Piippo <teemu@hecknology.net>
parents:
1170
diff
changeset
|
823 | return image.rgbSwapped().mirrored(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
824 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
825 | |
1131
03aa7091cb4a
Simplified camera tooltip code.
Teemu Piippo <teemu@hecknology.net>
parents:
1130
diff
changeset
|
826 | /* |
03aa7091cb4a
Simplified camera tooltip code.
Teemu Piippo <teemu@hecknology.net>
parents:
1130
diff
changeset
|
827 | * Show a tooltip if the cursor is currently hovering over a camera icon. |
03aa7091cb4a
Simplified camera tooltip code.
Teemu Piippo <teemu@hecknology.net>
parents:
1130
diff
changeset
|
828 | */ |
03aa7091cb4a
Simplified camera tooltip code.
Teemu Piippo <teemu@hecknology.net>
parents:
1130
diff
changeset
|
829 | void GLRenderer::showCameraIconTooltip() |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
830 | { |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
831 | for (CameraIcon & icon : m_cameraIcons) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
832 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
833 | if (icon.targetRect.contains (m_mousePosition)) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
834 | { |
1131
03aa7091cb4a
Simplified camera tooltip code.
Teemu Piippo <teemu@hecknology.net>
parents:
1130
diff
changeset
|
835 | QToolTip::showText(m_globalpos, m_cameras[static_cast<int>(icon.camera)].name()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
836 | update(); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
837 | break; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
838 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
839 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
840 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
841 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
842 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
843 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
844 | void GLRenderer::zoomToFit() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
845 | { |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
846 | currentCamera().setZoom(30.0f); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
847 | bool lastfilled = false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
848 | bool firstrun = true; |
901
6e89eaa1df70
- zoom-to-fit now works.. better than before
Teemu Piippo <crimsondusk64@gmail.com>
parents:
897
diff
changeset
|
849 | enum { black = 0xFF000000 }; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
850 | bool inward = true; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
851 | int runaway = 50; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
852 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
853 | // Use the pick list while drawing the scene, this way we can tell whether borders |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
854 | // are background or not. |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
855 | setPicking (true); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
856 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
857 | while (--runaway) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
858 | { |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
828
diff
changeset
|
859 | if (zoom() > 10000.0 or zoom() < 0.0) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
860 | { |
901
6e89eaa1df70
- zoom-to-fit now works.. better than before
Teemu Piippo <crimsondusk64@gmail.com>
parents:
897
diff
changeset
|
861 | // Nothing to draw if we get here. |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
862 | currentCamera().setZoom(30.0); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
863 | break; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
864 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
865 | |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
866 | currentCamera().zoomNotch(inward); |
1111
471572db2fe1
Replaced GLRenderer::m_width and GLRenderer::m_height with width() and height() calls.
Teemu Piippo <teemu@hecknology.net>
parents:
1110
diff
changeset
|
867 | QVector<unsigned char> capture (4 * width() * height()); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
868 | drawGLScene(); |
1111
471572db2fe1
Replaced GLRenderer::m_width and GLRenderer::m_height with width() and height() calls.
Teemu Piippo <teemu@hecknology.net>
parents:
1110
diff
changeset
|
869 | glReadPixels (0, 0, width(), height(), GL_RGBA, GL_UNSIGNED_BYTE, capture.data()); |
471572db2fe1
Replaced GLRenderer::m_width and GLRenderer::m_height with width() and height() calls.
Teemu Piippo <teemu@hecknology.net>
parents:
1110
diff
changeset
|
870 | QImage image (capture.constData(), width(), height(), QImage::Format_ARGB32); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
871 | bool filled = false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
872 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
873 | // Check the top and bottom rows |
901
6e89eaa1df70
- zoom-to-fit now works.. better than before
Teemu Piippo <crimsondusk64@gmail.com>
parents:
897
diff
changeset
|
874 | for (int i = 0; i < image.width(); ++i) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
875 | { |
1111
471572db2fe1
Replaced GLRenderer::m_width and GLRenderer::m_height with width() and height() calls.
Teemu Piippo <teemu@hecknology.net>
parents:
1110
diff
changeset
|
876 | if (image.pixel (i, 0) != black or image.pixel (i, height() - 1) != black) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
877 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
878 | filled = true; |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
879 | break; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
880 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
881 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
882 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
883 | // Left and right edges |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
884 | if (filled == false) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
885 | { |
901
6e89eaa1df70
- zoom-to-fit now works.. better than before
Teemu Piippo <crimsondusk64@gmail.com>
parents:
897
diff
changeset
|
886 | for (int i = 0; i < image.height(); ++i) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
887 | { |
1111
471572db2fe1
Replaced GLRenderer::m_width and GLRenderer::m_height with width() and height() calls.
Teemu Piippo <teemu@hecknology.net>
parents:
1110
diff
changeset
|
888 | if (image.pixel (0, i) != black or image.pixel (width() - 1, i) != black) |
706
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
889 | { |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
890 | filled = true; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
891 | break; |
d79083b9f74d
Merge ../ldforge into gl
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
892 | } |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
893 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
894 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
895 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
896 | if (firstrun) |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
897 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
898 | // If this is the first run, we don't know enough to determine |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
899 | // whether the zoom was to fit, so we mark in our knowledge so |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
900 | // far and start over. |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
901 | inward = not filled; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
902 | firstrun = false; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
903 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
904 | else |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
905 | { |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
906 | // If this run filled the screen and the last one did not, the |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
907 | // last run had ideal zoom - zoom a bit back and we should reach it. |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
828
diff
changeset
|
908 | if (filled and not lastfilled) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
909 | { |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
910 | currentCamera().zoomNotch(false); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
911 | break; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
912 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
913 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
914 | // If this run did not fill the screen and the last one did, we've |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
915 | // now reached ideal zoom so we're done here. |
840
d077dd19bf9a
- changed `&&` and `||` operators to their named variants `and` and `or`
Teemu Piippo <crimsondusk64@gmail.com>
parents:
828
diff
changeset
|
916 | if (not filled and lastfilled) |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
917 | break; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
918 | |
662
2f1bd9112408
- use the keyword 'not' in place of the exclamation mark for operator!, this is clearer. also converted uses of '== false' to this.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
655
diff
changeset
|
919 | inward = not filled; |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
920 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
921 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
922 | lastfilled = filled; |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
923 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
924 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
925 | setPicking (false); |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
926 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
927 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
928 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
929 | // |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
930 | void GLRenderer::zoomAllToFit() |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
931 | { |
901
6e89eaa1df70
- zoom-to-fit now works.. better than before
Teemu Piippo <crimsondusk64@gmail.com>
parents:
897
diff
changeset
|
932 | zoomToFit(); |
655
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
933 | } |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
934 | |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
935 | // ============================================================================= |
b376645315ab
- renamed files to camelCase
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
936 | // |
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
|
937 | void GLRenderer::highlightCursorObject() |
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
|
938 | { |
1017
fc1c13db9618
Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1015
diff
changeset
|
939 | if (not m_config->highlightObjectBelowCursor() and objectAtCursor() == nullptr) |
760
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
940 | return; |
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
|
941 | |
946 | 942 | LDObject* newObject = nullptr; |
945
c310073e4f22
More sharedpointer removal
Teemu Piippo <crimsondusk64@gmail.com>
parents:
944
diff
changeset
|
943 | LDObject* oldObject = objectAtCursor(); |
760
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
944 | qint32 newIndex; |
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
945 | |
1017
fc1c13db9618
Renamed ConfigurationValueBag to Configuration and added a pointer to it into HierarchyElement. This helps with the fight against global variables.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
1015
diff
changeset
|
946 | if (m_isCameraMoving or not m_config->highlightObjectBelowCursor()) |
760
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
947 | { |
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
948 | newIndex = 0; |
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
949 | } |
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
950 | else |
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
951 | { |
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
952 | setPicking (true); |
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
953 | drawGLScene(); |
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
954 | setPicking (false); |
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
955 | |
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
956 | unsigned char pixel[4]; |
1111
471572db2fe1
Replaced GLRenderer::m_width and GLRenderer::m_height with width() and height() calls.
Teemu Piippo <teemu@hecknology.net>
parents:
1110
diff
changeset
|
957 | glReadPixels (m_mousePosition.x(), height() - m_mousePosition.y(), 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &pixel[0]); |
760
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
958 | newIndex = pixel[0] * 0x10000 | pixel[1] * 0x100 | pixel[2]; |
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
959 | } |
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
|
960 | |
985
ed7b31b9f904
Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
961 | if (newIndex != (oldObject ? oldObject->id() : 0)) |
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
|
962 | { |
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
|
963 | if (newIndex != 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
|
964 | newObject = LDObject::fromID (newIndex); |
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
|
965 | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
966 | m_objectAtCursor = newObject; |
760
e4e585f464b3
- made the mouse-hover object highlight togglable from configuration
Santeri Piippo <crimsondusk64@gmail.com>
parents:
759
diff
changeset
|
967 | |
985
ed7b31b9f904
Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
968 | if (oldObject) |
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:
1111
diff
changeset
|
969 | emit objectHighlightingChanged(oldObject); |
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
|
970 | |
985
ed7b31b9f904
Remove "!= nullptr" expressions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
984
diff
changeset
|
971 | if (newObject) |
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:
1111
diff
changeset
|
972 | emit objectHighlightingChanged(newObject); |
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
|
973 | } |
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
|
974 | |
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
|
975 | update(); |
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
|
976 | } |
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
|
977 | |
827 | 978 | bool GLRenderer::mouseHasMoved() const |
979 | { | |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
980 | return m_totalMouseMove >= 10; |
827 | 981 | } |
982 | ||
983 | QPoint const& GLRenderer::mousePosition() const | |
984 | { | |
985 | return m_mousePosition; | |
986 | } | |
855
e16f1587ef44
- fixed compilation on windows systems
Santeri Piippo <crimsondusk64@gmail.com>
parents:
851
diff
changeset
|
987 | |
869
7184f3bae695
- circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
988 | QPointF const& GLRenderer::mousePositionF() const |
7184f3bae695
- circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
989 | { |
7184f3bae695
- circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
990 | return m_mousePositionF; |
7184f3bae695
- circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
991 | } |
7184f3bae695
- circle tool is now able to rotate the partial circular primitives spawned
Teemu Piippo <crimsondusk64@gmail.com>
parents:
866
diff
changeset
|
992 | |
897
ef9e4469975a
- pressing ctrl while drawing now locks the draw to cardinal directions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
882
diff
changeset
|
993 | Qt::KeyboardModifiers GLRenderer::keyboardModifiers() const |
ef9e4469975a
- pressing ctrl while drawing now locks the draw to cardinal directions
Teemu Piippo <crimsondusk64@gmail.com>
parents:
882
diff
changeset
|
994 | { |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
995 | return m_currentKeyboardModifiers; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
996 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
997 | |
1033 | 998 | Camera GLRenderer::camera() const |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
999 | { |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1000 | return m_camera; |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1001 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1002 | |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1003 | double GLRenderer::panning (Axis ax) const |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1004 | { |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
1005 | return (ax == X) ? currentCamera().panningX() : currentCamera().panningY(); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1006 | } |
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1007 | |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
1008 | double GLRenderer::zoom() |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1009 | { |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1125
diff
changeset
|
1010 | return currentCamera().zoom(); |
986
525921eae58c
Refactor GLRenderer and GLCompiler
Teemu Piippo <crimsondusk64@gmail.com>
parents:
985
diff
changeset
|
1011 | } |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
1012 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
1013 | const QGenericMatrix<4, 4, GLfloat>& GLRenderer::rotationMatrix() const |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
1014 | { |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
1015 | return m_rotationMatrix; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
1016 | } |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
1017 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
1018 | bool GLRenderer::isDrawingSelectionScene() const |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
1019 | { |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
1020 | return m_isDrawingSelectionScene; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
1021 | } |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
1022 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
1023 | Qt::MouseButtons GLRenderer::lastButtons() const |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
1024 | { |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
1025 | return m_lastButtons; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
1026 | } |
1108
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1107
diff
changeset
|
1027 | |
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:
1111
diff
changeset
|
1028 | const Model* GLRenderer::model() const |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1111
diff
changeset
|
1029 | { |
5f3139c802bf
Cleaned up GLCompiler. Among other changes, the compiler no longer has to be told what to compile.
Teemu Piippo <teemu@hecknology.net>
parents:
1111
diff
changeset
|
1030 | return m_model; |
1125
d8f94e56d42e
Moved the definitions of all configuration options into a new text file and made the configuration collector read that.
Teemu Piippo <teemu@hecknology.net>
parents:
1123
diff
changeset
|
1031 | } |
1178
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
1032 | |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
1033 | /* |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
1034 | * This virtual function lets derivative classes render something to the fixed camera |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
1035 | * before the main brick is rendered. |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
1036 | */ |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
1037 | void GLRenderer::drawFixedCameraBackdrop() {} |