Need some thoughts: SDL on Android vs PC

I’m seeing what I consider an odd difference when it comes to coordinates on android vs my pc. I’m mostly an SDL noob, so I’m hoping this is something simple. I’m doing some very basic collision detection in the Y direction. I have two rect’s falling (dillo1 & dillo2), and I stop updating their position when they ‘collide’ with the static rect (ground1). Here’s the basic code:

if((dillo1.dstRect.y + dillo1.getHeight()) < ground1.rect.y) {
    dillo1.dstRect.y += 3;
}
if((dillo2.dstRect.y + dillo2.getHeight()) < ground1.rect.y) {
    dillo2.dstRect.y += 5;
}		

When I compile and run this on my PC, it works fine (the moving rect’s stop when the bottom of them hit the top of the static rect). I’d show you, but I only can embed one media item in my post since I’m a new user. I’ll embed the android one that isn’t working as I’d expect.

So when I run the same code on my Samsung Galaxy S9, this happens:

As you can see, there’s 2 ‘dillo’ lengths between the bottom of them and the top of the ground. When I change the code to this (just switching + to -):

if((dillo1.dstRect.y - dillo1.getHeight()) < ground1.rect.y) {
    dillo1.dstRect.y += 3;
}
if((dillo2.dstRect.y - dillo2.getHeight()) < ground1.rect.y) {
    dillo2.dstRect.y += 5;
}

It works as I’d expect on Android, but not on PC. Other than the cpp code, I’m using the out of the box android project that comes with the SDL source code. I’m sure I’m missing something simple here, but can’t seem to figure it out when googling around. Any thoughts or pointers would be appreciated.

Newfound information:

If I change this line:

gRenderer = SDL_CreateRenderer(gWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);

to this:

gRenderer = SDL_CreateRenderer(gWindow, -1, SDL_RENDERER_SOFTWARE);

It works on both platforms. Obviously I don’t want to use a software renderer though. Still hoping to get some thoughts

Have you checked what .getHeight() is actually returning (on both devices)?

Yes, getHeight() is just a getter on my Dillo class that returns a hardcoded 157

Hey Sean. Yes, getHeight() is just a getter on my Dillo class that returns a hardcoded 157 and it returns 157 on both platforms.

Sounds like the coordinate system origin is different on your Android device vs PC.

It should be the top left on both, but seems like it’s at the bottom left on your device when rotated that way. What happens when you rotate it to landscape the opposite direction?

I’ve been thinking it’s related to that too, sjr. Regardless of which way I flip my phone the same thing happens. I’ve also changed:

        <activity android:name="SDLActivity"
            android:screenOrientation="landscape"

to:

        <activity android:name="SDLActivity"
            android:screenOrientation="reverseLandscape"

so the app would startup in the different orientations. This did not help either. Is there a different way I could/should specify landscape mode? And for what reasons could software rendering vs accelerated rendering throw off the coordinate system?