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 screen rotation issue: testdrawchessboard.c sample +
Michael Davies
Guest

Hi all,


If I build the testdrawchessboard.c sample (the software renderer demo) for Android and run it on a device, I can rotate the device to change orientation and the chessboard follows as expected. However, if I change the method of creating the software renderer (around line 110) from:



    surface = SDL_GetWindowSurface(window);
    renderer = SDL_CreateSoftwareRenderer(surface);



to


    renderer = SDL_CreateRenderer( window, -1, SDL_RENDERER_SOFTWARE | SDL_RENDERER_TARGETTEXTURE );



then when I launch the app, rotating the device to change orientation results in the screen going black until I restart the app.


Is my alternative method of creating a software renderer invalid, or is this a bug in SDL2?


Tested with Mercurial tip code (as of last night) using an HTC One M8 and Samsung Galaxy Note 4.


Thanks in advance,
Michael
Android screen rotation issue: testdrawchessboard.c sample +
Michael Davies
Guest

The plot thickens! I've discovered the testdrawchessboard.c sample is actually broken on Android, at least in my environment (latest SDL2 source from Mercurial, Android 7.0 (SDK 24), Android NDK 13.1). With no modifications to the sample source code, once the screen rotates, the software renderer no longer updates the screen, but it does keep the last image it rendered hanging around. I believe this bug has gone unnoticed because the DrawChessboard() method draws a static image, so it's entirely not obvious when the software renderer breaks and appears as if the sample is working. If you modify this line in DrawChessboard() from: 

Quote:
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0xFF);
to 

Quote:
SDL_SetRenderDrawColor(renderer, rand()%255, rand()%255, rand()%255, 0xFF);
it will turn the chessboard into a disco floor, and it will become obvious when the renderer stops updating the screen.


Cheers,
Michael

On 15 February 2017 at 13:40, Michael Davies wrote:
Quote:
Hi all,


If I build the testdrawchessboard.c sample (the software renderer demo) for Android and run it on a device, I can rotate the device to change orientation and the chessboard follows as expected. However, if I change the method of creating the software renderer (around line 110) from:



    surface = SDL_GetWindowSurface(window);
    renderer = SDL_CreateSoftwareRenderer(surface);



to


    renderer = SDL_CreateRenderer( window, -1, SDL_RENDERER_SOFTWARE | SDL_RENDERER_TARGETTEXTURE );



then when I launch the app, rotating the device to change orientation results in the screen going black until I restart the app.


Is my alternative method of creating a software renderer invalid, or is this a bug in SDL2?


Tested with Mercurial tip code (as of last night) using an HTC One M8 and Samsung Galaxy Note 4.


Thanks in advance,
Michael