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
This commit is contained in:
Josh Holtrop 2009-11-08 03:22:33 +00:00
parent 4831fd7658
commit 01c65d68dd
2 changed files with 14 additions and 5 deletions

View File

@ -79,6 +79,7 @@ Engine::Engine(const string & path, Video & video)
: m_video(video) : m_video(video)
{ {
m_next_object_index = 1; m_next_object_index = 1;
m_next_text_index = 1;
m_eye[0] = 0; m_eye[0] = 0;
m_eye[1] = -1; m_eye[1] = -1;
m_eye[2] = 0; 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, int Engine::renderText(const char * text, int mode, Uint8 r, Uint8 g, Uint8 b,
float br, float bg, float bb) Uint8 br, Uint8 bg, Uint8 bb)
{ {
SDL_Surface * surf = NULL; SDL_Surface * surf = NULL;
SDL_Color color = {r, g, b}; 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); surf = TTF_RenderText_Blended(m_font, text, color);
break; 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 */ /* called by SDL when the update timer expires */

View File

@ -135,8 +135,8 @@ class Engine
bool import(const char * name); bool import(const char * name);
GLuint loadTexture(const char * name); GLuint loadTexture(const char * name);
void debug_hook(lua_Debug * debug); void debug_hook(lua_Debug * debug);
int renderText(const char * text, int mode, float r, float g, float b, int renderText(const char * text, int mode, Uint8 r, Uint8 g, Uint8 b,
float br = 0.0, float bg = 0.0, float bb = 0.0); Uint8 br = 0, Uint8 bg = 0, Uint8 bb = 0);
/* lua services */ /* lua services */
int setCamera(lua_State * L); int setCamera(lua_State * L);
@ -169,8 +169,9 @@ class Engine
std::string m_engine_path; std::string m_engine_path;
OdeWorld m_world; OdeWorld m_world;
std::map<int, Object *> m_objects; std::map<int, Object *> m_objects;
std::map<int, SDL_Surface *> m_texts;
int m_next_object_index; int m_next_object_index;
std::map<int, SDL_Surface *> m_texts;
int m_next_text_index;
GLdouble m_eye[3]; GLdouble m_eye[3];
GLdouble m_center[3]; GLdouble m_center[3];
GLdouble m_up[3]; GLdouble m_up[3];