Discussion:
Android screen rotation issue: testdrawchessboard.c sample + alternate software renderer creation method
(too old to reply)
Michael Davies
2017-02-15 02:40:05 UTC
Permalink
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
Michael Davies
2017-02-15 23:27:55 UTC
Permalink
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:

SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0xFF);


to

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
Post by Michael Davies
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
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
Continue reading on narkive:
Loading...