Bladeren bron

ui: fix mouse coordinates handling when the window is resized.

legacy
Sam Hocevar 5 jaren geleden
bovenliggende
commit
6af1481c8e
4 gewijzigde bestanden met toevoegingen van 6 en 7 verwijderingen
  1. +1
    -1
      src/application/egl-app.cpp
  2. +1
    -1
      src/application/sdl-app.cpp
  3. +3
    -4
      src/ui/sdl-input.cpp
  4. +1
    -1
      src/ui/sdl-input.h

+ 1
- 1
src/application/egl-app.cpp Bestand weergeven

@@ -245,7 +245,7 @@ EglApp::EglApp(char const *title, ivec2 res, float fps) :
# endif

# if LOL_USE_SDL
new SdlInput(res.x, res.y, data->screen_size.x, data->screen_size.y);
new SdlInput(data->screen_size.x, data->screen_size.y);
# endif

Video::Setup((ivec2)data->screen_size);


+ 1
- 1
src/application/sdl-app.cpp Bestand weergeven

@@ -162,7 +162,7 @@ sdl::app::app(char const *title, ivec2 res, float fps)
new D3d9Input();
#endif

new SdlInput(res.x, res.y, screen_size.x, screen_size.y);
new SdlInput(screen_size.x, screen_size.y);
#endif
}



+ 3
- 4
src/ui/sdl-input.cpp Bestand weergeven

@@ -43,9 +43,8 @@ namespace lol
* Public SdlInput class
*/

SdlInput::SdlInput(int app_w, int app_h, int screen_w, int screen_h)
: m_app(vec2((float)app_w, (float)app_h)),
m_screen(vec2((float)screen_w, (float)screen_h))
SdlInput::SdlInput(int screen_w, int screen_h)
: m_screen(vec2((float)screen_w, (float)screen_h))
{
#if _WIN32 || defined __APPLE__
m_tick_in_draw_thread = true;
@@ -247,7 +246,7 @@ void SdlInput::tick(float seconds)
ivec2 window_size;
// FIXME: get actual window size
//SDL_GetWindowSize(m_window, &window_size.x, &window_size.y);
window_size = (ivec2)m_app;
window_size = Video::GetSize();

ivec2 mouse_pos(-1, -1);
SDL_GetMouseState(&mouse_pos.x, &mouse_pos.y);


+ 1
- 1
src/ui/sdl-input.h Bestand weergeven

@@ -36,7 +36,7 @@ class SdlInput : public entity
{
public:
/** passing the screen resolution (note: not the windowed app resolution!) allows to make the mouse axis resolution-independent */
SdlInput(int app_w, int app_h, int screen_w, int screen_h);
SdlInput(int screen_w, int screen_h);

virtual ~SdlInput();
void SetScreenResolution();


Laden…
Annuleren
Opslaan