Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…Headers into updates2

# Conflicts:
#	sdl.inc
  • Loading branch information
piXelicidio committed Sep 19, 2018
2 parents f0a505b + 31c6fb2 commit 66b3046
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 116 deletions.
File renamed without changes.
23 changes: 20 additions & 3 deletions README.md
@@ -1,4 +1,21 @@
Pascal-SDL-2-Headers
====================
# Pascal-SDL-2-Headers

This are the Pascal SDL 2 Headers.
These are the Pascal SDL 2 Headers.

## Installation

Just add the headers to your include path. Include sdl2.pas for the main SDL2 library (should be always needed). Furthermore headers for the other SDL2 libraries are provided:
- sdl2_image.pas
- sdl2_mixer.pas
- sdl2_net.pas
- sdl2_ttf.pas

## Bugs / Contributions

If you have any contributions, feel free to drop a pull request or send in a patch.

Same goes for bugs, please use the github issue tracker.

## License

You may license the Pascal SDL 2 Headers either with the MPL license or with the zlib license, both included.
20 changes: 10 additions & 10 deletions sdl.inc
Expand Up @@ -6,25 +6,25 @@ const
{$EXTERNALSYM SDL_INIT_TIMER}
SDL_INIT_AUDIO = $00000010;
{$EXTERNALSYM SDL_INIT_AUDIO}
SDL_INIT_VIDEO = $00000020;
SDL_INIT_VIDEO = $00000020; // SDL_INIT_VIDEO implies SDL_INIT_EVENTS
{$EXTERNALSYM SDL_INIT_VIDEO}
SDL_INIT_JOYSTICK = $00000200;
SDL_INIT_JOYSTICK = $00000200; // SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS
{$EXTERNALSYM SDL_INIT_JOYSTICK}
SDL_INIT_HAPTIC = $00001000;
{$EXTERNALSYM SDL_INIT_HAPTIC}
SDL_INIT_GAMECONTROLLER = $00002000; //turn on game controller also implicitly does JOYSTICK
{$EXTERNALSYM SDL_INIT_GAMECONTROLLER}
{$EXTERNALSYM SDL_INIT_GAMECONTROLLER}// SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK
SDL_INIT_EVENTS = $00004000;
{$EXTERNALSYM SDL_INIT_EVENTS}
SDL_INIT_NOPARACHUTE = $00100000; //Don't catch fatal signals
{$EXTERNALSYM SDL_INIT_NOPARACHUTE}
{$EXTERNALSYM SDL_INIT_NOPARACHUTE} // compatibility; this flag is ignored.
SDL_INIT_EVERYTHING = SDL_INIT_TIMER or
SDL_INIT_AUDIO or
SDL_INIT_VIDEO or
SDL_INIT_JOYSTICK or
SDL_INIT_HAPTIC or
SDL_INIT_GAMECONTROLLER OR
SDL_INIT_EVENTS;
SDL_INIT_AUDIO or
SDL_INIT_VIDEO or
SDL_INIT_EVENTS or
SDL_INIT_JOYSTICK or
SDL_INIT_HAPTIC or
SDL_INIT_GAMECONTROLLER;
{$EXTERNALSYM SDL_INIT_EVERYTHING}

