-[NEW] Window refreshes at the position it was
-[FIX] Window slightly moved after refresh. Probably only fixed on MY Linux.
This commit is contained in:
15
mini.cpp
15
mini.cpp
@@ -26,6 +26,9 @@ uint8_t screen_zoom = 4;
|
||||
bool screen_fullscreen = false;
|
||||
bool screen_cursor = true;
|
||||
|
||||
int windowpos_x = SDL_WINDOWPOS_UNDEFINED;
|
||||
int windowpos_y = SDL_WINDOWPOS_UNDEFINED;
|
||||
|
||||
surface_t surfaces[10];
|
||||
surface_t *screen_surface = &surfaces[0];
|
||||
surface_t *dest_surface = screen_surface;
|
||||
@@ -58,6 +61,7 @@ bool should_quit = false;
|
||||
SDL_Window *mini_win;
|
||||
SDL_Renderer *mini_ren;
|
||||
SDL_Texture *mini_bak;
|
||||
Uint32 windowID;
|
||||
Uint32 *pixels;
|
||||
int pitch;
|
||||
|
||||
@@ -198,12 +202,14 @@ void setmap(uint8_t surface) {
|
||||
}
|
||||
|
||||
void createDisplay() {
|
||||
mini_win = SDL_CreateWindow(window_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, screen_width*screen_zoom, screen_height*screen_zoom, screen_fullscreen?SDL_WINDOW_FULLSCREEN_DESKTOP:SDL_WINDOW_SHOWN);
|
||||
mini_win = SDL_CreateWindow(window_title, windowpos_x, windowpos_y, screen_width*screen_zoom, screen_height*screen_zoom, screen_fullscreen?SDL_WINDOW_FULLSCREEN_DESKTOP:SDL_WINDOW_SHOWN);
|
||||
windowID = SDL_GetWindowID(mini_win);
|
||||
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(screen_cursor?SDL_ENABLE:SDL_DISABLE);
|
||||
mini_bak = SDL_CreateTexture(mini_ren, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, screen_width, screen_height);
|
||||
SDL_GetWindowPosition(mini_win, &windowpos_x, &windowpos_y);
|
||||
}
|
||||
|
||||
void destroyDisplay() {
|
||||
@@ -324,6 +330,13 @@ int main(int argc,char*argv[]){
|
||||
if (mini_eve.type == SDL_CONTROLLERBUTTONDOWN) {
|
||||
pad_just_pressed = mini_eve.cbutton.button;
|
||||
}
|
||||
if ( (mini_eve.type == SDL_WINDOWEVENT) &&
|
||||
(mini_eve.window.windowID == windowID) &&
|
||||
(mini_eve.window.event == SDL_WINDOWEVENT_MOVED) ) {
|
||||
windowpos_x = mini_eve.window.data1-4;
|
||||
windowpos_y = mini_eve.window.data2-36;
|
||||
//SDL_GetWindowPosition(mini_win, &windowpos_x, &windowpos_y);
|
||||
}
|
||||
}
|
||||
keys = SDL_GetKeyboardState(NULL);
|
||||
mouse_buttons = SDL_GetMouseState(&mouse_x, &mouse_y);
|
||||
|
||||
Reference in New Issue
Block a user