| 1 |
// ____ _ __ |
| 2 |
// / __ )____ _____ | | / /___ ___________ |
| 3 |
// / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/ |
| 4 |
// / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ ) |
| 5 |
// /_____/\____/____/ |__/|__/\__,_/_/ /____/ |
| 6 |
// |
| 7 |
// A futuristic real-time strategy game. |
| 8 |
// This file is part of Bos Wars. |
| 9 |
// |
| 10 |
/**@name linedraw.cpp - The general linedraw functions. */ |
| 11 |
// |
| 12 |
// (c) Copyright 2000-2008 by Lutz Sammer, Stephan Rasenberg, |
| 13 |
// Jimmy Salmon, and Nehal Mistry |
| 14 |
// |
| 15 |
// This program is free software; you can redistribute it and/or modify |
| 16 |
// it under the terms of the GNU General Public License as published by |
| 17 |
// the Free Software Foundation; only version 2 of the License. |
| 18 |
// |
| 19 |
// This program is distributed in the hope that it will be useful, |
| 20 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
// GNU General Public License for more details. |
| 23 |
// |
| 24 |
// You should have received a copy of the GNU General Public License |
| 25 |
// along with this program; if not, write to the Free Software |
| 26 |
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 27 |
// 02111-1307, USA. |
| 28 |
// |
| 29 |
|
| 30 |
//@{ |
| 31 |
|
| 32 |
/*---------------------------------------------------------------------------- |
| 33 |
-- Includes |
| 34 |
----------------------------------------------------------------------------*/ |
| 35 |
|
| 36 |
#include <stdio.h> |
| 37 |
#include <stdlib.h> |
| 38 |
#include <string.h> |
| 39 |
|
| 40 |
#include "stratagus.h" |
| 41 |
#include "video.h" |
| 42 |
|
| 43 |
#include "intern_video.h" |
| 44 |
|
| 45 |
|
| 46 |
/*---------------------------------------------------------------------------- |
| 47 |
-- Declarations |
| 48 |
----------------------------------------------------------------------------*/ |
| 49 |
|
| 50 |
/** |
| 51 |
** Bitmask, denoting a postion left/right/above/below clip rectangle |
| 52 |
** (mainly used by VideoDrawLineClip) |
| 53 |
*/ |
| 54 |
#define ClipCodeInside 0 /// Clipping inside rectangle |
| 55 |
#define ClipCodeAbove 1 /// Clipping above rectangle |
| 56 |
#define ClipCodeBelow 2 /// Clipping below rectangle |
| 57 |
#define ClipCodeLeft 4 /// Clipping left rectangle |
| 58 |
#define ClipCodeRight 8 /// Clipping right rectangle |
| 59 |
|
| 60 |
|
| 61 |
namespace linedraw_sdl { |
| 62 |
|
| 63 |
void (*VideoDrawPixel)(Uint32 color, int x, int y); |
| 64 |
static void (*VideoDoDrawPixel)(Uint32 color, int x, int y); |
| 65 |
void (*VideoDrawTransPixel)(Uint32 color, int x, int y, unsigned char alpha); |
| 66 |
static void (*VideoDoDrawTransPixel)(Uint32 color, int x, int y, unsigned char alpha); |
| 67 |
|
| 68 |
/** |
| 69 |
** Draw a 16-bit pixel |
| 70 |
*/ |
| 71 |
static void VideoDoDrawPixel16(Uint32 color, int x, int y) |
| 72 |
{ |
| 73 |
((Uint16 *)TheScreen->pixels)[x + y * Video.Width] = color; |
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
** Draw a 16-bit pixel |
| 78 |
*/ |
| 79 |
void VideoDrawPixel16(Uint32 color, int x, int y) |
| 80 |
{ |
| 81 |
Video.LockScreen(); |
| 82 |
VideoDoDrawPixel16(color, x, y); |
| 83 |
Video.UnlockScreen(); |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
** Draw a 32-bit pixel |
| 88 |
*/ |
| 89 |
static void VideoDoDrawPixel32(Uint32 color, int x, int y) |
| 90 |
{ |
| 91 |
((Uint32 *)TheScreen->pixels)[x + y * Video.Width] = color; |
| 92 |
} |
| 93 |
|
| 94 |
/** |
| 95 |
** Draw a 32-bit pixel |
| 96 |
*/ |
| 97 |
void VideoDrawPixel32(Uint32 color, int x, int y) |
| 98 |
{ |
| 99 |
Video.LockScreen(); |
| 100 |
VideoDoDrawPixel32(color, x, y); |
| 101 |
Video.UnlockScreen(); |
| 102 |
} |
| 103 |
|
| 104 |
/** |
| 105 |
** Draw a transparent 16-bit pixel |
| 106 |
*/ |
| 107 |
static void VideoDoDrawTransPixel16(Uint32 color, int x, int y, unsigned char alpha) |
| 108 |
{ |
| 109 |
Uint16 *p; |
| 110 |
unsigned long dp; |
| 111 |
|
| 112 |
// Loses precision for speed |
| 113 |
alpha = (255 - alpha) >> 3; |
| 114 |
|
| 115 |
p = &((Uint16 *)TheScreen->pixels)[x + y * Video.Width]; |
| 116 |
color = (((color << 16) | color) & 0x07E0F81F); |
| 117 |
dp = *p; |
| 118 |
dp = ((dp << 16) | dp) & 0x07E0F81F; |
| 119 |
dp = ((((dp - color) * alpha) >> 5) + color) & 0x07E0F81F; |
| 120 |
*p = (Uint16)((dp >> 16) | dp); |
| 121 |
} |
| 122 |
|
| 123 |
/** |
| 124 |
** Draw a transparent 16-bit pixel |
| 125 |
*/ |
| 126 |
void VideoDrawTransPixel16(Uint32 color, int x, int y, unsigned char alpha) |
| 127 |
{ |
| 128 |
Video.LockScreen(); |
| 129 |
VideoDoDrawTransPixel16(color, x, y, alpha); |
| 130 |
Video.UnlockScreen(); |
| 131 |
} |
| 132 |
|
| 133 |
/** |
| 134 |
** Draw a transparent 32-bit pixel |
| 135 |
*/ |
| 136 |
static void VideoDoDrawTransPixel32(Uint32 color, int x, int y, unsigned char alpha) |
| 137 |
{ |
| 138 |
unsigned long sp2; |
| 139 |
unsigned long dp1; |
| 140 |
unsigned long dp2; |
| 141 |
Uint32 *p; |
| 142 |
|
| 143 |
alpha = 255 - alpha; |
| 144 |
|
| 145 |
p = &((Uint32*)TheScreen->pixels)[x + y * Video.Width]; |
| 146 |
|
| 147 |
sp2 = (color & 0xFF00FF00) >> 8; |
| 148 |
color &= 0x00FF00FF; |
| 149 |
|
| 150 |
dp1 = *p; |
| 151 |
dp2 = (dp1 & 0xFF00FF00) >> 8; |
| 152 |
dp1 &= 0x00FF00FF; |
| 153 |
|
| 154 |
dp1 = ((((dp1 - color) * alpha) >> 8) + color) & 0x00FF00FF; |
| 155 |
dp2 = ((((dp2 - sp2) * alpha) >> 8) + sp2) & 0x00FF00FF; |
| 156 |
*p = (dp1 | (dp2 << 8)); |
| 157 |
} |
| 158 |
|
| 159 |
/** |
| 160 |
** Draw a transparent 32-bit pixel |
| 161 |
*/ |
| 162 |
void VideoDrawTransPixel32(Uint32 color, int x, int y, unsigned char alpha) |
| 163 |
{ |
| 164 |
Video.LockScreen(); |
| 165 |
VideoDoDrawTransPixel32(color, x, y, alpha); |
| 166 |
Video.UnlockScreen(); |
| 167 |
} |
| 168 |
|
| 169 |
/** |
| 170 |
** Draw a clipped pixel |
| 171 |
*/ |
| 172 |
static void VideoDoDrawPixelClip(Uint32 color, int x, int y) |
| 173 |
{ |
| 174 |
if (x >= ClipX1 && y >= ClipY1 && x <= ClipX2 && y <= ClipY2) { |
| 175 |
VideoDoDrawPixel(color, x, y); |
| 176 |
} |
| 177 |
} |
| 178 |
|
| 179 |
/** |
| 180 |
** Draw a clipped pixel |
| 181 |
*/ |
| 182 |
void DrawPixelClip(Uint32 color, int x, int y) |
| 183 |
{ |
| 184 |
Video.LockScreen(); |
| 185 |
VideoDoDrawPixelClip(color, x, y); |
| 186 |
Video.UnlockScreen(); |
| 187 |
} |
| 188 |
|
| 189 |
/** |
| 190 |
** Draw a transparent clipped pixel |
| 191 |
*/ |
| 192 |
static void VideoDoDrawTransPixelClip(Uint32 color, int x, int y, unsigned char alpha) |
| 193 |
{ |
| 194 |
if (x >= ClipX1 && y >= ClipY1 && x <= ClipX2 && y <= ClipY2) { |
| 195 |
VideoDoDrawTransPixel(color, x, y, alpha); |
| 196 |
} |
| 197 |
} |
| 198 |
|
| 199 |
/** |
| 200 |
** Draw a transparent clipped pixel |
| 201 |
*/ |
| 202 |
void DrawTransPixelClip(Uint32 color, int x, int y, unsigned char alpha) |
| 203 |
{ |
| 204 |
Video.LockScreen(); |
| 205 |
VideoDoDrawTransPixelClip(color, x, y, alpha); |
| 206 |
Video.UnlockScreen(); |
| 207 |
} |
| 208 |
|
| 209 |
/** |
| 210 |
** Draw a vertical line |
| 211 |
*/ |
| 212 |
void DrawVLine(Uint32 color, int x, int y, int height) |
| 213 |
{ |
| 214 |
Video.LockScreen(); |
| 215 |
for (int i = 0; i < height; ++i) { |
| 216 |
VideoDoDrawPixel(color, x, y + i); |
| 217 |
} |
| 218 |
Video.UnlockScreen(); |
| 219 |
} |
| 220 |
|
| 221 |
/** |
| 222 |
** Draw a transparent vertical line |
| 223 |
*/ |
| 224 |
void DrawTransVLine(Uint32 color, int x, int y, |
| 225 |
int height, unsigned char alpha) |
| 226 |
{ |
| 227 |
Video.LockScreen(); |
| 228 |
for (int i = 0; i < height; ++i) { |
| 229 |
VideoDoDrawTransPixel(color, x, y + i, alpha); |
| 230 |
} |
| 231 |
Video.UnlockScreen(); |
| 232 |
} |
| 233 |
|
| 234 |
/** |
| 235 |
** Draw a vertical line clipped |
| 236 |
*/ |
| 237 |
void DrawVLineClip(Uint32 color, int x, int y, int height) |
| 238 |
{ |
| 239 |
int w = 1; |
| 240 |
CLIP_RECTANGLE(x, y, w, height); |
| 241 |
DrawVLine(color, x, y, height); |
| 242 |
} |
| 243 |
|
| 244 |
/** |
| 245 |
** Draw a transparent vertical line clipped |
| 246 |
*/ |
| 247 |
void DrawTransVLineClip(Uint32 color, int x, int y, |
| 248 |
int height, unsigned char alpha) |
| 249 |
{ |
| 250 |
Video.LockScreen(); |
| 251 |
for (int i = 0; i < height; ++i) { |
| 252 |
VideoDoDrawTransPixelClip(color, x, y + i, alpha); |
| 253 |
} |
| 254 |
Video.UnlockScreen(); |
| 255 |
} |
| 256 |
|
| 257 |
/** |
| 258 |
** Draw a horizontal line |
| 259 |
*/ |
| 260 |
void DrawHLine(Uint32 color, int x, int y, int width) |
| 261 |
{ |
| 262 |
Video.LockScreen(); |
| 263 |
for (int i = 0; i < width; ++i) { |
| 264 |
VideoDoDrawPixel(color, x + i, y); |
| 265 |
} |
| 266 |
Video.UnlockScreen(); |
| 267 |
} |
| 268 |
|
| 269 |
/** |
| 270 |
** Draw a horizontal line clipped |
| 271 |
*/ |
| 272 |
void DrawHLineClip(Uint32 color, int x, int y, int width) |
| 273 |
{ |
| 274 |
int h = 1; |
| 275 |
CLIP_RECTANGLE(x, y, width, h); |
| 276 |
DrawHLine(color, x, y, width); |
| 277 |
} |
| 278 |
|
| 279 |
/** |
| 280 |
** Draw a transparent horizontal line |
| 281 |
*/ |
| 282 |
void DrawTransHLine(Uint32 color, int x, int y, |
| 283 |
int width, unsigned char alpha) |
| 284 |
{ |
| 285 |
Video.LockScreen(); |
| 286 |
for (int i = 0; i < width; ++i) { |
| 287 |
VideoDoDrawTransPixel(color, x + i, y, alpha); |
| 288 |
} |
| 289 |
Video.UnlockScreen(); |
| 290 |
} |
| 291 |
|
| 292 |
/** |
| 293 |
** Draw a transparent horizontal line clipped |
| 294 |
*/ |
| 295 |
void DrawTransHLineClip(Uint32 color, int x, int y, |
| 296 |
int width, unsigned char alpha) |
| 297 |
{ |
| 298 |
Video.LockScreen(); |
| 299 |
for (int i = 0; i < width; ++i) { |
| 300 |
VideoDoDrawTransPixelClip(color, x + i, y, alpha); |
| 301 |
} |
| 302 |
Video.UnlockScreen(); |
| 303 |
} |
| 304 |
|
| 305 |
/** |
| 306 |
** Draw a line |
| 307 |
*/ |
| 308 |
void DrawLine(Uint32 color, int sx, int sy, int dx, int dy) |
| 309 |
{ |
| 310 |
int x; |
| 311 |
int y; |
| 312 |
int xlen; |
| 313 |
int ylen; |
| 314 |
int incr; |
| 315 |
|
| 316 |
if (sx == dx) { |
| 317 |
if (sy < dy) { |
| 318 |
DrawVLine(color, sx, sy, dy - sy + 1); |
| 319 |
} else { |
| 320 |
DrawVLine(color, dx, dy, sy - dy + 1); |
| 321 |
} |
| 322 |
return; |
| 323 |
} |
| 324 |
|
| 325 |
if (sy == dy) { |
| 326 |
if (sx < dx) { |
| 327 |
DrawHLine(color, sx, sy, dx - sx + 1); |
| 328 |
} else { |
| 329 |
DrawHLine(color, dx, dy, sx - dx + 1); |
| 330 |
} |
| 331 |
return; |
| 332 |
} |
| 333 |
|
| 334 |
// exchange coordinates |
| 335 |
if (sy > dy) { |
| 336 |
int t; |
| 337 |
t = dx; |
| 338 |
dx = sx; |
| 339 |
sx = t; |
| 340 |
t = dy; |
| 341 |
dy = sy; |
| 342 |
sy = t; |
| 343 |
} |
| 344 |
ylen = dy - sy; |
| 345 |
|
| 346 |
if (sx > dx) { |
| 347 |
xlen = sx - dx; |
| 348 |
incr = -1; |
| 349 |
} else { |
| 350 |
xlen = dx - sx; |
| 351 |
incr = 1; |
| 352 |
} |
| 353 |
|
| 354 |
y = sy; |
| 355 |
x = sx; |
| 356 |
|
| 357 |
if (xlen > ylen) { |
| 358 |
int p; |
| 359 |
|
| 360 |
if (sx > dx) { |
| 361 |
int t; |
| 362 |
t = sx; |
| 363 |
sx = dx; |
| 364 |
dx = t; |
| 365 |
y = dy; |
| 366 |
} |
| 367 |
|
| 368 |
p = (ylen << 1) - xlen; |
| 369 |
|
| 370 |
Video.LockScreen(); |
| 371 |
for (x = sx; x < dx; ++x) { |
| 372 |
VideoDoDrawPixel(color, x, y); |
| 373 |
if (p >= 0) { |
| 374 |
y += incr; |
| 375 |
p += (ylen - xlen) << 1; |
| 376 |
} else { |
| 377 |
p += (ylen << 1); |
| 378 |
} |
| 379 |
} |
| 380 |
Video.UnlockScreen(); |
| 381 |
return; |
| 382 |
} |
| 383 |
|
| 384 |
if (ylen > xlen) { |
| 385 |
int p; |
| 386 |
|
| 387 |
p = (xlen << 1) - ylen; |
| 388 |
|
| 389 |
Video.LockScreen(); |
| 390 |
for (y = sy; y < dy; ++y) { |
| 391 |
VideoDoDrawPixel(color, x, y); |
| 392 |
if (p >= 0) { |
| 393 |
x += incr; |
| 394 |
p += (xlen - ylen) << 1; |
| 395 |
} else { |
| 396 |
p += (xlen << 1); |
| 397 |
} |
| 398 |
} |
| 399 |
Video.UnlockScreen(); |
| 400 |
return; |
| 401 |
} |
| 402 |
|
| 403 |
// Draw a diagonal line |
| 404 |
if (ylen == xlen) { |
| 405 |
Video.LockScreen(); |
| 406 |
while (y != dy) { |
| 407 |
VideoDoDrawPixel(color, x, y); |
| 408 |
x += incr; |
| 409 |
++y; |
| 410 |
} |
| 411 |
Video.UnlockScreen(); |
| 412 |
} |
| 413 |
} |
| 414 |
|
| 415 |
/** |
| 416 |
** Draw a line clipped |
| 417 |
*/ |
| 418 |
void DrawLineClip(Uint32 color, int sx, int sy, int dx, int dy) |
| 419 |
{ |
| 420 |
int x; |
| 421 |
int y; |
| 422 |
int xlen; |
| 423 |
int ylen; |
| 424 |
int incr; |
| 425 |
|
| 426 |
if (sx == dx) { |
| 427 |
if (sy < dy) { |
| 428 |
DrawVLineClip(color, sx, sy, dy - sy + 1); |
| 429 |
} else { |
| 430 |
DrawVLineClip(color, dx, dy, sy - dy + 1); |
| 431 |
} |
| 432 |
return; |
| 433 |
} |
| 434 |
|
| 435 |
if (sy == dy) { |
| 436 |
if (sx < dx) { |
| 437 |
DrawHLineClip(color, sx, sy, dx - sx + 1); |
| 438 |
} else { |
| 439 |
DrawHLineClip(color, dx, dy, sx - dx + 1); |
| 440 |
} |
| 441 |
return; |
| 442 |
} |
| 443 |
|
| 444 |
// exchange coordinates |
| 445 |
if (sy > dy) { |
| 446 |
int t; |
| 447 |
t = dx; |
| 448 |
dx = sx; |
| 449 |
sx = t; |
| 450 |
t = dy; |
| 451 |
dy = sy; |
| 452 |
sy = t; |
| 453 |
} |
| 454 |
ylen = dy - sy; |
| 455 |
|
| 456 |
if (sx > dx) { |
| 457 |
xlen = sx - dx; |
| 458 |
incr = -1; |
| 459 |
} else { |
| 460 |
xlen = dx - sx; |
| 461 |
incr = 1; |
| 462 |
} |
| 463 |
|
| 464 |
y = sy; |
| 465 |
x = sx; |
| 466 |
|
| 467 |
if (xlen > ylen) { |
| 468 |
int p; |
| 469 |
|
| 470 |
if (sx > dx) { |
| 471 |
int t; |
| 472 |
t = sx; |
| 473 |
sx = dx; |
| 474 |
dx = t; |
| 475 |
y = dy; |
| 476 |
} |
| 477 |
|
| 478 |
p = (ylen << 1) - xlen; |
| 479 |
|
| 480 |
Video.LockScreen(); |
| 481 |
for (x = sx; x < dx; ++x) { |
| 482 |
VideoDoDrawPixelClip(color, x, y); |
| 483 |
if (p >= 0) { |
| 484 |
y += incr; |
| 485 |
p += (ylen - xlen) << 1; |
| 486 |
} else { |
| 487 |
p += (ylen << 1); |
| 488 |
} |
| 489 |
} |
| 490 |
Video.UnlockScreen(); |
| 491 |
return; |
| 492 |
} |
| 493 |
|
| 494 |
if (ylen > xlen) { |
| 495 |
int p; |
| 496 |
|
| 497 |
p = (xlen << 1) - ylen; |
| 498 |
|
| 499 |
Video.LockScreen(); |
| 500 |
for (y = sy; y < dy; ++y) { |
| 501 |
VideoDoDrawPixelClip(color, x, y); |
| 502 |
if (p >= 0) { |
| 503 |
x += incr; |
| 504 |
p += (xlen - ylen) << 1; |
| 505 |
} else { |
| 506 |
p += (xlen << 1); |
| 507 |
} |
| 508 |
} |
| 509 |
Video.UnlockScreen(); |
| 510 |
return; |
| 511 |
} |
| 512 |
|
| 513 |
// Draw a diagonal line |
| 514 |
if (ylen == xlen) { |
| 515 |
Video.LockScreen(); |
| 516 |
while (y != dy) { |
| 517 |
VideoDoDrawPixelClip(color, x, y); |
| 518 |
x += incr; |
| 519 |
++y; |
| 520 |
} |
| 521 |
Video.UnlockScreen(); |
| 522 |
} |
| 523 |
} |
| 524 |
|
| 525 |
/** |
| 526 |
** Draw a transparent line |
| 527 |
*/ |
| 528 |
void DrawTransLine(Uint32 color, int sx, int sy, |
| 529 |
int dx, int dy, unsigned char alpha) |
| 530 |
{ |
| 531 |
// FIXME: trans |
| 532 |
DrawLine(color, sx, sy, dx, dy); |
| 533 |
} |
| 534 |
|
| 535 |
/** |
| 536 |
** Draw a transparent line clipped |
| 537 |
*/ |
| 538 |
void DrawTransLineClip(Uint32 color, int sx, int sy, |
| 539 |
int dx, int dy, unsigned char alpha) |
| 540 |
{ |
| 541 |
// FIXME: trans |
| 542 |
DrawLineClip(color, sx, sy, dx, dy); |
| 543 |
} |
| 544 |
|
| 545 |
/** |
| 546 |
** Draw a rectangle |
| 547 |
*/ |
| 548 |
void DrawRectangle(Uint32 color, int x, int y, int w, int h) |
| 549 |
{ |
| 550 |
DrawHLine(color, x, y, w); |
| 551 |
DrawHLine(color, x, y + h - 1, w); |
| 552 |
|
| 553 |
DrawVLine(color, x, y + 1, h - 2); |
| 554 |
DrawVLine(color, x + w - 1, y + 1, h - 2); |
| 555 |
} |
| 556 |
|
| 557 |
/** |
| 558 |
** Draw a rectangle clipped |
| 559 |
*/ |
| 560 |
void DrawRectangleClip(Uint32 color, int x, int y, int w, int h) |
| 561 |
{ |
| 562 |
DrawHLineClip(color, x, y, w); |
| 563 |
DrawHLineClip(color, x, y + h - 1, w); |
| 564 |
|
| 565 |
DrawVLineClip(color, x, y + 1, h - 2); |
| 566 |
DrawVLineClip(color, x + w - 1, y + 1, h - 2); |
| 567 |
} |
| 568 |
|
| 569 |
/** |
| 570 |
** Draw a transparent rectangle |
| 571 |
*/ |
| 572 |
void DrawTransRectangle(Uint32 color, int x, int y, |
| 573 |
int w, int h, unsigned char alpha) |
| 574 |
{ |
| 575 |
DrawTransHLine(color, x, y, w, alpha); |
| 576 |
DrawTransHLine(color, x, y + h - 1, w, alpha); |
| 577 |
|
| 578 |
DrawTransVLine(color, x, y + 1, h - 2, alpha); |
| 579 |
DrawTransVLine(color, x + w - 1, y + 1, h - 2, alpha); |
| 580 |
} |
| 581 |
|
| 582 |
/** |
| 583 |
** Draw a transparent rectangle clipped. |
| 584 |
** |
| 585 |
** @param color color |
| 586 |
** @param x x coordinate on the screen |
| 587 |
** @param y y coordinate on the screen |
| 588 |
** @param h height of rectangle (0=don't draw). |
| 589 |
** @param w width of rectangle (0=don't draw). |
| 590 |
** @param alpha alpha value of pixels. |
| 591 |
*/ |
| 592 |
void DrawTransRectangleClip(Uint32 color, int x, int y, |
| 593 |
int w, int h, unsigned char alpha) |
| 594 |
{ |
| 595 |
DrawTransHLineClip(color, x, y, w, alpha); |
| 596 |
DrawTransHLineClip(color, x, y + h - 1, w, alpha); |
| 597 |
|
| 598 |
DrawTransVLineClip(color, x, y + 1, h - 2, alpha); |
| 599 |
DrawTransVLineClip(color, x + w - 1, y + 1, h - 2, alpha); |
| 600 |
} |
| 601 |
|
| 602 |
/** |
| 603 |
** Draw a filled rectangle |
| 604 |
*/ |
| 605 |
void FillRectangle(Uint32 color, int x, int y, int w, int h) |
| 606 |
{ |
| 607 |
SDL_Rect drect = { |
| 608 |
static_cast<Sint16>(x), |
| 609 |
static_cast<Sint16>(y), |
| 610 |
static_cast<Uint16>(w), |
| 611 |
static_cast<Uint16>(h) |
| 612 |
}; |
| 613 |
SDL_FillRect(TheScreen, &drect, color); |
| 614 |
} |
| 615 |
|
| 616 |
/** |
| 617 |
** Draw a filled rectangle clipped |
| 618 |
*/ |
| 619 |
void FillRectangleClip(Uint32 color, int x, int y, |
| 620 |
int w, int h) |
| 621 |
{ |
| 622 |
SDL_Rect oldrect; |
| 623 |
SDL_Rect newrect; |
| 624 |
|
| 625 |
SDL_GetClipRect(TheScreen, &oldrect); |
| 626 |
newrect.x = ClipX1; |
| 627 |
newrect.y = ClipY1; |
| 628 |
newrect.w = ClipX2 + 1 - ClipX1; |
| 629 |
newrect.h = ClipY2 + 1 - ClipY1; |
| 630 |
|
| 631 |
SDL_SetClipRect(TheScreen, &newrect); |
| 632 |
FillRectangle(color, x, y, w, h); |
| 633 |
SDL_SetClipRect(TheScreen, &oldrect); |
| 634 |
} |
| 635 |
|
| 636 |
/** |
| 637 |
** Draw a filled transparent rectangle |
| 638 |
*/ |
| 639 |
void FillTransRectangle(Uint32 color, int x, int y, |
| 640 |
int w, int h, unsigned char alpha) |
| 641 |
{ |
| 642 |
int ex = x + w; |
| 643 |
int ey = y + h; |
| 644 |
int sx = x; |
| 645 |
|
| 646 |
Video.LockScreen(); |
| 647 |
for (; y < ey; ++y) { |
| 648 |
for (x = sx; x < ex; ++x) { |
| 649 |
VideoDoDrawTransPixel(color, x, y, alpha); |
| 650 |
} |
| 651 |
} |
| 652 |
Video.UnlockScreen(); |
| 653 |
} |
| 654 |
|
| 655 |
/** |
| 656 |
** Draw a filled transparent rectangle clipped |
| 657 |
*/ |
| 658 |
void FillTransRectangleClip(Uint32 color, int x, int y, |
| 659 |
int w, int h, unsigned char alpha) |
| 660 |
{ |
| 661 |
CLIP_RECTANGLE(x, y, w, h); |
| 662 |
FillTransRectangle(color, x, y, w, h, alpha); |
| 663 |
} |
| 664 |
|
| 665 |
/** |
| 666 |
** Draw a circle |
| 667 |
*/ |
| 668 |
void DrawCircle(Uint32 color, int x, int y, int r) |
| 669 |
{ |
| 670 |
int p; |
| 671 |
int px; |
| 672 |
int py; |
| 673 |
|
| 674 |
p = 1 - r; |
| 675 |
py = r; |
| 676 |
|
| 677 |
Video.LockScreen(); |
| 678 |
for (px = 0; px <= py + 1; ++px) { |
| 679 |
VideoDoDrawPixel(color, x + px, y + py); |
| 680 |
VideoDoDrawPixel(color, x + px, y - py); |
| 681 |
VideoDoDrawPixel(color, x - px, y + py); |
| 682 |
VideoDoDrawPixel(color, x - px, y - py); |
| 683 |
|
| 684 |
VideoDoDrawPixel(color, x + py, y + px); |
| 685 |
VideoDoDrawPixel(color, x + py, y - px); |
| 686 |
VideoDoDrawPixel(color, x - py, y + px); |
| 687 |
VideoDoDrawPixel(color, x - py, y - px); |
| 688 |
|
| 689 |
if (p < 0) { |
| 690 |
p += 2 * px + 3; |
| 691 |
} else { |
| 692 |
p += 2 * (px - py) + 5; |
| 693 |
py -= 1; |
| 694 |
} |
| 695 |
} |
| 696 |
Video.UnlockScreen(); |
| 697 |
} |
| 698 |
|
| 699 |
/** |
| 700 |
** Draw a transparent circle |
| 701 |
*/ |
| 702 |
void DrawTransCircle(Uint32 color, int x, int y, |
| 703 |
int r, unsigned char alpha) |
| 704 |
{ |
| 705 |
int p; |
| 706 |
int px; |
| 707 |
int py; |
| 708 |
|
| 709 |
p = 1 - r; |
| 710 |
py = r; |
| 711 |
|
| 712 |
Video.LockScreen(); |
| 713 |
for (px = 0; px <= py + 1; ++px) { |
| 714 |
VideoDoDrawTransPixel(color, x + px, y + py, alpha); |
| 715 |
VideoDoDrawTransPixel(color, x + px, y - py, alpha); |
| 716 |
VideoDoDrawTransPixel(color, x - px, y + py, alpha); |
| 717 |
VideoDoDrawTransPixel(color, x - px, y - py, alpha); |
| 718 |
|
| 719 |
VideoDoDrawTransPixel(color, x + py, y + px, alpha); |
| 720 |
VideoDoDrawTransPixel(color, x + py, y - px, alpha); |
| 721 |
VideoDoDrawTransPixel(color, x - py, y + px, alpha); |
| 722 |
VideoDoDrawTransPixel(color, x - py, y - px, alpha); |
| 723 |
|
| 724 |
if (p < 0) { |
| 725 |
p += 2 * px + 3; |
| 726 |
} else { |
| 727 |
p += 2 * (px - py) + 5; |
| 728 |
py -= 1; |
| 729 |
} |
| 730 |
} |
| 731 |
Video.UnlockScreen(); |
| 732 |
} |
| 733 |
|
| 734 |
/** |
| 735 |
** Draw a circle clipped |
| 736 |
*/ |
| 737 |
void DrawCircleClip(Uint32 color, int x, int y, int r) |
| 738 |
{ |
| 739 |
int p; |
| 740 |
int px; |
| 741 |
int py; |
| 742 |
|
| 743 |
p = 1 - r; |
| 744 |
py = r; |
| 745 |
|
| 746 |
Video.LockScreen(); |
| 747 |
for (px = 0; px <= py + 1; ++px) { |
| 748 |
VideoDoDrawPixelClip(color, x + px, y + py); |
| 749 |
VideoDoDrawPixelClip(color, x + px, y - py); |
| 750 |
VideoDoDrawPixelClip(color, x - px, y + py); |
| 751 |
VideoDoDrawPixelClip(color, x - px, y - py); |
| 752 |
|
| 753 |
VideoDoDrawPixelClip(color, x + py, y + px); |
| 754 |
VideoDoDrawPixelClip(color, x + py, y - px); |
| 755 |
VideoDoDrawPixelClip(color, x - py, y + px); |
| 756 |
VideoDoDrawPixelClip(color, x - py, y - px); |
| 757 |
|
| 758 |
if (p < 0) { |
| 759 |
p += 2 * px + 3; |
| 760 |
} else { |
| 761 |
p += 2 * (px - py) + 5; |
| 762 |
py -= 1; |
| 763 |
} |
| 764 |
} |
| 765 |
Video.UnlockScreen(); |
| 766 |
} |
| 767 |
|
| 768 |
/** |
| 769 |
** Draw a transparent circle clipped |
| 770 |
*/ |
| 771 |
void DrawTransCircleClip(Uint32 color, int x, int y, |
| 772 |
int r, unsigned char alpha) |
| 773 |
{ |
| 774 |
int p; |
| 775 |
int px; |
| 776 |
int py; |
| 777 |
|
| 778 |
p = 1 - r; |
| 779 |
py = r; |
| 780 |
|
| 781 |
Video.LockScreen(); |
| 782 |
for (px = 0; px <= py + 1; ++px) { |
| 783 |
VideoDoDrawTransPixelClip(color, x + px, y + py, alpha); |
| 784 |
VideoDoDrawTransPixelClip(color, x + px, y - py, alpha); |
| 785 |
VideoDoDrawTransPixelClip(color, x - px, y + py, alpha); |
| 786 |
VideoDoDrawTransPixelClip(color, x - px, y - py, alpha); |
| 787 |
|
| 788 |
VideoDoDrawTransPixelClip(color, x + py, y + px, alpha); |
| 789 |
VideoDoDrawTransPixelClip(color, x + py, y - px, alpha); |
| 790 |
VideoDoDrawTransPixelClip(color, x - py, y + px, alpha); |
| 791 |
VideoDoDrawTransPixelClip(color, x - py, y - px, alpha); |
| 792 |
|
| 793 |
if (p < 0) { |
| 794 |
p += 2 * px + 3; |
| 795 |
} else { |
| 796 |
p += 2 * (px - py) + 5; |
| 797 |
py -= 1; |
| 798 |
} |
| 799 |
} |
| 800 |
Video.UnlockScreen(); |
| 801 |
} |
| 802 |
|
| 803 |
/** |
| 804 |
** Draw a filled circle |
| 805 |
*/ |
| 806 |
void FillCircle(Uint32 color, int x, int y, int r) |
| 807 |
{ |
| 808 |
int p; |
| 809 |
int px; |
| 810 |
int py; |
| 811 |
|
| 812 |
p = 1 - r; |
| 813 |
py = r; |
| 814 |
|
| 815 |
for (px = 0; px <= py; ++px) { |
| 816 |
|
| 817 |
// Fill up the middle half of the circle |
| 818 |
DrawVLine(color, x + px, y, py + 1); |
| 819 |
DrawVLine(color, x + px, y - py, py); |
| 820 |
if (px) { |
| 821 |
DrawVLine(color, x - px, y, py + 1); |
| 822 |
DrawVLine(color, x - px, y - py, py); |
| 823 |
} |
| 824 |
|
| 825 |
if (p < 0) { |
| 826 |
p += 2 * px + 3; |
| 827 |
} else { |
| 828 |
p += 2 * (px - py) + 5; |
| 829 |
py -= 1; |
| 830 |
// Fill up the left/right half of the circle |
| 831 |
if (py >= px) { |
| 832 |
DrawVLine(color, x + py + 1, y, px + 1); |
| 833 |
DrawVLine(color, x + py + 1, y - px, px); |
| 834 |
DrawVLine(color, x - py - 1, y, px + 1); |
| 835 |
DrawVLine(color, x - py - 1, y - px, px); |
| 836 |
} |
| 837 |
} |
| 838 |
} |
| 839 |
} |
| 840 |
|
| 841 |
/** |
| 842 |
** Draw a filled transparent circle |
| 843 |
*/ |
| 844 |
void FillTransCircle(Uint32 color, int x, int y, |
| 845 |
int r, unsigned char alpha) |
| 846 |
{ |
| 847 |
int p; |
| 848 |
int px; |
| 849 |
int py; |
| 850 |
|
| 851 |
p = 1 - r; |
| 852 |
py = r; |
| 853 |
|
| 854 |
for (px = 0; px <= py; ++px) { |
| 855 |
|
| 856 |
// Fill up the middle half of the circle |
| 857 |
DrawTransVLine(color, x + px, y, py + 1, alpha); |
| 858 |
DrawTransVLine(color, x + px, y - py, py, alpha); |
| 859 |
if (px) { |
| 860 |
DrawTransVLine(color, x - px, y, py + 1, alpha); |
| 861 |
DrawTransVLine(color, x - px, y - py, py, alpha); |
| 862 |
} |
| 863 |
|
| 864 |
if (p < 0) { |
| 865 |
p += 2 * px + 3; |
| 866 |
} else { |
| 867 |
p += 2 * (px - py) + 5; |
| 868 |
py -= 1; |
| 869 |
// Fill up the left/right half of the circle |
| 870 |
if (py >= px) { |
| 871 |
DrawTransVLine(color, x + py + 1, y, px + 1, alpha); |
| 872 |
DrawTransVLine(color, x + py + 1, y - px, px, alpha); |
| 873 |
DrawTransVLine(color, x - py - 1, y, px + 1, alpha); |
| 874 |
DrawTransVLine(color, x - py - 1, y - px, px, alpha); |
| 875 |
} |
| 876 |
} |
| 877 |
} |
| 878 |
} |
| 879 |
|
| 880 |
/** |
| 881 |
** Draw a filled circle clipped |
| 882 |
*/ |
| 883 |
void FillCircleClip(Uint32 color, int x, int y, int r) |
| 884 |
{ |
| 885 |
int p; |
| 886 |
int px; |
| 887 |
int py; |
| 888 |
|
| 889 |
p = 1 - r; |
| 890 |
py = r; |
| 891 |
|
| 892 |
for (px = 0; px <= py; ++px) { |
| 893 |
|
| 894 |
// Fill up the middle half of the circle |
| 895 |
DrawVLineClip(color, x + px, y, py + 1); |
| 896 |
DrawVLineClip(color, x + px, y - py, py); |
| 897 |
if (px) { |
| 898 |
DrawVLineClip(color, x - px, y, py + 1); |
| 899 |
DrawVLineClip(color, x - px, y - py, py); |
| 900 |
} |
| 901 |
|
| 902 |
if (p < 0) { |
| 903 |
p += 2 * px + 3; |
| 904 |
} else { |
| 905 |
p += 2 * (px - py) + 5; |
| 906 |
py -= 1; |
| 907 |
// Fill up the left/right half of the circle |
| 908 |
if (py >= px) { |
| 909 |
DrawVLineClip(color, x + py + 1, y, px + 1); |
| 910 |
DrawVLineClip(color, x + py + 1, y - px, px); |
| 911 |
DrawVLineClip(color, x - py - 1, y, px + 1); |
| 912 |
DrawVLineClip(color, x - py - 1, y - px, px); |
| 913 |
} |
| 914 |
} |
| 915 |
} |
| 916 |
} |
| 917 |
|
| 918 |
/** |
| 919 |
** Draw a filled transparent circle clipped |
| 920 |
*/ |
| 921 |
void FillTransCircleClip(Uint32 color, int x, int y, |
| 922 |
int r, unsigned char alpha) |
| 923 |
{ |
| 924 |
int p; |
| 925 |
int px; |
| 926 |
int py; |
| 927 |
|
| 928 |
p = 1 - r; |
| 929 |
py = r; |
| 930 |
|
| 931 |
for (px = 0; px <= py; ++px) { |
| 932 |
|
| 933 |
// Fill up the middle half of the circle |
| 934 |
DrawTransVLineClip(color, x + px, y, py + 1, alpha); |
| 935 |
DrawTransVLineClip(color, x + px, y - py, py, alpha); |
| 936 |
if (px) { |
| 937 |
DrawTransVLineClip(color, x - px, y, py + 1, alpha); |
| 938 |
DrawTransVLineClip(color, x - px, y - py, py, alpha); |
| 939 |
} |
| 940 |
|
| 941 |
if (p < 0) { |
| 942 |
p += 2 * px + 3; |
| 943 |
} else { |
| 944 |
p += 2 * (px - py) + 5; |
| 945 |
py -= 1; |
| 946 |
// Fill up the left/right half of the circle |
| 947 |
if (py >= px) { |
| 948 |
DrawTransVLineClip(color, x + py + 1, y, px + 1, alpha); |
| 949 |
DrawTransVLineClip(color, x + py + 1, y - px, px, alpha); |
| 950 |
DrawTransVLineClip(color, x - py - 1, y, px + 1, alpha); |
| 951 |
DrawTransVLineClip(color, x - py - 1, y - px, px, alpha); |
| 952 |
} |
| 953 |
} |
| 954 |
} |
| 955 |
} |
| 956 |
|
| 957 |
/** |
| 958 |
** Initialize line draw |
| 959 |
*/ |
| 960 |
void InitLineDraw(void) |
| 961 |
{ |
| 962 |
switch (Video.Depth) { |
| 963 |
case 16: |
| 964 |
VideoDrawPixel = VideoDrawPixel16; |
| 965 |
VideoDoDrawPixel = VideoDoDrawPixel16; |
| 966 |
VideoDrawTransPixel = VideoDrawTransPixel16; |
| 967 |
VideoDoDrawTransPixel = VideoDoDrawTransPixel16; |
| 968 |
break; |
| 969 |
case 32: |
| 970 |
VideoDrawPixel = VideoDrawPixel32; |
| 971 |
VideoDoDrawPixel = VideoDoDrawPixel32; |
| 972 |
VideoDrawTransPixel = VideoDrawTransPixel32; |
| 973 |
VideoDoDrawTransPixel = VideoDoDrawTransPixel32; |
| 974 |
} |
| 975 |
} |
| 976 |
|
| 977 |
} |
| 978 |
namespace linedraw_gl { |
| 979 |
|
| 980 |
/** |
| 981 |
** Draw pixel unclipped. |
| 982 |
** |
| 983 |
** @param color color |
| 984 |
** @param x x coordinate on the screen |
| 985 |
** @param y y coordinate on the screen |
| 986 |
*/ |
| 987 |
void DrawPixel(Uint32 color, int x, int y) |
| 988 |
{ |
| 989 |
GLubyte r, g, b, a; |
| 990 |
|
| 991 |
Video.GetRGBA(color, NULL, &r, &g, &b, &a); |
| 992 |
glDisable(GL_TEXTURE_2D); |
| 993 |
glColor4ub(r, g, b, a); |
| 994 |
glBegin(GL_POINTS); |
| 995 |
glVertex2i(x, y); |
| 996 |
glEnd(); |
| 997 |
glEnable(GL_TEXTURE_2D); |
| 998 |
} |
| 999 |
|
| 1000 |
/** |
| 1001 |
** Draw translucent pixel unclipped. |
| 1002 |
** |
| 1003 |
** @param color color |
| 1004 |
** @param x x coordinate on the screen |
| 1005 |
** @param y y coordinate on the screen |
| 1006 |
** @param alpha alpha value of pixel. |
| 1007 |
*/ |
| 1008 |
void DrawTransPixel(Uint32 color, int x, int y, |
| 1009 |
unsigned char alpha) |
| 1010 |
{ |
| 1011 |
GLubyte r, g, b; |
| 1012 |
|
| 1013 |
Video.GetRGB(color, NULL, &r, &g, &b); |
| 1014 |
color = Video.MapRGBA(0, r, g, b, alpha); |
| 1015 |
DrawPixel(color, x, y); |
| 1016 |
} |
| 1017 |
|
| 1018 |
/** |
| 1019 |
** Draw pixel clipped to current clip setting. |
| 1020 |
** |
| 1021 |
** @param color color |
| 1022 |
** @param x x coordinate on the screen |
| 1023 |
** @param y y coordinate on the screen |
| 1024 |
*/ |
| 1025 |
void DrawPixelClip(Uint32 color, int x, int y) |
| 1026 |
{ |
| 1027 |
if (x < ClipX1 || x > ClipX2 || y < ClipY1 || y > ClipY2) { |
| 1028 |
return; |
| 1029 |
} |
| 1030 |
DrawPixel(color, x, y); |
| 1031 |
} |
| 1032 |
|
| 1033 |
/** |
| 1034 |
** Draw translucent pixel clipped to current clip setting. |
| 1035 |
** |
| 1036 |
** @param color color |
| 1037 |
** @param x x coordinate on the screen |
| 1038 |
** @param y y coordinate on the screen |
| 1039 |
** @param alpha alpha value of pixel. |
| 1040 |
*/ |
| 1041 |
void DrawTransPixelClip(Uint32 color, int x, int y, |
| 1042 |
unsigned char alpha) |
| 1043 |
{ |
| 1044 |
GLubyte r, g, b; |
| 1045 |
|
| 1046 |
Video.GetRGB(color, NULL, &r, &g, &b); |
| 1047 |
color = Video.MapRGBA(0, r, g, b, alpha); |
| 1048 |
DrawPixelClip(color, x, y); |
| 1049 |
} |
| 1050 |
|
| 1051 |
/** |
| 1052 |
** Draw horizontal line unclipped. |
| 1053 |
** |
| 1054 |
** @param color color |
| 1055 |
** @param x x coordinate on the screen |
| 1056 |
** @param y y coordinate on the screen |
| 1057 |
** @param width width of line (0=don't draw). |
| 1058 |
*/ |
| 1059 |
void DrawHLine(Uint32 color, int x, int y, int width) |
| 1060 |
{ |
| 1061 |
GLubyte r, g, b, a; |
| 1062 |
|
| 1063 |
Video.GetRGBA(color, NULL, &r, &g, &b, &a); |
| 1064 |
glDisable(GL_TEXTURE_2D); |
| 1065 |
glColor4ub(r, g, b, a); |
| 1066 |
glBegin(GL_LINES); |
| 1067 |
glVertex2i(x, y); |
| 1068 |
glVertex2i(x + width, y); |
| 1069 |
glEnd(); |
| 1070 |
glEnable(GL_TEXTURE_2D); |
| 1071 |
} |
| 1072 |
|
| 1073 |
/** |
| 1074 |
** Draw translucent horizontal line unclipped. |
| 1075 |
** |
| 1076 |
** @param color color |
| 1077 |
** @param x x coordinate on the screen |
| 1078 |
** @param y y coordinate on the screen |
| 1079 |
** @param width width of line (0=don't draw). |
| 1080 |
** @param alpha alpha value of pixels. |
| 1081 |
*/ |
| 1082 |
void DrawTransHLine(Uint32 color, int x, int y, int width, |
| 1083 |
unsigned char alpha) |
| 1084 |
{ |
| 1085 |
GLubyte r, g, b; |
| 1086 |
|
| 1087 |
Video.GetRGB(color, NULL, &r, &g, &b); |
| 1088 |
color = Video.MapRGBA(0, r, g, b, alpha); |
| 1089 |
DrawHLine(color, x, y, width); |
| 1090 |
} |
| 1091 |
|
| 1092 |
/** |
| 1093 |
** Draw horizontal line clipped. |
| 1094 |
** |
| 1095 |
** @param color color |
| 1096 |
** @param x x coordinate on the screen |
| 1097 |
** @param y y coordinate on the screen |
| 1098 |
** @param width width of line (0=don't draw). |
| 1099 |
*/ |
| 1100 |
void DrawHLineClip(Uint32 color, int x, int y, int width) |
| 1101 |
{ |
| 1102 |
if (y < ClipY1 || y > ClipY2) { |
| 1103 |
return; |
| 1104 |
} |
| 1105 |
if (x < ClipX1) { |
| 1106 |
int f = ClipX1 - x; |
| 1107 |
if (width <= f) { |
| 1108 |
return; |
| 1109 |
} |
| 1110 |
width -= f; |
| 1111 |
x = ClipX1; |
| 1112 |
} |
| 1113 |
if ((x + width) > ClipX2 + 1) { |
| 1114 |
if (x > ClipX2) { |
| 1115 |
return; |
| 1116 |
} |
| 1117 |
width = ClipX2 - x + 1; |
| 1118 |
} |
| 1119 |
DrawHLine(color, x, y, width); |
| 1120 |
} |
| 1121 |
|
| 1122 |
/** |
| 1123 |
** Draw translucent horizontal line clipped. |
| 1124 |
** |
| 1125 |
** @param color Color index |
| 1126 |
** @param x X pixel coordinate on the screen |
| 1127 |
** @param y Y c pixeloordinate on the screen |
| 1128 |
** @param width Width of line (0=don't draw) |
| 1129 |
** @param alpha Alpha value of pixels |
| 1130 |
*/ |
| 1131 |
void DrawTransHLineClip(Uint32 color, int x, int y, int width, |
| 1132 |
unsigned char alpha) |
| 1133 |
{ |
| 1134 |
GLubyte r, g, b; |
| 1135 |
|
| 1136 |
Video.GetRGB(color, NULL, &r, &g, &b); |
| 1137 |
color = Video.MapRGBA(0, r, g, b, alpha); |
| 1138 |
DrawHLineClip(color, x, y, width); |
| 1139 |
} |
| 1140 |
|
| 1141 |
/** |
| 1142 |
** Draw vertical line unclipped. |
| 1143 |
** |
| 1144 |
** @param color color |
| 1145 |
** @param x x coordinate on the screen |
| 1146 |
** @param y y coordinate on the screen |
| 1147 |
** @param height height of line (0=don't draw). |
| 1148 |
*/ |
| 1149 |
void DrawVLine(Uint32 color, int x, int y, int height) |
| 1150 |
{ |
| 1151 |
GLubyte r, g, b, a; |
| 1152 |
|
| 1153 |
Video.GetRGBA(color, NULL, &r, &g, &b, &a); |
| 1154 |
glDisable(GL_TEXTURE_2D); |
| 1155 |
glColor4ub(r, g, b, a); |
| 1156 |
glBegin(GL_LINES); |
| 1157 |
glVertex2i(x, y); |
| 1158 |
glVertex2i(x, y + height); |
| 1159 |
glEnd(); |
| 1160 |
glEnable(GL_TEXTURE_2D); |
| 1161 |
} |
| 1162 |
|
| 1163 |
/** |
| 1164 |
** Draw translucent vertical line unclipped. |
| 1165 |
** |
| 1166 |
** @param color color |
| 1167 |
** @param x x coordinate on the screen |
| 1168 |
** @param y y coordinate on the screen |
| 1169 |
** @param height height of line (0=don't draw). |
| 1170 |
** @param alpha alpha value of pixels. |
| 1171 |
*/ |
| 1172 |
void DrawTransVLine(Uint32 color, int x, int y, int height, |
| 1173 |
unsigned char alpha) |
| 1174 |
{ |
| 1175 |
GLubyte r, g, b; |
| 1176 |
|
| 1177 |
Video.GetRGB(color, NULL, &r, &g, &b); |
| 1178 |
color = Video.MapRGBA(0, r, g, b, alpha); |
| 1179 |
DrawVLine(color, x, y, height); |
| 1180 |
} |
| 1181 |
|
| 1182 |
/** |
| 1183 |
** Draw vertical line clipped. |
| 1184 |
** |
| 1185 |
** @param color color |
| 1186 |
** @param x x coordinate on the screen |
| 1187 |
** @param y y coordinate on the screen |
| 1188 |
** @param height height of line (0=don't draw). |
| 1189 |
*/ |
| 1190 |
void DrawVLineClip(Uint32 color, int x, int y, int height) |
| 1191 |
{ |
| 1192 |
if (x < ClipX1 || x > ClipX2) { |
| 1193 |
return; |
| 1194 |
} |
| 1195 |
if (y < ClipY1) { |
| 1196 |
int f = ClipY1 - y; |
| 1197 |
if (height <= f) { |
| 1198 |
return; |
| 1199 |
} |
| 1200 |
height -= f; |
| 1201 |
y = ClipY1; |
| 1202 |
} |
| 1203 |
if ((y + height) > ClipY2 + 1) { |
| 1204 |
if (y > ClipY2) { |
| 1205 |
return; |
| 1206 |
} |
| 1207 |
height = ClipY2 - y + 1; |
| 1208 |
} |
| 1209 |
DrawVLine(color, x, y, height); |
| 1210 |
} |
| 1211 |
|
| 1212 |
/** |
| 1213 |
** Draw translucent vertical line clipped. |
| 1214 |
** |
| 1215 |
** @param color color |
| 1216 |
** @param x x coordinate on the screen |
| 1217 |
** @param y y coordinate on the screen |
| 1218 |
** @param height height of line (0=don't draw). |
| 1219 |
** @param alpha alpha value of pixels. |
| 1220 |
*/ |
| 1221 |
void DrawTransVLineClip(Uint32 color, int x, int y, |
| 1222 |
int height, unsigned char alpha) |
| 1223 |
{ |
| 1224 |
GLubyte r, g, b; |
| 1225 |
|
| 1226 |
Video.GetRGB(color, NULL, &r, &g, &b); |
| 1227 |
color = Video.MapRGBA(0, r, g, b, alpha); |
| 1228 |
DrawVLineClip(color, x, y, height); |
| 1229 |
} |
| 1230 |
|
| 1231 |
/** |
| 1232 |
** Draw line unclipped into 32bit framebuffer. |
| 1233 |
** |
| 1234 |
** @param color color |
| 1235 |
** @param x1 Source x coordinate on the screen |
| 1236 |
** @param y1 Source y coordinate on the screen |
| 1237 |
** @param x2 Destination x coordinate on the screen |
| 1238 |
** @param y2 Destination y coordinate on the screen |
| 1239 |
*/ |
| 1240 |
void DrawLine(Uint32 color, int x1, int y1, int x2, int y2) |
| 1241 |
{ |
| 1242 |
float xx1, yy1, xx2, yy2; |
| 1243 |
GLubyte r, g, b, a; |
| 1244 |
|
| 1245 |
xx1 = (float)x1; |
| 1246 |
xx2 = (float)x2; |
| 1247 |
yy1 = (float)y1; |
| 1248 |
yy2 = (float)y2; |
| 1249 |
|
| 1250 |
if (xx1 <= xx2) { |
| 1251 |
xx2 += 0.5f; |
| 1252 |
} else { |
| 1253 |
xx1 += 0.5f; |
| 1254 |
} |
| 1255 |
if (yy1 <= yy2) { |
| 1256 |
yy2 += 0.5f; |
| 1257 |
} else { |
| 1258 |
yy1 += 0.5f; |
| 1259 |
} |
| 1260 |
|
| 1261 |
Video.GetRGBA(color, NULL, &r, &g, &b, &a); |
| 1262 |
glDisable(GL_TEXTURE_2D); |
| 1263 |
glColor4ub(r, g, b, a); |
| 1264 |
glBegin(GL_LINES); |
| 1265 |
glVertex2f(xx1, yy1); |
| 1266 |
glVertex2f(xx2, yy2); |
| 1267 |
glEnd(); |
| 1268 |
glEnable(GL_TEXTURE_2D); |
| 1269 |
} |
| 1270 |
|
| 1271 |
/** |
| 1272 |
** Delivers bitmask denoting given point is left/right/above/below |
| 1273 |
** clip rectangle, used for faster determinination of clipped position. |
| 1274 |
** |
| 1275 |
** @param x pixel's x position (not restricted to screen width) |
| 1276 |
** @param y pixel's y position (not restricted to screen height) |
| 1277 |
*/ |
| 1278 |
static int ClipCodeLine(int x, int y) |
| 1279 |
{ |
| 1280 |
int result; |
| 1281 |
|
| 1282 |
if (y < ClipY1) { |
| 1283 |
result = ClipCodeAbove; |
| 1284 |
} else if (y > ClipY2) { |
| 1285 |
result = ClipCodeBelow; |
| 1286 |
} else { |
| 1287 |
result = ClipCodeInside; |
| 1288 |
} |
| 1289 |
|
| 1290 |
if (x < ClipX1) { |
| 1291 |
result |= ClipCodeLeft; |
| 1292 |
} else if (x > ClipX2) { |
| 1293 |
result |= ClipCodeRight; |
| 1294 |
} |
| 1295 |
|
| 1296 |
return result; |
| 1297 |
} |
| 1298 |
|
| 1299 |
/** |
| 1300 |
** Denotes entire line located at the same side outside clip rectangle |
| 1301 |
** (point 1 and 2 are both as left/right/above/below the clip rectangle) |
| 1302 |
** |
| 1303 |
** @param code1 ClipCode of one point of line |
| 1304 |
** @param code2 ClipCode of second point of line |
| 1305 |
*/ |
| 1306 |
static int LineIsUnclippedOnSameSide(int code1, int code2) |
| 1307 |
{ |
| 1308 |
return code1 & code2; |
| 1309 |
} |
| 1310 |
|
| 1311 |
/** |
| 1312 |
** Denotes part of (or entire) line located outside clip rectangle |
| 1313 |
** (point 1 and/or 2 is outside clip rectangle) |
| 1314 |
** |
| 1315 |
** @param code1 ClipCode of one point of line |
| 1316 |
** @param code2 ClipCode of second point of line |
| 1317 |
*/ |
| 1318 |
static int LineIsUnclipped(int code1, int code2) |
| 1319 |
{ |
| 1320 |
return code1 | code2; |
| 1321 |
} |
| 1322 |
|
| 1323 |
/** |
| 1324 |
** Draw line clipped. |
| 1325 |
** Based on Sutherland-Cohen clipping technique |
| 1326 |
** (Replaces Liang/Barksy clipping algorithm in CVS version 1.18, which |
| 1327 |
** might be faster, but that one contained some BUGs) |
| 1328 |
** |
| 1329 |
** @param color color |
| 1330 |
** @param x1 Source x coordinate on the screen |
| 1331 |
** @param y1 Source y coordinate on the screen |
| 1332 |
** @param x2 Destination x coordinate on the screen |
| 1333 |
** @param y2 Destination y coordinate on the screen |
| 1334 |
*/ |
| 1335 |
void DrawLineClip(Uint32 color, int x1, int y1, int x2, int y2) |
| 1336 |
{ |
| 1337 |
int code1; |
| 1338 |
int code2; |
| 1339 |
int temp; |
| 1340 |
|
| 1341 |
// Make sure coordinates or on/in clipped rectangle |
| 1342 |
while (code1 = ClipCodeLine(x1, y1), code2 = ClipCodeLine(x2, y2), |
| 1343 |
LineIsUnclipped(code1, code2)) { |
| 1344 |
if (LineIsUnclippedOnSameSide(code1, code2)) { |
| 1345 |
return; |
| 1346 |
} |
| 1347 |
|
| 1348 |
if (!code1) { |
| 1349 |
temp = x1; x1 = x2; x2 = temp; |
| 1350 |
temp = y1; y1 = y2; y2 = temp; |
| 1351 |
code1 = code2; |
| 1352 |
} |
| 1353 |
|
| 1354 |
if (code1 & ClipCodeAbove) { |
| 1355 |
temp = ClipY1; |
| 1356 |
x1 += (int)(((long)(temp - y1) * (x2 - x1)) / (y2 - y1)); |
| 1357 |
y1 = temp; |
| 1358 |
} else if (code1 & ClipCodeBelow) { |
| 1359 |
temp = ClipY2; |
| 1360 |
x1 += (int)(((long)(temp - y1) * (x2 - x1)) / (y2 - y1)); |
| 1361 |
y1 = temp; |
| 1362 |
} else if (code1 & ClipCodeLeft) { |
| 1363 |
temp = ClipX1; |
| 1364 |
y1 += (int)(((long)(temp - x1) * (y2 - y1)) / (x2 - x1)); |
| 1365 |
x1 = temp; |
| 1366 |
} else { /* code1 & ClipCodeRight */ |
| 1367 |
temp = ClipX2; |
| 1368 |
y1 += (int)(((long)(temp - x1) * (y2 - y1)) / (x2 - x1)); |
| 1369 |
x1 = temp; |
| 1370 |
} |
| 1371 |
} |
| 1372 |
|
| 1373 |
// Draw line based on clipped coordinates |
| 1374 |
// FIXME: As the clipped coordinates are rounded to integers, the line's |
| 1375 |
// direction vector might be slightly off. Somehow, the sub-pixel |
| 1376 |
// position(s) on the clipped retangle should be denoted to the line |
| 1377 |
// drawing routine.. |
| 1378 |
Assert(x1 >= ClipX1 && x2 >= ClipX1 && x1 <= ClipX2 && x2 <= ClipX2 && |
| 1379 |
y1 >= ClipY1 && y2 >= ClipY1 && y1 <= ClipY2 && y2 <= ClipY2); |
| 1380 |
DrawLine(color, x1, y1, x2, y2); |
| 1381 |
} |
| 1382 |
|
| 1383 |
/** |
| 1384 |
** Draw a transparent line |
| 1385 |
*/ |
| 1386 |
void DrawTransLine(Uint32 color, int sx, int sy, |
| 1387 |
int dx, int dy, unsigned char alpha) |
| 1388 |
{ |
| 1389 |
// FIXME: trans |
| 1390 |
DrawLine(color, sx, sy, dx, dy); |
| 1391 |
} |
| 1392 |
|
| 1393 |
/** |
| 1394 |
** Draw a transparent line clipped |
| 1395 |
*/ |
| 1396 |
void DrawTransLineClip(Uint32 color, int sx, int sy, |
| 1397 |
int dx, int dy, unsigned char alpha) |
| 1398 |
{ |
| 1399 |
// FIXME: trans |
| 1400 |
DrawLineClip(color, sx, sy, dx, dy); |
| 1401 |
} |
| 1402 |
|
| 1403 |
/** |
| 1404 |
** Draw rectangle. |
| 1405 |
** |
| 1406 |
** @param color color |
| 1407 |
** @param x x coordinate on the screen |
| 1408 |
** @param y y coordinate on the screen |
| 1409 |
** @param h height of rectangle (0=don't draw). |
| 1410 |
** @param w width of rectangle (0=don't draw). |
| 1411 |
*/ |
| 1412 |
void DrawRectangle(Uint32 color, int x, int y, int w, int h) |
| 1413 |
{ |
| 1414 |
GLubyte r, g, b, a; |
| 1415 |
|
| 1416 |
Video.GetRGBA(color, NULL, &r, &g, &b, &a); |
| 1417 |
glDisable(GL_TEXTURE_2D); |
| 1418 |
glColor4ub(r, g, b, a); |
| 1419 |
glBegin(GL_LINES); |
| 1420 |
glVertex2i(x, y); |
| 1421 |
glVertex2i(x + w, y); |
| 1422 |
|
| 1423 |
glVertex2i(x + w - 1, y + 1); |
| 1424 |
glVertex2i(x + w - 1, y + h); |
| 1425 |
|
| 1426 |
glVertex2i(x + w - 1, y + h - 1); |
| 1427 |
glVertex2i(x, y + h - 1); |
| 1428 |
|
| 1429 |
glVertex2i(x, y + h - 1); |
| 1430 |
glVertex2i(x, y + 1); |
| 1431 |
glEnd(); |
| 1432 |
glEnable(GL_TEXTURE_2D); |
| 1433 |
} |
| 1434 |
|
| 1435 |
/** |
| 1436 |
** Draw translucent rectangle. |
| 1437 |
** |
| 1438 |
** @param color color |
| 1439 |
** @param x x coordinate on the screen |
| 1440 |
** @param y y coordinate on the screen |
| 1441 |
** @param h height of rectangle (0=don't draw). |
| 1442 |
** @param w width of rectangle (0=don't draw). |
| 1443 |
** @param alpha alpha value of pixel. |
| 1444 |
*/ |
| 1445 |
void DrawTransRectangle(Uint32 color, int x, int y, |
| 1446 |
int w, int h, unsigned char alpha) |
| 1447 |
{ |
| 1448 |
GLubyte r, g, b; |
| 1449 |
|
| 1450 |
Video.GetRGB(color, NULL, &r, &g, &b); |
| 1451 |
color = Video.MapRGBA(0, r, g, b, alpha); |
| 1452 |
DrawRectangle(color, x, y, w, h); |
| 1453 |
} |
| 1454 |
|
| 1455 |
/** |
| 1456 |
** Draw rectangle clipped. |
| 1457 |
** |
| 1458 |
** @param color color |
| 1459 |
** @param x x coordinate on the screen |
| 1460 |
** @param y y coordinate on the screen |
| 1461 |
** @param h height of rectangle (0=don't draw). |
| 1462 |
** @param w width of rectangle (0=don't draw). |
| 1463 |
*/ |
| 1464 |
void DrawRectangleClip(Uint32 color, int x, int y, |
| 1465 |
int w, int h) |
| 1466 |
{ |
| 1467 |
int f; |
| 1468 |
int left; |
| 1469 |
int right; |
| 1470 |
int top; |
| 1471 |
int bottom; |
| 1472 |
|
| 1473 |
// Ensure non-empty rectangle |
| 1474 |
if (!w || !h) { |
| 1475 |
// rectangle is `void' |
| 1476 |
return; |
| 1477 |
} |
| 1478 |
|
| 1479 |
// Clip rectangle boundary |
| 1480 |
left = right = top = bottom = 1; |
| 1481 |
|
| 1482 |
if (x < ClipX1) { // no left side |
| 1483 |
f = ClipX1 - x; |
| 1484 |
if (w <= f) { |
| 1485 |
return; // entire rectangle left --> not visible |
| 1486 |
} |
| 1487 |
w -= f; |
| 1488 |
x = ClipX1; |
| 1489 |
left = 0; |
| 1490 |
} |
| 1491 |
if ((x + w) > ClipX2 + 1) { // no right side |
| 1492 |
if (x > ClipX2) { |
| 1493 |
return; // entire rectangle right --> not visible |
| 1494 |
} |
| 1495 |
w = ClipX2 - x + 1; |
| 1496 |
right = 0; |
| 1497 |
} |
| 1498 |
if (y < ClipY1) { // no top |
| 1499 |
f = ClipY1 - y; |
| 1500 |
if (h <= f) { |
| 1501 |
return; // entire rectangle above --> not visible |
| 1502 |
} |
| 1503 |
h -= f; |
| 1504 |
y = ClipY1; |
| 1505 |
top = 0; |
| 1506 |
} |
| 1507 |
if ((y + h) > ClipY2 + 1) { // no bottom |
| 1508 |
if (y > ClipY2) { |
| 1509 |
return; // entire rectangle below --> not visible |
| 1510 |
} |
| 1511 |
h = ClipY2 - y + 1; |
| 1512 |
bottom = 0; |
| 1513 |
} |
| 1514 |
|
| 1515 |
// Draw (part of) rectangle sides |
| 1516 |
// Note: _hline and _vline should be able to handle zero width/height |
| 1517 |
if (top) { |
| 1518 |
DrawHLine(color, x, y, w); |
| 1519 |
if (!--h) { |
| 1520 |
return; // rectangle as horizontal line |
| 1521 |
} |
| 1522 |
++y; |
| 1523 |
} |
| 1524 |
if (bottom) { |
| 1525 |
DrawHLine(color, x, y + h - 1, w); |
| 1526 |
--h; |
| 1527 |
} |
| 1528 |
if (left) { |
| 1529 |
DrawVLine(color, x, y, h); |
| 1530 |
if (!--w) { |
| 1531 |
return; // rectangle as vertical line |
| 1532 |
} |
| 1533 |
++x; |
| 1534 |
} |
| 1535 |
if (right) { |
| 1536 |
DrawVLine(color, x + w - 1, y, h); |
| 1537 |
} |
| 1538 |
} |
| 1539 |
|
| 1540 |
/** |
| 1541 |
** Draw translucent rectangle clipped. |
| 1542 |
** |
| 1543 |
** @param color color |
| 1544 |
** @param x x coordinate on the screen |
| 1545 |
** @param y y coordinate on the screen |
| 1546 |
** @param h height of rectangle (0=don't draw). |
| 1547 |
** @param w width of rectangle (0=don't draw). |
| 1548 |
** @param alpha alpha value of pixels. |
| 1549 |
*/ |
| 1550 |
void DrawTransRectangleClip(Uint32 color, int x, int y, |
| 1551 |
int w, int h, unsigned char alpha) |
| 1552 |
{ |
| 1553 |
GLubyte r, g, b; |
| 1554 |
|
| 1555 |
Video.GetRGB(color, NULL, &r, &g, &b); |
| 1556 |
color = Video.MapRGBA(0, r, g, b, alpha); |
| 1557 |
DrawRectangleClip(color, x, y, w, h); |
| 1558 |
} |
| 1559 |
|
| 1560 |
/** |
| 1561 |
** Fill rectangle. |
| 1562 |
** |
| 1563 |
** @param color color |
| 1564 |
** @param x x coordinate on the screen |
| 1565 |
** @param y y coordinate on the screen |
| 1566 |
** @param h height of rectangle (0=don't draw). |
| 1567 |
** @param w width of rectangle (0=don't draw). |
| 1568 |
*/ |
| 1569 |
void FillRectangle(Uint32 color, int x, int y, |
| 1570 |
int w, int h) |
| 1571 |
{ |
| 1572 |
GLubyte r, g, b, a; |
| 1573 |
|
| 1574 |
Video.GetRGBA(color, NULL, &r, &g, &b, &a); |
| 1575 |
glDisable(GL_TEXTURE_2D); |
| 1576 |
glColor4ub(r, g, b, a); |
| 1577 |
glBegin(GL_TRIANGLE_STRIP); |
| 1578 |
glVertex2i(x, y); |
| 1579 |
glVertex2i(x + w, y); |
| 1580 |
glVertex2i(x, y + h); |
| 1581 |
glVertex2i(x + w, y + h); |
| 1582 |
glEnd(); |
| 1583 |
glEnable(GL_TEXTURE_2D); |
| 1584 |
} |
| 1585 |
|
| 1586 |
/** |
| 1587 |
** Draw translucent rectangle. |
| 1588 |
** |
| 1589 |
** @param color color |
| 1590 |
** @param x x coordinate on the screen |
| 1591 |
** @param y y coordinate on the screen |
| 1592 |
** @param h height of rectangle (0=don't draw). |
| 1593 |
** @param w width of rectangle (0=don't draw). |
| 1594 |
** @param alpha alpha value of pixel. |
| 1595 |
*/ |
| 1596 |
void FillTransRectangle(Uint32 color, int x, int y, |
| 1597 |
int w, int h, unsigned char alpha) |
| 1598 |
{ |
| 1599 |
GLubyte r, g, b; |
| 1600 |
|
| 1601 |
Video.GetRGB(color, NULL, &r, &g, &b); |
| 1602 |
color = Video.MapRGBA(0, r, g, b, alpha); |
| 1603 |
FillRectangle(color, x, y, w, h); |
| 1604 |
} |
| 1605 |
|
| 1606 |
/** |
| 1607 |
** Fill rectangle clipped. |
| 1608 |
** |
| 1609 |
** @param color color |
| 1610 |
** @param x x coordinate on the screen |
| 1611 |
** @param y y coordinate on the screen |
| 1612 |
** @param h height of rectangle (0=don't draw). |
| 1613 |
** @param w width of rectangle (0=don't draw). |
| 1614 |
*/ |
| 1615 |
void FillRectangleClip(Uint32 color, int x, int y, |
| 1616 |
int w, int h) |
| 1617 |
{ |
| 1618 |
CLIP_RECTANGLE(x, y, w, h); |
| 1619 |
FillRectangle(color, x, y, w, h); |
| 1620 |
} |
| 1621 |
|
| 1622 |
/** |
| 1623 |
** Fill rectangle translucent clipped. |
| 1624 |
** |
| 1625 |
** @param color color |
| 1626 |
** @param x x coordinate on the screen |
| 1627 |
** @param y y coordinate on the screen |
| 1628 |
** @param h height of rectangle (0=don't draw). |
| 1629 |
** @param w width of rectangle (0=don't draw). |
| 1630 |
** @param alpha alpha value of pixels. |
| 1631 |
*/ |
| 1632 |
void FillTransRectangleClip(Uint32 color, int x, int y, |
| 1633 |
int w, int h, unsigned char alpha) |
| 1634 |
{ |
| 1635 |
GLubyte r, g, b; |
| 1636 |
|
| 1637 |
Video.GetRGB(color, NULL, &r, &g, &b); |
| 1638 |
color = Video.MapRGBA(0, r, g, b, alpha); |
| 1639 |
FillRectangleClip(color, x, y, w, h); |
| 1640 |
} |
| 1641 |
|
| 1642 |
/** |
| 1643 |
** Draw circle. |
| 1644 |
** |
| 1645 |
** @param color color |
| 1646 |
** @param x Center x coordinate on the screen |
| 1647 |
** @param y Center y coordinate on the screen |
| 1648 |
** @param radius radius of circle |
| 1649 |
*/ |
| 1650 |
void DrawCircle(Uint32 color, int x, int y, int radius) |
| 1651 |
{ |
| 1652 |
int cx; |
| 1653 |
int cy; |
| 1654 |
int df; |
| 1655 |
int d_e; |
| 1656 |
int d_se; |
| 1657 |
|
| 1658 |
cx = 0; |
| 1659 |
cy = radius; |
| 1660 |
df = 1 - radius; |
| 1661 |
d_e = 3; |
| 1662 |
d_se = -2 * radius + 5; |
| 1663 |
|
| 1664 |
// FIXME: could be much improved :) |
| 1665 |
do { |
| 1666 |
if (cx == 0) { |
| 1667 |
DrawPixel(color, x, y + cy); |
| 1668 |
DrawPixel(color, x, y - cy); |
| 1669 |
DrawPixel(color, x + cy, y); |
| 1670 |
DrawPixel(color, x - cy, y); |
| 1671 |
} else if (cx == cy) { |
| 1672 |
Assert(cx != 0 && cy != 0); |
| 1673 |
DrawPixel(color, x + cx, y + cy); |
| 1674 |
DrawPixel(color, x - cx, y + cy); |
| 1675 |
DrawPixel(color, x + cx, y - cy); |
| 1676 |
DrawPixel(color, x - cx, y - cy); |
| 1677 |
} else if (cx < cy) { |
| 1678 |
Assert(cx != 0 && cy != 0); |
| 1679 |
DrawPixel(color, x + cx, y + cy); |
| 1680 |
DrawPixel(color, x + cx, y - cy); |
| 1681 |
DrawPixel(color, x + cy, y + cx); |
| 1682 |
DrawPixel(color, x + cy, y - cx); |
| 1683 |
DrawPixel(color, x - cx, y + cy); |
| 1684 |
DrawPixel(color, x - cx, y - cy); |
| 1685 |
DrawPixel(color, x - cy, y + cx); |
| 1686 |
DrawPixel(color, x - cy, y - cx); |
| 1687 |
} |
| 1688 |
if (df < 0) { |
| 1689 |
df += d_e; |
| 1690 |
d_se += 2; |
| 1691 |
} else { |
| 1692 |
df += d_se; |
| 1693 |
d_se += 4; |
| 1694 |
--cy; |
| 1695 |
} |
| 1696 |
d_e += 2; |
| 1697 |
++cx; |
| 1698 |
} while (cx <= cy); |
| 1699 |
} |
| 1700 |
|
| 1701 |
/** |
| 1702 |
** Draw circle clipped. |
| 1703 |
** |
| 1704 |
** @param color color |
| 1705 |
** @param x Center x coordinate on the screen |
| 1706 |
** @param y Center y coordinate on the screen |
| 1707 |
** @param radius radius of circle |
| 1708 |
*/ |
| 1709 |
void DrawCircleClip(Uint32 color, int x, int y, int radius) |
| 1710 |
{ |
| 1711 |
int cx; |
| 1712 |
int cy; |
| 1713 |
int df; |
| 1714 |
int d_e; |
| 1715 |
int d_se; |
| 1716 |
|
| 1717 |
cx = 0; |
| 1718 |
cy = radius; |
| 1719 |
df = 1 - radius; |
| 1720 |
d_e = 3; |
| 1721 |
d_se = -2 * radius + 5; |
| 1722 |
|
| 1723 |
// FIXME: could be much improved :) |
| 1724 |
do { |
| 1725 |
if (cx == 0) { |
| 1726 |
DrawPixelClip(color, x, y + cy); |
| 1727 |
DrawPixelClip(color, x, y - cy); |
| 1728 |
DrawPixelClip(color, x + cy, y); |
| 1729 |
DrawPixelClip(color, x - cy, y); |
| 1730 |
} else if (cx == cy) { |
| 1731 |
Assert(cx != 0 && cy != 0); |
| 1732 |
DrawPixelClip(color, x + cx, y + cy); |
| 1733 |
DrawPixelClip(color, x - cx, y + cy); |
| 1734 |
DrawPixelClip(color, x + cx, y - cy); |
| 1735 |
DrawPixelClip(color, x - cx, y - cy); |
| 1736 |
} else if (cx < cy) { |
| 1737 |
Assert(cx != 0 && cy != 0); |
| 1738 |
DrawPixelClip(color, x + cx, y + cy); |
| 1739 |
DrawPixelClip(color, x + cx, y - cy); |
| 1740 |
DrawPixelClip(color, x + cy, y + cx); |
| 1741 |
DrawPixelClip(color, x + cy, y - cx); |
| 1742 |
DrawPixelClip(color, x - cx, y + cy); |
| 1743 |
DrawPixelClip(color, x - cx, y - cy); |
| 1744 |
DrawPixelClip(color, x - cy, y + cx); |
| 1745 |
DrawPixelClip(color, x - cy, y - cx); |
| 1746 |
} |
| 1747 |
if (df < 0) { |
| 1748 |
df += d_e; |
| 1749 |
d_se += 2; |
| 1750 |
} else { |
| 1751 |
df += d_se; |
| 1752 |
d_se += 4; |
| 1753 |
--cy; |
| 1754 |
} |
| 1755 |
d_e += 2; |
| 1756 |
++cx; |
| 1757 |
} while (cx <= cy); |
| 1758 |
} |
| 1759 |
|
| 1760 |
/** |
| 1761 |
** Draw translucent circle. |
| 1762 |
** |
| 1763 |
** @param color color |
| 1764 |
** @param x Center x coordinate on the screen |
| 1765 |
** @param y Center y coordinate on the screen |
| 1766 |
** @param radius radius of circle |
| 1767 |
** @param alpha alpha value of pixels. |
| 1768 |
*/ |
| 1769 |
void DrawTransCircle(Uint32 color, int x, int y, int radius, |
| 1770 |
unsigned char alpha) |
| 1771 |
{ |
| 1772 |
GLubyte r, g, b; |
| 1773 |
|
| 1774 |
Video.GetRGB(color, NULL, &r, &g, &b); |
| 1775 |
color = Video.MapRGBA(0, r, g, b, alpha); |
| 1776 |
DrawCircle(color, x, y, radius); |
| 1777 |
} |
| 1778 |
|
| 1779 |
/** |
| 1780 |
** Draw translucent circle clipped. |
| 1781 |
** |
| 1782 |
** @param color color |
| 1783 |
** @param x Center x coordinate on the screen |
| 1784 |
** @param y Center y coordinate on the screen |
| 1785 |
** @param radius radius of circle |
| 1786 |
** @param alpha alpha value of pixels. |
| 1787 |
*/ |
| 1788 |
void DrawTransCircleClip(Uint32 color, int x, int y, int radius, |
| 1789 |
unsigned char alpha) |
| 1790 |
{ |
| 1791 |
GLubyte r, g, b; |
| 1792 |
|
| 1793 |
Video.GetRGB(color, NULL, &r, &g, &b); |
| 1794 |
color = Video.MapRGBA(0, r, g, b, alpha); |
| 1795 |
DrawCircleClip(color, x, y, radius); |
| 1796 |
} |
| 1797 |
|
| 1798 |
/** |
| 1799 |
** Fill circle. |
| 1800 |
** |
| 1801 |
** @param color color |
| 1802 |
** @param x Center x coordinate on the screen |
| 1803 |
** @param y Center y coordinate on the screen |
| 1804 |
** @param radius radius of circle |
| 1805 |
*/ |
| 1806 |
void FillCircle(Uint32 color, int x, int y, int radius) |
| 1807 |
{ |
| 1808 |
int p; |
| 1809 |
int px; |
| 1810 |
int py; |
| 1811 |
|
| 1812 |
p = 1 - radius; |
| 1813 |
py = radius; |
| 1814 |
|
| 1815 |
for (px = 0; px <= py; ++px) { |
| 1816 |
// Fill up the middle half of the circle |
| 1817 |
DrawVLine(color, x + px, y, py + 1); |
| 1818 |
DrawVLine(color, x + px, y - py, py); |
| 1819 |
if (px) { |
| 1820 |
DrawVLine(color, x - px, y, py + 1); |
| 1821 |
DrawVLine(color, x - px, y - py, py); |
| 1822 |
} |
| 1823 |
|
| 1824 |
if (p < 0) { |
| 1825 |
p += 2 * px + 3; |
| 1826 |
} else { |
| 1827 |
p += 2 * (px - py) + 5; |
| 1828 |
py -= 1; |
| 1829 |
// Fill up the left/right half of the circle |
| 1830 |
if (py >= px) { |
| 1831 |
DrawVLine(color, x + py + 1, y, px + 1); |
| 1832 |
DrawVLine(color, x + py + 1, y - px, px); |
| 1833 |
DrawVLine(color, x - py - 1, y, px + 1); |
| 1834 |
DrawVLine(color, x - py - 1, y - px, px); |
| 1835 |
} |
| 1836 |
} |
| 1837 |
} |
| 1838 |
} |
| 1839 |
|
| 1840 |
/** |
| 1841 |
** Fill translucent circle clipped. |
| 1842 |
** |
| 1843 |
** @param color color |
| 1844 |
** @param x Center x coordinate on the screen |
| 1845 |
** @param y Center y coordinate on the screen |
| 1846 |
** @param radius radius of circle |
| 1847 |
** @param alpha alpha value of pixels. |
| 1848 |
*/ |
| 1849 |
void FillTransCircle(Uint32 color, int x, int y, |
| 1850 |
int radius, unsigned char alpha) |
| 1851 |
{ |
| 1852 |
GLubyte r, g, b; |
| 1853 |
|
| 1854 |
Video.GetRGB(color, NULL, &r, &g, &b); |
| 1855 |
color = Video.MapRGBA(0, r, g, b, alpha); |
| 1856 |
FillCircle(color, x, y, radius); |
| 1857 |
} |
| 1858 |
|
| 1859 |
/** |
| 1860 |
** Fill circle clipped. |
| 1861 |
** |
| 1862 |
** @param color color |
| 1863 |
** @param x Center x coordinate on the screen |
| 1864 |
** @param y Center y coordinate on the screen |
| 1865 |
** @param radius radius of circle |
| 1866 |
*/ |
| 1867 |
void FillCircleClip(Uint32 color, int x, int y, int radius) |
| 1868 |
{ |
| 1869 |
int cx; |
| 1870 |
int cy; |
| 1871 |
int df; |
| 1872 |
int d_e; |
| 1873 |
int d_se; |
| 1874 |
|
| 1875 |
cx = 0; |
| 1876 |
cy = radius; |
| 1877 |
df = 1 - radius; |
| 1878 |
d_e = 3; |
| 1879 |
d_se = -2 * radius + 5; |
| 1880 |
|
| 1881 |
// FIXME: could be much improved :) |
| 1882 |
do { |
| 1883 |
DrawHLineClip(color, x - cy, y - cx, 1 + cy * 2); |
| 1884 |
if (cx) { |
| 1885 |
DrawHLineClip(color, x - cy, y + cx, 1 + cy * 2); |
| 1886 |
} |
| 1887 |
if (df < 0) { |
| 1888 |
df += d_e; |
| 1889 |
d_se += 2; |
| 1890 |
} else { |
| 1891 |
if (cx != cy) { |
| 1892 |
DrawHLineClip(color, x - cx, y - cy, 1 + cx * 2); |
| 1893 |
DrawHLineClip(color, x - cx, y + cy, 1 + cx * 2); |
| 1894 |
} |
| 1895 |
df += d_se; |
| 1896 |
d_se += 4; |
| 1897 |
--cy; |
| 1898 |
} |
| 1899 |
d_e += 2; |
| 1900 |
++cx; |
| 1901 |
} while (cx <= cy); |
| 1902 |
} |
| 1903 |
|
| 1904 |
/** |
| 1905 |
** Fill translucent circle clipped. |
| 1906 |
** |
| 1907 |
** @param color color |
| 1908 |
** @param x Center x coordinate on the screen |
| 1909 |
** @param y Center y coordinate on the screen |
| 1910 |
** @param radius radius of circle |
| 1911 |
** @param alpha alpha value of pixels. |
| 1912 |
*/ |
| 1913 |
void FillTransCircleClip(Uint32 color, int x, int y, |
| 1914 |
int radius, unsigned char alpha) |
| 1915 |
{ |
| 1916 |
GLubyte r, g, b; |
| 1917 |
|
| 1918 |
Video.GetRGB(color, NULL, &r, &g, &b); |
| 1919 |
color = Video.MapRGBA(0, r, g, b, alpha); |
| 1920 |
FillCircleClip(color, x, y, radius); |
| 1921 |
} |
| 1922 |
|
| 1923 |
/** |
| 1924 |
** Initialize line draw |
| 1925 |
*/ |
| 1926 |
void InitLineDraw(void) |
| 1927 |
{ |
| 1928 |
} |
| 1929 |
|
| 1930 |
} |
| 1931 |
|
| 1932 |
void CVideo::DrawPixelClip(Uint32 color, int x, int y) |
| 1933 |
{ |
| 1934 |
if (UseOpenGL) { |
| 1935 |
linedraw_gl::DrawPixelClip(color, x, y); |
| 1936 |
} else { |
| 1937 |
linedraw_sdl::DrawPixelClip(color, x, y); |
| 1938 |
} |
| 1939 |
} |
| 1940 |
void CVideo::DrawTransPixelClip(Uint32 color, int x, int y, unsigned char alpha) |
| 1941 |
{ |
| 1942 |
if (UseOpenGL) { |
| 1943 |
linedraw_gl::DrawTransPixelClip(color, x, y, alpha); |
| 1944 |
} else { |
| 1945 |
linedraw_sdl::DrawTransPixelClip(color, x, y, alpha); |
| 1946 |
} |
| 1947 |
} |
| 1948 |
|
| 1949 |
void CVideo::DrawVLine(Uint32 color, int x, int y, int height) |
| 1950 |
{ |
| 1951 |
if (UseOpenGL) { |
| 1952 |
linedraw_gl::DrawVLine(color, x, y, height); |
| 1953 |
} else { |
| 1954 |
linedraw_sdl::DrawVLine(color, x, y, height); |
| 1955 |
} |
| 1956 |
} |
| 1957 |
void CVideo::DrawTransVLine(Uint32 color, int x, int y, int height, unsigned char alpha) |
| 1958 |
{ |
| 1959 |
if (UseOpenGL) { |
| 1960 |
linedraw_gl::DrawTransVLine(color, x, y, height, alpha); |
| 1961 |
} else { |
| 1962 |
linedraw_sdl::DrawTransVLine(color, x, y, height, alpha); |
| 1963 |
} |
| 1964 |
} |
| 1965 |
void CVideo::DrawVLineClip(Uint32 color, int x, int y, int height) |
| 1966 |
{ |
| 1967 |
if (UseOpenGL) { |
| 1968 |
linedraw_gl::DrawVLineClip(color, x, y, height); |
| 1969 |
} else { |
| 1970 |
linedraw_sdl::DrawVLineClip(color, x, y, height); |
| 1971 |
} |
| 1972 |
} |
| 1973 |
void CVideo::DrawTransVLineClip(Uint32 color, int x, int y, int height, unsigned char alpha) |
| 1974 |
{ |
| 1975 |
if (UseOpenGL) { |
| 1976 |
linedraw_gl::DrawTransVLineClip(color, x, y, height, alpha); |
| 1977 |
} else { |
| 1978 |
linedraw_sdl::DrawTransVLineClip(color, x, y, height, alpha); |
| 1979 |
} |
| 1980 |
} |
| 1981 |
|
| 1982 |
void CVideo::DrawHLine(Uint32 color, int x, int y, int width) |
| 1983 |
{ |
| 1984 |
if (UseOpenGL) { |
| 1985 |
linedraw_gl::DrawHLine(color, x, y, width); |
| 1986 |
} else { |
| 1987 |
linedraw_sdl::DrawHLine(color, x, y, width); |
| 1988 |
} |
| 1989 |
} |
| 1990 |
void CVideo::DrawTransHLine(Uint32 color, int x, int y, int width, unsigned char alpha) |
| 1991 |
{ |
| 1992 |
if (UseOpenGL) { |
| 1993 |
linedraw_gl::DrawTransHLine(color, x, y, width, alpha); |
| 1994 |
} else { |
| 1995 |
linedraw_sdl::DrawTransHLine(color, x, y, width, alpha); |
| 1996 |
} |
| 1997 |
} |
| 1998 |
void CVideo::DrawHLineClip(Uint32 color, int x, int y, int width) |
| 1999 |
{ |
| 2000 |
if (UseOpenGL) { |
| 2001 |
linedraw_gl::DrawHLineClip(color, x, y, width); |
| 2002 |
} else { |
| 2003 |
linedraw_sdl::DrawHLineClip(color, x, y, width); |
| 2004 |
} |
| 2005 |
} |
| 2006 |
void CVideo::DrawTransHLineClip(Uint32 color, int x, int y, int width, unsigned char alpha) |
| 2007 |
{ |
| 2008 |
if (UseOpenGL) { |
| 2009 |
linedraw_gl::DrawTransHLineClip(color, x, y, width, alpha); |
| 2010 |
} else { |
| 2011 |
linedraw_sdl::DrawTransHLineClip(color, x, y, width, alpha); |
| 2012 |
} |
| 2013 |
} |
| 2014 |
|
| 2015 |
void CVideo::DrawLine(Uint32 color, int sx, int sy, int dx, int dy) |
| 2016 |
{ |
| 2017 |
if (UseOpenGL) { |
| 2018 |
linedraw_gl::DrawLine(color, sx, sy, dx, dy); |
| 2019 |
} else { |
| 2020 |
linedraw_sdl::DrawLine(color, sx, sy, dx, dy); |
| 2021 |
} |
| 2022 |
} |
| 2023 |
void CVideo::DrawTransLine(Uint32 color, int sx, int sy, int dx, int dy, unsigned char alpha) |
| 2024 |
{ |
| 2025 |
if (UseOpenGL) { |
| 2026 |
linedraw_gl::DrawTransLine(color, sx, sy, dx, dy, alpha); |
| 2027 |
} else { |
| 2028 |
linedraw_sdl::DrawTransLine(color, sx, sy, dx, dy, alpha); |
| 2029 |
} |
| 2030 |
} |
| 2031 |
void CVideo::DrawLineClip(Uint32 color, int sx, int sy, int dx, int dy) |
| 2032 |
{ |
| 2033 |
if (UseOpenGL) { |
| 2034 |
linedraw_gl::DrawLineClip(color, sx, sy, dx, dy); |
| 2035 |
} else { |
| 2036 |
linedraw_sdl::DrawLineClip(color, sx, sy, dx, dy); |
| 2037 |
} |
| 2038 |
} |
| 2039 |
void CVideo::DrawTransLineClip(Uint32 color, int sx, int sy, int dx, int dy, unsigned char alpha) |
| 2040 |
{ |
| 2041 |
if (UseOpenGL) { |
| 2042 |
linedraw_gl::DrawTransLineClip(color, sx, sy, dx, dy, alpha); |
| 2043 |
} else { |
| 2044 |
linedraw_sdl::DrawTransLineClip(color, sx, sy, dx, dy, alpha); |
| 2045 |
} |
| 2046 |
} |
| 2047 |
|
| 2048 |
void CVideo::DrawRectangle(Uint32 color, int x, int y, int w, int h) |
| 2049 |
{ |
| 2050 |
if (UseOpenGL) { |
| 2051 |
linedraw_gl::DrawRectangle(color, x, y, w, h); |
| 2052 |
} else { |
| 2053 |
linedraw_sdl::DrawRectangle(color, x, y, w, h); |
| 2054 |
} |
| 2055 |
} |
| 2056 |
void CVideo::DrawTransRectangle(Uint32 color, int x, int y, int w, int h, unsigned char alpha) |
| 2057 |
{ |
| 2058 |
if (UseOpenGL) { |
| 2059 |
linedraw_gl::DrawTransRectangle(color, x, y, w, h, alpha); |
| 2060 |
} else { |
| 2061 |
linedraw_sdl::DrawTransRectangle(color, x, y, w, h, alpha); |
| 2062 |
} |
| 2063 |
} |
| 2064 |
void CVideo::DrawRectangleClip(Uint32 color, int x, int y, int w, int h) |
| 2065 |
{ |
| 2066 |
if (UseOpenGL) { |
| 2067 |
linedraw_gl::DrawRectangleClip(color, x, y, w, h); |
| 2068 |
} else { |
| 2069 |
linedraw_sdl::DrawRectangleClip(color, x, y, w, h); |
| 2070 |
} |
| 2071 |
} |
| 2072 |
void CVideo::DrawTransRectangleClip(Uint32 color, int x, int y, int w, int h, unsigned char alpha) |
| 2073 |
{ |
| 2074 |
if (UseOpenGL) { |
| 2075 |
linedraw_gl::DrawTransRectangleClip(color, x, y, w, h, alpha); |
| 2076 |
} else { |
| 2077 |
linedraw_sdl::DrawTransRectangleClip(color, x, y, w, h, alpha); |
| 2078 |
} |
| 2079 |
} |
| 2080 |
|
| 2081 |
void CVideo::FillRectangle(Uint32 color, int x, int y, int w, int h) |
| 2082 |
{ |
| 2083 |
if (UseOpenGL) { |
| 2084 |
linedraw_gl::FillRectangle(color, x, y, w, h); |
| 2085 |
} else { |
| 2086 |
linedraw_sdl::FillRectangle(color, x, y, w, h); |
| 2087 |
} |
| 2088 |
} |
| 2089 |
void CVideo::FillTransRectangle(Uint32 color, int x, int y, int w, int h, unsigned char alpha) |
| 2090 |
{ |
| 2091 |
if (UseOpenGL) { |
| 2092 |
linedraw_gl::FillTransRectangle(color, x, y, w, h, alpha); |
| 2093 |
} else { |
| 2094 |
linedraw_sdl::FillTransRectangle(color, x, y, w, h, alpha); |
| 2095 |
} |
| 2096 |
} |
| 2097 |
void CVideo::FillRectangleClip(Uint32 color, int x, int y, int w, int h) |
| 2098 |
{ |
| 2099 |
if (UseOpenGL) { |
| 2100 |
linedraw_gl::FillRectangleClip(color, x, y, w, h); |
| 2101 |
} else { |
| 2102 |
linedraw_sdl::FillRectangleClip(color, x, y, w, h); |
| 2103 |
} |
| 2104 |
} |
| 2105 |
void CVideo::FillTransRectangleClip(Uint32 color, int x, int y, int w, int h, unsigned char alpha) |
| 2106 |
{ |
| 2107 |
if (UseOpenGL) { |
| 2108 |
linedraw_gl::FillTransRectangleClip(color, x, y, w, h, alpha); |
| 2109 |
} else { |
| 2110 |
linedraw_sdl::FillTransRectangleClip(color, x, y, w, h, alpha); |
| 2111 |
} |
| 2112 |
} |
| 2113 |
|
| 2114 |
void CVideo::DrawCircle(Uint32 color, int x, int y, int r) |
| 2115 |
{ |
| 2116 |
if (UseOpenGL) { |
| 2117 |
linedraw_gl::DrawCircle(color, x, y, r); |
| 2118 |
} else { |
| 2119 |
linedraw_sdl::DrawCircle(color, x, y, r); |
| 2120 |
} |
| 2121 |
} |
| 2122 |
void CVideo::DrawTransCircle(Uint32 color, int x, int y, int r, unsigned char alpha) |
| 2123 |
{ |
| 2124 |
if (UseOpenGL) { |
| 2125 |
linedraw_gl::DrawTransCircle(color, x, y, r, alpha); |
| 2126 |
} else { |
| 2127 |
linedraw_sdl::DrawTransCircle(color, x, y, r, alpha); |
| 2128 |
} |
| 2129 |
} |
| 2130 |
void CVideo::DrawCircleClip(Uint32 color, int x, int y, int r) |
| 2131 |
{ |
| 2132 |
if (UseOpenGL) { |
| 2133 |
linedraw_gl::DrawCircleClip(color, x, y, r); |
| 2134 |
} else { |
| 2135 |
linedraw_sdl::DrawCircleClip(color, x, y, r); |
| 2136 |
} |
| 2137 |
} |
| 2138 |
void CVideo::DrawTransCircleClip(Uint32 color, int x, int y, int r, unsigned char alpha) |
| 2139 |
{ |
| 2140 |
if (UseOpenGL) { |
| 2141 |
linedraw_gl::DrawTransCircleClip(color, x, y, r, alpha); |
| 2142 |
} else { |
| 2143 |
linedraw_sdl::DrawTransCircleClip(color, x, y, r, alpha); |
| 2144 |
} |
| 2145 |
} |
| 2146 |
|
| 2147 |
void CVideo::FillCircle(Uint32 color, int x, int y, int r) |
| 2148 |
{ |
| 2149 |
if (UseOpenGL) { |
| 2150 |
linedraw_gl::FillCircle(color, x, y, r); |
| 2151 |
} else { |
| 2152 |
linedraw_sdl::FillCircle(color, x, y, r); |
| 2153 |
} |
| 2154 |
} |
| 2155 |
void CVideo::FillTransCircle(Uint32 color, int x, int y, int r, unsigned char alpha) |
| 2156 |
{ |
| 2157 |
if (UseOpenGL) { |
| 2158 |
linedraw_gl::FillTransCircle(color, x, y, r, alpha); |
| 2159 |
} else { |
| 2160 |
linedraw_sdl::FillTransCircle(color, x, y, r, alpha); |
| 2161 |
} |
| 2162 |
} |
| 2163 |
void CVideo::FillCircleClip(Uint32 color, int x, int y, int r) |
| 2164 |
{ |
| 2165 |
if (UseOpenGL) { |
| 2166 |
linedraw_gl::FillCircleClip(color, x, y, r); |
| 2167 |
} else { |
| 2168 |
linedraw_sdl::FillCircleClip(color, x, y, r); |
| 2169 |
} |
| 2170 |
} |
| 2171 |
void CVideo::FillTransCircleClip(Uint32 color, int x, int y, int r, unsigned char alpha) |
| 2172 |
{ |
| 2173 |
if (UseOpenGL) { |
| 2174 |
linedraw_gl::FillTransCircleClip(color, x, y, r, alpha); |
| 2175 |
} else { |
| 2176 |
linedraw_sdl::FillTransCircleClip(color, x, y, r, alpha); |
| 2177 |
} |
| 2178 |
} |
| 2179 |
|
| 2180 |
void InitLineDraw(void) |
| 2181 |
{ |
| 2182 |
if (UseOpenGL) { |
| 2183 |
linedraw_gl::InitLineDraw(); |
| 2184 |
} else { |
| 2185 |
linedraw_sdl::InitLineDraw(); |
| 2186 |
} |
| 2187 |
} |
| 2188 |
|
| 2189 |
//@} |