initial commit of DSFML2
some basic things work, much still has to be done - made as few changes as possible to make it compile under D2 - removed system.thread, use standard threads - lots of other changes git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1333 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
dd255a916d
commit
8431753ba3
58 changed files with 1297 additions and 1274 deletions
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* This software is provided 'as-is', without any express or
|
||||
* implied warranty. In no event will the authors be held
|
||||
|
@ -25,9 +26,21 @@
|
|||
|
||||
module dsfml.graphics.font;
|
||||
|
||||
import dsfml.system.common;
|
||||
import dsfml.system.exception;
|
||||
import dsfml.system.stringutil;
|
||||
import dsfml.system.common,
|
||||
dsfml.system.exception,
|
||||
dsfml.system.stringutil;
|
||||
|
||||
import dsfml.graphics.common,
|
||||
dsfml.graphics.rect;
|
||||
|
||||
|
||||
/// Glyph describes a glyph (a visual character)
|
||||
struct Glyph
|
||||
{
|
||||
int Advance; /// Offset to move horizontically to the next character
|
||||
sfIntRect Rectangle; /// Bounding rectangle of the glyph, in relative coordinates
|
||||
sfFloatRect TexCoords; /// Texture coordinates of the glyph inside the bitmap font
|
||||
}
|
||||
|
||||
/**
|
||||
* Font is the low-level class for loading and
|
||||
|
@ -35,7 +48,11 @@ import dsfml.system.stringutil;
|
|||
*/
|
||||
class Font : DSFMLObject
|
||||
{
|
||||
/**
|
||||
private:
|
||||
static Font s_default;
|
||||
public:
|
||||
|
||||
/**
|
||||
* Get SFML default built-in font (Arial)
|
||||
*/
|
||||
static Font getDefaultFont()
|
||||
|
@ -50,15 +67,13 @@ class Font : DSFMLObject
|
|||
*
|
||||
* Params:
|
||||
* filename = font file to load
|
||||
* charSize = size of characters (30 by default)
|
||||
* charset = characters set to generate (empty by default - takes the ASCII range [31, 255])
|
||||
*/
|
||||
this(char[] filename, uint charSize = 30, dchar[] charset = null)
|
||||
this(string filename)
|
||||
{
|
||||
if (filename is null || filename.length == 0)
|
||||
throw new LoadingException("LoadingException : Filename is invalid.");
|
||||
|
||||
super(sfFont_CreateFromFile(toStringz(filename), charSize, toStringz(charset)));
|
||||
super(sfFont_CreateFromFile(toStringz(filename)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,15 +81,13 @@ class Font : DSFMLObject
|
|||
*
|
||||
* Params:
|
||||
* data = data to load
|
||||
* charSize = size of characters (30 by default)
|
||||
* charset = characters set to generate (empty by default - takes the ASCII range [31, 255])
|
||||
*/
|
||||
this(byte[] data, uint charSize = 30, dchar[] charset = null)
|
||||
this(ubyte[] data)
|
||||
{
|
||||
if (data is null || data.length == 0)
|
||||
throw new Exception("LoadingException : Memory stream is invalid.");
|
||||
|
||||
super(sfFont_CreateFromMemory(data.ptr, data.length, charSize, toStringz(charset)));
|
||||
super(sfFont_CreateFromMemory(data.ptr, data.length));
|
||||
}
|
||||
|
||||
|
||||
|
@ -84,40 +97,10 @@ class Font : DSFMLObject
|
|||
}
|
||||
|
||||
|
||||
|
||||
package:
|
||||
|
||||
this(void* ptr)
|
||||
{
|
||||
super(ptr, true);
|
||||
}
|
||||
|
||||
private:
|
||||
static Font s_default;
|
||||
|
||||
extern (C)
|
||||
{
|
||||
typedef void* function() pf_sfFont_Create;
|
||||
typedef void* function(char*, uint, dchar*) pf_sfFont_CreateFromFile;
|
||||
typedef void* function(byte*, size_t, uint, dchar*) pf_sfFont_CreateFromMemory;
|
||||
typedef void function(void*) pf_sfFont_Destroy;
|
||||
typedef void* function() pf_sfFont_GetDefaultFont;
|
||||
|
||||
static pf_sfFont_Create sfFont_Create;
|
||||
static pf_sfFont_CreateFromFile sfFont_CreateFromFile;
|
||||
static pf_sfFont_CreateFromMemory sfFont_CreateFromMemory;
|
||||
static pf_sfFont_Destroy sfFont_Destroy;
|
||||
static pf_sfFont_GetDefaultFont sfFont_GetDefaultFont;
|
||||
}
|
||||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-graphics");
|
||||
|
||||
sfFont_Create = cast(pf_sfFont_Create) dll.getSymbol("sfFont_Create");
|
||||
sfFont_CreateFromFile = cast(pf_sfFont_CreateFromFile) dll.getSymbol("sfFont_CreateFromFile");
|
||||
sfFont_CreateFromMemory = cast(pf_sfFont_CreateFromMemory) dll.getSymbol("sfFont_CreateFromMemory");
|
||||
sfFont_Destroy = cast(pf_sfFont_Destroy) dll.getSymbol("sfFont_Destroy");
|
||||
sfFont_GetDefaultFont = cast(pf_sfFont_GetDefaultFont) dll.getSymbol("sfFont_GetDefaultFont");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue