updated SDL wrapper
This commit is contained in:
parent
03744be67e
commit
e7140f290b
8 changed files with 732 additions and 747 deletions
|
|
@ -177,78 +177,78 @@ const
|
|||
UNICODE_BOM_SWAPPED* = 0x0000FFFE
|
||||
|
||||
type
|
||||
PFont* = ptr Tfont
|
||||
TFont{.final.} = object
|
||||
PFont* = ptr TFont
|
||||
TFont = object
|
||||
|
||||
|
||||
# This macro can be used to fill a version structure with the compile-time
|
||||
# version of the SDL_ttf library.
|
||||
|
||||
proc Linked_Version*(): sdl.Pversion{.cdecl, importc: "TTF_Linked_Version",
|
||||
proc linkedVersion*(): sdl.Pversion{.cdecl, importc: "TTF_Linked_Version",
|
||||
dynlib: ttfLibName.}
|
||||
# This function tells the library whether UNICODE text is generally
|
||||
# byteswapped. A UNICODE BOM character in a string will override
|
||||
# this setting for the remainder of that string.
|
||||
#
|
||||
proc ByteSwappedUNICODE*(swapped: cint){.cdecl,
|
||||
proc byteSwappedUNICODE*(swapped: cint){.cdecl,
|
||||
importc: "TTF_ByteSwappedUNICODE", dynlib: ttfLibName.}
|
||||
#returns 0 on succes, -1 if error occurs
|
||||
proc Init*(): cint{.cdecl, importc: "TTF_Init", dynlib: ttfLibName.}
|
||||
proc init*(): cint{.cdecl, importc: "TTF_Init", dynlib: ttfLibName.}
|
||||
#
|
||||
# Open a font file and create a font of the specified point size.
|
||||
# Some .fon fonts will have several sizes embedded in the file, so the
|
||||
# point size becomes the index of choosing which size. If the value
|
||||
# is too high, the last indexed size will be the default.
|
||||
#
|
||||
proc OpenFont*(filename: cstring, ptsize: cint): PFont{.cdecl,
|
||||
proc openFont*(filename: cstring, ptsize: cint): PFont{.cdecl,
|
||||
importc: "TTF_OpenFont", dynlib: ttfLibName.}
|
||||
proc OpenFontIndex*(filename: cstring, ptsize: cint, index: int32): PFont{.
|
||||
proc openFontIndex*(filename: cstring, ptsize: cint, index: int32): PFont{.
|
||||
cdecl, importc: "TTF_OpenFontIndex", dynlib: ttfLibName.}
|
||||
proc OpenFontRW*(src: PRWops, freesrc: cint, ptsize: cint): PFont{.cdecl,
|
||||
proc openFontRW*(src: PRWops, freesrc: cint, ptsize: cint): PFont{.cdecl,
|
||||
importc: "TTF_OpenFontRW", dynlib: ttfLibName.}
|
||||
proc OpenFontIndexRW*(src: PRWops, freesrc: cint, ptsize: cint, index: int32): PFont{.
|
||||
proc openFontIndexRW*(src: PRWops, freesrc: cint, ptsize: cint, index: int32): PFont{.
|
||||
cdecl, importc: "TTF_OpenFontIndexRW", dynlib: ttfLibName.}
|
||||
proc GetFontStyle*(font: PFont): cint{.cdecl,
|
||||
proc getFontStyle*(font: PFont): cint{.cdecl,
|
||||
importc: "TTF_GetFontStyle", dynlib: ttfLibName.}
|
||||
proc SetFontStyle*(font: PFont, style: cint){.cdecl,
|
||||
proc setFontStyle*(font: PFont, style: cint){.cdecl,
|
||||
importc: "TTF_SetFontStyle", dynlib: ttfLibName.}
|
||||
# Get the total height of the font - usually equal to point size
|
||||
proc FontHeight*(font: PFont): cint{.cdecl, importc: "TTF_FontHeight",
|
||||
proc fontHeight*(font: PFont): cint{.cdecl, importc: "TTF_FontHeight",
|
||||
dynlib: ttfLibName.}
|
||||
# Get the offset from the baseline to the top of the font
|
||||
# This is a positive value, relative to the baseline.
|
||||
#
|
||||
proc FontAscent*(font: PFont): cint{.cdecl, importc: "TTF_FontAscent",
|
||||
proc fontAscent*(font: PFont): cint{.cdecl, importc: "TTF_FontAscent",
|
||||
dynlib: ttfLibName.}
|
||||
# Get the offset from the baseline to the bottom of the font
|
||||
# This is a negative value, relative to the baseline.
|
||||
#
|
||||
proc FontDescent*(font: PFont): cint{.cdecl, importc: "TTF_FontDescent",
|
||||
proc fontDescent*(font: PFont): cint{.cdecl, importc: "TTF_FontDescent",
|
||||
dynlib: ttfLibName.}
|
||||
# Get the recommended spacing between lines of text for this font
|
||||
proc FontLineSkip*(font: PFont): cint{.cdecl,
|
||||
proc fontLineSkip*(font: PFont): cint{.cdecl,
|
||||
importc: "TTF_FontLineSkip", dynlib: ttfLibName.}
|
||||
# Get the number of faces of the font
|
||||
proc FontFaces*(font: PFont): int32{.cdecl, importc: "TTF_FontFaces",
|
||||
proc fontFaces*(font: PFont): int32{.cdecl, importc: "TTF_FontFaces",
|
||||
dynlib: ttfLibName.}
|
||||
# Get the font face attributes, if any
|
||||
proc FontFaceIsFixedWidth*(font: PFont): cint{.cdecl,
|
||||
proc fontFaceIsFixedWidth*(font: PFont): cint{.cdecl,
|
||||
importc: "TTF_FontFaceIsFixedWidth", dynlib: ttfLibName.}
|
||||
proc FontFaceFamilyName*(font: PFont): cstring{.cdecl,
|
||||
proc fontFaceFamilyName*(font: PFont): cstring{.cdecl,
|
||||
importc: "TTF_FontFaceFamilyName", dynlib: ttfLibName.}
|
||||
proc FontFaceStyleName*(font: PFont): cstring{.cdecl,
|
||||
proc fontFaceStyleName*(font: PFont): cstring{.cdecl,
|
||||
importc: "TTF_FontFaceStyleName", dynlib: ttfLibName.}
|
||||
# Get the metrics (dimensions) of a glyph
|
||||
proc GlyphMetrics*(font: PFont, ch: Uint16, minx: var cint,
|
||||
proc glyphMetrics*(font: PFont, ch: uint16, minx: var cint,
|
||||
maxx: var cint, miny: var cint, maxy: var cint,
|
||||
advance: var cint): cint{.cdecl,
|
||||
importc: "TTF_GlyphMetrics", dynlib: ttfLibName.}
|
||||
# Get the dimensions of a rendered string of text
|
||||
proc SizeText*(font: PFont, text: cstring, w: var cint, y: var cint): cint{.
|
||||
proc sizeText*(font: PFont, text: cstring, w: var cint, y: var cint): cint{.
|
||||
cdecl, importc: "TTF_SizeText", dynlib: ttfLibName.}
|
||||
proc SizeUTF8*(font: PFont, text: cstring, w: var cint, y: var cint): cint{.
|
||||
proc sizeUTF8*(font: PFont, text: cstring, w: var cint, y: var cint): cint{.
|
||||
cdecl, importc: "TTF_SizeUTF8", dynlib: ttfLibName.}
|
||||
proc SizeUNICODE*(font: PFont, text: PUint16, w: var cint, y: var cint): cint{.
|
||||
proc sizeUNICODE*(font: PFont, text: PUInt16, w: var cint, y: var cint): cint{.
|
||||
cdecl, importc: "TTF_SizeUNICODE", dynlib: ttfLibName.}
|
||||
# Create an 8-bit palettized surface and render the given text at
|
||||
# fast quality with the given font and color. The 0 pixel is the
|
||||
|
|
@ -256,9 +256,9 @@ proc SizeUNICODE*(font: PFont, text: PUint16, w: var cint, y: var cint): cint{.
|
|||
# to the text color.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc RenderUTF8_Solid*(font: PFont, text: cstring, fg: TColor): PSurface{.
|
||||
proc renderUTF8Solid*(font: PFont, text: cstring, fg: TColor): PSurface{.
|
||||
cdecl, importc: "TTF_RenderUTF8_Solid", dynlib: ttfLibName.}
|
||||
proc RenderUNICODE_Solid*(font: PFont, text: PUint16, fg: TColor): PSurface{.
|
||||
proc renderUNICODE_Solid*(font: PFont, text: PUInt16, fg: TColor): PSurface{.
|
||||
cdecl, importc: "TTF_RenderUNICODE_Solid", dynlib: ttfLibName.}
|
||||
#
|
||||
#Create an 8-bit palettized surface and render the given glyph at
|
||||
|
|
@ -268,20 +268,20 @@ proc RenderUNICODE_Solid*(font: PFont, text: PUint16, fg: TColor): PSurface{.
|
|||
# centering in the X direction, and aligned normally in the Y direction.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc RenderGlyph_Solid*(font: PFont, ch: Uint16, fg: TColor): PSurface{.
|
||||
proc renderGlyphSolid*(font: PFont, ch: uint16, fg: TColor): PSurface{.
|
||||
cdecl, importc: "TTF_RenderGlyph_Solid", dynlib: ttfLibName.}
|
||||
# Create an 8-bit palettized surface and render the given text at
|
||||
# high quality with the given font and colors. The 0 pixel is background,
|
||||
# while other pixels have varying degrees of the foreground color.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc RenderText_Shaded*(font: PFont, text: cstring, fg: TColor,
|
||||
proc renderTextShaded*(font: PFont, text: cstring, fg: TColor,
|
||||
bg: TColor): PSurface{.cdecl,
|
||||
importc: "TTF_RenderText_Shaded", dynlib: ttfLibName.}
|
||||
proc RenderUTF8_Shaded*(font: PFont, text: cstring, fg: TColor,
|
||||
proc renderUTF8Shaded*(font: PFont, text: cstring, fg: TColor,
|
||||
bg: TColor): PSurface{.cdecl,
|
||||
importc: "TTF_RenderUTF8_Shaded", dynlib: ttfLibName.}
|
||||
proc RenderUNICODE_Shaded*(font: PFont, text: PUint16, fg: TColor,
|
||||
proc renderUNICODE_Shaded*(font: PFont, text: PUInt16, fg: TColor,
|
||||
bg: TColor): PSurface{.cdecl,
|
||||
importc: "TTF_RenderUNICODE_Shaded", dynlib: ttfLibName.}
|
||||
# Create an 8-bit palettized surface and render the given glyph at
|
||||
|
|
@ -291,17 +291,17 @@ proc RenderUNICODE_Shaded*(font: PFont, text: PUint16, fg: TColor,
|
|||
# direction, and aligned normally in the Y direction.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc RenderGlyph_Shaded*(font: PFont, ch: Uint16, fg: TColor, bg: TColor): PSurface{.
|
||||
proc renderGlyphShaded*(font: PFont, ch: uint16, fg: TColor, bg: TColor): PSurface{.
|
||||
cdecl, importc: "TTF_RenderGlyph_Shaded", dynlib: ttfLibName.}
|
||||
# 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.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc RenderText_Blended*(font: PFont, text: cstring, fg: TColor): PSurface{.
|
||||
proc renderTextBlended*(font: PFont, text: cstring, fg: TColor): PSurface{.
|
||||
cdecl, importc: "TTF_RenderText_Blended", dynlib: ttfLibName.}
|
||||
proc RenderUTF8_Blended*(font: PFont, text: cstring, fg: TColor): PSurface{.
|
||||
proc renderUTF8Blended*(font: PFont, text: cstring, fg: TColor): PSurface{.
|
||||
cdecl, importc: "TTF_RenderUTF8_Blended", dynlib: ttfLibName.}
|
||||
proc RenderUNICODE_Blended*(font: PFont, text: PUint16, fg: TColor): PSurface{.
|
||||
proc RenderUNICODE_Blended*(font: PFont, text: PUInt16, fg: TColor): PSurface{.
|
||||
cdecl, importc: "TTF_RenderUNICODE_Blended", dynlib: ttfLibName.}
|
||||
# Create a 32-bit ARGB surface and render the given glyph at high quality,
|
||||
# using alpha blending to dither the font with the given color.
|
||||
|
|
@ -309,29 +309,29 @@ proc RenderUNICODE_Blended*(font: PFont, text: PUint16, fg: TColor): PSurface{.
|
|||
# direction, and aligned normally in the Y direction.
|
||||
# This function returns the new surface, or NULL if there was an error.
|
||||
#
|
||||
proc RenderGlyph_Blended*(font: PFont, ch: Uint16, fg: TColor): PSurface{.
|
||||
proc renderGlyphBlended*(font: PFont, ch: uint16, fg: TColor): PSurface{.
|
||||
cdecl, importc: "TTF_RenderGlyph_Blended", dynlib: ttfLibName.}
|
||||
# For compatibility with previous versions, here are the old functions
|
||||
##define TTF_RenderText(font, text, fg, bg)
|
||||
# #define TTF_RenderText(font, text, fg, bg)
|
||||
# TTF_RenderText_Shaded(font, text, fg, bg)
|
||||
##define TTF_RenderUTF8(font, text, fg, bg)
|
||||
# #define TTF_RenderUTF8(font, text, fg, bg)
|
||||
# TTF_RenderUTF8_Shaded(font, text, fg, bg)
|
||||
##define TTF_RenderUNICODE(font, text, fg, bg)
|
||||
# #define TTF_RenderUNICODE(font, text, fg, bg)
|
||||
# TTF_RenderUNICODE_Shaded(font, text, fg, bg)
|
||||
# Close an opened font file
|
||||
proc CloseFont*(font: PFont){.cdecl, importc: "TTF_CloseFont",
|
||||
# Close an opened font file
|
||||
proc closeFont*(font: PFont){.cdecl, importc: "TTF_CloseFont",
|
||||
dynlib: ttfLibName.}
|
||||
#De-initialize TTF engine
|
||||
proc Quit*(){.cdecl, importc: "TTF_Quit", dynlib: ttfLibName.}
|
||||
# De-initialize TTF engine
|
||||
proc quit*(){.cdecl, importc: "TTF_Quit", dynlib: ttfLibName.}
|
||||
# Check if the TTF engine is initialized
|
||||
proc WasInit*(): cint{.cdecl, importc: "TTF_WasInit", dynlib: ttfLibName.}
|
||||
proc wasInit*(): cint{.cdecl, importc: "TTF_WasInit", dynlib: ttfLibName.}
|
||||
|
||||
|
||||
proc VERSION*(X: var sdl.Tversion) =
|
||||
X.major = MAJOR_VERSION
|
||||
X.minor = MINOR_VERSION
|
||||
X.patch = PATCHLEVEL
|
||||
proc version*(x: var sdl.Tversion) =
|
||||
x.major = MAJOR_VERSION
|
||||
x.minor = MINOR_VERSION
|
||||
x.patch = PATCHLEVEL
|
||||
|
||||
|
||||
proc RenderText_Solid*(font: PFont, text: cstring, fg: TColor): PSurface{.
|
||||
proc renderTextSolid*(font: PFont, text: cstring, fg: TColor): PSurface{.
|
||||
cdecl, importc: "TTF_RenderText_Solid", dynlib: ttfLibName.}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue