/* initialize subsystems and allocate memory to objects */ int init() { int rval; /* initialize SDL */ if (SDL_Init(SDL_INIT_VIDEO) < 0) { fprintf(stderr, "SDL_Init: %s\n", SDL_GetError()); rval = -1; goto error; } /* initialize SDLNet */ if (SDLNet_Init() < 0) { fprintf(stderr, "SDLNet_Init: %s\n", SDL_GetError()); rval = -1; goto error; } /* create window (renderer comes with it) */ g_window = window_alloc(SCREEN_WIDTH, SCREEN_HEIGHT); if (!g_window) { fprintf(stderr, "window could not be created!"); rval = -1; goto error; } /* create player stick */ g_player = stick_alloc(20, SCREEN_HEIGHT / 2); if (!g_player) { fprintf(stderr, "player could not be created!"); rval = -1; goto error; } /* create opponent stick */ g_opponent = stick_alloc(SCREEN_WIDTH - 40, SCREEN_HEIGHT / 2); if (!g_opponent) { fprintf(stderr, "player could not be created!"); rval = -1; goto error; } /* create ball */ g_ball = ball_alloc(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2); if (!g_ball) { fprintf(stderr, "ball could not be created!"); rval = -1; goto error; } /* create score struct */ g_score = calloc(1, sizeof(score_state)); if (!g_score) { fprintf(stderr, "score could not be created!"); rval = -1; goto error; } g_score->player_score = 0; g_score->opponent_score = 0; rval = 0; return rval; error: return rval; }
int main() { pixbuf_t *icon1 = parse_png("/usr/share/icons/browser48.png"); pixbuf_t *icon2 = parse_png("/usr/share/icons/edit48.png"); pixbuf_t *icon3 = parse_png("/usr/share/icons/qonsole48.png"); pixbuf_t *icon4 = parse_png("/usr/share/icons/cpanel48.png"); pixbuf_t *icon5 = parse_png("/usr/share/icons/poweroff48.png"); window_t *win; iconview_t *iconview; /* allocate a window */ win = window_alloc("Quafios Launcher", /* title */ 465, /* width */ 100, /* height */ -2, /* x (center) */ -2, /* y (center) */ 0xFFC0C0C0, /* bg color */ "/usr/share/icons/launcher16.png" /* iconfile */); /* allocate iconview */ iconview = iconview_alloc(5, 48, 48, win->pixbuf->width, win->pixbuf->height, 0); /* insert iconview */ window_insert(win, iconview, 0, 0); /* insert icons */ iconview_insert(iconview, icon1, "Home"); iconview_insert(iconview, icon2, "Editor"); iconview_insert(iconview, icon3, "Qonsole"); iconview_insert(iconview, icon4, "Settings"); iconview_insert(iconview, icon5, "Turn off"); /* initialize events */ iconview->double_click = launch; /* redraw on the window */ iconview_redraw(iconview); /* loop */ gui_loop(); /* done */ return 0; }
int main() { /* initialize the font */ font_init(); /* initialize timer */ timer_init(); /* allocate a window */ win = window_alloc("Qonsole", /* title */ font_width*80, /* width */ font_height*25, /* height */ -1, /* x (random) */ -1, /* y (random) */ 0xFF000000, /* bg color */ "/usr/share/icons/qonsole16.png" /* iconfile */); /* initialize window event handlers */ win->press = pstty_press; /* initialize pstty */ pstty_init(); /* execute the shell */ exec_shell("/bin/rash"); /* set receiver */ set_receiver(pstty_event); /* loop */ gui_loop(); /* done */ return 0; }
void init_graphic(void) { global* global_handle = global_get_singleton(); config* config_handle = NULL; config_alloc(&config_handle, "config/graphics.cfg"); int resx = config_get_int_value(config_handle, "resx"); int resy = config_get_int_value(config_handle, "resy"); int samples = config_get_int_value(config_handle, "msaa"); int windowed = config_get_int_value(config_handle, "windowed"); int vsync = config_get_int_value(config_handle, "vertical_sync"); config_free(&config_handle); window* window_handle = NULL; window_alloc(&window_handle, resx, resy, samples, !windowed, vsync, 1); window_set_blend_mode(window_handle, WINDOW_BLEND_ALPHA); window_set_clear_color(window_handle, 0.0f, 0.0f, 0.0f, 0.0f); global_set(global_handle, GLOBAL_WINDOW, window_handle); hl_render* hl_render_handle = NULL; hl_render_alloc(&hl_render_handle); global_set(global_handle, GLOBAL_HL_RENDER, hl_render_handle); // effect* effect_motion_blur_handle = NULL; // effect_alloc(&effect_motion_blur_handle, effect_motion_blur_init, effect_motion_blur_render, effect_motion_blur_config, effect_motion_blur_free, window_get_width(window_handle), window_get_height(window_handle)); // hl_render_add_effect(hl_render_handle, effect_motion_blur_handle, WINDOW_BLEND_ALPHA); camera* camera_handle = NULL; camera_alloc(&camera_handle); camera_set_dimension(camera_handle, CAMERA_SIZE * (float) window_get_width(window_handle) / (float) window_get_height(window_handle), CAMERA_SIZE); camera_set_position(camera_handle, 0.0f, 0.0f); camera_update_matrices(camera_handle); global_set(global_handle, GLOBAL_CAMERA, camera_handle); shader* shader_texture_handle = NULL; shader_alloc(&shader_texture_handle, SHADER_TEXTURE_VS, SHADER_TEXTURE_PS); global_set(global_handle, GLOBAL_SHADER_TEXTURE, shader_texture_handle); text* text_handle = NULL; text_alloc(&text_handle, camera_handle, window_handle); global_set(global_handle, GLOBAL_TEXT, text_handle); input* input_handle = NULL; input_alloc(&input_handle, window_handle); global_set(global_handle, GLOBAL_INPUT, input_handle); debug_draw* debug_draw_handle = NULL; debug_draw_alloc(&debug_draw_handle, hl_render_handle); global_set(global_handle, GLOBAL_DEBUG_DRAW, debug_draw_handle); }