Simple Directmedia Layer

examples/pen/01-drawing-lines: Match render target size to renderer output.

Otherwise, on HiDPI displays (like a retina iPad), the lines you draw don't
match where the pen is touching.

Changed files
+6 -1
examples
pen
01-drawing-lines
+6 -1
examples/pen/01-drawing-lines/drawing-lines.c
··· 23 /* This function runs once at startup. */ 24 SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) 25 { 26 SDL_SetAppMetadata("Example Pen Drawing Lines", "1.0", "com.example.pen-drawing-lines"); 27 28 if (!SDL_Init(SDL_INIT_VIDEO)) { ··· 37 38 /* we make a render target so we can draw lines to it and not have to record and redraw every pen stroke each frame. 39 Instead rendering a frame for us is a single texture draw. */ 40 - render_target = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, 640, 480); 41 if (!render_target) { 42 SDL_Log("Couldn't create render target: %s", SDL_GetError()); 43 return SDL_APP_FAILURE;
··· 23 /* This function runs once at startup. */ 24 SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[]) 25 { 26 + int w, h; 27 + 28 SDL_SetAppMetadata("Example Pen Drawing Lines", "1.0", "com.example.pen-drawing-lines"); 29 30 if (!SDL_Init(SDL_INIT_VIDEO)) { ··· 39 40 /* we make a render target so we can draw lines to it and not have to record and redraw every pen stroke each frame. 41 Instead rendering a frame for us is a single texture draw. */ 42 + 43 + /* make sure the render target matches output size (for hidpi displays, etc) so drawing matches the pen's position on a tablet display. */ 44 + SDL_GetRenderOutputSize(renderer, &w, &h); 45 + render_target = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, w, h); 46 if (!render_target) { 47 SDL_Log("Couldn't create render target: %s", SDL_GetError()); 48 return SDL_APP_FAILURE;