Wed, 20 Mar 2013 13:27:43 +0200
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
30
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
1 | /* |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
3 | * Copyright (C) 2013 Santeri `arezey` Piippo |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
4 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
8 | * (at your option) any later version. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
9 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
13 | * GNU General Public License for more details. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
14 | * |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
17 | */ |
31ff9aabd506
Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents:
28
diff
changeset
|
18 | |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #include <QtGui> |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include <QGLWidget> |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
21 | #include <GL/glu.h> |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | #include "common.h" |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | #include "file.h" |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | #include "gldraw.h" |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | #include "bbox.h" |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
27 | #define GL_VERTEX(V) glVertex3d (V.x, V.y, V.z); |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
28 | |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
29 | // ============================================================================= |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
30 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
31 | // ============================================================================= |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | renderer::renderer (QWidget* parent) { |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
33 | parent = parent; // shhh, GCC |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
34 | fRotX = fRotY = fRotZ = 0.0; |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | fZoom = 1.0; |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
38 | // ============================================================================= |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
39 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
40 | // ============================================================================= |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | void renderer::initializeGL () { |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
42 | glLoadIdentity(); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | glMatrixMode (GL_MODELVIEW); |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
44 | |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
45 | setBackground (); |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
46 | |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
47 | glEnable (GL_POLYGON_OFFSET_FILL); |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
48 | glPolygonOffset (1.0f, 1.0f); |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
49 | |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | glEnable (GL_DEPTH_TEST); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | glShadeModel (GL_SMOOTH); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | glEnable (GL_MULTISAMPLE); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
54 | glEnable (GL_DITHER); |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
55 | glEnable (GL_BLEND); |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
56 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
57 | |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
58 | glEnable (GL_LINE_SMOOTH); |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
59 | glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
60 | glLineWidth (4 * 2.0f); |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
61 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
62 | compileObjects (); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
63 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
65 | // ============================================================================= |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
66 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
67 | // ============================================================================= |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
68 | void renderer::setBackground () { |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
69 | QColor col (gl_bgcolor.value.chars()); |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
70 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
71 | if (col.isValid ()) { |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
72 | glClearColor ( |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
73 | ((double)col.red()) / 255.0f, |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
74 | ((double)col.green()) / 255.0f, |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
75 | ((double)col.blue()) / 255.0f, |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
76 | 1.0f); |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
77 | } else { |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
78 | glClearColor (0.8f, 0.8f, 0.85f, 1.0f); |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
79 | } |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
80 | } |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
81 | |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
82 | // ============================================================================= |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
83 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
84 | // ============================================================================= |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | void renderer::hardRefresh () { |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
86 | compileObjects (); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | paintGL (); |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
88 | swapBuffers (); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
91 | // ============================================================================= |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
92 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
93 | // ============================================================================= |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | void renderer::resizeGL (int w, int h) { |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | glViewport (0, 0, w, h); |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
96 | glLoadIdentity (); |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
97 | glMatrixMode (GL_PROJECTION); |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
98 | gluPerspective (45.0f, (double)w / (double)h, 0.1f, 100.0f); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
99 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
100 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
101 | // ============================================================================= |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
102 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
103 | // ============================================================================= |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | void renderer::paintGL () { |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
105 | glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
106 | printf ("painting..\n"); |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
107 | glMatrixMode (GL_MODELVIEW); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
108 | |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
109 | glPushMatrix (); |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
110 | glLoadIdentity (); |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
111 | |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
112 | /* |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
113 | glTranslatef ( |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
114 | (g_BBox.v0.x + g_BBox.v1.x) / -2.0, |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
115 | (g_BBox.v0.y + g_BBox.v1.y) / -2.0, |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
116 | (g_BBox.v0.z + g_BBox.v1.z) / -2.0 |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
117 | ); |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
118 | */ |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
119 | |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
120 | glTranslatef (0.0f, 0.0f, -5.0f); |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
121 | glTranslatef (0.0f, 0.0f, -fZoom); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
122 | |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
123 | // glScalef (0.75f, 1.15f, 0.0f); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
124 | glRotatef (fRotX, 1.0f, 0.0f, 0.0f); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
125 | glRotatef (fRotY, 0.0f, 1.0f, 0.0f); |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
126 | // glRotatef (fRotZ, 0.0f, 0.0f, 1.0f); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
127 | |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
128 | glCallList (uObjList); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
129 | glPopMatrix (); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
130 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
131 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
132 | // ============================================================================= |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
133 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
134 | // ============================================================================= |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
135 | void renderer::compileObjects () { |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
136 | printf ("compile all objects\n"); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
137 | |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
138 | uObjList = glGenLists (1); |
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
139 | glNewList (uObjList, GL_COMPILE); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
140 | |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
141 | if (!g_CurrentFile) { |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
142 | printf ("renderer: no files loaded, cannot compile anything\n"); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
143 | return; |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
144 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
145 | |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
146 | for (ulong i = 0; i < g_CurrentFile->objects.size(); i++) |
28
208adc847377
added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
147 | compileOneObject (g_CurrentFile->objects[i]); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
148 | |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
149 | glEndList (); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
150 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
151 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
152 | // ============================================================================= |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
153 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
154 | // ============================================================================= |
28
208adc847377
added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
155 | void renderer::compileOneObject (LDObject* obj) { |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
156 | if (!obj) |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
157 | return; |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
158 | |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
159 | switch (obj->getType ()) { |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
160 | case OBJ_CondLine: // For now, treat condlines like normal lines. |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
161 | case OBJ_Line: |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
162 | { |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
163 | glColor3f (0.0f, 0.0f, 0.0f); // Draw all lines black for now |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
164 | // draw lines |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
165 | LDLine* line = static_cast<LDLine*> (obj); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
166 | glBegin (GL_LINES); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
167 | for (short i = 0; i < 2; ++i) |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
168 | GL_VERTEX (line->vaCoords[i]) |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
169 | glEnd (); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
170 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
171 | break; |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
172 | |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
173 | case OBJ_Triangle: |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
174 | { |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
175 | LDTriangle* tri = static_cast<LDTriangle*> (obj); |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
176 | glColor3f (0.5f, 0.0f, 0.0f); // Draw all polygons red for now |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
177 | glBegin (GL_TRIANGLES); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
178 | for (short i = 0; i < 3; ++i) |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
179 | GL_VERTEX (tri->vaCoords[i]) |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
180 | glEnd (); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
181 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
182 | break; |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
183 | |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
184 | case OBJ_Quad: |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
185 | { |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
186 | LDQuad* quad = static_cast<LDQuad*> (obj); |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
187 | glColor3f (0.5f, 0.0f, 0.0f); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
188 | glBegin (GL_QUADS); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
189 | for (short i = 0; i < 4; ++i) |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
190 | GL_VERTEX (quad->vaCoords[i]) |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
191 | glEnd (); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
192 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
193 | break; |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
194 | |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
195 | default: |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
196 | break; |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
197 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
198 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
199 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
200 | // ============================================================================= |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
201 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
202 | // ============================================================================= |
28
208adc847377
added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
203 | void renderer::clampAngle (double& fAngle) { |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
204 | while (fAngle < 0) |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
205 | fAngle += 360.0; |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
206 | while (fAngle > 360.0) |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
207 | fAngle -= 360.0; |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
208 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
209 | |
32
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
210 | // ============================================================================= |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
211 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5d22b7ecf110
Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents:
30
diff
changeset
|
212 | // ============================================================================= |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
213 | void renderer::mouseMoveEvent (QMouseEvent *event) { |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
214 | int dx = event->x () - lastPos.x (); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
215 | int dy = event->y () - lastPos.y (); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
216 | |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
217 | if (event->buttons () & Qt::LeftButton) { |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
218 | fRotX = fRotX + (dy); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
219 | fRotY = fRotY + (dx); |
28
208adc847377
added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
220 | clampAngle (fRotX); |
208adc847377
added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
221 | clampAngle (fRotY); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
222 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
223 | |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
224 | if (event->buttons () & Qt::RightButton) { |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
225 | fRotX = fRotX + (dy); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
226 | fRotZ = fRotZ + (dx); |
28
208adc847377
added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
227 | clampAngle (fRotX); |
208adc847377
added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents:
26
diff
changeset
|
228 | clampAngle (fRotZ); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
229 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
230 | |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
231 | if (event->buttons () & Qt::MidButton) { |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
232 | fZoom += (dy / 100.0); |
46
69962c85f717
Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
32
diff
changeset
|
233 | fZoom = clamp (fZoom, 0.01, 100.0); |
26
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
234 | } |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
235 | |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
236 | printf ("%.3f %.3f %.3f %.3f\n", |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
237 | fRotX, fRotY, fRotZ, fZoom); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
238 | lastPos = event->pos(); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
239 | updateGL (); |
83184d9407c7
Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
240 | } |