00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00031
00032
00033
00034
00035
00036 #include <stdio.h>
00037 #include <stdlib.h>
00038 #include <string.h>
00039
00040 #include "stratagus.h"
00041 #include "video.h"
00042
00043 #include "intern_video.h"
00044
00045
00046
00047
00048
00049
00054 #define ClipCodeInside 0
00055 #define ClipCodeAbove 1
00056 #define ClipCodeBelow 2
00057 #define ClipCodeLeft 4
00058 #define ClipCodeRight 8
00059
00060
00061 namespace linedraw_sdl {
00062
00063 void (*VideoDrawPixel)(Uint32 color, int x, int y);
00064 static void (*VideoDoDrawPixel)(Uint32 color, int x, int y);
00065 void (*VideoDrawTransPixel)(Uint32 color, int x, int y, unsigned char alpha);
00066 static void (*VideoDoDrawTransPixel)(Uint32 color, int x, int y, unsigned char alpha);
00067
00071 static void VideoDoDrawPixel16(Uint32 color, int x, int y)
00072 {
00073 ((Uint16 *)TheScreen->pixels)[x + y * Video.Width] = color;
00074 }
00075
00079 void VideoDrawPixel16(Uint32 color, int x, int y)
00080 {
00081 Video.LockScreen();
00082 VideoDoDrawPixel16(color, x, y);
00083 Video.UnlockScreen();
00084 }
00085
00089 static void VideoDoDrawPixel32(Uint32 color, int x, int y)
00090 {
00091 ((Uint32 *)TheScreen->pixels)[x + y * Video.Width] = color;
00092 }
00093
00097 void VideoDrawPixel32(Uint32 color, int x, int y)
00098 {
00099 Video.LockScreen();
00100 VideoDoDrawPixel32(color, x, y);
00101 Video.UnlockScreen();
00102 }
00103
00107 static void VideoDoDrawTransPixel16(Uint32 color, int x, int y, unsigned char alpha)
00108 {
00109 Uint16 *p;
00110 unsigned long dp;
00111
00112
00113 alpha = (255 - alpha) >> 3;
00114
00115 p = &((Uint16 *)TheScreen->pixels)[x + y * Video.Width];
00116 color = (((color << 16) | color) & 0x07E0F81F);
00117 dp = *p;
00118 dp = ((dp << 16) | dp) & 0x07E0F81F;
00119 dp = ((((dp - color) * alpha) >> 5) + color) & 0x07E0F81F;
00120 *p = (Uint16)((dp >> 16) | dp);
00121 }
00122
00126 void VideoDrawTransPixel16(Uint32 color, int x, int y, unsigned char alpha)
00127 {
00128 Video.LockScreen();
00129 VideoDoDrawTransPixel16(color, x, y, alpha);
00130 Video.UnlockScreen();
00131 }
00132
00136 static void VideoDoDrawTransPixel32(Uint32 color, int x, int y, unsigned char alpha)
00137 {
00138 unsigned long sp2;
00139 unsigned long dp1;
00140 unsigned long dp2;
00141 Uint32 *p;
00142
00143 alpha = 255 - alpha;
00144
00145 p = &((Uint32*)TheScreen->pixels)[x + y * Video.Width];
00146
00147 sp2 = (color & 0xFF00FF00) >> 8;
00148 color &= 0x00FF00FF;
00149
00150 dp1 = *p;
00151 dp2 = (dp1 & 0xFF00FF00) >> 8;
00152 dp1 &= 0x00FF00FF;
00153
00154 dp1 = ((((dp1 - color) * alpha) >> 8) + color) & 0x00FF00FF;
00155 dp2 = ((((dp2 - sp2) * alpha) >> 8) + sp2) & 0x00FF00FF;
00156 *p = (dp1 | (dp2 << 8));
00157 }
00158
00162 void VideoDrawTransPixel32(Uint32 color, int x, int y, unsigned char alpha)
00163 {
00164 Video.LockScreen();
00165 VideoDoDrawTransPixel32(color, x, y, alpha);
00166 Video.UnlockScreen();
00167 }
00168
00172 static void VideoDoDrawPixelClip(Uint32 color, int x, int y)
00173 {
00174 if (x >= ClipX1 && y >= ClipY1 && x <= ClipX2 && y <= ClipY2) {
00175 VideoDoDrawPixel(color, x, y);
00176 }
00177 }
00178
00182 void DrawPixelClip(Uint32 color, int x, int y)
00183 {
00184 Video.LockScreen();
00185 VideoDoDrawPixelClip(color, x, y);
00186 Video.UnlockScreen();
00187 }
00188
00192 static void VideoDoDrawTransPixelClip(Uint32 color, int x, int y, unsigned char alpha)
00193 {
00194 if (x >= ClipX1 && y >= ClipY1 && x <= ClipX2 && y <= ClipY2) {
00195 VideoDoDrawTransPixel(color, x, y, alpha);
00196 }
00197 }
00198
00202 void DrawTransPixelClip(Uint32 color, int x, int y, unsigned char alpha)
00203 {
00204 Video.LockScreen();
00205 VideoDoDrawTransPixelClip(color, x, y, alpha);
00206 Video.UnlockScreen();
00207 }
00208
00212 void DrawVLine(Uint32 color, int x, int y, int height)
00213 {
00214 Video.LockScreen();
00215 for (int i = 0; i < height; ++i) {
00216 VideoDoDrawPixel(color, x, y + i);
00217 }
00218 Video.UnlockScreen();
00219 }
00220
00224 void DrawTransVLine(Uint32 color, int x, int y,
00225 int height, unsigned char alpha)
00226 {
00227 Video.LockScreen();
00228 for (int i = 0; i < height; ++i) {
00229 VideoDoDrawTransPixel(color, x, y + i, alpha);
00230 }
00231 Video.UnlockScreen();
00232 }
00233
00237 void DrawVLineClip(Uint32 color, int x, int y, int height)
00238 {
00239 int w = 1;
00240 CLIP_RECTANGLE(x, y, w, height);
00241 DrawVLine(color, x, y, height);
00242 }
00243
00247 void DrawTransVLineClip(Uint32 color, int x, int y,
00248 int height, unsigned char alpha)
00249 {
00250 Video.LockScreen();
00251 for (int i = 0; i < height; ++i) {
00252 VideoDoDrawTransPixelClip(color, x, y + i, alpha);
00253 }
00254 Video.UnlockScreen();
00255 }
00256
00260 void DrawHLine(Uint32 color, int x, int y, int width)
00261 {
00262 Video.LockScreen();
00263 for (int i = 0; i < width; ++i) {
00264 VideoDoDrawPixel(color, x + i, y);
00265 }
00266 Video.UnlockScreen();
00267 }
00268
00272 void DrawHLineClip(Uint32 color, int x, int y, int width)
00273 {
00274 int h = 1;
00275 CLIP_RECTANGLE(x, y, width, h);
00276 DrawHLine(color, x, y, width);
00277 }
00278
00282 void DrawTransHLine(Uint32 color, int x, int y,
00283 int width, unsigned char alpha)
00284 {
00285 Video.LockScreen();
00286 for (int i = 0; i < width; ++i) {
00287 VideoDoDrawTransPixel(color, x + i, y, alpha);
00288 }
00289 Video.UnlockScreen();
00290 }
00291
00295 void DrawTransHLineClip(Uint32 color, int x, int y,
00296 int width, unsigned char alpha)
00297 {
00298 Video.LockScreen();
00299 for (int i = 0; i < width; ++i) {
00300 VideoDoDrawTransPixelClip(color, x + i, y, alpha);
00301 }
00302 Video.UnlockScreen();
00303 }
00304
00308 void DrawLine(Uint32 color, int sx, int sy, int dx, int dy)
00309 {
00310 int x;
00311 int y;
00312 int xlen;
00313 int ylen;
00314 int incr;
00315
00316 if (sx == dx) {
00317 if (sy < dy) {
00318 DrawVLine(color, sx, sy, dy - sy + 1);
00319 } else {
00320 DrawVLine(color, dx, dy, sy - dy + 1);
00321 }
00322 return;
00323 }
00324
00325 if (sy == dy) {
00326 if (sx < dx) {
00327 DrawHLine(color, sx, sy, dx - sx + 1);
00328 } else {
00329 DrawHLine(color, dx, dy, sx - dx + 1);
00330 }
00331 return;
00332 }
00333
00334
00335 if (sy > dy) {
00336 int t;
00337 t = dx;
00338 dx = sx;
00339 sx = t;
00340 t = dy;
00341 dy = sy;
00342 sy = t;
00343 }
00344 ylen = dy - sy;
00345
00346 if (sx > dx) {
00347 xlen = sx - dx;
00348 incr = -1;
00349 } else {
00350 xlen = dx - sx;
00351 incr = 1;
00352 }
00353
00354 y = sy;
00355 x = sx;
00356
00357 if (xlen > ylen) {
00358 int p;
00359
00360 if (sx > dx) {
00361 int t;
00362 t = sx;
00363 sx = dx;
00364 dx = t;
00365 y = dy;
00366 }
00367
00368 p = (ylen << 1) - xlen;
00369
00370 Video.LockScreen();
00371 for (x = sx; x < dx; ++x) {
00372 VideoDoDrawPixel(color, x, y);
00373 if (p >= 0) {
00374 y += incr;
00375 p += (ylen - xlen) << 1;
00376 } else {
00377 p += (ylen << 1);
00378 }
00379 }
00380 Video.UnlockScreen();
00381 return;
00382 }
00383
00384 if (ylen > xlen) {
00385 int p;
00386
00387 p = (xlen << 1) - ylen;
00388
00389 Video.LockScreen();
00390 for (y = sy; y < dy; ++y) {
00391 VideoDoDrawPixel(color, x, y);
00392 if (p >= 0) {
00393 x += incr;
00394 p += (xlen - ylen) << 1;
00395 } else {
00396 p += (xlen << 1);
00397 }
00398 }
00399 Video.UnlockScreen();
00400 return;
00401 }
00402
00403
00404 if (ylen == xlen) {
00405 Video.LockScreen();
00406 while (y != dy) {
00407 VideoDoDrawPixel(color, x, y);
00408 x += incr;
00409 ++y;
00410 }
00411 Video.UnlockScreen();
00412 }
00413 }
00414
00418 void DrawLineClip(Uint32 color, int sx, int sy, int dx, int dy)
00419 {
00420 int x;
00421 int y;
00422 int xlen;
00423 int ylen;
00424 int incr;
00425
00426 if (sx == dx) {
00427 if (sy < dy) {
00428 DrawVLineClip(color, sx, sy, dy - sy + 1);
00429 } else {
00430 DrawVLineClip(color, dx, dy, sy - dy + 1);
00431 }
00432 return;
00433 }
00434
00435 if (sy == dy) {
00436 if (sx < dx) {
00437 DrawHLineClip(color, sx, sy, dx - sx + 1);
00438 } else {
00439 DrawHLineClip(color, dx, dy, sx - dx + 1);
00440 }
00441 return;
00442 }
00443
00444
00445 if (sy > dy) {
00446 int t;
00447 t = dx;
00448 dx = sx;
00449 sx = t;
00450 t = dy;
00451 dy = sy;
00452 sy = t;
00453 }
00454 ylen = dy - sy;
00455
00456 if (sx > dx) {
00457 xlen = sx - dx;
00458 incr = -1;
00459 } else {
00460 xlen = dx - sx;
00461 incr = 1;
00462 }
00463
00464 y = sy;
00465 x = sx;
00466
00467 if (xlen > ylen) {
00468 int p;
00469
00470 if (sx > dx) {
00471 int t;
00472 t = sx;
00473 sx = dx;
00474 dx = t;
00475 y = dy;
00476 }
00477
00478 p = (ylen << 1) - xlen;
00479
00480 Video.LockScreen();
00481 for (x = sx; x < dx; ++x) {
00482 VideoDoDrawPixelClip(color, x, y);
00483 if (p >= 0) {
00484 y += incr;
00485 p += (ylen - xlen) << 1;
00486 } else {
00487 p += (ylen << 1);
00488 }
00489 }
00490 Video.UnlockScreen();
00491 return;
00492 }
00493
00494 if (ylen > xlen) {
00495 int p;
00496
00497 p = (xlen << 1) - ylen;
00498
00499 Video.LockScreen();
00500 for (y = sy; y < dy; ++y) {
00501 VideoDoDrawPixelClip(color, x, y);
00502 if (p >= 0) {
00503 x += incr;
00504 p += (xlen - ylen) << 1;
00505 } else {
00506 p += (xlen << 1);
00507 }
00508 }
00509 Video.UnlockScreen();
00510 return;
00511 }
00512
00513
00514 if (ylen == xlen) {
00515 Video.LockScreen();
00516 while (y != dy) {
00517 VideoDoDrawPixelClip(color, x, y);
00518 x += incr;
00519 ++y;
00520 }
00521 Video.UnlockScreen();
00522 }
00523 }
00524
00528 void DrawTransLine(Uint32 color, int sx, int sy,
00529 int dx, int dy, unsigned char alpha)
00530 {
00531
00532 DrawLine(color, sx, sy, dx, dy);
00533 }
00534
00538 void DrawTransLineClip(Uint32 color, int sx, int sy,
00539 int dx, int dy, unsigned char alpha)
00540 {
00541
00542 DrawLineClip(color, sx, sy, dx, dy);
00543 }
00544
00548 void DrawRectangle(Uint32 color, int x, int y, int w, int h)
00549 {
00550 DrawHLine(color, x, y, w);
00551 DrawHLine(color, x, y + h - 1, w);
00552
00553 DrawVLine(color, x, y + 1, h - 2);
00554 DrawVLine(color, x + w - 1, y + 1, h - 2);
00555 }
00556
00560 void DrawRectangleClip(Uint32 color, int x, int y, int w, int h)
00561 {
00562 DrawHLineClip(color, x, y, w);
00563 DrawHLineClip(color, x, y + h - 1, w);
00564
00565 DrawVLineClip(color, x, y + 1, h - 2);
00566 DrawVLineClip(color, x + w - 1, y + 1, h - 2);
00567 }
00568
00572 void DrawTransRectangle(Uint32 color, int x, int y,
00573 int w, int h, unsigned char alpha)
00574 {
00575 DrawTransHLine(color, x, y, w, alpha);
00576 DrawTransHLine(color, x, y + h - 1, w, alpha);
00577
00578 DrawTransVLine(color, x, y + 1, h - 2, alpha);
00579 DrawTransVLine(color, x + w - 1, y + 1, h - 2, alpha);
00580 }
00581
00592 void DrawTransRectangleClip(Uint32 color, int x, int y,
00593 int w, int h, unsigned char alpha)
00594 {
00595 DrawTransHLineClip(color, x, y, w, alpha);
00596 DrawTransHLineClip(color, x, y + h - 1, w, alpha);
00597
00598 DrawTransVLineClip(color, x, y + 1, h - 2, alpha);
00599 DrawTransVLineClip(color, x + w - 1, y + 1, h - 2, alpha);
00600 }
00601
00605 void FillRectangle(Uint32 color, int x, int y, int w, int h)
00606 {
00607 SDL_Rect drect = {x, y, w, h};
00608 SDL_FillRect(TheScreen, &drect, color);
00609 }
00610
00614 void FillRectangleClip(Uint32 color, int x, int y,
00615 int w, int h)
00616 {
00617 SDL_Rect oldrect;
00618 SDL_Rect newrect;
00619
00620 SDL_GetClipRect(TheScreen, &oldrect);
00621 newrect.x = ClipX1;
00622 newrect.y = ClipY1;
00623 newrect.w = ClipX2 + 1 - ClipX1;
00624 newrect.h = ClipY2 + 1 - ClipY1;
00625
00626 SDL_SetClipRect(TheScreen, &newrect);
00627 FillRectangle(color, x, y, w, h);
00628 SDL_SetClipRect(TheScreen, &oldrect);
00629 }
00630
00634 void FillTransRectangle(Uint32 color, int x, int y,
00635 int w, int h, unsigned char alpha)
00636 {
00637 int ex = x + w;
00638 int ey = y + h;
00639 int sx = x;
00640
00641 Video.LockScreen();
00642 for (; y < ey; ++y) {
00643 for (x = sx; x < ex; ++x) {
00644 VideoDoDrawTransPixel(color, x, y, alpha);
00645 }
00646 }
00647 Video.UnlockScreen();
00648 }
00649
00653 void FillTransRectangleClip(Uint32 color, int x, int y,
00654 int w, int h, unsigned char alpha)
00655 {
00656 CLIP_RECTANGLE(x, y, w, h);
00657 FillTransRectangle(color, x, y, w, h, alpha);
00658 }
00659
00663 void DrawCircle(Uint32 color, int x, int y, int r)
00664 {
00665 int p;
00666 int px;
00667 int py;
00668
00669 p = 1 - r;
00670 py = r;
00671
00672 Video.LockScreen();
00673 for (px = 0; px <= py + 1; ++px) {
00674 VideoDoDrawPixel(color, x + px, y + py);
00675 VideoDoDrawPixel(color, x + px, y - py);
00676 VideoDoDrawPixel(color, x - px, y + py);
00677 VideoDoDrawPixel(color, x - px, y - py);
00678
00679 VideoDoDrawPixel(color, x + py, y + px);
00680 VideoDoDrawPixel(color, x + py, y - px);
00681 VideoDoDrawPixel(color, x - py, y + px);
00682 VideoDoDrawPixel(color, x - py, y - px);
00683
00684 if (p < 0) {
00685 p += 2 * px + 3;
00686 } else {
00687 p += 2 * (px - py) + 5;
00688 py -= 1;
00689 }
00690 }
00691 Video.UnlockScreen();
00692 }
00693
00697 void DrawTransCircle(Uint32 color, int x, int y,
00698 int r, unsigned char alpha)
00699 {
00700 int p;
00701 int px;
00702 int py;
00703
00704 p = 1 - r;
00705 py = r;
00706
00707 Video.LockScreen();
00708 for (px = 0; px <= py + 1; ++px) {
00709 VideoDoDrawTransPixel(color, x + px, y + py, alpha);
00710 VideoDoDrawTransPixel(color, x + px, y - py, alpha);
00711 VideoDoDrawTransPixel(color, x - px, y + py, alpha);
00712 VideoDoDrawTransPixel(color, x - px, y - py, alpha);
00713
00714 VideoDoDrawTransPixel(color, x + py, y + px, alpha);
00715 VideoDoDrawTransPixel(color, x + py, y - px, alpha);
00716 VideoDoDrawTransPixel(color, x - py, y + px, alpha);
00717 VideoDoDrawTransPixel(color, x - py, y - px, alpha);
00718
00719 if (p < 0) {
00720 p += 2 * px + 3;
00721 } else {
00722 p += 2 * (px - py) + 5;
00723 py -= 1;
00724 }
00725 }
00726 Video.UnlockScreen();
00727 }
00728
00732 void DrawCircleClip(Uint32 color, int x, int y, int r)
00733 {
00734 int p;
00735 int px;
00736 int py;
00737
00738 p = 1 - r;
00739 py = r;
00740
00741 Video.LockScreen();
00742 for (px = 0; px <= py + 1; ++px) {
00743 VideoDoDrawPixelClip(color, x + px, y + py);
00744 VideoDoDrawPixelClip(color, x + px, y - py);
00745 VideoDoDrawPixelClip(color, x - px, y + py);
00746 VideoDoDrawPixelClip(color, x - px, y - py);
00747
00748 VideoDoDrawPixelClip(color, x + py, y + px);
00749 VideoDoDrawPixelClip(color, x + py, y - px);
00750 VideoDoDrawPixelClip(color, x - py, y + px);
00751 VideoDoDrawPixelClip(color, x - py, y - px);
00752
00753 if (p < 0) {
00754 p += 2 * px + 3;
00755 } else {
00756 p += 2 * (px - py) + 5;
00757 py -= 1;
00758 }
00759 }
00760 Video.UnlockScreen();
00761 }
00762
00766 void DrawTransCircleClip(Uint32 color, int x, int y,
00767 int r, unsigned char alpha)
00768 {
00769 int p;
00770 int px;
00771 int py;
00772
00773 p = 1 - r;
00774 py = r;
00775
00776 Video.LockScreen();
00777 for (px = 0; px <= py + 1; ++px) {
00778 VideoDoDrawTransPixelClip(color, x + px, y + py, alpha);
00779 VideoDoDrawTransPixelClip(color, x + px, y - py, alpha);
00780 VideoDoDrawTransPixelClip(color, x - px, y + py, alpha);
00781 VideoDoDrawTransPixelClip(color, x - px, y - py, alpha);
00782
00783 VideoDoDrawTransPixelClip(color, x + py, y + px, alpha);
00784 VideoDoDrawTransPixelClip(color, x + py, y - px, alpha);
00785 VideoDoDrawTransPixelClip(color, x - py, y + px, alpha);
00786 VideoDoDrawTransPixelClip(color, x - py, y - px, alpha);
00787
00788 if (p < 0) {
00789 p += 2 * px + 3;
00790 } else {
00791 p += 2 * (px - py) + 5;
00792 py -= 1;
00793 }
00794 }
00795 Video.UnlockScreen();
00796 }
00797
00801 void FillCircle(Uint32 color, int x, int y, int r)
00802 {
00803 int p;
00804 int px;
00805 int py;
00806
00807 p = 1 - r;
00808 py = r;
00809
00810 for (px = 0; px <= py; ++px) {
00811
00812
00813 DrawVLine(color, x + px, y, py + 1);
00814 DrawVLine(color, x + px, y - py, py);
00815 if (px) {
00816 DrawVLine(color, x - px, y, py + 1);
00817 DrawVLine(color, x - px, y - py, py);
00818 }
00819
00820 if (p < 0) {
00821 p += 2 * px + 3;
00822 } else {
00823 p += 2 * (px - py) + 5;
00824 py -= 1;
00825
00826 if (py >= px) {
00827 DrawVLine(color, x + py + 1, y, px + 1);
00828 DrawVLine(color, x + py + 1, y - px, px);
00829 DrawVLine(color, x - py - 1, y, px + 1);
00830 DrawVLine(color, x - py - 1, y - px, px);
00831 }
00832 }
00833 }
00834 }
00835
00839 void FillTransCircle(Uint32 color, int x, int y,
00840 int r, unsigned char alpha)
00841 {
00842 int p;
00843 int px;
00844 int py;
00845
00846 p = 1 - r;
00847 py = r;
00848
00849 for (px = 0; px <= py; ++px) {
00850
00851
00852 DrawTransVLine(color, x + px, y, py + 1, alpha);
00853 DrawTransVLine(color, x + px, y - py, py, alpha);
00854 if (px) {
00855 DrawTransVLine(color, x - px, y, py + 1, alpha);
00856 DrawTransVLine(color, x - px, y - py, py, alpha);
00857 }
00858
00859 if (p < 0) {
00860 p += 2 * px + 3;
00861 } else {
00862 p += 2 * (px - py) + 5;
00863 py -= 1;
00864
00865 if (py >= px) {
00866 DrawTransVLine(color, x + py + 1, y, px + 1, alpha);
00867 DrawTransVLine(color, x + py + 1, y - px, px, alpha);
00868 DrawTransVLine(color, x - py - 1, y, px + 1, alpha);
00869 DrawTransVLine(color, x - py - 1, y - px, px, alpha);
00870 }
00871 }
00872 }
00873 }
00874
00878 void FillCircleClip(Uint32 color, int x, int y, int r)
00879 {
00880 int p;
00881 int px;
00882 int py;
00883
00884 p = 1 - r;
00885 py = r;
00886
00887 for (px = 0; px <= py; ++px) {
00888
00889
00890 DrawVLineClip(color, x + px, y, py + 1);
00891 DrawVLineClip(color, x + px, y - py, py);
00892 if (px) {
00893 DrawVLineClip(color, x - px, y, py + 1);
00894 DrawVLineClip(color, x - px, y - py, py);
00895 }
00896
00897 if (p < 0) {
00898 p += 2 * px + 3;
00899 } else {
00900 p += 2 * (px - py) + 5;
00901 py -= 1;
00902
00903 if (py >= px) {
00904 DrawVLineClip(color, x + py + 1, y, px + 1);
00905 DrawVLineClip(color, x + py + 1, y - px, px);
00906 DrawVLineClip(color, x - py - 1, y, px + 1);
00907 DrawVLineClip(color, x - py - 1, y - px, px);
00908 }
00909 }
00910 }
00911 }
00912
00916 void FillTransCircleClip(Uint32 color, int x, int y,
00917 int r, unsigned char alpha)
00918 {
00919 int p;
00920 int px;
00921 int py;
00922
00923 p = 1 - r;
00924 py = r;
00925
00926 for (px = 0; px <= py; ++px) {
00927
00928
00929 DrawTransVLineClip(color, x + px, y, py + 1, alpha);
00930 DrawTransVLineClip(color, x + px, y - py, py, alpha);
00931 if (px) {
00932 DrawTransVLineClip(color, x - px, y, py + 1, alpha);
00933 DrawTransVLineClip(color, x - px, y - py, py, alpha);
00934 }
00935
00936 if (p < 0) {
00937 p += 2 * px + 3;
00938 } else {
00939 p += 2 * (px - py) + 5;
00940 py -= 1;
00941
00942 if (py >= px) {
00943 DrawTransVLineClip(color, x + py + 1, y, px + 1, alpha);
00944 DrawTransVLineClip(color, x + py + 1, y - px, px, alpha);
00945 DrawTransVLineClip(color, x - py - 1, y, px + 1, alpha);
00946 DrawTransVLineClip(color, x - py - 1, y - px, px, alpha);
00947 }
00948 }
00949 }
00950 }
00951
00955 void InitLineDraw(void)
00956 {
00957 switch (Video.Depth) {
00958 case 16:
00959 VideoDrawPixel = VideoDrawPixel16;
00960 VideoDoDrawPixel = VideoDoDrawPixel16;
00961 VideoDrawTransPixel = VideoDrawTransPixel16;
00962 VideoDoDrawTransPixel = VideoDoDrawTransPixel16;
00963 break;
00964 case 32:
00965 VideoDrawPixel = VideoDrawPixel32;
00966 VideoDoDrawPixel = VideoDoDrawPixel32;
00967 VideoDrawTransPixel = VideoDrawTransPixel32;
00968 VideoDoDrawTransPixel = VideoDoDrawTransPixel32;
00969 }
00970 }
00971
00972 }
00973 namespace linedraw_gl {
00974
00982 void DrawPixel(Uint32 color, int x, int y)
00983 {
00984 GLubyte r, g, b, a;
00985
00986 Video.GetRGBA(color, NULL, &r, &g, &b, &a);
00987 glDisable(GL_TEXTURE_2D);
00988 glColor4ub(r, g, b, a);
00989 glBegin(GL_POINTS);
00990 glVertex2i(x, y);
00991 glEnd();
00992 glEnable(GL_TEXTURE_2D);
00993 }
00994
01003 void DrawTransPixel(Uint32 color, int x, int y,
01004 unsigned char alpha)
01005 {
01006 GLubyte r, g, b;
01007
01008 Video.GetRGB(color, NULL, &r, &g, &b);
01009 color = Video.MapRGBA(0, r, g, b, alpha);
01010 DrawPixel(color, x, y);
01011 }
01012
01020 void DrawPixelClip(Uint32 color, int x, int y)
01021 {
01022 if (x < ClipX1 || x > ClipX2 || y < ClipY1 || y > ClipY2) {
01023 return;
01024 }
01025 DrawPixel(color, x, y);
01026 }
01027
01036 void DrawTransPixelClip(Uint32 color, int x, int y,
01037 unsigned char alpha)
01038 {
01039 GLubyte r, g, b;
01040
01041 Video.GetRGB(color, NULL, &r, &g, &b);
01042 color = Video.MapRGBA(0, r, g, b, alpha);
01043 DrawPixelClip(color, x, y);
01044 }
01045
01054 void DrawHLine(Uint32 color, int x, int y, int width)
01055 {
01056 GLubyte r, g, b, a;
01057
01058 Video.GetRGBA(color, NULL, &r, &g, &b, &a);
01059 glDisable(GL_TEXTURE_2D);
01060 glColor4ub(r, g, b, a);
01061 glBegin(GL_LINES);
01062 glVertex2i(x, y);
01063 glVertex2i(x + width, y);
01064 glEnd();
01065 glEnable(GL_TEXTURE_2D);
01066 }
01067
01077 void DrawTransHLine(Uint32 color, int x, int y, int width,
01078 unsigned char alpha)
01079 {
01080 GLubyte r, g, b;
01081
01082 Video.GetRGB(color, NULL, &r, &g, &b);
01083 color = Video.MapRGBA(0, r, g, b, alpha);
01084 DrawHLine(color, x, y, width);
01085 }
01086
01095 void DrawHLineClip(Uint32 color, int x, int y, int width)
01096 {
01097 if (y < ClipY1 || y > ClipY2) {
01098 return;
01099 }
01100 if (x < ClipX1) {
01101 int f = ClipX1 - x;
01102 if (width <= f) {
01103 return;
01104 }
01105 width -= f;
01106 x = ClipX1;
01107 }
01108 if ((x + width) > ClipX2 + 1) {
01109 if (x > ClipX2) {
01110 return;
01111 }
01112 width = ClipX2 - x + 1;
01113 }
01114 DrawHLine(color, x, y, width);
01115 }
01116
01126 void DrawTransHLineClip(Uint32 color, int x, int y, int width,
01127 unsigned char alpha)
01128 {
01129 GLubyte r, g, b;
01130
01131 Video.GetRGB(color, NULL, &r, &g, &b);
01132 color = Video.MapRGBA(0, r, g, b, alpha);
01133 DrawHLineClip(color, x, y, width);
01134 }
01135
01144 void DrawVLine(Uint32 color, int x, int y, int height)
01145 {
01146 GLubyte r, g, b, a;
01147
01148 Video.GetRGBA(color, NULL, &r, &g, &b, &a);
01149 glDisable(GL_TEXTURE_2D);
01150 glColor4ub(r, g, b, a);
01151 glBegin(GL_LINES);
01152 glVertex2i(x, y);
01153 glVertex2i(x, y + height);
01154 glEnd();
01155 glEnable(GL_TEXTURE_2D);
01156 }
01157
01167 void DrawTransVLine(Uint32 color, int x, int y, int height,
01168 unsigned char alpha)
01169 {
01170 GLubyte r, g, b;
01171
01172 Video.GetRGB(color, NULL, &r, &g, &b);
01173 color = Video.MapRGBA(0, r, g, b, alpha);
01174 DrawVLine(color, x, y, height);
01175 }
01176
01185 void DrawVLineClip(Uint32 color, int x, int y, int height)
01186 {
01187 if (x < ClipX1 || x > ClipX2) {
01188 return;
01189 }
01190 if (y < ClipY1) {
01191 int f = ClipY1 - y;
01192 if (height <= f) {
01193 return;
01194 }
01195 height -= f;
01196 y = ClipY1;
01197 }
01198 if ((y + height) > ClipY2 + 1) {
01199 if (y > ClipY2) {
01200 return;
01201 }
01202 height = ClipY2 - y + 1;
01203 }
01204 DrawVLine(color, x, y, height);
01205 }
01206
01216 void DrawTransVLineClip(Uint32 color, int x, int y,
01217 int height, unsigned char alpha)
01218 {
01219 GLubyte r, g, b;
01220
01221 Video.GetRGB(color, NULL, &r, &g, &b);
01222 color = Video.MapRGBA(0, r, g, b, alpha);
01223 DrawVLineClip(color, x, y, height);
01224 }
01225
01235 void DrawLine(Uint32 color, int x1, int y1, int x2, int y2)
01236 {
01237 float xx1, yy1, xx2, yy2;
01238 GLubyte r, g, b, a;
01239
01240 xx1 = (float)x1;
01241 xx2 = (float)x2;
01242 yy1 = (float)y1;
01243 yy2 = (float)y2;
01244
01245 if (xx1 <= xx2) {
01246 xx2 += 0.5f;
01247 } else {
01248 xx1 += 0.5f;
01249 }
01250 if (yy1 <= yy2) {
01251 yy2 += 0.5f;
01252 } else {
01253 yy1 += 0.5f;
01254 }
01255
01256 Video.GetRGBA(color, NULL, &r, &g, &b, &a);
01257 glDisable(GL_TEXTURE_2D);
01258 glColor4ub(r, g, b, a);
01259 glBegin(GL_LINES);
01260 glVertex2f(xx1, yy1);
01261 glVertex2f(xx2, yy2);
01262 glEnd();
01263 glEnable(GL_TEXTURE_2D);
01264 }
01265
01273 static int ClipCodeLine(int x, int y)
01274 {
01275 int result;
01276
01277 if (y < ClipY1) {
01278 result = ClipCodeAbove;
01279 } else if (y > ClipY2) {
01280 result = ClipCodeBelow;
01281 } else {
01282 result = ClipCodeInside;
01283 }
01284
01285 if (x < ClipX1) {
01286 result |= ClipCodeLeft;
01287 } else if (x > ClipX2) {
01288 result |= ClipCodeRight;
01289 }
01290
01291 return result;
01292 }
01293
01301 static int LineIsUnclippedOnSameSide(int code1, int code2)
01302 {
01303 return code1 & code2;
01304 }
01305
01313 static int LineIsUnclipped(int code1, int code2)
01314 {
01315 return code1 | code2;
01316 }
01317
01330 void DrawLineClip(Uint32 color, int x1, int y1, int x2, int y2)
01331 {
01332 int code1;
01333 int code2;
01334 int temp;
01335
01336
01337 while (code1 = ClipCodeLine(x1, y1), code2 = ClipCodeLine(x2, y2),
01338 LineIsUnclipped(code1, code2)) {
01339 if (LineIsUnclippedOnSameSide(code1, code2)) {
01340 return;
01341 }
01342
01343 if (!code1) {
01344 temp = x1; x1 = x2; x2 = temp;
01345 temp = y1; y1 = y2; y2 = temp;
01346 code1 = code2;
01347 }
01348
01349 if (code1 & ClipCodeAbove) {
01350 temp = ClipY1;
01351 x1 += (int)(((long)(temp - y1) * (x2 - x1)) / (y2 - y1));
01352 y1 = temp;
01353 } else if (code1 & ClipCodeBelow) {
01354 temp = ClipY2;
01355 x1 += (int)(((long)(temp - y1) * (x2 - x1)) / (y2 - y1));
01356 y1 = temp;
01357 } else if (code1 & ClipCodeLeft) {
01358 temp = ClipX1;
01359 y1 += (int)(((long)(temp - x1) * (y2 - y1)) / (x2 - x1));
01360 x1 = temp;
01361 } else {
01362 temp = ClipX2;
01363 y1 += (int)(((long)(temp - x1) * (y2 - y1)) / (x2 - x1));
01364 x1 = temp;
01365 }
01366 }
01367
01368
01369
01370
01371
01372
01373 Assert(x1 >= ClipX1 && x2 >= ClipX1 && x1 <= ClipX2 && x2 <= ClipX2 &&
01374 y1 >= ClipY1 && y2 >= ClipY1 && y1 <= ClipY2 && y2 <= ClipY2);
01375 DrawLine(color, x1, y1, x2, y2);
01376 }
01377
01381 void DrawTransLine(Uint32 color, int sx, int sy,
01382 int dx, int dy, unsigned char alpha)
01383 {
01384
01385 DrawLine(color, sx, sy, dx, dy);
01386 }
01387
01391 void DrawTransLineClip(Uint32 color, int sx, int sy,
01392 int dx, int dy, unsigned char alpha)
01393 {
01394
01395 DrawLineClip(color, sx, sy, dx, dy);
01396 }
01397
01407 void DrawRectangle(Uint32 color, int x, int y, int w, int h)
01408 {
01409 GLubyte r, g, b, a;
01410
01411 Video.GetRGBA(color, NULL, &r, &g, &b, &a);
01412 glDisable(GL_TEXTURE_2D);
01413 glColor4ub(r, g, b, a);
01414 glBegin(GL_LINES);
01415 glVertex2i(x, y);
01416 glVertex2i(x + w, y);
01417
01418 glVertex2i(x + w - 1, y + 1);
01419 glVertex2i(x + w - 1, y + h);
01420
01421 glVertex2i(x + w - 1, y + h - 1);
01422 glVertex2i(x, y + h - 1);
01423
01424 glVertex2i(x, y + h - 1);
01425 glVertex2i(x, y + 1);
01426 glEnd();
01427 glEnable(GL_TEXTURE_2D);
01428 }
01429
01440 void DrawTransRectangle(Uint32 color, int x, int y,
01441 int w, int h, unsigned char alpha)
01442 {
01443 GLubyte r, g, b;
01444
01445 Video.GetRGB(color, NULL, &r, &g, &b);
01446 color = Video.MapRGBA(0, r, g, b, alpha);
01447 DrawRectangle(color, x, y, w, h);
01448 }
01449
01459 void DrawRectangleClip(Uint32 color, int x, int y,
01460 int w, int h)
01461 {
01462 int f;
01463 int left;
01464 int right;
01465 int top;
01466 int bottom;
01467
01468
01469 if (!w || !h) {
01470
01471 return;
01472 }
01473
01474
01475 left = right = top = bottom = 1;
01476
01477 if (x < ClipX1) {
01478 f = ClipX1 - x;
01479 if (w <= f) {
01480 return;
01481 }
01482 w -= f;
01483 x = ClipX1;
01484 left = 0;
01485 }
01486 if ((x + w) > ClipX2 + 1) {
01487 if (x > ClipX2) {
01488 return;
01489 }
01490 w = ClipX2 - x + 1;
01491 right = 0;
01492 }
01493 if (y < ClipY1) {
01494 f = ClipY1 - y;
01495 if (h <= f) {
01496 return;
01497 }
01498 h -= f;
01499 y = ClipY1;
01500 top = 0;
01501 }
01502 if ((y + h) > ClipY2 + 1) {
01503 if (y > ClipY2) {
01504 return;
01505 }
01506 h = ClipY2 - y + 1;
01507 bottom = 0;
01508 }
01509
01510
01511
01512 if (top) {
01513 DrawHLine(color, x, y, w);
01514 if (!--h) {
01515 return;
01516 }
01517 ++y;
01518 }
01519 if (bottom) {
01520 DrawHLine(color, x, y + h - 1, w);
01521 --h;
01522 }
01523 if (left) {
01524 DrawVLine(color, x, y, h);
01525 if (!--w) {
01526 return;
01527 }
01528 ++x;
01529 }
01530 if (right) {
01531 DrawVLine(color, x + w - 1, y, h);
01532 }
01533 }
01534
01545 void DrawTransRectangleClip(Uint32 color, int x, int y,
01546 int w, int h, unsigned char alpha)
01547 {
01548 GLubyte r, g, b;
01549
01550 Video.GetRGB(color, NULL, &r, &g, &b);
01551 color = Video.MapRGBA(0, r, g, b, alpha);
01552 DrawRectangleClip(color, x, y, w, h);
01553 }
01554
01564 void FillRectangle(Uint32 color, int x, int y,
01565 int w, int h)
01566 {
01567 GLubyte r, g, b, a;
01568
01569 Video.GetRGBA(color, NULL, &r, &g, &b, &a);
01570 glDisable(GL_TEXTURE_2D);
01571 glColor4ub(r, g, b, a);
01572 glBegin(GL_TRIANGLE_STRIP);
01573 glVertex2i(x, y);
01574 glVertex2i(x + w, y);
01575 glVertex2i(x, y + h);
01576 glVertex2i(x + w, y + h);
01577 glEnd();
01578 glEnable(GL_TEXTURE_2D);
01579 }
01580
01591 void FillTransRectangle(Uint32 color, int x, int y,
01592 int w, int h, unsigned char alpha)
01593 {
01594 GLubyte r, g, b;
01595
01596 Video.GetRGB(color, NULL, &r, &g, &b);
01597 color = Video.MapRGBA(0, r, g, b, alpha);
01598 FillRectangle(color, x, y, w, h);
01599 }
01600
01610 void FillRectangleClip(Uint32 color, int x, int y,
01611 int w, int h)
01612 {
01613 CLIP_RECTANGLE(x, y, w, h);
01614 FillRectangle(color, x, y, w, h);
01615 }
01616
01627 void FillTransRectangleClip(Uint32 color, int x, int y,
01628 int w, int h, unsigned char alpha)
01629 {
01630 GLubyte r, g, b;
01631
01632 Video.GetRGB(color, NULL, &r, &g, &b);
01633 color = Video.MapRGBA(0, r, g, b, alpha);
01634 FillRectangleClip(color, x, y, w, h);
01635 }
01636
01645 void DrawCircle(Uint32 color, int x, int y, int radius)
01646 {
01647 int cx;
01648 int cy;
01649 int df;
01650 int d_e;
01651 int d_se;
01652
01653 cx = 0;
01654 cy = radius;
01655 df = 1 - radius;
01656 d_e = 3;
01657 d_se = -2 * radius + 5;
01658
01659
01660 do {
01661 if (cx == 0) {
01662 DrawPixel(color, x, y + cy);
01663 DrawPixel(color, x, y - cy);
01664 DrawPixel(color, x + cy, y);
01665 DrawPixel(color, x - cy, y);
01666 } else if (cx == cy) {
01667 Assert(cx != 0 && cy != 0);
01668 DrawPixel(color, x + cx, y + cy);
01669 DrawPixel(color, x - cx, y + cy);
01670 DrawPixel(color, x + cx, y - cy);
01671 DrawPixel(color, x - cx, y - cy);
01672 } else if (cx < cy) {
01673 Assert(cx != 0 && cy != 0);
01674 DrawPixel(color, x + cx, y + cy);
01675 DrawPixel(color, x + cx, y - cy);
01676 DrawPixel(color, x + cy, y + cx);
01677 DrawPixel(color, x + cy, y - cx);
01678 DrawPixel(color, x - cx, y + cy);
01679 DrawPixel(color, x - cx, y - cy);
01680 DrawPixel(color, x - cy, y + cx);
01681 DrawPixel(color, x - cy, y - cx);
01682 }
01683 if (df < 0) {
01684 df += d_e;
01685 d_se += 2;
01686 } else {
01687 df += d_se;
01688 d_se += 4;
01689 --cy;
01690 }
01691 d_e += 2;
01692 ++cx;
01693 } while (cx <= cy);
01694 }
01695
01704 void DrawCircleClip(Uint32 color, int x, int y, int radius)
01705 {
01706 int cx;
01707 int cy;
01708 int df;
01709 int d_e;
01710 int d_se;
01711
01712 cx = 0;
01713 cy = radius;
01714 df = 1 - radius;
01715 d_e = 3;
01716 d_se = -2 * radius + 5;
01717
01718
01719 do {
01720 if (cx == 0) {
01721 DrawPixelClip(color, x, y + cy);
01722 DrawPixelClip(color, x, y - cy);
01723 DrawPixelClip(color, x + cy, y);
01724 DrawPixelClip(color, x - cy, y);
01725 } else if (cx == cy) {
01726 Assert(cx != 0 && cy != 0);
01727 DrawPixelClip(color, x + cx, y + cy);
01728 DrawPixelClip(color, x - cx, y + cy);
01729 DrawPixelClip(color, x + cx, y - cy);
01730 DrawPixelClip(color, x - cx, y - cy);
01731 } else if (cx < cy) {
01732 Assert(cx != 0 && cy != 0);
01733 DrawPixelClip(color, x + cx, y + cy);
01734 DrawPixelClip(color, x + cx, y - cy);
01735 DrawPixelClip(color, x + cy, y + cx);
01736 DrawPixelClip(color, x + cy, y - cx);
01737 DrawPixelClip(color, x - cx, y + cy);
01738 DrawPixelClip(color, x - cx, y - cy);
01739 DrawPixelClip(color, x - cy, y + cx);
01740 DrawPixelClip(color, x - cy, y - cx);
01741 }
01742 if (df < 0) {
01743 df += d_e;
01744 d_se += 2;
01745 } else {
01746 df += d_se;
01747 d_se += 4;
01748 --cy;
01749 }
01750 d_e += 2;
01751 ++cx;
01752 } while (cx <= cy);
01753 }
01754
01764 void DrawTransCircle(Uint32 color, int x, int y, int radius,
01765 unsigned char alpha)
01766 {
01767 GLubyte r, g, b;
01768
01769 Video.GetRGB(color, NULL, &r, &g, &b);
01770 color = Video.MapRGBA(0, r, g, b, alpha);
01771 DrawCircle(color, x, y, radius);
01772 }
01773
01783 void DrawTransCircleClip(Uint32 color, int x, int y, int radius,
01784 unsigned char alpha)
01785 {
01786 GLubyte r, g, b;
01787
01788 Video.GetRGB(color, NULL, &r, &g, &b);
01789 color = Video.MapRGBA(0, r, g, b, alpha);
01790 DrawCircleClip(color, x, y, radius);
01791 }
01792
01801 void FillCircle(Uint32 color, int x, int y, int radius)
01802 {
01803 int p;
01804 int px;
01805 int py;
01806
01807 p = 1 - radius;
01808 py = radius;
01809
01810 for (px = 0; px <= py; ++px) {
01811
01812 DrawVLine(color, x + px, y, py + 1);
01813 DrawVLine(color, x + px, y - py, py);
01814 if (px) {
01815 DrawVLine(color, x - px, y, py + 1);
01816 DrawVLine(color, x - px, y - py, py);
01817 }
01818
01819 if (p < 0) {
01820 p += 2 * px + 3;
01821 } else {
01822 p += 2 * (px - py) + 5;
01823 py -= 1;
01824
01825 if (py >= px) {
01826 DrawVLine(color, x + py + 1, y, px + 1);
01827 DrawVLine(color, x + py + 1, y - px, px);
01828 DrawVLine(color, x - py - 1, y, px + 1);
01829 DrawVLine(color, x - py - 1, y - px, px);
01830 }
01831 }
01832 }
01833 }
01834
01844 void FillTransCircle(Uint32 color, int x, int y,
01845 int radius, unsigned char alpha)
01846 {
01847 GLubyte r, g, b;
01848
01849 Video.GetRGB(color, NULL, &r, &g, &b);
01850 color = Video.MapRGBA(0, r, g, b, alpha);
01851 FillCircle(color, x, y, radius);
01852 }
01853
01862 void FillCircleClip(Uint32 color, int x, int y, int radius)
01863 {
01864 int cx;
01865 int cy;
01866 int df;
01867 int d_e;
01868 int d_se;
01869
01870 cx = 0;
01871 cy = radius;
01872 df = 1 - radius;
01873 d_e = 3;
01874 d_se = -2 * radius + 5;
01875
01876
01877 do {
01878 DrawHLineClip(color, x - cy, y - cx, 1 + cy * 2);
01879 if (cx) {
01880 DrawHLineClip(color, x - cy, y + cx, 1 + cy * 2);
01881 }
01882 if (df < 0) {
01883 df += d_e;
01884 d_se += 2;
01885 } else {
01886 if (cx != cy) {
01887 DrawHLineClip(color, x - cx, y - cy, 1 + cx * 2);
01888 DrawHLineClip(color, x - cx, y + cy, 1 + cx * 2);
01889 }
01890 df += d_se;
01891 d_se += 4;
01892 --cy;
01893 }
01894 d_e += 2;
01895 ++cx;
01896 } while (cx <= cy);
01897 }
01898
01908 void FillTransCircleClip(Uint32 color, int x, int y,
01909 int radius, unsigned char alpha)
01910 {
01911 GLubyte r, g, b;
01912
01913 Video.GetRGB(color, NULL, &r, &g, &b);
01914 color = Video.MapRGBA(0, r, g, b, alpha);
01915 FillCircleClip(color, x, y, radius);
01916 }
01917
01921 void InitLineDraw(void)
01922 {
01923 }
01924
01925 }
01926
01927 void CVideo::DrawPixelClip(Uint32 color, int x, int y)
01928 {
01929 if (UseOpenGL) {
01930 linedraw_gl::DrawPixelClip(color, x, y);
01931 } else {
01932 linedraw_sdl::DrawPixelClip(color, x, y);
01933 }
01934 }
01935 void CVideo::DrawTransPixelClip(Uint32 color, int x, int y, unsigned char alpha)
01936 {
01937 if (UseOpenGL) {
01938 linedraw_gl::DrawTransPixelClip(color, x, y, alpha);
01939 } else {
01940 linedraw_sdl::DrawTransPixelClip(color, x, y, alpha);
01941 }
01942 }
01943
01944 void CVideo::DrawVLine(Uint32 color, int x, int y, int height)
01945 {
01946 if (UseOpenGL) {
01947 linedraw_gl::DrawVLine(color, x, y, height);
01948 } else {
01949 linedraw_sdl::DrawVLine(color, x, y, height);
01950 }
01951 }
01952 void CVideo::DrawTransVLine(Uint32 color, int x, int y, int height, unsigned char alpha)
01953 {
01954 if (UseOpenGL) {
01955 linedraw_gl::DrawTransVLine(color, x, y, height, alpha);
01956 } else {
01957 linedraw_sdl::DrawTransVLine(color, x, y, height, alpha);
01958 }
01959 }
01960 void CVideo::DrawVLineClip(Uint32 color, int x, int y, int height)
01961 {
01962 if (UseOpenGL) {
01963 linedraw_gl::DrawVLineClip(color, x, y, height);
01964 } else {
01965 linedraw_sdl::DrawVLineClip(color, x, y, height);
01966 }
01967 }
01968 void CVideo::DrawTransVLineClip(Uint32 color, int x, int y, int height, unsigned char alpha)
01969 {
01970 if (UseOpenGL) {
01971 linedraw_gl::DrawTransVLineClip(color, x, y, height, alpha);
01972 } else {
01973 linedraw_sdl::DrawTransVLineClip(color, x, y, height, alpha);
01974 }
01975 }
01976
01977 void CVideo::DrawHLine(Uint32 color, int x, int y, int width)
01978 {
01979 if (UseOpenGL) {
01980 linedraw_gl::DrawHLine(color, x, y, width);
01981 } else {
01982 linedraw_sdl::DrawHLine(color, x, y, width);
01983 }
01984 }
01985 void CVideo::DrawTransHLine(Uint32 color, int x, int y, int width, unsigned char alpha)
01986 {
01987 if (UseOpenGL) {
01988 linedraw_gl::DrawTransHLine(color, x, y, width, alpha);
01989 } else {
01990 linedraw_sdl::DrawTransHLine(color, x, y, width, alpha);
01991 }
01992 }
01993 void CVideo::DrawHLineClip(Uint32 color, int x, int y, int width)
01994 {
01995 if (UseOpenGL) {
01996 linedraw_gl::DrawHLineClip(color, x, y, width);
01997 } else {
01998 linedraw_sdl::DrawHLineClip(color, x, y, width);
01999 }
02000 }
02001 void CVideo::DrawTransHLineClip(Uint32 color, int x, int y, int width, unsigned char alpha)
02002 {
02003 if (UseOpenGL) {
02004 linedraw_gl::DrawTransHLineClip(color, x, y, width, alpha);
02005 } else {
02006 linedraw_sdl::DrawTransHLineClip(color, x, y, width, alpha);
02007 }
02008 }
02009
02010 void CVideo::DrawLine(Uint32 color, int sx, int sy, int dx, int dy)
02011 {
02012 if (UseOpenGL) {
02013 linedraw_gl::DrawLine(color, sx, sy, dx, dy);
02014 } else {
02015 linedraw_sdl::DrawLine(color, sx, sy, dx, dy);
02016 }
02017 }
02018 void CVideo::DrawTransLine(Uint32 color, int sx, int sy, int dx, int dy, unsigned char alpha)
02019 {
02020 if (UseOpenGL) {
02021 linedraw_gl::DrawTransLine(color, sx, sy, dx, dy, alpha);
02022 } else {
02023 linedraw_sdl::DrawTransLine(color, sx, sy, dx, dy, alpha);
02024 }
02025 }
02026 void CVideo::DrawLineClip(Uint32 color, int sx, int sy, int dx, int dy)
02027 {
02028 if (UseOpenGL) {
02029 linedraw_gl::DrawLineClip(color, sx, sy, dx, dy);
02030 } else {
02031 linedraw_sdl::DrawLineClip(color, sx, sy, dx, dy);
02032 }
02033 }
02034 void CVideo::DrawTransLineClip(Uint32 color, int sx, int sy, int dx, int dy, unsigned char alpha)
02035 {
02036 if (UseOpenGL) {
02037 linedraw_gl::DrawTransLineClip(color, sx, sy, dx, dy, alpha);
02038 } else {
02039 linedraw_sdl::DrawTransLineClip(color, sx, sy, dx, dy, alpha);
02040 }
02041 }
02042
02043 void CVideo::DrawRectangle(Uint32 color, int x, int y, int w, int h)
02044 {
02045 if (UseOpenGL) {
02046 linedraw_gl::DrawRectangle(color, x, y, w, h);
02047 } else {
02048 linedraw_sdl::DrawRectangle(color, x, y, w, h);
02049 }
02050 }
02051 void CVideo::DrawTransRectangle(Uint32 color, int x, int y, int w, int h, unsigned char alpha)
02052 {
02053 if (UseOpenGL) {
02054 linedraw_gl::DrawTransRectangle(color, x, y, w, h, alpha);
02055 } else {
02056 linedraw_sdl::DrawTransRectangle(color, x, y, w, h, alpha);
02057 }
02058 }
02059 void CVideo::DrawRectangleClip(Uint32 color, int x, int y, int w, int h)
02060 {
02061 if (UseOpenGL) {
02062 linedraw_gl::DrawRectangleClip(color, x, y, w, h);
02063 } else {
02064 linedraw_sdl::DrawRectangleClip(color, x, y, w, h);
02065 }
02066 }
02067 void CVideo::DrawTransRectangleClip(Uint32 color, int x, int y, int w, int h, unsigned char alpha)
02068 {
02069 if (UseOpenGL) {
02070 linedraw_gl::DrawTransRectangleClip(color, x, y, w, h, alpha);
02071 } else {
02072 linedraw_sdl::DrawTransRectangleClip(color, x, y, w, h, alpha);
02073 }
02074 }
02075
02076 void CVideo::FillRectangle(Uint32 color, int x, int y, int w, int h)
02077 {
02078 if (UseOpenGL) {
02079 linedraw_gl::FillRectangle(color, x, y, w, h);
02080 } else {
02081 linedraw_sdl::FillRectangle(color, x, y, w, h);
02082 }
02083 }
02084 void CVideo::FillTransRectangle(Uint32 color, int x, int y, int w, int h, unsigned char alpha)
02085 {
02086 if (UseOpenGL) {
02087 linedraw_gl::FillTransRectangle(color, x, y, w, h, alpha);
02088 } else {
02089 linedraw_sdl::FillTransRectangle(color, x, y, w, h, alpha);
02090 }
02091 }
02092 void CVideo::FillRectangleClip(Uint32 color, int x, int y, int w, int h)
02093 {
02094 if (UseOpenGL) {
02095 linedraw_gl::FillRectangleClip(color, x, y, w, h);
02096 } else {
02097 linedraw_sdl::FillRectangleClip(color, x, y, w, h);
02098 }
02099 }
02100 void CVideo::FillTransRectangleClip(Uint32 color, int x, int y, int w, int h, unsigned char alpha)
02101 {
02102 if (UseOpenGL) {
02103 linedraw_gl::FillTransRectangleClip(color, x, y, w, h, alpha);
02104 } else {
02105 linedraw_sdl::FillTransRectangleClip(color, x, y, w, h, alpha);
02106 }
02107 }
02108
02109 void CVideo::DrawCircle(Uint32 color, int x, int y, int r)
02110 {
02111 if (UseOpenGL) {
02112 linedraw_gl::DrawCircle(color, x, y, r);
02113 } else {
02114 linedraw_sdl::DrawCircle(color, x, y, r);
02115 }
02116 }
02117 void CVideo::DrawTransCircle(Uint32 color, int x, int y, int r, unsigned char alpha)
02118 {
02119 if (UseOpenGL) {
02120 linedraw_gl::DrawTransCircle(color, x, y, r, alpha);
02121 } else {
02122 linedraw_sdl::DrawTransCircle(color, x, y, r, alpha);
02123 }
02124 }
02125 void CVideo::DrawCircleClip(Uint32 color, int x, int y, int r)
02126 {
02127 if (UseOpenGL) {
02128 linedraw_gl::DrawCircleClip(color, x, y, r);
02129 } else {
02130 linedraw_sdl::DrawCircleClip(color, x, y, r);
02131 }
02132 }
02133 void CVideo::DrawTransCircleClip(Uint32 color, int x, int y, int r, unsigned char alpha)
02134 {
02135 if (UseOpenGL) {
02136 linedraw_gl::DrawTransCircleClip(color, x, y, r, alpha);
02137 } else {
02138 linedraw_sdl::DrawTransCircleClip(color, x, y, r, alpha);
02139 }
02140 }
02141
02142 void CVideo::FillCircle(Uint32 color, int x, int y, int r)
02143 {
02144 if (UseOpenGL) {
02145 linedraw_gl::FillCircle(color, x, y, r);
02146 } else {
02147 linedraw_sdl::FillCircle(color, x, y, r);
02148 }
02149 }
02150 void CVideo::FillTransCircle(Uint32 color, int x, int y, int r, unsigned char alpha)
02151 {
02152 if (UseOpenGL) {
02153 linedraw_gl::FillTransCircle(color, x, y, r, alpha);
02154 } else {
02155 linedraw_sdl::FillTransCircle(color, x, y, r, alpha);
02156 }
02157 }
02158 void CVideo::FillCircleClip(Uint32 color, int x, int y, int r)
02159 {
02160 if (UseOpenGL) {
02161 linedraw_gl::FillCircleClip(color, x, y, r);
02162 } else {
02163 linedraw_sdl::FillCircleClip(color, x, y, r);
02164 }
02165 }
02166 void CVideo::FillTransCircleClip(Uint32 color, int x, int y, int r, unsigned char alpha)
02167 {
02168 if (UseOpenGL) {
02169 linedraw_gl::FillTransCircleClip(color, x, y, r, alpha);
02170 } else {
02171 linedraw_sdl::FillTransCircleClip(color, x, y, r, alpha);
02172 }
02173 }
02174
02175 void InitLineDraw(void)
02176 {
02177 if (UseOpenGL) {
02178 linedraw_gl::InitLineDraw();
02179 } else {
02180 linedraw_sdl::InitLineDraw();
02181 }
02182 }
02183