From 01c65d68dd82bc711295c32cfaf06f052d49a1ea Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 8 Nov 2009 03:22:33 +0000 Subject: [PATCH] adding text surfaces to m_texts, switched floats to Uint8's for SDL_Color git-svn-id: svn://anubis/anaglym/trunk@157 99a6e188-d820-4881-8870-2d33a10e2619 --- Engine.cc | 12 ++++++++++-- Engine.h | 7 ++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Engine.cc b/Engine.cc index a049ee9..1cffbef 100644 --- a/Engine.cc +++ b/Engine.cc @@ -79,6 +79,7 @@ Engine::Engine(const string & path, Video & video) : m_video(video) { m_next_object_index = 1; + m_next_text_index = 1; m_eye[0] = 0; m_eye[1] = -1; m_eye[2] = 0; @@ -462,8 +463,8 @@ void Engine::debug_hook(lua_Debug * debug) } } -int Engine::renderText(const char * text, int mode, float r, float g, float b, - float br, float bg, float bb) +int Engine::renderText(const char * text, int mode, Uint8 r, Uint8 g, Uint8 b, + Uint8 br, Uint8 bg, Uint8 bb) { SDL_Surface * surf = NULL; SDL_Color color = {r, g, b}; @@ -480,6 +481,13 @@ int Engine::renderText(const char * text, int mode, float r, float g, float b, surf = TTF_RenderText_Blended(m_font, text, color); break; } + if (surf != NULL) + { + int id = m_next_text_index++; + m_texts[id] = surf; + return id; + } + return 0; } /* called by SDL when the update timer expires */ diff --git a/Engine.h b/Engine.h index 8ee1a5f..170db2d 100644 --- a/Engine.h +++ b/Engine.h @@ -135,8 +135,8 @@ class Engine bool import(const char * name); GLuint loadTexture(const char * name); void debug_hook(lua_Debug * debug); - int renderText(const char * text, int mode, float r, float g, float b, - float br = 0.0, float bg = 0.0, float bb = 0.0); + int renderText(const char * text, int mode, Uint8 r, Uint8 g, Uint8 b, + Uint8 br = 0, Uint8 bg = 0, Uint8 bb = 0); /* lua services */ int setCamera(lua_State * L); @@ -169,8 +169,9 @@ class Engine std::string m_engine_path; OdeWorld m_world; std::map m_objects; - std::map m_texts; int m_next_object_index; + std::map m_texts; + int m_next_text_index; GLdouble m_eye[3]; GLdouble m_center[3]; GLdouble m_up[3];