Freeciv-3.2
Loading...
Searching...
No Matches
graphics.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14/***********************************************************************
15 graphics.c - description
16 -------------------
17 begin : Mon Jul 1 2002
18 copyright : (C) 2000 by Michael Speck
19 : (C) 2002 by Rafał Bursig
20 email : Michael Speck <kulkanie@gmx.net>
21 : Rafał Bursig <bursig@poczta.fm>
22***********************************************************************/
23
24#ifdef HAVE_CONFIG_H
25#include <fc_config.h>
26#endif
27
28/* SDL3 */
29#include <SDL3_image/SDL_image.h>
30#include <SDL3_ttf/SDL_ttf.h>
31
32/* utility */
33#include "fcintl.h"
34#include "log.h"
35
36/* client */
37#include "tilespec.h"
38
39/* gui-sdl3 */
40#include "colors.h"
41#include "gui_tilespec.h"
42#include "mapview.h"
43#include "themebackgrounds.h"
44#include "themespec.h"
45
46#include "graphics.h"
47
48/* ------------------------------ */
49
51
53
54static bool render_dirty = TRUE;
55
56/**********************************************************************/
60{
61 struct gui_layer *result;
62
63 result = fc_calloc(1, sizeof(struct gui_layer));
64
65 result->dest_rect = (SDL_Rect){x, y, 0, 0};
66 result->surface = surface;
67
68 return result;
69}
70
71/**********************************************************************/
75{
76 FREESURFACE((*gui_layer)->surface);
78}
79
80/**********************************************************************/
84{
85 int i = 0;
86
87 while ((i < main_data.guis_count) && main_data.guis[i]) {
88 if (main_data.guis[i]->surface == surface) {
89 return main_data.guis[i];
90 }
91 i++;
92 }
93
94 return NULL;
95}
96
97/**********************************************************************/
106{
107 struct gui_layer *gui_layer = NULL;
108 SDL_Surface *buffer;
109
110 buffer = create_surf(width, height);
111 gui_layer = gui_layer_new(0, 0, buffer);
112
113 /* Add to buffers array */
114 if (main_data.guis) {
115 int i;
116
117 /* Find NULL element */
118 for (i = 0; i < main_data.guis_count; i++) {
119 if (!main_data.guis[i]) {
121 return gui_layer;
122 }
123 }
126 main_data.guis_count * sizeof(struct gui_layer *));
128 } else {
129 main_data.guis = fc_calloc(1, sizeof(struct gui_layer *));
132 }
133
134 return gui_layer;
135}
136
137/**********************************************************************/
142{
143 int i;
144
145 for (i = 0; i < main_data.guis_count - 1; i++) {
146 if (main_data.guis[i] && (main_data.guis[i] == gui_layer)) {
148 main_data.guis[i] = main_data.guis[i + 1];
149 main_data.guis[i + 1] = NULL;
150 } else {
151 if (!main_data.guis[i]) {
152 main_data.guis[i] = main_data.guis[i + 1];
153 main_data.guis[i + 1] = NULL;
154 }
155 }
156 }
157
160 }
161}
162
163/**********************************************************************/
168{
169 if (gui_layer) {
172 }
173}
174
175/**********************************************************************/
180{
181 if (gui_layer) {
184 }
185}
186
187/* ============ Freeciv sdl graphics function =========== */
188
189/**********************************************************************/
194 unsigned char alpha_mod)
195{
196 bool ret;
197
198 if (src == NULL || dst == NULL) {
199 return 1;
200 }
201
203
204 ret = SDL_BlitSurface(src, srcrect, dst, dstrect);
205
206 if (!ret) {
207 log_error("SDL_BlitSurface() fails: %s", SDL_GetError());
208
209 return -1;
210 }
211
212 return 0;
213}
214
215/**********************************************************************/
219 unsigned char alpha_mod)
220{
222
224}
225
226/**********************************************************************/
233{
235 prect ? prect->w : psource->w,
236 prect ? prect->h : psource->h);
237
238 if (alphablit(psource, prect, new_surf, NULL, 255) != 0) {
240
241 return NULL;
242 }
243
244 return new_surf;
245}
246
247/**********************************************************************/
258{
259 SDL_Surface *dest = NULL;
260 int row, col;
264 unsigned char src_alpha, mask_alpha;
266 = SDL_GetPixelFormatDetails(src->format);
270
271 dest = copy_surface(src);
272
274
275 lock_surf(src);
277 lock_surf(dest);
278
279 src_pixel = (Uint32 *)src->pixels;
280 dest_pixel = (Uint32 *)dest->pixels;
281
282 for (row = 0; row < src->h; row++) {
283 mask_pixel = (Uint32 *)mask->pixels
284 + mask->w * (row + mask_offset_y)
286
287 for (col = 0; col < src->w; col++) {
288 src_alpha = (*src_pixel & src_details->Amask) >> src_details->Ashift;
289 mask_alpha = (*mask_pixel & mask_details->Amask) >> mask_details->Ashift;
290
291 *dest_pixel = (*src_pixel & ~src_details->Amask)
292 | (((src_alpha * mask_alpha) / 255) << dest_details->Ashift);
293
295 }
296 }
297
298 unlock_surf(dest);
300 unlock_surf(src);
301
302 return dest;
303}
304
305/**********************************************************************/
309{
311
312 if (!fname) {
313 return NULL;
314 }
315
316 if ((buf = IMG_Load(fname)) == NULL) {
317 log_error(_("load_surf: Failed to load graphic file %s!"), fname);
318
319 return NULL;
320 }
321
322 return buf;
323}
324
325/**********************************************************************/
329 int width, int height)
330{
332
333 if (surf == NULL) {
334 log_error(_("Unable to create Sprite (Surface) of size "
335 "%d x %d %d Bits"),
337 return NULL;
338 }
339
340 return surf;
341}
342
343/**********************************************************************/
350
351/**********************************************************************/
358
359/**********************************************************************/
364{
366 SDL_Color color = {255, 255, 255, 128};
367
368 new_surf = create_surf(w, h);
369
370 if (!new_surf) {
371 return NULL;
372 }
373
374 if (!pcolor) {
375 /* pcolor->unused == ALPHA */
376 pcolor = &color;
377 }
378
381 NULL,
382 pcolor->r, pcolor->g, pcolor->b,
383 pcolor->a));
384
385 if (pcolor->a != 255) {
387 }
388
389 return new_surf;
390}
391
392/**********************************************************************/
397{
398 /* SDL_FillSurfaceRect() might change the rectangle, so we create a copy */
399 if (dstrect) {
401
402 return SDL_FillSurfaceRect(surf, &_dstrect,
404 NULL, 0, 0, 0, 0));
405 } else {
406 return SDL_FillSurfaceRect(surf, NULL,
408 NULL, 0, 0, 0, 0));
409 }
410}
411
412/**********************************************************************/
424
425/**********************************************************************/
431{
432 if (!surf) {
433 return 0x0;
434 }
435
436 switch (SDL_GetPixelFormatDetails(surf->format)->bytes_per_pixel) {
437 case 1:
438 return *(Uint8 *) ((Uint8 *) surf->pixels + y * surf->pitch + x);
439
440 case 2:
441 return *((Uint16 *)surf->pixels + y * surf->pitch / sizeof(Uint16) + x);
442
443 case 3:
444 {
445 /* Here ptr is the address to the pixel we want to retrieve */
446 Uint8 *ptr =
447 (Uint8 *) surf->pixels + y * surf->pitch + x * 3;
448
449 if (is_bigendian()) {
450 return ptr[0] << 16 | ptr[1] << 8 | ptr[2];
451 } else {
452 return ptr[0] | ptr[1] << 8 | ptr[2] << 16;
453 }
454 }
455 case 4:
456 return *((Uint32 *)surf->pixels + y * surf->pitch / sizeof(Uint32) + x);
457
458 default:
459 return 0; /* Shouldn't happen, but avoids warnings */
460 }
461}
462
463/**********************************************************************/
469{
470 if (!surf) {
471 return 0;
472 }
473
474 switch (SDL_GetPixelFormatDetails(surf->format)->bytes_per_pixel) {
475 case 1:
476 return *((Uint8 *)surf->pixels);
477
478 case 2:
479 return *((Uint16 *)surf->pixels);
480
481 case 3:
482 {
483 if (is_bigendian()) {
484 return (((Uint8 *)surf->pixels)[0] << 16)
485 | (((Uint8 *)surf->pixels)[1] << 8)
486 | ((Uint8 *)surf->pixels)[2];
487 } else {
488 return ((Uint8 *)surf->pixels)[0]
489 | (((Uint8 *)surf->pixels)[1] << 8)
490 | (((Uint8 *)surf->pixels)[2] << 16);
491 }
492 }
493 case 4:
494 return *((Uint32 *)surf->pixels);
495
496 default:
497 return 0; /* Shouldn't happen, but avoids warnings */
498 }
499}
500
501/* ===================================================================== */
502
503/**********************************************************************/
506void init_sdl(int flags)
507{
508 bool success;
509
514 main_data.dummy = NULL; /* Can't create yet -- hope we don't need it */
518
520 success = SDL_InitSubSystem(flags);
521 } else {
522 success = SDL_Init(flags);
523 }
524 if (!success) {
525 log_fatal(_("Unable to initialize SDL3 library: %s"), SDL_GetError());
527 }
528
530
531 /* Initialize the TTF library */
532 if (!TTF_Init()) {
533 log_fatal(_("Unable to initialize SDL3_ttf library: %s"), SDL_GetError());
535 }
536
538}
539
540/**********************************************************************/
543static void free_surfaces(void)
544{
545 if (main_data.renderer != NULL) {
548
550 }
551}
552
553/**********************************************************************/
557{
559
562
563 if (main_surface == NULL || main_data.map == NULL) {
564 log_fatal(_("Failed to create RGB surface: %s"), SDL_GetError());
565 return FALSE;
566 }
567
569
570 if (main_data.renderer == NULL) {
571 log_fatal(_("Failed to create renderer: %s"), SDL_GetError());
572 return FALSE;
573 }
574
578 width, height);
579
580 if (main_data.maintext == NULL) {
581 log_fatal(_("Failed to create texture: %s"), SDL_GetError());
582 return FALSE;
583 }
584
585 if (main_data.gui) {
588 } else {
590 }
591
593
594 return TRUE;
595}
596
597/**********************************************************************/
610
611/**********************************************************************/
614bool set_video_mode(unsigned width, unsigned height, unsigned flags_in)
615{
616 main_data.screen = SDL_CreateWindow(_("SDL3 Client for Freeciv"),
617 width, height, 0);
618
619 if (main_data.screen == NULL) {
620 log_fatal(_("Failed to create main window: %s"), SDL_GetError());
621 return FALSE;
622 }
623
625 const SDL_DisplayMode *mode;
626
629 width = mode->w;
630 height = mode->h;
631 }
632
634 return FALSE;
635 }
636
637 return TRUE;
638}
639
640/**********************************************************************/
655
656/**********************************************************************/
660{
661 return main_surface->w;
662}
663
664/**********************************************************************/
668{
669 return main_surface->h;
670}
671
672/**********************************************************************/
677{
679
680 if (prect && (prect->x < - prect->w || prect->x >= surf->w
681 || prect->y < - prect->h || prect->y >= surf->h)) {
682 return -2;
683 }
684
685 if (pcolor->a == 255) {
686 return SDL_FillSurfaceRect(surf, prect,
688 NULL,
689 pcolor->r, pcolor->g, pcolor->b));
690 }
691
692 if (!pcolor->a) {
693 return -3;
694 }
695
696 colorbar = create_surf(surf->w, surf->h);
697
700 NULL,
701 pcolor->r, pcolor->g, pcolor->b));
702
703 return alphablit(colorbar, NULL, surf, NULL, pcolor->a);
704}
705
706/**********************************************************************/
710{
711 int ww = prect->w, hh = prect->h;
712
713 if (prect->x < 0) {
714 ww += prect->x;
715 prect->x = 0;
716 }
717
718 if (prect->y < 0) {
719 hh += prect->y;
720 prect->y = 0;
721 }
722
723 if (prect->x + ww > main_window_width()) {
724 ww = main_window_width() - prect->x;
725 }
726
727 if (prect->y + hh > main_window_height()) {
728 hh = main_window_height() - prect->y;
729 }
730
731 /* End Correction */
732
733 if (ww <= 0 || hh <= 0) {
734 return FALSE; /* surprise :) */
735 } else {
736 prect->w = ww;
737 prect->h = hh;
738 }
739
740 return TRUE;
741}
742
743/**********************************************************************/
746bool is_in_rect_area(int x, int y, const SDL_Rect *rect)
747{
748 return ((x >= rect->x) && (x < rect->x + rect->w)
749 && (y >= rect->y) && (y < rect->y + rect->h));
750}
751
752/* ===================================================================== */
753
754/**********************************************************************/
758{
759 int w, h, x, y;
760 Uint16 minX, maxX, minY, maxY;
762 Uint32 mask;
763 const struct SDL_PixelFormatDetails *details
764 = SDL_GetPixelFormatDetails(surf->format);
765
766 fc_assert(surf != NULL);
767 fc_assert(rect != NULL);
768
769 minX = surf->w;
770 maxX = 0;
771 minY = surf->h;
772 maxY = 0;
773
774 if (!SDL_GetSurfaceColorKey(surf, &colorkey)) {
775 /* Use alpha instead of colorkey */
776 mask = details->Amask;
777 colorkey = 0;
778 } else {
779 mask = 0xffffffff;
780 }
781
782 lock_surf(surf);
783
784 switch (details->bytes_per_pixel) {
785 case 1:
786 {
787 Uint8 *pixel = (Uint8 *)surf->pixels;
788 Uint8 *start = pixel;
789
790 x = 0;
791 y = 0;
792 w = surf->w;
793 h = surf->h;
794 while (h--) {
795 do {
796 if (*pixel != colorkey) {
797 if (minY > y) {
798 minY = y;
799 }
800
801 if (minX > x) {
802 minX = x;
803 }
804 break;
805 }
806 pixel++;
807 x++;
808 } while (--w > 0);
809 w = surf->w;
810 x = 0;
811 y++;
812 pixel = start + surf->pitch;
813 start = pixel;
814 }
815
816 w = surf->w;
817 h = surf->h;
818 x = w - 1;
819 y = h - 1;
820 pixel = (Uint8 *)((Uint8 *)surf->pixels + (y * surf->pitch) + x);
821 start = pixel;
822 while (h--) {
823 do {
824 if (*pixel != colorkey) {
825 if (maxY < y) {
826 maxY = y;
827 }
828
829 if (maxX < x) {
830 maxX = x;
831 }
832 break;
833 }
834 pixel--;
835 x--;
836 } while (--w > 0);
837 w = surf->w;
838 x = w - 1;
839 y--;
840 pixel = start - surf->pitch;
841 start = pixel;
842 }
843 break;
844 }
845 case 2:
846 {
847 Uint16 *pixel = (Uint16 *)surf->pixels;
848 Uint16 *start = pixel;
849
850 x = 0;
851 y = 0;
852 w = surf->w;
853 h = surf->h;
854 while (h--) {
855 do {
856 if (*pixel != colorkey) {
857 if (minY > y) {
858 minY = y;
859 }
860
861 if (minX > x) {
862 minX = x;
863 }
864 break;
865 }
866 pixel++;
867 x++;
868 } while (--w > 0);
869 w = surf->w;
870 x = 0;
871 y++;
872 pixel = start + surf->pitch / 2;
873 start = pixel;
874 }
875
876 w = surf->w;
877 h = surf->h;
878 x = w - 1;
879 y = h - 1;
880 pixel = ((Uint16 *)surf->pixels + (y * surf->pitch / 2) + x);
881 start = pixel;
882 while (h--) {
883 do {
884 if (*pixel != colorkey) {
885 if (maxY < y) {
886 maxY = y;
887 }
888
889 if (maxX < x) {
890 maxX = x;
891 }
892 break;
893 }
894 pixel--;
895 x--;
896 } while (--w > 0);
897 w = surf->w;
898 x = w - 1;
899 y--;
900 pixel = start - surf->pitch / 2;
901 start = pixel;
902 }
903 break;
904 }
905 case 3:
906 {
907 Uint8 *pixel = (Uint8 *)surf->pixels;
908 Uint8 *start = pixel;
910
911 x = 0;
912 y = 0;
913 w = surf->w;
914 h = surf->h;
915 while (h--) {
916 do {
917 if (is_bigendian()) {
918 color = (pixel[0] << 16 | pixel[1] << 8 | pixel[2]);
919 } else {
920 color = (pixel[0] | pixel[1] << 8 | pixel[2] << 16);
921 }
922 if (color != colorkey) {
923 if (minY > y) {
924 minY = y;
925 }
926
927 if (minX > x) {
928 minX = x;
929 }
930 break;
931 }
932 pixel += 3;
933 x++;
934 } while (--w > 0);
935 w = surf->w;
936 x = 0;
937 y++;
938 pixel = start + surf->pitch / 3;
939 start = pixel;
940 }
941
942 w = surf->w;
943 h = surf->h;
944 x = w - 1;
945 y = h - 1;
946 pixel = (Uint8 *)((Uint8 *)surf->pixels + (y * surf->pitch) + x * 3);
947 start = pixel;
948 while (h--) {
949 do {
950 if (is_bigendian()) {
951 color = (pixel[0] << 16 | pixel[1] << 8 | pixel[2]);
952 } else {
953 color = (pixel[0] | pixel[1] << 8 | pixel[2] << 16);
954 }
955 if (color != colorkey) {
956 if (maxY < y) {
957 maxY = y;
958 }
959
960 if (maxX < x) {
961 maxX = x;
962 }
963 break;
964 }
965 pixel -= 3;
966 x--;
967 } while (--w > 0);
968 w = surf->w;
969 x = w - 1;
970 y--;
971 pixel = start - surf->pitch / 3;
972 start = pixel;
973 }
974 break;
975 }
976 case 4:
977 {
978 Uint32 *pixel = (Uint32 *)surf->pixels;
979 Uint32 *start = pixel;
980
981 x = 0;
982 y = 0;
983 w = surf->w;
984 h = surf->h;
985 while (h--) {
986 do {
987 if (((*pixel) & mask) != colorkey) {
988 if (minY > y) {
989 minY = y;
990 }
991
992 if (minX > x) {
993 minX = x;
994 }
995 break;
996 }
997 pixel++;
998 x++;
999 } while (--w > 0);
1000 w = surf->w;
1001 x = 0;
1002 y++;
1003 pixel = start + surf->pitch / 4;
1004 start = pixel;
1005 }
1006
1007 w = surf->w;
1008 h = surf->h;
1009 x = w - 1;
1010 y = h - 1;
1011 pixel = ((Uint32 *)surf->pixels + (y * surf->pitch / 4) + x);
1012 start = pixel;
1013 while (h--) {
1014 do {
1015 if (((*pixel) & mask) != colorkey) {
1016 if (maxY < y) {
1017 maxY = y;
1018 }
1019
1020 if (maxX < x) {
1021 maxX = x;
1022 }
1023 break;
1024 }
1025 pixel--;
1026 x--;
1027 } while (--w > 0);
1028 w = surf->w;
1029 x = w - 1;
1030 y--;
1031 pixel = start - surf->pitch / 4;
1032 start = pixel;
1033 }
1034 break;
1035 }
1036 }
1037
1038 unlock_surf(surf);
1039 rect->x = minX;
1040 rect->y = minY;
1041 rect->w = maxX - minX + 1;
1042 rect->h = maxY - minY + 1;
1043}
1044
1045/**********************************************************************/
1056
1057/**********************************************************************/
1062{
1063 if (psrc == NULL) {
1064 return NULL;
1065 }
1066
1067 return zoomSurface((SDL_Surface*)psrc,
1068 (double)new_width / psrc->w,
1069 (double)new_height / psrc->h,
1070 smooth);
1071}
1072
1073/**********************************************************************/
1082 int smooth, bool scale_up,
1084{
1085 SDL_Surface *tmp_surface, *result;
1086
1087 if (psrc == NULL) {
1088 return NULL;
1089 }
1090
1091 if (!(!scale_up && ((new_width >= psrc->w) && (new_height >= psrc->h)))) {
1092 if ((new_width - psrc->w) <= (new_height - psrc->h)) {
1093 /* horizontal limit */
1095 (double)new_width / psrc->w,
1096 (double)new_width / psrc->w,
1097 smooth);
1098 } else {
1099 /* vertical limit */
1101 (double)new_height / psrc->h,
1102 (double)new_height / psrc->h,
1103 smooth);
1104 }
1105 } else {
1107 1.0,
1108 1.0,
1109 smooth);
1110 }
1111
1112 if (absolute_dimensions) {
1113 SDL_Rect area = {
1114 (new_width - tmp_surface->w) / 2,
1115 (new_height - tmp_surface->h) / 2,
1116 0, 0
1117 };
1118
1119 result = create_surf(new_width, new_height);
1120 alphablit(tmp_surface, NULL, result, &area, 255);
1122 } else {
1123 result = tmp_surface;
1124 }
1125
1126 return result;
1127}
1128
1129/**********************************************************************/
1133{
1134 SDL_Surface *copy = SDL_CreateSurface(src->w, src->h, src->format);
1135
1136 alphablit(src, NULL, copy, NULL, 255);
1137
1138 return copy;
1139}
1140
1141/* ============ Freeciv game graphics function =========== */
1142
1143/**********************************************************************/
1147{
1148 switch (type) {
1149 case TS_ISOMETRIC:
1150 case TS_OVERHEAD:
1151 return TRUE;
1152 }
1153
1154 return FALSE;
1155}
1156
1157/**********************************************************************/
1161{
1162}
1163
1164/**********************************************************************/
1170{
1171 struct color gsdl3_color = { .color = pcolor };
1174 SDL_Rect tmp, dst = { .x = left, .y = top, .w = 0, .h = 0 };
1175
1176 tmp = dst;
1177 alphablit(vertical->psurface, NULL, dest, &tmp, 255);
1178
1179 dst.x += width - 1;
1180 tmp = dst;
1181 alphablit(vertical->psurface, NULL, dest, &tmp, 255);
1182
1183 dst.x = left;
1184 tmp = dst;
1185 alphablit(horizontal->psurface, NULL, dest, &tmp, 255);
1186
1187 dst.y += height - 1;
1188 tmp = dst;
1189 alphablit(horizontal->psurface, NULL, dest, &tmp, 255);
1190
1193}
1194
1195/**********************************************************************/
1200{
1201 int xl = x0 < x1 ? x0 : x1;
1202 int xr = x0 < x1 ? x1 : x0;
1203 int yt = y0 < y1 ? y0 : y1;
1204 int yb = y0 < y1 ? y1 : y0;
1205 int w = (xr - xl) + 1;
1206 int h = (yb - yt) + 1;
1207 struct sprite *spr;
1208 SDL_Rect dst = { xl, yt, w, h };
1209 SDL_Color *pcol;
1210 struct color gsdl3_color;
1211 int l = MAX((xr - xl) + 1, (yb - yt) + 1);
1212 int i;
1213 const struct SDL_PixelFormatDetails *details;
1214
1215 pcol = fc_malloc(sizeof(pcol));
1216 pcol->r = pcolor->r;
1217 pcol->g = pcolor->g;
1218 pcol->b = pcolor->b;
1219 pcol->a = 0; /* Fill with transparency */
1220
1221 gsdl3_color.color = pcol;
1222 spr = create_sprite(w, h, &gsdl3_color);
1223
1224 lock_surf(spr->psurface);
1225 details = SDL_GetPixelFormatDetails(spr->psurface->format);
1226
1227 /* Set off transparency from pixels belonging to the line */
1228 if ((x0 <= x1 && y0 <= y1)
1229 || (x1 <= x0 && y1 <= y0)) {
1230 for (i = 0; i < l; i++) {
1231 int cx = (xr - xl) * i / l;
1232 int cy = (yb - yt) * i / l;
1233
1234 *((Uint32 *)spr->psurface->pixels + spr->psurface->w * cy + cx)
1235 |= (pcolor->a << details->Ashift);
1236 }
1237 } else {
1238 for (i = 0; i < l; i++) {
1239 int cx = (xr - xl) * i / l;
1240 int cy = yb - yt - (yb - yt) * i / l;
1241
1242 *((Uint32 *)spr->psurface->pixels + spr->psurface->w * cy + cx)
1243 |= (pcolor->a << details->Ashift);
1244 }
1245 }
1246
1247 unlock_surf(spr->psurface);
1248
1249 alphablit(spr->psurface, NULL, dest, &dst, 255);
1250
1252 free(pcol);
1253}
SDL_Surface * zoomSurface(SDL_Surface *src, double zoomx, double zoomy, int smooth)
Zoom a surface by independent horizontal and vertical factors with optional smoothing.
struct canvas int int struct sprite int int int int height
Definition canvas_g.h:44
struct canvas int int int int struct sprite *sprite struct canvas struct color * pcolor
Definition canvas_g.h:56
struct canvas int int struct sprite int int int width
Definition canvas_g.h:44
char * incite_cost
Definition comments.c:75
#define _(String)
Definition fcintl.h:67
bool is_view_supported(enum ts_type type)
Definition graphics.c:53
void tileset_type_set(enum ts_type type)
Definition graphics.c:67
GType type
Definition repodlgs.c:1313
void free_sprite(struct sprite *s)
Definition sprite.c:278
struct sprite * create_sprite(int width, int height, struct color *pcolor)
Definition sprite.c:84
SDL_Surface * resize_surface(const SDL_Surface *psrc, Uint16 new_width, Uint16 new_height, int smooth)
Definition graphics.c:1237
bool set_video_mode(unsigned width, unsigned height, unsigned flags_in)
Definition graphics.c:636
int main_window_width(void)
Definition graphics.c:685
void layer_rect_to_screen_rect(struct gui_layer *gui_layer, SDL_Rect *dest_rect)
Definition graphics.c:185
SDL_Surface * load_surf(const char *fname)
Definition graphics.c:307
SDL_Surface * create_surf_with_format(SDL_PixelFormat *pf, int width, int height, Uint32 flags)
Definition graphics.c:328
void init_sdl(int flags)
Definition graphics.c:506
void update_main_screen(void)
Definition graphics.c:669
void remove_gui_layer(struct gui_layer *gui_layer)
Definition graphics.c:148
SDL_Surface * create_filled_surface(Uint16 w, Uint16 h, Uint32 flags, SDL_Color *pcolor)
Definition graphics.c:368
int fill_rect_alpha(SDL_Surface *surf, SDL_Rect *prect, SDL_Color *pcolor)
Definition graphics.c:865
void gui_layer_destroy(struct gui_layer **gui_layer)
Definition graphics.c:81
void create_line(SDL_Surface *dest, Sint16 x0, Sint16 y0, Sint16 x1, Sint16 y1, SDL_Color *pcolor)
Definition graphics.c:1379
SDL_Surface * copy_surface(SDL_Surface *src)
Definition graphics.c:1309
SDL_Surface * mask_surface(SDL_Surface *src, SDL_Surface *mask, int mask_offset_x, int mask_offset_y)
Definition graphics.c:262
struct gui_layer * gui_layer_new(int x, int y, SDL_Surface *surface)
Definition graphics.c:66
void quit_sdl(void)
Definition graphics.c:622
SDL_Surface * crop_visible_part_from_surface(SDL_Surface *psrc)
Definition graphics.c:1225
SDL_Surface * crop_rect_from_surface(SDL_Surface *psource, SDL_Rect *prect)
Definition graphics.c:236
int alphablit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:199
struct gui_layer * get_gui_layer(SDL_Surface *surface)
Definition graphics.c:90
bool is_in_rect_area(int x, int y, const SDL_Rect *rect)
Definition graphics.c:925
int screen_blit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Rect *dstrect, unsigned char alpha_mod)
Definition graphics.c:223
struct sdl2_data main_data
Definition graphics.c:57
static SDL_Surface * main_surface
Definition graphics.c:59
int blit_entire_src(SDL_Surface *psrc, SDL_Surface *pdest, Sint16 dest_x, Sint16 dest_y)
Definition graphics.c:417
Uint32 get_first_pixel(SDL_Surface *surf)
Definition graphics.c:468
SDL_Surface * convert_surf(SDL_Surface *surf_in)
Definition graphics.c:359
SDL_Surface * create_surf(int width, int height, Uint32 flags)
Definition graphics.c:351
void get_smaller_surface_rect(SDL_Surface *surf, SDL_Rect *rect)
Definition graphics.c:936
struct gui_layer * add_gui_layer(int width, int height)
Definition graphics.c:112
int clear_surface(SDL_Surface *surf, SDL_Rect *dstrect)
Definition graphics.c:400
bool correct_rect_region(SDL_Rect *prect)
Definition graphics.c:888
void screen_rect_to_layer_rect(struct gui_layer *gui_layer, SDL_Rect *dest_rect)
Definition graphics.c:173
void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, Sint16 width, Sint16 height, SDL_Color *pcolor)
Definition graphics.c:1348
static void free_surfaces(void)
Definition graphics.c:543
bool create_surfaces(int width, int height)
Definition graphics.c:556
int main_window_height(void)
Definition graphics.c:693
static bool render_dirty
Definition graphics.c:61
SDL_Surface * resize_surface_box(const SDL_Surface *psrc, Uint16 new_width, Uint16 new_height, int smooth, bool scale_up, bool absolute_dimensions)
Definition graphics.c:1257
#define FREESURFACE(ptr)
Definition graphics.h:322
#define unlock_surf(surf)
Definition graphics.h:344
#define lock_surf(surf)
Definition graphics.h:333
Uint32 get_pixel(SDL_Surface *surf, Sint16 x, Sint16 y)
Definition graphics.c:430
#define fc_assert(condition)
Definition log.h:176
#define log_fatal(message,...)
Definition log.h:100
#define log_error(message,...)
Definition log.h:103
#define fc_calloc(n, esz)
Definition mem.h:38
#define FC_FREE(ptr)
Definition mem.h:41
#define fc_realloc(ptr, sz)
Definition mem.h:36
#define fc_malloc(sz)
Definition mem.h:34
#define MAX(x, y)
Definition shared.h:54
struct sprite int int int int struct sprite * mask
Definition sprite_g.h:32
struct sprite int int y
Definition sprite_g.h:31
struct sprite int int int int struct sprite int mask_offset_x
Definition sprite_g.h:32
struct sprite int x
Definition sprite_g.h:31
struct sprite int int int int struct sprite int int mask_offset_y
Definition sprite_g.h:32
Definition colors.h:21
GdkRGBA color
Definition colors.h:22
SDL_Surface * surface
Definition graphics.h:229
SDL_Rect dest_rect
Definition graphics.h:228
int guis_count
Definition graphics.h:207
SDL_Surface * dummy
Definition graphics.h:211
SDL_Renderer * renderer
Definition graphics.h:213
SDL_Texture * maintext
Definition graphics.h:212
struct gui_layer * gui
Definition graphics.h:215
int rects_count
Definition graphics.h:206
struct gui_layer ** guis
Definition graphics.h:216
SDL_Window * screen
Definition graphics.h:209
SDL_Surface * map
Definition graphics.h:210
static bool is_bigendian(void)
Definition support.h:235
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47