mirror of
https://github.com/Interlisp/maiko.git
synced 2026-02-14 19:56:28 +00:00
Only update texture on damage.
This commit is contained in:
30
src/sdl.c
30
src/sdl.c
@@ -207,8 +207,12 @@ void set_pixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
|
||||
}
|
||||
int should_update_texture = 0;
|
||||
|
||||
void sdl_notify_damage(int x, int y, int w, int h) {
|
||||
should_update_texture = 1;
|
||||
}
|
||||
|
||||
void sdl_bitblt_to_screen(int _x, int _y, int _w, int _h) {
|
||||
// printf("bitblting\n");
|
||||
//printf("bitblting\n");
|
||||
int before = SDL_GetTicks();
|
||||
int width = sdl_displaywidth;
|
||||
int height = sdl_displayheight;
|
||||
@@ -234,7 +238,7 @@ void sdl_bitblt_to_screen(int _x, int _y, int _w, int _h) {
|
||||
}
|
||||
}
|
||||
}
|
||||
should_update_texture = 1;
|
||||
//should_update_texture = 1;
|
||||
int after = SDL_GetTicks();
|
||||
// printf("bitblting took %dms\n", after - before);
|
||||
/* before = SDL_GetTicks(); */
|
||||
@@ -414,27 +418,25 @@ void process_SDLevents() {
|
||||
}
|
||||
}
|
||||
// handle_keyboard();
|
||||
/* sdl_bitblt_to_screen(); */
|
||||
// SDL_UpdateTexture(sdl_texture, NULL, buffer, sdl_displaywidth * sizeof(Uint32));
|
||||
int before = 0;
|
||||
int after = 0;
|
||||
/* if(should_update_texture) { */
|
||||
/* before = SDL_GetTicks(); */
|
||||
/* SDL_UpdateTexture(sdl_texture, NULL, buffer, sdl_displaywidth * sizeof(Uint32)); */
|
||||
/* after = SDL_GetTicks(); */
|
||||
/* should_update_texture = 0; */
|
||||
/* } */
|
||||
// printf("UpdateTexture took %dms\n", after - before);
|
||||
if(should_update_texture) {
|
||||
before = SDL_GetTicks();
|
||||
sdl_bitblt_to_screen(0, 0, sdl_displaywidth, sdl_displayheight);
|
||||
SDL_UpdateTexture(sdl_texture, NULL, buffer, sdl_displaywidth * sizeof(Uint32));
|
||||
after = SDL_GetTicks();
|
||||
// printf("UpdateTexture took %dms\n", after - before);
|
||||
should_update_texture = 0;
|
||||
}
|
||||
int this_draw = SDL_GetTicks();
|
||||
before = SDL_GetTicks();
|
||||
// printf("processing events took %dms\n", before - process_events_time);
|
||||
if(this_draw - last_draw > 16) {
|
||||
before = SDL_GetTicks();
|
||||
SDL_UpdateTexture(sdl_texture, NULL, buffer, sdl_displaywidth * sizeof(Uint32));
|
||||
/* SDL_UpdateTexture(sdl_texture, NULL, buffer, sdl_displaywidth * sizeof(Uint32)); */
|
||||
after = SDL_GetTicks();
|
||||
should_update_texture = 0;
|
||||
// should_update_texture = 0;
|
||||
|
||||
sdl_bitblt_to_screen(0, 0, sdl_displaywidth, sdl_displayheight);
|
||||
SDL_RenderClear(sdl_renderer);
|
||||
SDL_Rect r;
|
||||
r.x = 0;
|
||||
|
||||
Reference in New Issue
Block a user