The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Android touch event and resolution problem
Lazy Kitty


Joined: 01 May 2014
Posts: 3
I've been trying to get the pixel coordinates from the SDL_FINGERDOWN event, but I seem to need the screen resolution for this to work.

I created my window using
Code:
SDL_CreateWindowAndRenderer(0, 0, 0, &window, &renderer) < 0)


And everything I've tried to get a resolution from my window or renderer.

Code:

SDL_GetWindowSize(window, windowWidth, windowHeight);
SDL_GetRendererOutputSize(renderer, windowWidth, windowHeight);
SDL_GL_GetDrawableSize(window, windowWidth, windowHeight);


Those just seem to return a 0x0 resolution.

And

Code:
SDL_GetWindowSurface(window)


Just crashes my app when I try to get the width or height from the surface.

Does anyone have any other ideas on how to get it to work?
Lazy Kitty


Joined: 01 May 2014
Posts: 3
After trying some other things to work around this and failing horribly, I read around in the code a little bit and found out about DisplayMode in SDL_AndroidVideo.c.

I've managed to get the resolution with

Code:

SDL_DisplayMode display;
SDL_GetCurrentDisplayMode(0, &display);
windowWidth = display.w;
windowHeight = display.h;