Mercurial > mplayer.hg
annotate libvo/matrixview.c @ 35501:7bb176fac55c
Use boolean symbolic constants in Win32 GUI.
Use them wherever suitable and useful to make code easier to read.
author | ib |
---|---|
date | Tue, 04 Dec 2012 20:06:43 +0000 |
parents | f8c523d09e5e |
children | f464ea910bd2 |
rev | line source |
---|---|
30140 | 1 /* |
2 * Copyright (C) 2003 Alex Zolotov <nightradio@knoppix.ru> | |
3 * Mucked with by Tugrul Galatali <tugrul@galatali.com> | |
4 * | |
5 * MatrixView is free software; you can redistribute it and/or modify | |
30182
ab027cdbba31
Change license terms for matrixview to GPLv2 "or later", all known
reimar
parents:
30160
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
ab027cdbba31
Change license terms for matrixview to GPLv2 "or later", all known
reimar
parents:
30160
diff
changeset
|
7 * the Free Software Foundation; either version 2 of the License, or |
ab027cdbba31
Change license terms for matrixview to GPLv2 "or later", all known
reimar
parents:
30160
diff
changeset
|
8 * (at your option) any later version. |
30140 | 9 * |
10 * MatrixView is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 * GNU General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU General Public License along | |
30160
f91c628dc701
Refer to MatrixView instead of MPlayer in code taken from MatrixView.
diego
parents:
30153
diff
changeset
|
16 * with MatrixView; if not, write to the Free Software Foundation, Inc., |
30140 | 17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
18 */ | |
19 | |
20 /** | |
21 * Ported to an MPlayer video out plugin by Pigeon <pigeon at pigeond.net> | |
22 * August 2006 | |
23 */ | |
24 | |
25 #include <math.h> | |
26 #include <stdio.h> | |
27 #include <stdint.h> | |
28 #include <stdlib.h> | |
29 #include <string.h> | |
30 #include "gl_common.h" | |
31 #include "matrixview.h" | |
32 #include "matrixview_font.h" | |
33 | |
30153 | 34 static float matrix_contrast = 1.5; |
30140 | 35 static float matrix_brightness = 1.0; |
36 | |
37 // Settings for our light. Try playing with these (or add more lights). | |
30153 | 38 static float Light_Ambient[] = { 0.1f, 0.1f, 0.1f, 1.0f }; |
39 static float Light_Diffuse[] = { 1.2f, 1.2f, 1.2f, 1.0f }; | |
30140 | 40 static float Light_Position[] = { 2.0f, 2.0f, 0.0f, 1.0f }; |
41 | |
42 static const uint8_t flare[4][4] = { | |
43 { 0, 0, 0, 0}, | |
44 { 0, 180, 0, 0}, | |
45 { 0, 0, 0, 0}, | |
46 { 0, 0, 0, 0} | |
47 }; | |
48 | |
49 #define MAX_TEXT_X 0x4000 | |
50 #define MAX_TEXT_Y 0x4000 | |
51 static int text_x = 0; | |
52 static int text_y = 0; | |
34060
fab4513840cb
Add () around macro definitions where necessary to avoid bad surprises.
reimar
parents:
34054
diff
changeset
|
53 #define _text_x (text_x/2) |
fab4513840cb
Add () around macro definitions where necessary to avoid bad surprises.
reimar
parents:
34054
diff
changeset
|
54 #define _text_y (text_y/2) |
30140 | 55 |
56 // Scene position | |
57 #define Z_Off -128.0f | |
58 #define Z_Depth 8 | |
59 | |
60 static uint8_t *speed; | |
61 static uint8_t *text; | |
62 static uint8_t *text_light; | |
63 static float *text_depth; | |
64 | |
65 static float *bump_pic; | |
66 | |
67 static void draw_char(int num, float light, float x, float y, float z) | |
68 { | |
69 float tx, ty; | |
70 int num2, num3; | |
71 | |
72 num &= 63; | |
73 //light = light / 255; //light=7-light;num+=(light*60); | |
74 light = light / 255 * matrix_brightness; | |
75 num2 = num / 10; | |
76 num3 = num - (num2 * 10); | |
77 ty = (float)num2 / 7; | |
78 tx = (float)num3 / 10; | |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
79 mpglNormal3f(0.0f, 0.0f, 1.0f); // Needed for lighting |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
80 mpglColor4f(0.0, 1.0, 0.0, light); // Basic polygon color |
30140 | 81 |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
82 mpglTexCoord2f(tx, ty); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
83 mpglVertex3f(x, y, z); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
84 mpglTexCoord2f(tx + 0.1, ty); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
85 mpglVertex3f(x + 1, y, z); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
86 mpglTexCoord2f(tx + 0.1, ty + 0.166); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
87 mpglVertex3f(x + 1, y - 1, z); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
88 mpglTexCoord2f(tx, ty + 0.166); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
89 mpglVertex3f(x, y - 1, z); |
30140 | 90 } |
91 | |
92 static void draw_illuminatedchar(int num, float x, float y, float z) | |
93 { | |
94 float tx, ty; | |
95 int num2, num3; | |
96 | |
97 num2 = num / 10; | |
98 num3 = num - (num2 * 10); | |
99 ty = (float)num2 / 7; | |
100 tx = (float)num3 / 10; | |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
101 mpglNormal3f(0.0f, 0.0f, 1.0f); // Needed for lighting |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
102 mpglColor4f(1.0, 1.0, 1.0, .5); // Basic polygon color |
30140 | 103 |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
104 mpglTexCoord2f(tx, ty); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
105 mpglVertex3f(x, y, z); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
106 mpglTexCoord2f(tx + 0.1, ty); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
107 mpglVertex3f(x + 1, y, z); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
108 mpglTexCoord2f(tx + 0.1, ty + 0.166); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
109 mpglVertex3f(x + 1, y - 1, z); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
110 mpglTexCoord2f(tx, ty + 0.166); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
111 mpglVertex3f(x, y - 1, z); |
30140 | 112 } |
113 | |
114 static void draw_flare(float x, float y, float z) //flare | |
115 { | |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
116 mpglNormal3f(0.0f, 0.0f, 1.0f); // Needed for lighting |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
117 mpglColor4f(1.0, 1.0, 1.0, .8); // Basic polygon color |
30140 | 118 |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
119 mpglTexCoord2f(0, 0); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
120 mpglVertex3f(x - 1, y + 1, z); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
121 mpglTexCoord2f(0.75, 0); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
122 mpglVertex3f(x + 2, y + 1, z); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
123 mpglTexCoord2f(0.75, 0.75); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
124 mpglVertex3f(x + 2, y - 2, z); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
125 mpglTexCoord2f(0, 0.75); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
126 mpglVertex3f(x - 1, y - 2, z); |
30140 | 127 } |
128 | |
129 static void draw_text(uint8_t *pic) | |
130 { | |
131 int x, y; | |
132 int p = 0; | |
133 int c, c_pic; | |
134 int pic_fade = 255; | |
135 | |
136 for (y = _text_y; y > -_text_y; y--) { | |
137 for (x = -_text_x; x < _text_x; x++) { | |
30153 | 138 c = text_light[p] - (text[p] >> 1); |
30140 | 139 c += pic_fade; |
140 if (c > 255) | |
141 c = 255; | |
142 | |
143 if (pic) { | |
144 // Original code | |
145 //c_pic = pic[p] * matrix_contrast - (255 - pic_fade); | |
146 | |
147 c_pic = (255 - pic[p]) * matrix_contrast - (255 - pic_fade); | |
148 | |
149 if (c_pic < 0) | |
150 c_pic = 0; | |
151 | |
152 c -= c_pic; | |
153 | |
154 if (c < 0) | |
155 c = 0; | |
156 | |
157 bump_pic[p] = (255.0f - c_pic) / (256 / Z_Depth); | |
158 } else { | |
159 bump_pic[p] = Z_Depth; | |
160 } | |
161 | |
162 if (text[p] && c > 10) | |
163 draw_char(text[p] + 1, c, x, y, text_depth[p] + bump_pic[p]); | |
164 | |
165 if (text_depth[p] < 0.1) | |
166 text_depth[p] = 0; | |
167 else | |
168 text_depth[p] /= 1.1; | |
169 | |
170 if (text_light[p] > 128 && text_light[p + text_x] < 10) | |
30153 | 171 draw_illuminatedchar(text[p] + 1, x, y, |
172 text_depth[p] + bump_pic[p]); | |
30140 | 173 |
174 p++; | |
175 } | |
176 } | |
177 } | |
178 | |
179 static void draw_flares(void) | |
180 { | |
181 float x, y; | |
182 int p = 0; | |
183 | |
184 for (y = _text_y; y > -_text_y; y--) { | |
185 for (x = -_text_x; x < _text_x; x++) { | |
186 if (text_light[p] > 128 && text_light[p + text_x] < 10) | |
30153 | 187 draw_flare(x, y, text_depth[p] + bump_pic[p]); |
30140 | 188 p++; |
189 } | |
190 } | |
191 } | |
192 | |
193 static void scroll(double dCurrentTime) | |
194 { | |
195 int a, s, polovina; | |
196 //static double dLastCycle = -1; | |
197 static double dLastMove = -1; | |
198 | |
199 if (dCurrentTime - dLastMove > 1.0 / (text_y / 1.5)) { | |
200 dLastMove = dCurrentTime; | |
201 | |
202 polovina = text_x * text_y / 2; | |
203 s = 0; | |
204 for (a = text_x * text_y + text_x - 1; a >= text_x; a--) { | |
205 if (speed[s]) | |
206 text_light[a] = text_light[a - text_x]; //scroll light table down | |
207 s++; | |
208 if (s >= text_x) | |
209 s = 0; | |
210 } | |
211 memmove(text_light + text_x, text_light, text_x * text_y); | |
212 memset(text_light, 253, text_x); | |
213 | |
214 s = 0; | |
215 for (a = polovina; a < text_x * text_y; a++) { | |
216 if (text_light[a] == 255) | |
217 text_light[s] = text_light[s + text_x] >> 1; //make black bugs in top line | |
218 | |
219 s++; | |
220 | |
221 if (s >= text_x) | |
222 s = 0; | |
223 } | |
224 } | |
225 } | |
226 | |
227 static void make_change(double dCurrentTime) | |
228 { | |
229 int r = rand() % text_x * text_y; | |
230 | |
231 text[r] += 133; //random bugs | |
232 | |
233 r = rand() % (4 * text_x); | |
234 if (r < text_x && text_light[r]) | |
235 text_light[r] = 255; //white bugs | |
236 | |
237 scroll (dCurrentTime); | |
238 } | |
239 | |
240 | |
241 static void make_text(void) | |
242 { | |
243 int a; | |
244 | |
245 for (a = 0; a < text_x * text_y; a++) | |
246 text[a] = rand() >> 8; // avoid the lowest bits of rand() | |
247 | |
248 for (a = 0; a < text_x; a++) | |
249 speed[a] = rand() >= RAND_MAX / 2; | |
250 } | |
251 | |
252 static void ourBuildTextures(void) | |
253 { | |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
254 mpglTexImage2D(GL_TEXTURE_2D, 0, 1, 128, 64, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
255 font_texture); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
256 mpglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
257 mpglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
30140 | 258 |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
259 mpglBindTexture(GL_TEXTURE_2D, 1); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
260 mpglTexImage2D(GL_TEXTURE_2D, 0, 1, 4, 4, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
261 flare); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
262 mpglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
263 mpglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
30140 | 264 |
265 // Some pretty standard settings for wrapping and filtering. | |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
266 mpglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
267 mpglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
268 mpglBindTexture(GL_TEXTURE_2D, 0); |
30140 | 269 } |
270 | |
271 void matrixview_init(int w, int h) | |
272 { | |
273 make_text(); | |
274 | |
275 ourBuildTextures(); | |
276 | |
277 // Color to clear color buffer to. | |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
278 mpglClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
30140 | 279 |
280 // Depth to clear depth buffer to; type of test. | |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
281 mpglClearDepth(1.0); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
282 mpglDepthFunc(GL_LESS); |
30140 | 283 |
284 // Enables Smooth Color Shading; try GL_FLAT for (lack of) fun. | |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
285 mpglShadeModel(GL_SMOOTH); |
30140 | 286 |
287 // Set up a light, turn it on. | |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
288 mpglLightfv(GL_LIGHT1, GL_POSITION, Light_Position); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
289 mpglLightfv(GL_LIGHT1, GL_AMBIENT, Light_Ambient); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
290 mpglLightfv(GL_LIGHT1, GL_DIFFUSE, Light_Diffuse); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
291 mpglEnable(GL_LIGHT1); |
30140 | 292 |
293 // A handy trick -- have surface material mirror the color. | |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
294 mpglColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
295 mpglEnable(GL_COLOR_MATERIAL); |
30140 | 296 |
297 // Allow adjusting of texture color via glColor | |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
298 mpglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
30140 | 299 |
34054
a70e8abec089
Change silly matrixview code to not needlessly change state on every frame
reimar
parents:
30945
diff
changeset
|
300 mpglEnable(GL_BLEND); |
a70e8abec089
Change silly matrixview code to not needlessly change state on every frame
reimar
parents:
30945
diff
changeset
|
301 mpglEnable(GL_TEXTURE_2D); |
a70e8abec089
Change silly matrixview code to not needlessly change state on every frame
reimar
parents:
30945
diff
changeset
|
302 |
a70e8abec089
Change silly matrixview code to not needlessly change state on every frame
reimar
parents:
30945
diff
changeset
|
303 mpglDisable(GL_LIGHTING); |
a70e8abec089
Change silly matrixview code to not needlessly change state on every frame
reimar
parents:
30945
diff
changeset
|
304 mpglBlendFunc(GL_SRC_ALPHA, GL_ONE); |
a70e8abec089
Change silly matrixview code to not needlessly change state on every frame
reimar
parents:
30945
diff
changeset
|
305 mpglDisable(GL_DEPTH_TEST); |
a70e8abec089
Change silly matrixview code to not needlessly change state on every frame
reimar
parents:
30945
diff
changeset
|
306 |
30140 | 307 matrixview_reshape(w, h); |
308 } | |
309 | |
310 | |
311 void matrixview_reshape(int w, int h) | |
312 { | |
34337
f8c523d09e5e
Use glLoadMatrixf. This makes it easier to support OpenGL ES.
reimar
parents:
34060
diff
changeset
|
313 double nearplane = -Z_Off - Z_Depth; |
f8c523d09e5e
Use glLoadMatrixf. This makes it easier to support OpenGL ES.
reimar
parents:
34060
diff
changeset
|
314 // perspective projection, also adjusting vertex position |
f8c523d09e5e
Use glLoadMatrixf. This makes it easier to support OpenGL ES.
reimar
parents:
34060
diff
changeset
|
315 // by Z_Off and with simplified Z equation since the absolute |
f8c523d09e5e
Use glLoadMatrixf. This makes it easier to support OpenGL ES.
reimar
parents:
34060
diff
changeset
|
316 // Z value does not matter, only relative to other pixels |
f8c523d09e5e
Use glLoadMatrixf. This makes it easier to support OpenGL ES.
reimar
parents:
34060
diff
changeset
|
317 float matrix[16] = { |
f8c523d09e5e
Use glLoadMatrixf. This makes it easier to support OpenGL ES.
reimar
parents:
34060
diff
changeset
|
318 nearplane / _text_x, 0, 0, 0, |
f8c523d09e5e
Use glLoadMatrixf. This makes it easier to support OpenGL ES.
reimar
parents:
34060
diff
changeset
|
319 0, nearplane / _text_y, 0, 0, |
f8c523d09e5e
Use glLoadMatrixf. This makes it easier to support OpenGL ES.
reimar
parents:
34060
diff
changeset
|
320 0, 0, 1, -1, |
f8c523d09e5e
Use glLoadMatrixf. This makes it easier to support OpenGL ES.
reimar
parents:
34060
diff
changeset
|
321 0, 0, 0, -Z_Off |
f8c523d09e5e
Use glLoadMatrixf. This makes it easier to support OpenGL ES.
reimar
parents:
34060
diff
changeset
|
322 }; |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
323 mpglViewport(0, 0, w, h); |
30140 | 324 |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
325 mpglMatrixMode(GL_PROJECTION); |
34337
f8c523d09e5e
Use glLoadMatrixf. This makes it easier to support OpenGL ES.
reimar
parents:
34060
diff
changeset
|
326 mpglLoadMatrixf(matrix); |
30140 | 327 |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
328 mpglMatrixMode(GL_MODELVIEW); |
34054
a70e8abec089
Change silly matrixview code to not needlessly change state on every frame
reimar
parents:
30945
diff
changeset
|
329 mpglLoadIdentity(); |
30140 | 330 } |
331 | |
332 | |
30153 | 333 void matrixview_draw(int w, int h, double currentTime, float frameTime, |
334 uint8_t *data) | |
30140 | 335 { |
336 // Clear the color and depth buffers. | |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
337 mpglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
30140 | 338 |
339 // OK, let's start drawing our planer quads. | |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
340 mpglBegin(GL_QUADS); |
30140 | 341 draw_text(data); |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
342 mpglEnd(); |
30140 | 343 |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
344 mpglBindTexture(GL_TEXTURE_2D, 1); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
345 mpglBegin(GL_QUADS); |
30140 | 346 draw_flares(); |
30945
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
347 mpglEnd(); |
55917a674d7d
Add mpgl prefix to all OpenGL-related function pointers.
reimar
parents:
30182
diff
changeset
|
348 mpglBindTexture(GL_TEXTURE_2D, 0); |
30140 | 349 |
350 make_change(currentTime); | |
351 } | |
352 | |
353 void matrixview_contrast_set(float contrast) | |
354 { | |
355 matrix_contrast = contrast; | |
356 } | |
357 | |
358 void matrixview_brightness_set(float brightness) | |
359 { | |
360 matrix_brightness = brightness; | |
361 } | |
362 | |
363 | |
364 void matrixview_matrix_resize(int w, int h) | |
365 { | |
366 int elems; | |
367 free(speed); | |
368 speed = NULL; | |
369 free(text); | |
370 text = NULL; | |
371 free(text_light); | |
372 text_light = NULL; | |
373 free(text_depth); | |
374 text_depth = NULL; | |
375 if (w > MAX_TEXT_X || h > MAX_TEXT_Y) | |
376 return; | |
377 elems = w * (h + 1); | |
378 speed = calloc(w, sizeof(*speed)); | |
379 text = calloc(elems, sizeof(*text)); | |
380 text_light = calloc(elems, sizeof(*text_light)); | |
381 text_depth = calloc(elems, sizeof(*text_depth)); | |
382 bump_pic = calloc(elems, sizeof(*bump_pic)); | |
383 text_x = w; | |
384 text_y = h; | |
385 make_text(); | |
386 } |