{**
Expand Down
39 changes: 30 additions & 9 deletions sdl2.pas
Expand Up @@ -141,10 +141,11 @@ interface
{$IF DEFINED(UNIX) AND NOT DEFINED(ANDROID)}
uses
{$IFDEF DARWIN}
CocoaAll,
{$ENDIF}
CocoaAll;
{$ELSE}
X,
XLib;
{$ENDIF}
{$ENDIF}

const
Expand Down Expand Up @@ -212,7 +213,7 @@ interface
implementation

//from "sdl_version.h"
procedure SDL_VERSION(Out x: TSDL_Version);
procedure SDL_VERSION(out x: TSDL_Version);
begin
x.major := SDL_MAJOR_VERSION;
x.minor := SDL_MINOR_VERSION;
Expand Down Expand Up @@ -384,26 +385,45 @@ function SDL_LoadBMP(_file: PAnsiChar): PSDL_Surface;
Result := SDL_LoadBMP_RW(SDL_RWFromFile(_file, 'rb'), 1);
end;

function SDL_SaveBMP(Const surface:PSDL_Surface; Const filename:AnsiString):sInt32;
function SDL_SaveBMP(const surface: PSDL_Surface; const filename: AnsiString
): sInt32;
begin
Result := SDL_SaveBMP_RW(surface, SDL_RWFromFile(PAnsiChar(filename), 'wb'), 1)
end;

{**
* Evaluates to true if the surface needs to be locked before access.
*}
function SDL_MUSTLOCK(Const S:PSDL_Surface):Boolean;
function SDL_MUSTLOCK(const S: PSDL_Surface): Boolean;
begin
Result := ((S^.flags and SDL_RLEACCEL) <> 0)
end;

//from "sdl_sysvideo.h"

function FULLSCREEN_VISIBLE(W: PSDL_Window): Variant;
begin
Result := ((W^.flags and SDL_WINDOW_FULLSCREEN) and (W^.flags and SDL_WINDOW_SHOWN) and not (W^.flags and SDL_WINDOW_MINIMIZED));
end;

//from "sdl_video.h"
function SDL_WindowPos_IsUndefined(X: Variant): Variant;

function SDL_WINDOWPOS_UNDEFINED_DISPLAY(X: Variant): Variant;
begin
Result := (SDL_WINDOWPOS_UNDEFINED_MASK or X);
end;

function SDL_WINDOWPOS_ISUNDEFINED(X: Variant): Variant;
begin
Result := (X and $FFFF0000) = SDL_WINDOWPOS_UNDEFINED_MASK;
end;

function SDL_WindowPos_IsCentered(X: Variant): Variant;
function SDL_WINDOWPOS_CENTERED_DISPLAY(X: Variant): Variant;
begin
Result := (SDL_WINDOWPOS_CENTERED_MASK or X);
end;

function SDL_WINDOWPOS_ISCENTERED(X: Variant): Variant;
begin
Result := (X and $FFFF0000) = SDL_WINDOWPOS_CENTERED_MASK;
end;
Expand All @@ -416,7 +436,7 @@ function SDL_GetEventState(type_: UInt32): UInt8;
end;

// from "sdl_timer.h"
function SDL_TICKS_PASSED(Const A, B:UInt32):Boolean;
function SDL_TICKS_PASSED(const A, B: UInt32): Boolean;
begin
Result := ((Int64(B) - Int64(A)) <= 0)
end;
Expand All @@ -425,7 +445,8 @@ function SDL_TICKS_PASSED(Const A, B:UInt32):Boolean;
{**
* Load a set of mappings from a file, filtered by the current SDL_GetPlatform()
*}
function SDL_GameControllerAddMappingsFromFile(Const FilePath:PAnsiChar):SInt32;
function SDL_GameControllerAddMappingsFromFile(const FilePath: PAnsiChar
): SInt32;
begin
Result := SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(FilePath, 'rb'), 1)
end;
Expand Down
2 changes: 1 addition & 1 deletion sdl2_ttf.pas
Expand Up @@ -227,7 +227,7 @@ function TTF_RenderGlyph_Shaded(font: PTTF_Font; ch: UInt16; fg, bg: TSDL_Color)
*}
function TTF_RenderText_Blended(font: PTTF_Font; text: PAnsiChar; fg: TSDL_Color): PSDL_Surface cdecl; external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderText_Blended' {$ENDIF} {$ENDIF};
function TTF_RenderUTF8_Blended(font: PTTF_Font; text: PAnsiChar; fg: TSDL_Color): PSDL_Surface cdecl; external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderUTF8_Blended' {$ENDIF} {$ENDIF};
function TTF_RenderUNICODE_Blended(font: PTTF_Font; text: UInt16; fg: TSDL_Color): PSDL_Surface cdecl; external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderUNICODE_Blended' {$ENDIF} {$ENDIF};
function TTF_RenderUNICODE_Blended(font: PTTF_Font; text: PUInt16; fg: TSDL_Color): PSDL_Surface cdecl; external TTF_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_TTF_RenderUNICODE_Blended' {$ENDIF} {$ENDIF};

{* Create a 32-bit ARGB surface and render the given text at high quality,
using alpha blending to dither the font with the given color.
Expand Down
4 changes: 3 additions & 1 deletion sdlsyswm.inc
Expand Up @@ -5,7 +5,9 @@
{$ENDIF}

{$IF DEFINED (LINUX) OR DEFINED(UNIX) AND NOT DEFINED(ANDROID)}
{$DEFINE SDL_VIDEO_DRIVER_X11}
{$IFNDEF DARWIN}
{$DEFINE SDL_VIDEO_DRIVER_X11}
{$ENDIF}
{$IFEND}

{$IFDEF DARWIN}
Expand Down

0 comments on commit 66b3046

Please sign in to comment.