changeset 33:6886402c1545

Started implementing FreeType. Loads the freetype library and a font, but nothing else yet. committer: Diggory Hardy <diggory.hardy@gmail.com>
author Diggory Hardy <diggory.hardy@gmail.com>
date Thu, 01 May 2008 10:55:04 +0100
parents 316b0230a849
children 6b4116e6355c
files codeDoc/gui/GUI notes.txt codeDoc/jobs.txt mde/ft/init.d mde/scheduler/init2.d mde/sdl.d
diffstat 5 files changed, 65 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/codeDoc/gui/GUI notes.txt	Wed Apr 30 18:05:56 2008 +0100
+++ b/codeDoc/gui/GUI notes.txt	Thu May 01 10:55:04 2008 +0100
@@ -9,13 +9,12 @@
     ->* create orthographic projection
     ->* draw boxes
     ->  maybe more (text, textures, ...)
-->* Windows with size & position
+->  Windows with size & position
+    ->  position from Gui
 ->  Widgets:
     ->* minimum size but expandable, auto-set
         ->  no ability to resize yet except from config files
-    ->* grid "layout" widgets
     ->  scripted widgets
-    ->  decent rendering/theme system
 ->  Text rendering
     -> text library?
 
--- a/codeDoc/jobs.txt	Wed Apr 30 18:05:56 2008 +0100
+++ b/codeDoc/jobs.txt	Thu May 01 10:55:04 2008 +0100
@@ -3,6 +3,7 @@
 
 
 In progress:
+FreeType implementing...
 
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mde/ft/init.d	Thu May 01 10:55:04 2008 +0100
@@ -0,0 +1,48 @@
+/* LICENSE BLOCK
+Part of mde: a Modular D game-oriented Engine
+Copyright © 2007-2008 Diggory Hardy
+
+This program is free software: you can redistribute it and/or modify it under the terms
+of the GNU General Public License as published by the Free Software Foundation, either
+version 2 of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>. */
+
+/// Sets up freetype (in a basic way).
+module mde.ft.init;
+
+import derelict.freetype.ft;
+
+import tango.stdc.stringz;
+import tango.util.log.Log : Log, Logger;
+
+private Logger logger;
+static this () {
+    logger = Log.getLogger ("mde.ft.init");
+}
+
+FT_Library  library;
+FT_Face     face;
+
+// FIXME: use a different exception
+const PATH = "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf";
+void initFreeType () {
+    if (FT_Init_FreeType (&library))
+        throw new Exception ("error initialising the FreeType library");
+        
+    if (FT_New_Face (library, toStringz(PATH), 0, &face))
+        throw new Exception ("Unable to read font: "~PATH);
+        
+    if (FT_Set_Pixel_Sizes (face, 32,32))
+        throw new Exception ("Unable to set pixel size");
+}
+
+void cleanupFreeType () {
+    FT_Done_Face (face);
+    FT_Done_FreeType (library);
+}
--- a/mde/scheduler/init2.d	Wed Apr 30 18:05:56 2008 +0100
+++ b/mde/scheduler/init2.d	Thu May 01 10:55:04 2008 +0100
@@ -35,8 +35,9 @@
 import global = mde.global;
 import mde.gui.Gui;
 import mde.input.Input;
+import ft = mde.ft.init;
 
-// NOTE: error reporting needs revision
+// NOTE: error reporting needs a revision
 
 private Logger logger;
 static this () {
@@ -44,9 +45,10 @@
     
     init.addFunc (&initInput, "initInput");
     init.addFunc (&guiLoad, "guiLoad");
+    init.addFunc (&initFreeType, "initFreeType");
 }
 
-void guiLoad () {
+void guiLoad () {   // init func
     try {
         gui.load ("gui");
     } catch (Exception e) {
@@ -74,6 +76,15 @@
     }
 }
 
+void initFreeType () {  // init func
+    try {
+        ft.initFreeType;
+    } catch (Exception e) {
+        logger.fatal ("initFreeType failed: " ~ e.msg);
+        setInitFailure;
+    }
+}
+
 /+ Potential wrapper function:
 // Template to call function, catching exceptions:
 void wrap(alias Func) () {
--- a/mde/sdl.d	Wed Apr 30 18:05:56 2008 +0100
+++ b/mde/sdl.d	Thu May 01 10:55:04 2008 +0100
@@ -15,7 +15,7 @@
 
 /** Just a temporary place to put SDL Init and Video stuff.
 */
-module mde.SDL;
+module mde.sdl;
 
 import mde.scheduler.initFunctions;
 import mde.input.joystick;