Example #1
0
asset_hndl asset_hndl_new_load(fpath path) {
  asset_hndl ah = asset_hndl_new(path);
  if (!file_isloaded(ah.path)) {
    file_load(ah.path);
  }
  return ah;
}
Example #2
0
void graphics_viewport_set_icon(fpath icon) {
  SDL_Surface* window_icon = SDL_LoadBMP(asset_hndl_new(icon).path.ptr);
  SDL_SetWindowIcon(screen, window_icon);
  SDL_FreeSurface(window_icon);
}
Example #3
0
asset* asset_get(fpath path) {
  asset_hndl ah = asset_hndl_new(path);
  return asset_hndl_ptr(&ah);
}
Example #4
0
void sea_init() {
  
  graphics_viewport_set_dimensions(1280, 720);
  graphics_viewport_set_title("Sea");

  camera* cam = entity_new("camera", camera);
  cam->position = vec3_new(50.0, 50.0, 50.0);
  cam->target = vec3_new(0, 5, 0);
  cam->near_clip = 0.1;
  
  light* sun = entity_new("sun", light);
  light_set_type(sun, light_type_spot);
  sun->position = vec3_new(20,23,16);
  sun->ambient_color = vec3_new(0.5, 0.5, 0.5);
  sun->diffuse_color = vec3_new(1.0,  0.894, 0.811);
  sun->specular_color = vec3_mul(vec3_new(1.0,  0.894, 0.811), 4);
  sun->power = 5;
  
  light* backlight = entity_new("backlight", light);
  light_set_type(backlight, light_type_point);
  backlight->position = vec3_new(-22,10,-13);
  backlight->ambient_color = vec3_new(0.2, 0.2, 0.2);
  backlight->diffuse_color = vec3_new(0.729, 0.729, 1.0);
  backlight->specular_color = vec3_mul(vec3_new(0.729, 0.729, 1.0), 1);
  backlight->power = 2;
  
  shadow_mapper_init(sun);  
  
  forward_renderer_init();
  forward_renderer_set_camera(cam);
  forward_renderer_set_shadow_light(sun);
  forward_renderer_set_shadow_texture( shadow_mapper_depth_texture() );
  forward_renderer_add_light(sun);
  forward_renderer_add_light(backlight);
  
  folder_load(P("./resources/"));
  
  renderable* r_seaplane = asset_get(P("./resources/seaplane.obj"));
  r_seaplane->material = asset_hndl_new(P("./resources/seaplane.mat"));
  
  static_object* s_seaplane = entity_new("seaplane", static_object);
  s_seaplane->renderable = asset_hndl_new_ptr(r_seaplane);
  s_seaplane->scale = vec3_new(3,1,3);
  
  renderable* r_skydome = asset_get(P("./resources/skydome.obj"));
  r_skydome->material = asset_hndl_new_load(P("$CORANGE/shaders/skydome.mat"));
  
  static_object* skydome = entity_new("skydome", static_object);
  skydome->renderable = asset_hndl_new_ptr(r_skydome);
  skydome->position = vec3_new(0, -512, 0);
  skydome->scale = vec3_new(1024, 1024, 1024);
  
  folder_load(P("./resources/corvette/"));
  
  renderable* r_corvette = asset_get(P("./resources/corvette/corvette.obj"));
  r_corvette->material = asset_hndl_new_load(P("./resources/corvette/corvette.mat"));
  
  static_object* s_corvette = entity_new("corvette", static_object);
  s_corvette->renderable = asset_hndl_new_ptr(r_corvette);
  //s_corvette->collision_body = collision_body_new_mesh(asset_get("./resources/corvette/corvette.col"));
  s_corvette->scale = vec3_new(1.5, 1.5, 1.5);
  s_corvette->position = vec3_new(0, 0.5, 0);
  
  static_object* center_sphere = entity_new("center_sphere", static_object);
  center_sphere->position = vec3_new(0, 5, 0);
  //center_sphere->renderable = asset_get("./resources/ball.obj");
  //center_sphere->collision_body = collision_body_new_sphere(sphere_new(v3_zero(), 1.0f));
  
  ui_button* framerate = ui_elem_new("framerate", ui_button);
  ui_button_move(framerate, vec2_new(10,10));
  ui_button_resize(framerate, vec2_new(30,25));
  ui_button_set_label(framerate, "FRAMERATE");
  ui_button_disable(framerate);
  
}