- [FIX] El ratolí ja va correctament en pantalla completa.
- [FIX] Els shaders ja van correctament a pantalla completa.
This commit is contained in:
@@ -28,6 +28,8 @@ namespace draw
|
|||||||
static int desktop_height;
|
static int desktop_height;
|
||||||
static int window_width;
|
static int window_width;
|
||||||
static int window_height;
|
static int window_height;
|
||||||
|
static int offset_x = 0;
|
||||||
|
static int offset_y = 0;
|
||||||
char window_title[256];
|
char window_title[256];
|
||||||
|
|
||||||
surface *screen {nullptr}; // La superficie screen, que representa la pantalla. Se crea i destrueix internament
|
surface *screen {nullptr}; // La superficie screen, que representa la pantalla. Se crea i destrueix internament
|
||||||
@@ -64,9 +66,21 @@ namespace draw
|
|||||||
window_width = canvas_width*screen_zoom;
|
window_width = canvas_width*screen_zoom;
|
||||||
window_height = window_ratio != 1 ? int(float(canvas_width)*window_ratio*float(screen_zoom)) : canvas_height*screen_zoom;
|
window_height = window_ratio != 1 ? int(float(canvas_width)*window_ratio*float(screen_zoom)) : canvas_height*screen_zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (screen_fullscreen) {
|
if (screen_fullscreen) {
|
||||||
window_width = desktop_width;
|
if (desktop_width * window_ratio > desktop_height) {
|
||||||
window_height = desktop_height;
|
offset_y = 0;
|
||||||
|
window_height = desktop_height;
|
||||||
|
window_width = desktop_height/window_ratio;
|
||||||
|
offset_x = (desktop_width - window_width)/2;
|
||||||
|
} else {
|
||||||
|
offset_x = 0;
|
||||||
|
window_width = desktop_width;
|
||||||
|
window_height = desktop_width*window_ratio;
|
||||||
|
offset_y = (desktop_height - window_height)/2;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
offset_x = offset_y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sdl_window = SDL_CreateWindow(window_title, window_width, window_height, SDL_WINDOW_OPENGL|(screen_fullscreen?SDL_WINDOW_FULLSCREEN:0));
|
sdl_window = SDL_CreateWindow(window_title, window_width, window_height, SDL_WINDOW_OPENGL|(screen_fullscreen?SDL_WINDOW_FULLSCREEN:0));
|
||||||
@@ -200,6 +214,16 @@ namespace draw
|
|||||||
return float(window_height) / float(canvas_height);
|
return float(window_height) / float(canvas_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int getOffsetX()
|
||||||
|
{
|
||||||
|
return offset_x;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int getOffsetY()
|
||||||
|
{
|
||||||
|
return offset_y;
|
||||||
|
}
|
||||||
|
|
||||||
bool getFullscreen() {
|
bool getFullscreen() {
|
||||||
return screen_fullscreen;
|
return screen_fullscreen;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ namespace draw
|
|||||||
const int getZoom();
|
const int getZoom();
|
||||||
const float getScaleX();
|
const float getScaleX();
|
||||||
const float getScaleY();
|
const float getScaleY();
|
||||||
|
const int getOffsetX();
|
||||||
|
const int getOffsetY();
|
||||||
|
|
||||||
bool getFullscreen();
|
bool getFullscreen();
|
||||||
void setFullscreen(const bool value);
|
void setFullscreen(const bool value);
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ namespace input
|
|||||||
{
|
{
|
||||||
float x;
|
float x;
|
||||||
SDL_GetMouseState(&x, NULL);
|
SDL_GetMouseState(&x, NULL);
|
||||||
return x/draw::getScaleX();
|
return (x-draw::getOffsetX())/draw::getScaleX();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Torna la posició Y actual del ratolí
|
// Torna la posició Y actual del ratolí
|
||||||
@@ -87,7 +87,7 @@ namespace input
|
|||||||
{
|
{
|
||||||
float y;
|
float y;
|
||||||
SDL_GetMouseState(NULL, &y);
|
SDL_GetMouseState(NULL, &y);
|
||||||
return y/draw::getScaleY();
|
return (y-draw::getOffsetY())/draw::getScaleY();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determina si el botó del ratolí especificat està sent polsada ara mateix
|
// Determina si el botó del ratolí especificat està sent polsada ara mateix
|
||||||
|
|||||||
Reference in New Issue
Block a user