I use libSDL2 and make use of the Cliprect.

Simplified I have this code:

SDL_Window* window = SDL_CreateWindow(
     "foo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
     1024, 768, SDL_WINDOW_SHOWN);
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1,
      SDL_RENDERER_ACCELERATED |  SDL_RENDERER_TARGETTEXTURE);
SDL_Texture* offscreenTexture = SDL_CreateTexture(
     renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, 
     1024, 768);

SDL_Rect sdlRect = { 100, 100, 200, 200 };
SDL_RenderSetClipRect(renderer, &sdlRect);

I noticed that SDL_RenderSetClipRect works different on different platforms: On each one the clipping rectangle has a size of 200x200. On some platforms the y = 100 is measured from top of the screen (as I expected) and on some platforms it is measured from bottom.

          1024                       1024
|---------------------|          |---------------------|
|   100               |          |                     |
|   *****             |          |                     |
|   *****             |          |                     |
|   *****             |   768    |                     |
|                     |          |   *****             |
|                     |          |   *****             |
|                     |          |   *****             |
|                     |          |   100               |
|---------------------|          |---------------------|

Why? How can I tell the two cases apart?

1

There are 1 answers

1
skypjack On BEST ANSWER

It seems to be due to an already fixed and then reopened bug of SDL.
See here for further details.

Trying to sum up the discussion, it could be due to the fact that OpenGL coordinate system has (0,0) at the bottom left and SDL didn't correctly abstract over it, while SDL should give the users the abstraction of a coherent coordinate system with origin set to the top left.

The information in the bug are consistent with what you provide as a response to my question in the comment. I suggest you to follow that bug and update SDL to get the latest from the upstream.