Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sdlrender.inc to 2.0.22 #48

Conversation

suve
Copy link
Collaborator

@suve suve commented Apr 30, 2022

This patch adds missing type and function definitions, updating sdlrenderer.inc to SDL 2.0.22. Solves issue #47.

This patch omits the SDL_RenderGetMetalLayer() and SDL_RenderGetMetalCommandEncoder() functions. FPC doesn't have units for working with Metal, so these will be of very limited use to anyone. We may still do it for completeness sake, though.

@Free-Pascal-meets-SDL-Website
Copy link
Collaborator

Thanks for this work!

This patch omits the SDL_RenderGetMetalLayer() and SDL_RenderGetMetalCommandEncoder() functions. FPC doesn't have units for working with Metal, so these will be of very limited use to anyone. We may still do it for completeness sake, though.

I agree we shouldn't omit these, we don't know if in the future there will be support or someone may need these for whatever reason we can't think of. This can be a task for a later update. Maybe we create an issue about this.

Some ideas to the PR:

  1. We should rename the file to sdlrender.inc (as the C-include is SDL_render.h).
  2. The enums should be adapted accord. to our code style guidelines (see example below).
  3. Comments should be retained.

Line 39+

  PSDL_ScaleMode = ^TSDL_ScaleMode;
  TSDL_ScaleMode = (
    SDL_ScaleModeNearest,
    SDL_ScaleModeLinear,
    SDL_ScaleModeBest
  ); 

According to out style guide it should be like:

C:

typedef enum
{
   SDL_JOYSTICK_POWER_UNKNOWN = -1,
   SDL_JOYSTICK_POWER_EMPTY,   /* <= 5% */
   SDL_JOYSTICK_POWER_LOW,     /* <= 20% */
   SDL_JOYSTICK_POWER_MEDIUM,  /* <= 70% */
   SDL_JOYSTICK_POWER_FULL,    /* <= 100% */
   SDL_JOYSTICK_POWER_WIRED,
   SDL_JOYSTICK_POWER_MAX
} SDL_JoystickPowerLevel;

Pascal:

type
  TSDL_JoystickPowerLevel = type Integer;

const
  SDL_JOYSTICK_POWER_UNKNOWN = TSDL_JoystickPowerLevel(-1);
  SDL_JOYSTICK_POWER_EMPTY   = TSDL_JoystickPowerLevel(0);  {* <= 5% *}
  SDL_JOYSTICK_POWER_LOW     = TSDL_JoystickPowerLevel(1);  {* <= 20% *}
  SDL_JOYSTICK_POWER_MEDIUM  = TSDL_JoystickPowerLevel(2);  {* <= 70% *}
  SDL_JOYSTICK_POWER_FULL    = TSDL_JoystickPowerLevel(3);  {* <= 100% *}
  SDL_JOYSTICK_POWER_WIRED   = TSDL_JoystickPowerLevel(4);
  SDL_JOYSTICK_POWER_MAX     = TSDL_JoystickPowerLevel(5);

Hint 1: C enums start at 0 if no explicit value is set.

What do you think? Best regards

@suve
Copy link
Collaborator Author

suve commented May 21, 2022

Changed enumeration types to type aliases and added the Metal functions.

@Free-Pascal-meets-SDL-Website
Copy link
Collaborator

Thanks, excellent work!

@Free-Pascal-meets-SDL-Website Free-Pascal-meets-SDL-Website merged commit b4bada6 into PascalGameDevelopment:master May 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants