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
);
85 int is_kmod(int a
, int b
)
90 SDL_Surface
*ext_render_text(char *s
, TTF_Font
*font
, SDL_Color
*c
)
95 tmp
= TTF_RenderText_Solid(font
, s
, *c
);
96 res
= SDL_DisplayFormat(tmp
);
101 void *ext_make_color(int r
, int g
, int b
)
105 res
= (SDL_Color
*) bl_malloc(sizeof(SDL_Color
));
113 int ext_convert_color(int r
, int g
, int b
)
115 return SDL_MapRGB(screen
->format
, r
, g
, b
);
118 void blit_img(SDL_Surface
*image
, int x
, int y
)
124 SDL_BlitSurface(image
, NULL
, screen
, &rect
);
127 SDL_Surface
*ext_display_format_alpha(SDL_Surface
*img
)
132 res
= SDL_DisplayFormatAlpha(img
);
133 SDL_FreeSurface(img
);
137 SDL_Surface
*ext_display_format(SDL_Surface
*img
)
142 res
= SDL_DisplayFormat(img
);
143 SDL_FreeSurface(img
);
147 TTF_Font
*ext_ttf_openfont(char *font
, int size
)
149 return TTF_OpenFont(font
, size
);
152 void *free_ttf_font(TTF_Font
*font
)