10 static SDL_Surface
*screen
;
12 void ext_fill_rect(int x
, int y
, int w
, int h
, int c
)
20 SDL_FillRect(screen
, &rect
, c
);
26 //screen = SDL_SetVideoMode(640, 480, 0, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_FULLSCREEN);
27 screen
= SDL_SetVideoMode(640, 480, 0, SDL_HWSURFACE
| SDL_DOUBLEBUF
);
28 //screen = SDL_SetVideoMode(640, 480, 0, SDL_SWSURFACE | SDL_FULLSCREEN);
30 fprintf(stderr
, "Can't set video mode: %s\n", SDL_GetError());
33 //SDL_ShowCursor(SDL_DISABLE);
40 //printf("SDL_Init()...\n");
41 //status = SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO|SDL_INIT_TIMER);
42 status
= SDL_Init(SDL_INIT_VIDEO
|SDL_INIT_TIMER
);
44 fprintf(stderr
, "Can't init SDL: %s\n", SDL_GetError());
48 //printf("TTF_Init()...\n");
51 fprintf(stderr
, "init_glue: TTF_Init failed: %s\n", SDL_GetError());
59 signal(SIGTERM
, exit
);
61 SDL_WM_SetCaption(NETWALK_VERSION
, NETWALK_VERSION
);
63 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY
, SDL_DEFAULT_REPEAT_INTERVAL
);
66 void ext_update_screen()
71 EIF_OBJ
ext_poll_event(EIF_OBJ em
)
75 while (SDL_PollEvent(&event
)) {
76 if (event
.type
== SDL_KEYDOWN
) {
77 return EVENTMAKER_make_keydown(em
, event
.key
.keysym
.sym
, SDL_GetModState());
78 } else if (event
.type
== SDL_MOUSEBUTTONDOWN
) {
79 return EVENTMAKER_make_mbdown(em
, event
.button
.button
, SDL_GetModState(), event
.button
.x
, event
.button
.y
);
80 } else if (event
.type
== SDL_QUIT
) {
81 return EVENTMAKER_make_quit(em
);
87 int is_kmod(int a
, int b
)
92 SDL_Surface
*ext_render_text(char *s
, TTF_Font
*font
, SDL_Color
*c
)
97 tmp
= TTF_RenderText_Solid(font
, s
, *c
);
98 res
= SDL_DisplayFormat(tmp
);
103 void *ext_make_color(int r
, int g
, int b
)
107 res
= (SDL_Color
*) bl_malloc(sizeof(SDL_Color
));
115 int ext_convert_color(int r
, int g
, int b
)
117 return SDL_MapRGB(screen
->format
, r
, g
, b
);
120 void *free_img(void *image
)
122 SDL_FreeSurface((SDL_Surface
*) image
);
126 void blit_img(SDL_Surface
*image
, int x
, int y
)
132 SDL_BlitSurface(image
, NULL
, screen
, &rect
);
135 SDL_Surface
*ext_display_format_alpha(SDL_Surface
*img
)
140 res
= SDL_DisplayFormatAlpha(img
);
141 SDL_FreeSurface(img
);
145 SDL_Surface
*ext_display_format(SDL_Surface
*img
)
150 res
= SDL_DisplayFormat(img
);
151 SDL_FreeSurface(img
);
155 TTF_Font
*ext_ttf_openfont(char *font
, int size
)
157 return TTF_OpenFont(font
, size
);
160 void *free_ttf_font(TTF_Font
*font
)
166 static int textsizewidth
;
167 static int textsizeheight
;
170 return textsizewidth
;
174 return textsizeheight
;
177 void ext_get_text_size(TTF_Font
*font
, const char* text
)
179 TTF_SizeText(font
, text
, &textsizewidth
, &textsizeheight
);