void init(float winwidth, float winheight, float pixratio) { parg_state_clearcolor((Vector4){gray, gray, gray, 1}); parg_state_depthtest(0); parg_state_cullfaces(0); parg_shader_load_from_asset(SHADER_SIMPLE); float worldheight = worldwidth * sqrt(0.75); parg_zcam_init(worldwidth, worldheight, fovy); trimesh = parg_mesh_sierpinski(worldwidth, 10); printf("%d triangles\n", parg_mesh_ntriangles(trimesh)); }
void init(float winwidth, float winheight, float pixratio) { parg_state_clearcolor((Vector4){gray, gray, gray, 1}); parg_state_depthtest(0); parg_state_cullfaces(0); parg_shader_load_from_asset(SHADER_ZOOMING); palmstexture = parg_texture_from_asset(TEXTURE_PALMS); int imgwidth, imgheight; parg_texture_info(palmstexture, &imgwidth, &imgheight); float worldheight = worldwidth * imgheight / imgwidth; parg_zcam_init(worldwidth, worldheight, fovy); rectmesh = parg_mesh_rectangle(worldwidth, worldheight); }
void init(float winwidth, float winheight, float pixratio) { printf( "Spacebar to toggle texture modes.\n" "D to toggle auto-zooming demo mode.\n" "G to toggle the slippy map grid.\n"); parg_state_clearcolor((Vector4){0.43, 0.61, 0.8, 1}); parg_state_cullfaces(1); parg_state_depthtest(0); parg_shader_load_from_asset(SHADER_DEFAULT); parg_zcam_init(1, 1, fovy); parg_zcam_set_position(0, 0, STARTZ); ocean_texture = parg_texture_from_asset(TEXTURE_OCEAN); paper_texture = parg_texture_from_asset(TEXTURE_PAPER); // Decode the europe image. int* rawdata; parg_buffer* colorbuf = parg_buffer_slurp_asset(TEXTURE_EUROPE, (void*) &rawdata); int width = *rawdata++; int height = *rawdata++; int ncomps = *rawdata++; parg_texture_fliprows(rawdata, width * ncomps, height); // Sample the ocean color from one corner of the image. int ocean_color = rawdata[0]; // Perform marching squares and generate a mesh. par_msquares_meshlist* mlist = par_msquares_color((parg_byte*) rawdata, width, height, 16, ocean_color, 4, PAR_MSQUARES_SWIZZLE | PAR_MSQUARES_DUAL | PAR_MSQUARES_HEIGHTS | PAR_MSQUARES_SIMPLIFY); par_msquares_mesh const* mesh; mesh = par_msquares_get_mesh(mlist, 0); landmass_mesh = parg_mesh_create( mesh->points, mesh->npoints, mesh->triangles, mesh->ntriangles); mesh = par_msquares_get_mesh(mlist, 1); ocean_mesh = parg_mesh_create( mesh->points, mesh->npoints, mesh->triangles, mesh->ntriangles); parg_buffer_unlock(colorbuf); par_msquares_free(mlist); }