void vg_destroy_context(struct vg_context *ctx) { struct pipe_resource **cbuf = &ctx->mask.cbuf; renderer_destroy(ctx->renderer); shaders_cache_destroy(ctx->sc); shader_destroy(ctx->shader); paint_destroy(ctx->default_paint); if (*cbuf) pipe_resource_reference(cbuf, NULL); if (ctx->mask.union_fs) vg_shader_destroy(ctx, ctx->mask.union_fs); if (ctx->mask.intersect_fs) vg_shader_destroy(ctx, ctx->mask.intersect_fs); if (ctx->mask.subtract_fs) vg_shader_destroy(ctx, ctx->mask.subtract_fs); if (ctx->mask.set_fs) vg_shader_destroy(ctx, ctx->mask.set_fs); cso_destroy_context(ctx->cso_context); cso_hash_delete(ctx->owned_objects[VG_OBJECT_PAINT]); cso_hash_delete(ctx->owned_objects[VG_OBJECT_IMAGE]); cso_hash_delete(ctx->owned_objects[VG_OBJECT_MASK]); cso_hash_delete(ctx->owned_objects[VG_OBJECT_FONT]); cso_hash_delete(ctx->owned_objects[VG_OBJECT_PATH]); api_destroy_dispatch(ctx->dispatch); FREE(ctx); }
void vg_destroy_context(struct vg_context *ctx) { struct pipe_resource **cbuf = &ctx->mask.cbuf; struct pipe_resource **vsbuf = &ctx->vs_const_buffer; util_destroy_blit(ctx->blit); renderer_destroy(ctx->renderer); shaders_cache_destroy(ctx->sc); shader_destroy(ctx->shader); paint_destroy(ctx->default_paint); if (*cbuf) pipe_resource_reference(cbuf, NULL); if (*vsbuf) pipe_resource_reference(vsbuf, NULL); if (ctx->clear.fs) { cso_delete_fragment_shader(ctx->cso_context, ctx->clear.fs); ctx->clear.fs = NULL; } if (ctx->plain_vs) { vg_shader_destroy(ctx, ctx->plain_vs); ctx->plain_vs = NULL; } if (ctx->clear_vs) { vg_shader_destroy(ctx, ctx->clear_vs); ctx->clear_vs = NULL; } if (ctx->texture_vs) { vg_shader_destroy(ctx, ctx->texture_vs); ctx->texture_vs = NULL; } if (ctx->pass_through_depth_fs) vg_shader_destroy(ctx, ctx->pass_through_depth_fs); if (ctx->mask.union_fs) vg_shader_destroy(ctx, ctx->mask.union_fs); if (ctx->mask.intersect_fs) vg_shader_destroy(ctx, ctx->mask.intersect_fs); if (ctx->mask.subtract_fs) vg_shader_destroy(ctx, ctx->mask.subtract_fs); if (ctx->mask.set_fs) vg_shader_destroy(ctx, ctx->mask.set_fs); cso_release_all(ctx->cso_context); cso_destroy_context(ctx->cso_context); cso_hash_delete(ctx->owned_objects[VG_OBJECT_PAINT]); cso_hash_delete(ctx->owned_objects[VG_OBJECT_IMAGE]); cso_hash_delete(ctx->owned_objects[VG_OBJECT_MASK]); cso_hash_delete(ctx->owned_objects[VG_OBJECT_FONT]); cso_hash_delete(ctx->owned_objects[VG_OBJECT_PATH]); api_destroy_dispatch(ctx->dispatch); FREE(ctx); }
void engine_destroy_windows() { // Destroy the renderer renderer_destroy(&engineInstance->renderer); glfwDestroyWindow(engineInstance->window); glfwTerminate(); }
/** * free element */ void led_unregister_from_gui(NiftyconfLed * l) { if(!l) return; /* destroy renderer of this tile */ renderer_destroy(l->renderer); led_set_privdata(l->l, NULL); free(l); }
void bina_exit() { renderer_destroy(); if (m.window) { sdl_destroy_window(m.window); } log_d("exiting library"); sdl_quit(); }
int main(int argc, char* argv[]) { uint8_t input[FRAME_WIDTH * FRAME_HEIGHT]; if (renderer_create(FRAME_WIDTH, FRAME_HEIGHT, RENDER_VISIBLE) < 0) return -1; stream_t* stream = stream_create(); frames_t* frames = &(stream->frames); tiles_t* tiles = &(stream->tiles); size_t actual = 0; for (int index = FIRST_INDEX; index <= LAST_INDEX; ++index) { char path[256]; sprintf(path, "images/image-%04d.raw", index); FILE* fp = fopen(path, "rb"); if (!fp) break; if (fread(input, FRAME_WIDTH*FRAME_HEIGHT, 1, fp) < 1) break; fclose(fp); frame_t frame; tile_index_t* indices = frame.tiles; for (int y = 0; y < FRAME_HEIGHT; y += TILE_HEIGHT) { for (int x = 0; x < FRAME_WIDTH; x += TILE_WIDTH) { tile_t tile; *(indices++) = tiles_insert(tiles, input + x + y * FRAME_WIDTH, 200, FRAME_WIDTH); ++ actual; } } frames_add(frames, &frame); if (index % 10 == 0) { if (renderer_update(FRAME_WIDTH, FRAME_HEIGHT, input, 0) < 0) return 0; } fprintf(stderr, "\rpath: %s, frames: %lu tiles: %lu/%lu blocks: %lu", path, buffer_count(&(frames->buffer)), buffer_count(&(tiles->buffer)), actual, buffer_count(&(tiles->blocks.buffer))); } renderer_destroy(); fprintf(stderr, "\n"); stream_optimize_blocks(stream, BLOCK_PASSES, MAX_BLOCK_ERROR); stream_optimize_tiles(stream, MAX_TILE_ERROR); // stream_optimize_frames(stream); fprintf(stderr, "\nsaving...\n"); FILE* out = fopen("anim.bin", "wb"); if (stream_save(stream, out) < 0) { fprintf(stderr, "failed to save stream\n"); return -1; } fclose(out); stream_destroy(stream); return 0; }
int main(int argc, char* argv[]) { // our demo variables World* demoworld = 0; Camera* democamera = 0; Tileset* demotileset = 0; Renderer* demorenderer = 0; // init SDL if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { fprintf(stderr, "SDL Library Initialization Failed!\n\tSDL Error: %s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit); // create the window if (!SDL_SetVideoMode(SCREEN_W, SCREEN_H, SCREEN_BPP, SDL_HWSURFACE | SDL_DOUBLEBUF)) { fprintf(stderr, "SDL Screen Initialization Failed! %dx%d@%dbpp\nSDL Error: %s\n", SCREEN_W, SCREEN_H, SCREEN_BPP, SDL_GetError()); exit(1); } // set the window caption SDL_WM_SetCaption("Basic SDL Map Editor Example Demo -- by Richard Marks <*****@*****.**>", 0); // create our keyboard handler Keyboard* keyboard = keyboard_create(); // load the world demoworld = world_load("example_demo.map"); if (!demoworld) { fprintf(stderr, "unable to load the world file!\n"); exit(1); } // load the tileset demotileset = tileset_load("example_demo.png", 32, 32); if (!demotileset) { fprintf(stderr, "unable to load the tileset file!\n"); exit(1); } // create the camera democamera = camera_create( // anchor position of the camera is at 32,32 on the screen 32, 32, // the camera view is 30 x 22 tiles 30, 22, // need to tell the camera the size of the tiles demotileset->width, demotileset->height); // create the renderer demorenderer = renderer_create(demoworld, demotileset, democamera); // pre-render the scene renderer_pre_render(demorenderer); fprintf(stderr, "\nstarting main loop...\n\n"); // start the main loop SDL_Event event; bool running = true; int startticks = SDL_GetTicks(); int mainlooptimer = SDL_GetTicks(); while(running) { // check for our window being closed while(SDL_PollEvent(&event)) { if (SDL_QUIT == event.type) { running = false; } } // update our keyboard handler keyboard_update(keyboard); // start timing our code startticks = SDL_GetTicks(); // check for our controls // ESC and Q quits if (keyboard->key[SDLK_ESCAPE] || keyboard->key[SDLK_q]) { running = false; } const unsigned int CAMERASPEED = 16; // W and up arrow if (keyboard->key[SDLK_w] || keyboard->key[SDLK_UP]) { if (democamera->inpixels->y > 0) { democamera->inpixels->y -= CAMERASPEED; } } // S and down arrow if (keyboard->key[SDLK_s] || keyboard->key[SDLK_DOWN]) { if (democamera->inpixels->y < demorenderer->scene->h - democamera->inpixels->h) { democamera->inpixels->y += CAMERASPEED; } } // A and left arrow if (keyboard->key[SDLK_a] || keyboard->key[SDLK_LEFT]) { if (democamera->inpixels->x > 0) { democamera->inpixels->x -= CAMERASPEED; } } // D and right arrow if (keyboard->key[SDLK_d] || keyboard->key[SDLK_RIGHT]) { if (democamera->inpixels->x < demorenderer->scene->w - democamera->inpixels->w) { democamera->inpixels->x += CAMERASPEED; } } // render our scene renderer_render(demorenderer); // flip our double buffer SDL_Flip(SDL_GetVideoSurface()); // lock our framerate to roughly 30 FPS int tickdiff = SDL_GetTicks() - startticks; if (tickdiff < 33) { SDL_Delay(33 - tickdiff); } } int tickdiff = SDL_GetTicks() - mainlooptimer; fprintf(stderr, "finished after %d ticks!\n\n", tickdiff); // destroy our pointers tileset_destroy(demotileset); renderer_destroy(demorenderer); world_destroy(demoworld); camera_destroy(democamera); keyboard_destroy(keyboard); return 0; }