Mercurial > hg > dmlib
annotate tools/libgutil.c @ 2294:7f6ba3b32f54
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 03 Jul 2019 10:28:43 +0300 |
parents | ef08af6887b7 |
children | 6d12670e0248 |
rev | line source |
---|---|
1327
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 * Common graphics utility functions for tools |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 * Programmed and designed by Matti 'ccr' Hamalainen |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
4 * (C) Copyright 2012-2015 Tecnic Software productions (TNSP) |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 * |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 * Please read file 'COPYING' for information on license and distribution. |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 */ |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 #include "libgutil.h" |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 void dmFillRect(SDL_Surface *screen, int x0, int y0, int x1, int y1, Uint32 col) |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 { |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 SDL_Rect rc; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 rc.x = x0; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 rc.y = y0; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 rc.w = x1 - x0 + 1; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 rc.h = y1 - y0 + 1; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 SDL_FillRect(screen, &rc, col); |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 } |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 void dmDrawHLine(SDL_Surface *screen, int x0, int x1, int yc, const Uint32 col) |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 { |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
24 const int bpp = screen->format->BytesPerPixel, |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
25 cx0 = screen->clip_rect.x, cy0 = screen->clip_rect.y, |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
26 cx1 = screen->clip_rect.x + screen->clip_rect.w - 1, |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
27 cy1 = screen->clip_rect.y + screen->clip_rect.h - 1; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
29 DM_SWAP(int, x0, x1); |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 if (yc < cy0|| yc > cy1 || x1 < cx0 || x0 > cx1) return; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 if (x0 < cx0) x0 = cx0; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 if (x1 > cx1) x1 = cx1; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 int x = x1 - x0 + 1; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
35 Uint8 *pix = ((Uint8 *) screen->pixels) + yc * screen->pitch + (x0 * bpp); |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
36 switch (screen->format->BitsPerPixel) |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
37 { |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 case 8: |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 while (x--) |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
40 *pix++ = col; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 break; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
43 case 32: |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
44 { |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
45 Uint32 *p = (Uint32 *) pix; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
46 while (x--) |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
47 *p++ = col; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
48 } |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
49 break; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 } |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
51 } |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 void dmDrawVLine(SDL_Surface *screen, int y0, int y1, int xc, const Uint32 col) |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 { |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 const int bpp = screen->format->BytesPerPixel, |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
57 pitch = screen->pitch / bpp, |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 cx0 = screen->clip_rect.x, cy0 = screen->clip_rect.y, |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 cx1 = screen->clip_rect.x + screen->clip_rect.w - 1, |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
60 cy1 = screen->clip_rect.y + screen->clip_rect.h - 1; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
61 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
62 DM_SWAP(int, y0, y1); |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
63 if (xc < cx0 || xc > cx1 || y1 < cy0 || y0 > cy1) return; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
64 if (y0 < cy0) y0 = cy0; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
65 if (y1 > cy1) y1 = cy1; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
67 int y = y1 - y0 + 1; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 Uint8 *pix = ((Uint8 *) screen->pixels) + y0 * screen->pitch + (xc * bpp); |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
69 switch (screen->format->BitsPerPixel) |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 { |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
71 case 8: |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 while (y--) |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
73 { |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
74 *pix = col; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
75 pix += pitch; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
76 } |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
77 break; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
78 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
79 case 32: |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
80 { |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
81 Uint32 *p = (Uint32 *) pix; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
82 while (y--) |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
83 { |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
84 *p = col; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
85 p += pitch; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 } |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
87 } |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
88 break; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
89 } |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
90 } |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
91 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
92 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
93 void dmDrawBox3D(SDL_Surface *screen, int x0, int y0, int x1, int y1, Uint32 ucol, Uint32 dcol) |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
94 { |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
95 dmDrawHLine(screen, x0 , x1 - 1, y0, ucol); |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
96 dmDrawHLine(screen, x0 + 1, x1 , y1, dcol); |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
97 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
98 dmDrawVLine(screen, y0 , y1 - 1, x0, ucol); |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
99 dmDrawVLine(screen, y0 + 1, y1 , x1, dcol); |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
100 } |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
101 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
102 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
103 void dmFillBox3D(SDL_Surface *screen, int x0, int y0, int x1, int y1, Uint32 bgcol, Uint32 ucol, Uint32 dcol) |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
104 { |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
105 SDL_Rect rc; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
106 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
107 rc.x = x0 + 1; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
108 rc.y = y0 + 1; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
109 rc.w = x1 - x0 - 1; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
110 rc.h = y1 - y0 - 1; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
111 SDL_FillRect(screen, &rc, bgcol); |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
112 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
113 dmDrawBox3D(screen, x0, y0, x1, y1, ucol, dcol); |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
114 } |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
115 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
116 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
117 void dmDrawBMTextConstQ(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt) |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
118 { |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
119 const char *ptr = fmt; |
1957
ef08af6887b7
Revamp the bitmap font system to use single SDL_Surface for the font
Matti Hamalainen <ccr@tnsp.org>
parents:
1327
diff
changeset
|
120 DMUnscaledBlitFunc blit = dmGetUnscaledBlitFunc(font->glyphs->format, screen->format, mode); |
ef08af6887b7
Revamp the bitmap font system to use single SDL_Surface for the font
Matti Hamalainen <ccr@tnsp.org>
parents:
1327
diff
changeset
|
121 Uint8 *orig = font->glyphs->pixels; |
ef08af6887b7
Revamp the bitmap font system to use single SDL_Surface for the font
Matti Hamalainen <ccr@tnsp.org>
parents:
1327
diff
changeset
|
122 SDL_Surface surf; |
ef08af6887b7
Revamp the bitmap font system to use single SDL_Surface for the font
Matti Hamalainen <ccr@tnsp.org>
parents:
1327
diff
changeset
|
123 |
ef08af6887b7
Revamp the bitmap font system to use single SDL_Surface for the font
Matti Hamalainen <ccr@tnsp.org>
parents:
1327
diff
changeset
|
124 memcpy(&surf, font->glyphs, sizeof(SDL_Surface)); |
1327
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
125 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
126 while (*ptr) |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
127 { |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
128 int ch = toupper(*ptr++); |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
129 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
130 if (ch == '_') |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
131 { |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
132 xc += 4; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
133 continue; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
134 } |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
135 |
1957
ef08af6887b7
Revamp the bitmap font system to use single SDL_Surface for the font
Matti Hamalainen <ccr@tnsp.org>
parents:
1327
diff
changeset
|
136 if (ch < font->maxglyph && ch != ' ') |
1327
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
137 { |
1957
ef08af6887b7
Revamp the bitmap font system to use single SDL_Surface for the font
Matti Hamalainen <ccr@tnsp.org>
parents:
1327
diff
changeset
|
138 DMBitmapGlyph *glyph = &font->glyphMap[ch]; |
1327
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
139 |
1957
ef08af6887b7
Revamp the bitmap font system to use single SDL_Surface for the font
Matti Hamalainen <ccr@tnsp.org>
parents:
1327
diff
changeset
|
140 if (glyph->index >= 0) |
ef08af6887b7
Revamp the bitmap font system to use single SDL_Surface for the font
Matti Hamalainen <ccr@tnsp.org>
parents:
1327
diff
changeset
|
141 { |
ef08af6887b7
Revamp the bitmap font system to use single SDL_Surface for the font
Matti Hamalainen <ccr@tnsp.org>
parents:
1327
diff
changeset
|
142 surf.pixels = orig + glyph->index * font->gsize; |
ef08af6887b7
Revamp the bitmap font system to use single SDL_Surface for the font
Matti Hamalainen <ccr@tnsp.org>
parents:
1327
diff
changeset
|
143 surf.w = glyph->width; |
ef08af6887b7
Revamp the bitmap font system to use single SDL_Surface for the font
Matti Hamalainen <ccr@tnsp.org>
parents:
1327
diff
changeset
|
144 surf.h = glyph->height; |
ef08af6887b7
Revamp the bitmap font system to use single SDL_Surface for the font
Matti Hamalainen <ccr@tnsp.org>
parents:
1327
diff
changeset
|
145 |
ef08af6887b7
Revamp the bitmap font system to use single SDL_Surface for the font
Matti Hamalainen <ccr@tnsp.org>
parents:
1327
diff
changeset
|
146 blit(&surf, xc, yc, screen); |
ef08af6887b7
Revamp the bitmap font system to use single SDL_Surface for the font
Matti Hamalainen <ccr@tnsp.org>
parents:
1327
diff
changeset
|
147 } |
1327
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
148 } |
1957
ef08af6887b7
Revamp the bitmap font system to use single SDL_Surface for the font
Matti Hamalainen <ccr@tnsp.org>
parents:
1327
diff
changeset
|
149 xc += font->width; |
1327
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
150 } |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
151 } |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
152 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
153 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
154 void dmDrawBMTextVAQ(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt, va_list ap) |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
155 { |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
156 char tmp[512]; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
157 vsnprintf(tmp, sizeof(tmp), fmt, ap); |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
158 dmDrawBMTextConstQ(screen, font, mode, xc, yc, tmp); |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
159 } |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
160 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
161 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
162 void dmDrawBMTextQ(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt, ...) |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
163 { |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
164 va_list ap; |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
165 |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
166 va_start(ap, fmt); |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
167 dmDrawBMTextVAQ(screen, font, mode, xc, yc, fmt, ap); |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
168 va_end(ap); |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
169 } |