-Sync even when not in focus
This commit is contained in:
12
mini.cpp
12
mini.cpp
@@ -196,7 +196,7 @@ int main(int argc,char*argv[]){
|
||||
|
||||
SDL_Init(SDL_INIT_EVERYTHING);
|
||||
mini_win = SDL_CreateWindow(window_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, screen_width*screen_zoom, screen_height*screen_zoom, SDL_WINDOW_SHOWN);
|
||||
mini_ren = SDL_CreateRenderer(mini_win, -1, SDL_RENDERER_PRESENTVSYNC);
|
||||
mini_ren = SDL_CreateRenderer(mini_win, -1, 0);
|
||||
//SDL_CreateWindowAndRenderer(512,512,0,&mini_win,&mini_ren);
|
||||
SDL_RenderSetLogicalSize(mini_ren, screen_width, screen_height);
|
||||
SDL_ShowCursor(show_cursor);
|
||||
@@ -210,14 +210,15 @@ int main(int argc,char*argv[]){
|
||||
lua_init(lua_files);
|
||||
lua_call_init();
|
||||
|
||||
while(!should_exit) {
|
||||
Uint32 dt=SDL_GetTicks();
|
||||
key_just_pressed = 0;
|
||||
while(!should_exit) {
|
||||
mouse_wheel = 0;
|
||||
while(SDL_PollEvent(&mini_eve)) {
|
||||
if (mini_eve.type == SDL_QUIT) { should_exit=true; should_quit=true; break; }
|
||||
if (mini_eve.type == SDL_KEYDOWN) {
|
||||
#ifdef DEBUG
|
||||
if (mini_eve.key.keysym.scancode == SDL_SCANCODE_ESCAPE) {
|
||||
if (mini_eve.key.keysym.scancode == SDL_SCANCODE_F1) {
|
||||
chirp_stop();
|
||||
if (lua_is_playing()) {
|
||||
lua_quit();
|
||||
@@ -228,6 +229,7 @@ int main(int argc,char*argv[]){
|
||||
}
|
||||
} else if (mini_eve.key.keysym.scancode == SDL_SCANCODE_F5) {
|
||||
chirp_stop();
|
||||
should_exit=true;
|
||||
} else {
|
||||
key_just_pressed = mini_eve.key.keysym.scancode;
|
||||
}
|
||||
@@ -243,11 +245,15 @@ int main(int argc,char*argv[]){
|
||||
mouse_buttons = SDL_GetMouseState(&mouse_x, &mouse_y);
|
||||
mouse_x /= screen_zoom; mouse_y /= screen_zoom;
|
||||
|
||||
if (SDL_GetTicks()-dt>13) {
|
||||
dt = SDL_GetTicks();
|
||||
if (lua_is_playing()) {
|
||||
lua_call_update();
|
||||
} else {
|
||||
loop();
|
||||
}
|
||||
key_just_pressed = 0;
|
||||
}
|
||||
SDL_LockTexture(mini_bak, NULL, (void**)&pixels, &pitch);
|
||||
for (int i=0;i<screen_surface->size;++i) pixels[i] = palette[screen_surface->p[i]];
|
||||
SDL_UnlockTexture(mini_bak);
|
||||
|
||||
Reference in New Issue
Block a user