From 1b294eb6cf1faaea874d5521f1d93f8d870180e6 Mon Sep 17 00:00:00 2001 From: tobigun Date: Sun, 25 Apr 2010 09:07:50 +0000 Subject: added Finalize3D finalization as opponent for Initialize3D and for a clean finalization git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2307 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/base/TextGL.pas | 14 ++++++++------ src/base/UGraphic.pas | 16 +++++++++++++++- src/base/UMain.pas | 22 +++++++--------------- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/base/TextGL.pas b/src/base/TextGL.pas index 7ee574c3..c354a500 100644 --- a/src/base/TextGL.pas +++ b/src/base/TextGL.pas @@ -61,8 +61,8 @@ var Fonts: array of TGLFont; ActFont: integer; -procedure BuildFont; // build our bitmap font -procedure KillFont; // delete the font +procedure BuildFonts; // builds all fonts +procedure KillFonts; // deletes all font function glTextWidth(const text: UTF8String): real; // returns text width procedure glPrint(const text: UTF8String); // custom GL "Print" routine procedure ResetFont(); // reset font settings of active font @@ -121,7 +121,7 @@ const 'Normal', 'Bold', 'Outline1', 'Outline2' ); -procedure BuildFont; +procedure BuildFonts; var I: integer; FontIni: TMemIniFile; @@ -183,10 +183,12 @@ end; // Deletes the font -procedure KillFont; +procedure KillFonts; +var + I: integer; begin - // delete all characters - //glDeleteLists(..., 256); + for I := 0 to High(Fonts) do + Fonts[I].Font.Free; end; function glTextWidth(const text: UTF8String): real; diff --git a/src/base/UGraphic.pas b/src/base/UGraphic.pas index 33e862f2..d22744db 100644 --- a/src/base/UGraphic.pas +++ b/src/base/UGraphic.pas @@ -265,6 +265,7 @@ const Skin_P2_ScoreL = 640; procedure Initialize3D (Title: string); +procedure Finalize3D; procedure Reinitialize3D; procedure SwapBuffers; @@ -290,7 +291,13 @@ uses procedure LoadFontTextures; begin Log.LogStatus('Building Fonts', 'LoadTextures'); - BuildFont; + BuildFonts; +end; + +procedure UnloadFontTextures; +begin + Log.LogStatus('Kill Fonts', 'UnloadFontTextures'); + KillFonts; end; procedure LoadTextures; @@ -599,6 +606,13 @@ begin glMatrixMode(GL_MODELVIEW); end; +procedure Finalize3D; +begin + // TODO: finalize other stuff + UnloadFontTextures; + SDL_QuitSubSystem(SDL_INIT_VIDEO); +end; + procedure Reinitialize3D; begin InitializeScreen; diff --git a/src/base/UMain.pas b/src/base/UMain.pas index 550fe9cd..ca14525f 100644 --- a/src/base/UMain.pas +++ b/src/base/UMain.pas @@ -155,15 +155,6 @@ begin Log.BenchmarkEnd(1); Log.LogBenchmark('Loading Language', 1); -{ - // SDL_ttf (Not used yet, maybe in version 1.5) - Log.BenchmarkStart(1); - Log.LogStatus('Initialize SDL_ttf', 'Initialization'); - TTF_Init(); - Log.BenchmarkEnd(1); - Log.LogBenchmark('Initializing SDL_ttf', 1); -} - // Skin Log.BenchmarkStart(1); Log.LogStatus('Loading Skin List', 'Initialization'); @@ -320,16 +311,17 @@ begin // call an uninitialize routine for every initialize step // or at least use the corresponding Free methods + Log.LogStatus('Finalize Media', 'Finalization'); FinalizeMedia(); - //TTF_Quit(); + Log.LogStatus('Uninitialize 3D', 'Finalization'); + Finalize3D(); + + Log.LogStatus('Finalize SDL', 'Finalization'); SDL_Quit(); - if assigned(Log) then - begin - Log.LogStatus('Main Loop', 'Finished'); - Log.Free; - end; + Log.LogStatus('Finalize Log', 'Finalization'); + Log.Free; {$IFNDEF Debug} end; {$ENDIF} -- cgit v1.2.3