UFO: Alien Invasion
Loading...
Searching...
No Matches
r_draw.cpp
Go to the documentation of this file.
1
4
5/*
6Copyright (C) 1997-2001 Id Software, Inc.
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; either version 2
11of the License, or (at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23*/
24
25#include "r_local.h"
26#include "r_sphere.h"
27#include "r_error.h"
28#include "r_draw.h"
29#include "r_mesh.h"
30#include "r_framebuffer.h"
31#include "r_program.h"
32#include "r_misc.h"
33#include "../cl_console.h"
34
36
37/* console font */
39
40#define MAX_CHARS 8192
41
44typedef struct char_arrays_s {
45 GLfloat texcoords[MAX_CHARS * 4 * 2];
47
48 GLshort verts[MAX_CHARS * 4 * 2];
50
51 GLbyte colors[MAX_CHARS * 4 * 4];
54
56
57#define MAX_BATCH_ENTRIES 512
58
60typedef struct batch_arrays_s {
61 GLshort verts[MAX_BATCH_ENTRIES * 4 * 2];
63
64 GLbyte colors[MAX_BATCH_ENTRIES * 4 * 4];
67
69
70#define MAX_BBOX_ENTRIES 256
71
72typedef struct bbox_arrays_s {
73 float bboxes[3 * 8 * MAX_BBOX_ENTRIES];
76
78
83void R_DrawInitLocal (void)
84{
85 shadow = R_FindImage("pics/sfx/shadow", it_effect);
86 if (shadow == r_noTexture)
87 Com_Printf("Could not find shadow image in game pics/sfx directory!\n");
88
89 draw_chars = R_FindImage("pics/conchars", it_chars);
91 Com_Error(ERR_FATAL, "Could not find conchars image in game pics directory!");
92}
93
99void R_DrawChar (int x, int y, int num, uint32_t color)
100{
101 num &= 255;
102
103 if ((num & 127) == ' ') /* space */
104 return;
105
106 if (y <= -con_fontHeight)
107 return; /* totally off screen */
108
109 if (r_char_arrays.vert_index >= lengthof(r_char_arrays.verts))
110 return;
111
112 int row = (int) num >> 4;
113 int col = (int) num & 15;
114
115 /* 0.0625 => 16 cols (conchars images) */
116 float frow = row * 0.0625;
117 float fcol = col * 0.0625;
118
119 memcpy(&r_char_arrays.colors[r_char_arrays.color_index + 0], &color, 4);
120 memcpy(&r_char_arrays.colors[r_char_arrays.color_index + 4], &color, 4);
121 memcpy(&r_char_arrays.colors[r_char_arrays.color_index + 8], &color, 4);
122 memcpy(&r_char_arrays.colors[r_char_arrays.color_index + 12], &color, 4);
123
124 r_char_arrays.color_index += 16;
125
126 r_char_arrays.texcoords[r_char_arrays.texcoord_index + 0] = fcol;
127 r_char_arrays.texcoords[r_char_arrays.texcoord_index + 1] = frow;
128
129 r_char_arrays.texcoords[r_char_arrays.texcoord_index + 2] = fcol + 0.0625;
130 r_char_arrays.texcoords[r_char_arrays.texcoord_index + 3] = frow;
131
132 r_char_arrays.texcoords[r_char_arrays.texcoord_index + 4] = fcol + 0.0625;
133 r_char_arrays.texcoords[r_char_arrays.texcoord_index + 5] = frow + 0.0625;
134
135 r_char_arrays.texcoords[r_char_arrays.texcoord_index + 6] = fcol;
136 r_char_arrays.texcoords[r_char_arrays.texcoord_index + 7] = frow + 0.0625;
137
138 r_char_arrays.texcoord_index += 8;
139
140 r_char_arrays.verts[r_char_arrays.vert_index + 0] = x;
141 r_char_arrays.verts[r_char_arrays.vert_index + 1] = y;
142
143 r_char_arrays.verts[r_char_arrays.vert_index + 2] = x + con_fontWidth;
144 r_char_arrays.verts[r_char_arrays.vert_index + 3] = y;
145
146 r_char_arrays.verts[r_char_arrays.vert_index + 4] = x + con_fontWidth;
147 r_char_arrays.verts[r_char_arrays.vert_index + 5] = y + con_fontHeight;
148
149 r_char_arrays.verts[r_char_arrays.vert_index + 6] = x;
150 r_char_arrays.verts[r_char_arrays.vert_index + 7] = y + con_fontHeight;
151
152 r_char_arrays.vert_index += 8;
153}
154
155void R_DrawChars (void)
156{
157 if (!r_char_arrays.vert_index)
158 return;
159
160 R_BindTexture(draw_chars->texnum);
161
162 R_EnableColorArray(true);
163
164 /* alter the array pointers */
165 R_BindArray(GL_COLOR_ARRAY, GL_UNSIGNED_BYTE, r_char_arrays.colors);
166 R_BindArray(GL_TEXTURE_COORD_ARRAY, GL_FLOAT, r_char_arrays.texcoords);
167 glVertexPointer(2, GL_SHORT, 0, r_char_arrays.verts);
168
169 R_DrawArrays(0, r_char_arrays.vert_index / 2);
170
171 refdef.batchCount++;
172
173 r_char_arrays.color_index = 0;
174 r_char_arrays.texcoord_index = 0;
175 r_char_arrays.vert_index = 0;
176
177 /* and restore them */
178 R_BindDefaultArray(GL_TEXTURE_COORD_ARRAY);
179 R_BindDefaultArray(GL_VERTEX_ARRAY);
180 R_BindDefaultArray(GL_COLOR_ARRAY);
181
182 R_EnableColorArray(false);
183}
184
188void R_DrawFill (int x, int y, int w, int h, const vec4_t color)
189{
190 const float nx = x * viddef.rx;
191 const float ny = y * viddef.ry;
192 const float nw = w * viddef.rx;
193 const float nh = h * viddef.ry;
194 const int r = color[0] * 255.0;
195 const int g = color[1] * 255.0;
196 const int b = color[2] * 255.0;
197 const int a = color[3] * 255.0;
198 const uint32_t c = LittleLong((r << 0) + (g << 8) + (b << 16) + (a << 24));
199
200 if (r_fill_arrays.color_index >= lengthof(r_fill_arrays.colors))
201 return;
202
203 /* duplicate color data to all 4 verts */
204 memcpy(&r_fill_arrays.colors[r_fill_arrays.color_index + 0], &c, 4);
205 memcpy(&r_fill_arrays.colors[r_fill_arrays.color_index + 4], &c, 4);
206 memcpy(&r_fill_arrays.colors[r_fill_arrays.color_index + 8], &c, 4);
207 memcpy(&r_fill_arrays.colors[r_fill_arrays.color_index + 12], &c, 4);
208
209 r_fill_arrays.color_index += 16;
210
211 /* populate verts */
212 r_fill_arrays.verts[r_fill_arrays.vert_index + 0] = nx;
213 r_fill_arrays.verts[r_fill_arrays.vert_index + 1] = ny;
214
215 r_fill_arrays.verts[r_fill_arrays.vert_index + 2] = nx + nw;
216 r_fill_arrays.verts[r_fill_arrays.vert_index + 3] = ny;
217
218 r_fill_arrays.verts[r_fill_arrays.vert_index + 4] = nx + nw;
219 r_fill_arrays.verts[r_fill_arrays.vert_index + 5] = ny + nh;
220
221 r_fill_arrays.verts[r_fill_arrays.vert_index + 6] = nx;
222 r_fill_arrays.verts[r_fill_arrays.vert_index + 7] = ny + nh;
223
224 r_fill_arrays.vert_index += 8;
225
229 R_DrawFills();
230}
231
232void R_DrawFills (void)
233{
234 if (!r_fill_arrays.vert_index)
235 return;
236
238
239 R_EnableColorArray(true);
240
241 /* alter the array pointers */
242 R_BindArray(GL_COLOR_ARRAY, GL_UNSIGNED_BYTE, r_fill_arrays.colors);
243 glVertexPointer(2, GL_SHORT, 0, r_fill_arrays.verts);
244
245 R_DrawArrays(0, r_fill_arrays.vert_index / 2);
246
247 refdef.batchCount++;
248
249 /* and restore them */
250 R_BindDefaultArray(GL_VERTEX_ARRAY);
251 R_BindDefaultArray(GL_COLOR_ARRAY);
252
253 R_EnableColorArray(false);
254
256
257 r_fill_arrays.vert_index = r_fill_arrays.color_index = 0;
258
259 R_Color(nullptr);
260}
261
270int R_UploadData (const char* name, unsigned* frame, int width, int height)
271{
272 image_t* img;
273 unsigned* scaled;
274 int scaledWidth, scaledHeight;
275 int samples = r_config.gl_compressed_solid_format ? r_config.gl_compressed_solid_format : r_config.gl_solid_format;
276#ifdef GL_VERSION_ES_CM_1_0
277 samples = GL_RGBA;
278#endif
279
280 R_GetScaledTextureSize(width, height, &scaledWidth, &scaledHeight);
281
282 img = R_FindImage(name, it_pic);
283 if (img == r_noTexture)
284 Com_Error(ERR_FATAL, "Could not find the searched image: %s", name);
285
286 /* scan the texture for any non-255 alpha */
287 for (unsigned const* i = frame, * const end = i + scaledHeight * scaledWidth; i != end; ++i) {
288 if ((*i & 0xFF000000U) != 0xFF000000U) {
289 samples = r_config.gl_compressed_alpha_format ? r_config.gl_compressed_alpha_format : r_config.gl_alpha_format;
290 break;
291 }
292 }
293
294 if (scaledWidth != width || scaledHeight != height) { /* whereas others need to be scaled */
295 scaled = Mem_PoolAllocTypeN(unsigned, scaledWidth * scaledHeight, vid_imagePool);
296 R_ScaleTexture(frame, width, height, scaled, scaledWidth, scaledHeight);
297 } else {
298 scaled = frame;
299 }
300
301 R_BindTexture(img->texnum);
302 if (img->upload_width == scaledWidth && img->upload_height == scaledHeight) {
303 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, scaledWidth, scaledHeight, GL_RGBA, GL_UNSIGNED_BYTE, scaled);
304 } else {
305 /* Reallocate the texture */
306 img->width = width;
307 img->height = height;
308 img->upload_width = scaledWidth;
309 img->upload_height = scaledHeight;
310 glTexImage2D(GL_TEXTURE_2D, 0, samples, scaledWidth, scaledHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, scaled);
311 }
312 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
313 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
314 R_CheckError();
315
316 if (scaled != frame)
317 Mem_Free(scaled);
318
319 return img->texnum;
320}
321
328void R_DrawTexture (int texnum, int x, int y, int w, int h)
329{
330 const vec2_t vertexes[] = {Vector2FromInt(x, y), Vector2FromInt(x + w, y), Vector2FromInt(x + w, y + h), Vector2FromInt(x, y + h)};
331
332 R_BindTexture(texnum);
333 R_DrawImageArray(default_texcoords, vertexes, nullptr);
334}
335
341void R_DrawImage (float x, float y, const image_t* image)
342{
343 if (!image)
344 return;
345
346 R_DrawTexture(image->texnum, x * viddef.rx, y * viddef.ry, image->width * viddef.rx, image->height * viddef.ry);
347}
348
349void R_DrawStretchImage (float x, float y, int w, int h, const image_t* image)
350{
351 if (!image)
352 return;
353
354 R_DrawTexture(image->texnum, x * viddef.rx, y * viddef.ry, w * viddef.rx, h * viddef.ry);
355}
356
357const image_t* R_DrawImageArray (const vec2_t texcoords[4], const vec2_t verts[4], const image_t* image)
358{
359 /* alter the array pointers */
360 glVertexPointer(2, GL_FLOAT, 0, verts);
361 R_BindArray(GL_TEXTURE_COORD_ARRAY, GL_FLOAT, texcoords);
362
363 if (image != nullptr)
364 R_BindTexture(image->texnum);
365
366 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
367
368 refdef.batchCount++;
369
370 /* and restore them */
371 R_BindDefaultArray(GL_TEXTURE_COORD_ARRAY);
372 R_BindDefaultArray(GL_VERTEX_ARRAY);
373
374 return image;
375}
376
390void R_DrawRect (int x, int y, int w, int h, const vec4_t color, float lineWidth, int pattern)
391{
392 const float nx = x * viddef.rx;
393 const float ny = y * viddef.ry;
394 const float nw = w * viddef.rx;
395 const float nh = h * viddef.ry;
396 const vec2_t points[] = { { nx, ny }, { nx + nw, ny }, { nx + nw, ny + nh }, { nx, ny + nh } };
397
398 R_Color(color);
399
400 glDisable(GL_TEXTURE_2D);
401 glLineWidth(lineWidth);
402#ifndef GL_VERSION_ES_CM_1_0
403 glLineStipple(2, pattern);
404 glEnable(GL_LINE_STIPPLE);
405#endif
406
407 glVertexPointer(2, GL_FLOAT, 0, points);
408 glDrawArrays(GL_LINE_LOOP, 0, 4);
409 R_BindDefaultArray(GL_VERTEX_ARRAY);
410
411 refdef.batchCount++;
412
413 glEnable(GL_TEXTURE_2D);
414 glLineWidth(1.0f);
415#ifndef GL_VERSION_ES_CM_1_0
416 glDisable(GL_LINE_STIPPLE);
417#endif
418
419 R_Color(nullptr);
420}
421
422void R_DrawCircle (float radius, const vec4_t color, float thickness, const vec3_t shift)
423{
424 vec3_t points[16];
425 const size_t steps = lengthof(points);
426
427 glEnable(GL_LINE_SMOOTH);
428 glLineWidth(thickness);
429
430 R_Color(color);
431
432 for (unsigned int i = 0; i < steps; i++) {
433 const float a = 2.0f * M_PI * (float) i / (float) steps;
434 VectorSet(points[i], shift[0] + radius * cos(a), shift[1] + radius * sin(a), shift[2]);
435 }
436
437 R_BindArray(GL_VERTEX_ARRAY, GL_FLOAT, points);
438 glDrawArrays(GL_LINE_LOOP, 0, steps);
439 R_BindDefaultArray(GL_VERTEX_ARRAY);
440
441 refdef.batchCount++;
442
443 R_Color(nullptr);
444
445 glLineWidth(1.0f);
446 glDisable(GL_LINE_SMOOTH);
447}
448
449#define MAX_LINEVERTS 256
450
451static inline void R_Draw2DArray (int points, int* verts, GLenum mode)
452{
453 /* fit it on screen */
454 if (points > MAX_LINEVERTS * 2)
455 points = MAX_LINEVERTS * 2;
456
457 /* set vertex array pointer */
458 glVertexPointer(2, GL_SHORT, 0, r_state.vertex_array_2d);
459
460 for (int i = 0; i < points * 2; i += 2) {
461 r_state.vertex_array_2d[i] = verts[i] * viddef.rx;
462 r_state.vertex_array_2d[i + 1] = verts[i + 1] * viddef.ry;
463 }
464
465 glDisable(GL_TEXTURE_2D);
466 glDrawArrays(mode, 0, points);
467 glEnable(GL_TEXTURE_2D);
468 glVertexPointer(3, GL_FLOAT, 0, r_state.vertex_array_3d);
469
470 refdef.batchCount++;
471}
472
477void R_DrawLineStrip (int points, int* verts)
478{
479 R_Draw2DArray(points, verts, GL_LINE_STRIP);
480}
481
485void R_DrawLineLoop (int points, int* verts)
486{
487 R_Draw2DArray(points, verts, GL_LINE_LOOP);
488}
489
494void R_DrawLine (int* verts, float thickness)
495{
496 if (thickness > 0.0)
497 glLineWidth(thickness);
498
499 R_Draw2DArray(2, verts, GL_LINES);
500
501 if (thickness > 0.0)
502 glLineWidth(1.0);
503}
504
509void R_DrawPolygon (int points, int* verts)
510{
511 R_Draw2DArray(points, verts, GL_TRIANGLE_FAN);
512}
513
514typedef struct {
515 int x;
516 int y;
517 int width;
519} rect_t;
520
521#define MAX_CLIPRECT 16
522
524
525static int currentClipRect = 0;
526
533static void R_RectIntersection (const rect_t* a, const rect_t* b, rect_t* out)
534{
535 out->x = (a->x > b->x) ? a->x : b->x;
536 out->y = (a->y > b->y) ? a->y : b->y;
537 out->width = ((a->x + a->width < b->x + b->width) ? a->x + a->width : b->x + b->width) - out->x;
538 out->height = ((a->y + a->height < b->y + b->height) ? a->y + a->height : b->y + b->height) - out->y;
539 if (out->width < 0)
540 out->width = 0;
541 if (out->height < 0)
542 out->height = 0;
543}
544
550void R_PushClipRect (int x, int y, int width, int height)
551{
552 const int depth = currentClipRect;
553 assert(depth < MAX_CLIPRECT);
554
555 if (depth == 0) {
556 clipRect[depth].x = x * viddef.rx;
557 clipRect[depth].y = (viddef.virtualHeight - (y + height)) * viddef.ry;
558 clipRect[depth].width = width * viddef.rx;
559 clipRect[depth].height = height * viddef.ry;
560 } else {
561 rect_t rect;
562 rect.x = x * viddef.rx;
563 rect.y = (viddef.virtualHeight - (y + height)) * viddef.ry;
564 rect.width = width * viddef.rx;
565 rect.height = height * viddef.ry;
566 R_RectIntersection(&clipRect[depth - 1], &rect, &clipRect[depth]);
567 }
568
569 glScissor(clipRect[depth].x, clipRect[depth].y, clipRect[depth].width, clipRect[depth].height);
570
571 if (currentClipRect == 0)
572 glEnable(GL_SCISSOR_TEST);
574}
575
579void R_PopClipRect (void)
580{
581 assert(currentClipRect > 0);
583 if (currentClipRect == 0)
584 glDisable(GL_SCISSOR_TEST);
585 else {
586 const int depth = currentClipRect - 1;
587 glScissor(clipRect[depth].x, clipRect[depth].y, clipRect[depth].width, clipRect[depth].height);
588 }
589}
590
596void R_CleanupDepthBuffer (int x, int y, int width, int height)
597{
598 const float nx = x * viddef.rx;
599 const float ny = y * viddef.ry;
600 const int nwidth = width * viddef.rx;
601 const int nheight = height * viddef.ry;
602 const GLboolean hasDepthTest = glIsEnabled(GL_DEPTH_TEST);
603 const GLfloat bigZ = 2000.0f;
604 const vec3_t points [] = { { nx, ny, bigZ }, { nx + nwidth, ny, bigZ }, { nx + nwidth, ny + nheight, bigZ }, { nx, ny + nheight, bigZ } };
605
606 GLint depthFunc;
607 glGetIntegerv(GL_DEPTH_FUNC, &depthFunc);
608
609 /* we want to overwrite depth buffer not to have his constraints */
610 glEnable(GL_DEPTH_TEST);
611 glDepthFunc(GL_ALWAYS);
612 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
613
614 R_BindArray(GL_VERTEX_ARRAY, GL_FLOAT, points);
615 glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
616 R_BindDefaultArray(GL_VERTEX_ARRAY);
617
618 refdef.batchCount++;
619
620 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
621 if (!hasDepthTest)
622 glDisable(GL_DEPTH_TEST);
623 glDepthFunc(depthFunc);
624}
625
630static void R_ComputeBoundingBox (const vec3_t mins, const vec3_t maxs, vec3_t bbox[8])
631{
632 /* compute a full bounding box */
633 for (int i = 0; i < 8; i++) {
634 bbox[i][0] = (i & 1) ? mins[0] : maxs[0];
635 bbox[i][1] = (i & 2) ? mins[1] : maxs[1];
636 bbox[i][2] = (i & 4) ? mins[2] : maxs[2];
637 }
638}
639
641{
642 const int step = 3 * 8;
643 const int bboxes = r_bbox_array.bboxes_index / step;
644 const GLushort indexes[] = { 2, 1, 0, 1, 4, 5, 1, 7, 3, 2, 7, 6, 2, 4, 0 };
645 const GLushort indexes2[] = { 4, 6, 7 };
646
647 if (!r_bbox_array.bboxes_index)
648 return;
649
650 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
651
652 R_Color(nullptr);
653
654 for (int i = 0; i < bboxes; i++) {
655 const float* bbox = &r_bbox_array.bboxes[i * step];
656 R_BindArray(GL_VERTEX_ARRAY, GL_FLOAT, bbox);
657 /* Draw top and sides */
658 glDrawElements(GL_TRIANGLE_FAN, 15, GL_UNSIGNED_SHORT, indexes);
659 /* Draw bottom */
660 glDrawElements(GL_TRIANGLE_FAN, 3, GL_UNSIGNED_SHORT, indexes2);
661 }
662
663 R_BindDefaultArray(GL_VERTEX_ARRAY);
664
665 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
666
667 r_bbox_array.bboxes_index = 0;
668}
669
670void R_DrawBoundingBoxBatched (const AABB& absbox)
671{
672 vec3_t bbox[8];
673 const size_t max = lengthof(r_bbox_array.bboxes);
674
675 if (r_bbox_array.bboxes_index >= max)
676 return;
677
678 R_ComputeBoundingBox(absbox.mins, absbox.maxs, bbox);
679
680 for (int i = 0; i < 8; i++) {
681 VectorCopy(bbox[i], &r_bbox_array.bboxes[r_bbox_array.bboxes_index]);
682 r_bbox_array.bboxes_index += 3;
683 }
684}
685
690void R_DrawBoundingBox (const AABB& absBox)
691{
692 vec3_t bbox[8];
693 const GLushort indexes[] = { 2, 1, 0, 1, 4, 5, 1, 7, 3, 2, 7, 6, 2, 4, 0 };
694 const GLushort indexes2[] = { 4, 6, 7 };
695
696 R_ComputeBoundingBox(absBox.mins, absBox.maxs, bbox);
697
698 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
699
700 R_BindArray(GL_VERTEX_ARRAY, GL_FLOAT, bbox);
701 /* Draw top and sides */
702 glDrawElements(GL_TRIANGLE_STRIP, 15, GL_UNSIGNED_SHORT, indexes);
703 /* Draw bottom */
704 glDrawElements(GL_TRIANGLE_STRIP, 3, GL_UNSIGNED_SHORT, indexes2);
705 R_BindDefaultArray(GL_VERTEX_ARRAY);
706
707 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
708}
709
714void R_DrawTexturedBox (const vec3_t a0, const vec3_t a1)
715{
716 const GLfloat texcoords[] = { 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, };
717 const vec3_t bbox[] = {
718 { a0[0], a0[1], a0[2] }, { a0[0], a0[1], a1[2] }, { a1[0], a0[1], a1[2] }, { a1[0], a0[1], a0[2] },
719 { a1[0], a1[1], a0[2] }, { a1[0], a1[1], a1[2] }, { a0[0], a1[1], a1[2] }, { a0[0], a1[1], a0[2] },
720 { a0[0], a0[1], a0[2] }, { a0[0], a0[1], a1[2] }, { a1[0], a0[1], a1[2] }, { a1[0], a0[1], a0[2] },
721 { a1[0], a1[1], a0[2] }, { a1[0], a1[1], a1[2] }, { a0[0], a1[1], a1[2] }, { a0[0], a1[1], a0[2] } };
722 const GLushort indexes[] = { 0, 1, 2, 1, 2, 3, 4, 5, 6, 6, 7, 4, 2 + 8, 3 + 8, 4 + 8, 2 + 8, 5 + 8, 4 + 8, 6 + 8, 7 + 8,
723 0 + 8, 0 + 8, 1 + 8, 6 + 8, };
724
725 R_BindArray(GL_TEXTURE_COORD_ARRAY, GL_FLOAT, texcoords);
726 R_BindArray(GL_VERTEX_ARRAY, GL_FLOAT, bbox);
727
728 /* Draw sides only */
729 glDrawElements(GL_TRIANGLES, 8 * 3, GL_UNSIGNED_SHORT, indexes);
730
731 R_BindDefaultArray(GL_VERTEX_ARRAY);
732 R_BindDefaultArray(GL_TEXTURE_COORD_ARRAY);
733}
#define LittleLong(X)
Definition byte.h:37
const int con_fontWidth
const int con_fontHeight
Console header file.
memPool_t * vid_imagePool
Definition cl_main.cpp:88
rendererData_t refdef
Definition r_main.cpp:45
void R_Color(const vec4_t rgba)
Change the color to given value.
Definition r_state.cpp:1011
viddef_t viddef
Definition cl_video.cpp:34
Definition aabb.h:42
vec3_t maxs
Definition aabb.h:258
vec3_t mins
Definition aabb.h:257
void Com_Error(int code, const char *fmt,...)
Definition common.cpp:459
void Com_Printf(const char *const fmt,...)
Definition common.cpp:428
#define ERR_FATAL
Definition common.h:210
void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *texels)
Definition gldummy.cpp:17
void glTexParameterf(GLenum target, GLenum pname, GLfloat param)
Definition gldummy.cpp:13
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
const char int mode
Definition ioapi.h:41
#define M_PI
Definition mathlib.h:34
#define Mem_PoolAllocTypeN(type, n, pool)
Definition mem.h:42
#define Mem_Free(ptr)
Definition mem.h:35
void R_DrawTexture(int texnum, int x, int y, int w, int h)
Bind and draw a texture.
Definition r_draw.cpp:328
#define MAX_CLIPRECT
Definition r_draw.cpp:521
void R_DrawBoundingBoxes(void)
Definition r_draw.cpp:640
static image_t * draw_chars
Definition r_draw.cpp:38
void R_DrawFill(int x, int y, int w, int h, const vec4_t color)
Fills a box of pixels with a single color.
Definition r_draw.cpp:188
void R_DrawLine(int *verts, float thickness)
Draws one line with only one start and one end point.
Definition r_draw.cpp:494
void R_DrawChar(int x, int y, int num, uint32_t color)
Draws one 8*8 graphics character with 0 being transparent. It can be clipped to the top of the screen...
Definition r_draw.cpp:99
void R_DrawPolygon(int points, int *verts)
Definition r_draw.cpp:509
static bbox_arrays_t r_bbox_array
Definition r_draw.cpp:77
static char_arrays_t r_char_arrays
Definition r_draw.cpp:55
void R_PopClipRect(void)
Definition r_draw.cpp:579
void R_DrawLineStrip(int points, int *verts)
2 dimensional line strip
Definition r_draw.cpp:477
void R_DrawImage(float x, float y, const image_t *image)
Draws an image or parts of it.
Definition r_draw.cpp:341
void R_DrawFills(void)
Definition r_draw.cpp:232
void R_DrawChars(void)
Definition r_draw.cpp:155
void R_DrawStretchImage(float x, float y, int w, int h, const image_t *image)
Definition r_draw.cpp:349
#define MAX_CHARS
Definition r_draw.cpp:40
static void R_RectIntersection(const rect_t *a, const rect_t *b, rect_t *out)
Compute the intersection of 2 rect.
Definition r_draw.cpp:533
#define MAX_BBOX_ENTRIES
Definition r_draw.cpp:70
void R_DrawBoundingBoxBatched(const AABB &absbox)
Definition r_draw.cpp:670
void R_DrawLineLoop(int points, int *verts)
Definition r_draw.cpp:485
void R_PushClipRect(int x, int y, int width, int height)
Force to draw only on a rect.
Definition r_draw.cpp:550
static void R_ComputeBoundingBox(const vec3_t mins, const vec3_t maxs, vec3_t bbox[8])
Compute the bounding box for an entity out of the mins, maxs.
Definition r_draw.cpp:630
void R_DrawTexturedBox(const vec3_t a0, const vec3_t a1)
Draws the textured box, the caller should bind the texture.
Definition r_draw.cpp:714
static int currentClipRect
Definition r_draw.cpp:525
void R_DrawInitLocal(void)
Loads some textures and init the 3d globe.
Definition r_draw.cpp:83
void R_DrawBoundingBox(const AABB &absBox)
Draws the model bounding box.
Definition r_draw.cpp:690
void R_DrawCircle(float radius, const vec4_t color, float thickness, const vec3_t shift)
Definition r_draw.cpp:422
const image_t * R_DrawImageArray(const vec2_t texcoords[4], const vec2_t verts[4], const image_t *image)
Definition r_draw.cpp:357
image_t * shadow
Definition r_draw.cpp:35
static void R_Draw2DArray(int points, int *verts, GLenum mode)
Definition r_draw.cpp:451
int R_UploadData(const char *name, unsigned *frame, int width, int height)
Uploads image data.
Definition r_draw.cpp:270
#define MAX_LINEVERTS
Definition r_draw.cpp:449
void R_CleanupDepthBuffer(int x, int y, int width, int height)
"Clean up" the depth buffer into a rect
Definition r_draw.cpp:596
#define MAX_BATCH_ENTRIES
Definition r_draw.cpp:57
void R_DrawRect(int x, int y, int w, int h, const vec4_t color, float lineWidth, int pattern)
Draws a rect to the screen. Also has support for stippled rendering of the rect.
Definition r_draw.cpp:390
static batch_arrays_t r_fill_arrays
Definition r_draw.cpp:68
static rect_t clipRect[MAX_CLIPRECT]
Definition r_draw.cpp:523
Error checking function.
#define R_CheckError()
Definition r_error.h:30
QGL_EXTERN GLint
Definition r_gl.h:135
QGL_EXTERN GLint i
Definition r_gl.h:113
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition r_gl.h:110
QGL_EXTERN GLboolean(APIENTRY *qglIsRenderbufferEXT)(GLuint)
void R_DrawArrays(GLint first, GLsizei count)
Definition r_gl.h:35
QGL_EXTERN const GLuint *QGL_EXTERN GLuint *QGL_EXTERN GLenum
Definition r_gl.h:127
image_t * R_FindImage(const char *pname, imagetype_t type)
Finds or loads the given image.
Definition r_image.cpp:603
void R_GetScaledTextureSize(int width, int height, int *scaledWidth, int *scaledHeight)
Calculates the texture size that should be used to upload the texture data.
Definition r_image.cpp:220
void R_ScaleTexture(const unsigned *in, int inwidth, int inheight, unsigned *out, int outwidth, int outheight)
Definition r_image.cpp:172
image_t * r_noTexture
Definition r_main.cpp:51
@ it_pic
Definition r_image.h:45
@ it_effect
Definition r_image.h:43
@ it_chars
Definition r_image.h:42
local graphics definitions
rconfig_t r_config
Definition r_main.cpp:47
rstate_t r_state
Definition r_main.cpp:48
static ipos3_t shift
The shift array is used for random map assemblies (RMA) to shift the mins/maxs and stuff like that.
Functions to generate and render spheres.
void R_EnableTexture(gltexunit_t *texunit, bool enable)
Definition r_state.cpp:303
void R_BindDefaultArray(GLenum target)
Binds the appropriate shared vertex array to the specified target.
Definition r_state.cpp:182
const vec2_t default_texcoords[4]
Definition r_state.cpp:30
void R_EnableColorArray(bool enable)
Definition r_state.cpp:332
void R_BindArray(GLenum target, GLenum type, const void *array)
Definition r_state.cpp:148
#define texunit_diffuse
Definition r_state.h:68
#define R_BindTexture(tn)
Definition r_state.h:184
#define lengthof(x)
Definition shared.h:105
array to store batched vertices and colors per frame
Definition r_draw.cpp:60
GLbyte colors[MAX_BATCH_ENTRIES *4 *4]
Definition r_draw.cpp:64
GLshort verts[MAX_BATCH_ENTRIES *4 *2]
Definition r_draw.cpp:61
int bboxes_index
Definition r_draw.cpp:74
float bboxes[3 *8 *MAX_BBOX_ENTRIES]
Definition r_draw.cpp:73
Characters are batched per frame and drawn in one shot accumulate coordinates and colors as vertex ar...
Definition r_draw.cpp:44
GLshort verts[MAX_CHARS *4 *2]
Definition r_draw.cpp:48
GLfloat texcoords[MAX_CHARS *4 *2]
Definition r_draw.cpp:45
int texcoord_index
Definition r_draw.cpp:46
GLbyte colors[MAX_CHARS *4 *4]
Definition r_draw.cpp:51
int color_index
Definition r_draw.cpp:52
int upload_height
Definition r_image.h:65
int upload_width
Definition r_image.h:65
int height
Definition r_image.h:64
int width
Definition r_image.h:64
GLuint texnum
Definition r_image.h:66
int y
Definition r_draw.cpp:516
int height
Definition r_draw.cpp:518
int x
Definition r_draw.cpp:515
int width
Definition r_draw.cpp:517
vec_t vec3_t[3]
Definition ufotypes.h:39
vec_t vec4_t[4]
Definition ufotypes.h:40
vec_t vec2_t[2]
Definition ufotypes.h:38
#define Vector2FromInt(x, y)
Definition vector.h:40
#define VectorCopy(src, dest)
Definition vector.h:51
#define VectorSet(v, x, y, z)
Definition vector.h:59