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