int mouse_x, mouse_y, mouse_state[3];
unsigned int modkeys;
-int scr_width, scr_height;
int fullscr;
long time_msec;
char *start_scr_name;
static rtk_draw_ops guigfx = {gui_fill, 0, gui_drawtext, gui_textrect};
+ if(!(framebuf = malloc(SCR_WIDTH * SCR_HEIGHT))) {
+ errormsg("failed to allocate framebuffer (%dx%d)\n", SCR_WIDTH, SCR_HEIGHT);
+ return -1;
+ }
+
rtk_setup(&guigfx);
/* initialize screens */
}
cleanup_logger();
+ free(framebuf);
}
void app_display(void)
cur_scr->display();
}
-void app_reshape(int x, int y)
-{
- int numpix = x * y;
- int prev_numpix = scr_width * scr_height;
-
- if(!framebuf || numpix > prev_numpix) {
- void *tmp;
- if(!(tmp = realloc(framebuf, numpix * sizeof *framebuf))) {
- errormsg("failed to resize framebuffer to %dx%d\n", x, y);
- return;
- }
- framebuf = tmp;
- }
-
- scr_width = x;
- scr_height = y;
-
- if(cur_scr && cur_scr->reshape) {
- cur_scr->reshape(x, y);
- }
-
- app_invalidate(0, 0, 0, 0);
-}
-
void app_keyboard(int key, int press)
{
long msec;
return;
}
break;
-
- case '\n':
- case '\r':
- if(modkeys & KEY_MOD_ALT) {
- case KEY_F11:
- app_fullscreen(-1);
- return;
- }
- break;
}
}
if(scr->start && scr->start() == -1) {
return;
}
- if(scr->reshape) {
- scr->reshape(scr_width, scr_height);
- }
if(prev && prev->stop) {
prev->stop();
cur_scr = scr;
}
-void gui_fill(rtk_rect *rect, int color)
+void gui_fill(rtk_rect *rect, uint32_t color)
{
int i, j;
unsigned char *fb;
rect->height += rect->y;
rect->y = 0;
}
- if(rect->x + rect->width >= scr_width) {
- rect->width = scr_width - rect->x;
+ if(rect->x + rect->width >= SCR_WIDTH) {
+ rect->width = SCR_WIDTH - rect->x;
}
- if(rect->y + rect->height >= scr_height) {
- rect->height = scr_height - rect->y;
+ if(rect->y + rect->height >= SCR_HEIGHT) {
+ rect->height = SCR_HEIGHT - rect->y;
}
- fb = framebuf + rect->y * scr_width + rect->x;
+ fb = framebuf + rect->y * SCR_WIDTH + rect->x;
for(i=0; i<rect->height; i++) {
for(j=0; j<rect->width; j++) {
fb[j] = color;
}
- fb += scr_width;
+ fb += SCR_WIDTH;
}
}