finished textbox implementation and it does not work -- apparently blitting to an OpenGL surface does not work for any font type... i'll have to switch to FTGL or something else
git-svn-id: svn://anubis/anaglym/trunk@161 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
8746e81fe4
commit
8425807f99
@ -503,6 +503,15 @@ void Engine::getScreenSize(int * width, int * height)
|
|||||||
*height = m_video.getHeight();
|
*height = m_video.getHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Engine::drawText(int id, int x, int y)
|
||||||
|
{
|
||||||
|
if (m_textboxes.find(id) != m_textboxes.end())
|
||||||
|
{
|
||||||
|
SDL_Rect dstrect = {x, y, 0, 0};
|
||||||
|
SDL_BlitSurface(m_textboxes[id], NULL, m_video.getSurface(), &dstrect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* called by SDL when the update timer expires */
|
/* called by SDL when the update timer expires */
|
||||||
Uint32 Engine::updateCallback(Uint32 interval, void * param)
|
Uint32 Engine::updateCallback(Uint32 interval, void * param)
|
||||||
{
|
{
|
||||||
|
1
Engine.h
1
Engine.h
@ -139,6 +139,7 @@ class Engine
|
|||||||
Uint8 r, Uint8 g, Uint8 b,
|
Uint8 r, Uint8 g, Uint8 b,
|
||||||
Uint8 br = 0, Uint8 bg = 0, Uint8 bb = 0);
|
Uint8 br = 0, Uint8 bg = 0, Uint8 bb = 0);
|
||||||
void getScreenSize(int * width, int * height);
|
void getScreenSize(int * width, int * height);
|
||||||
|
void drawText(int id, int x, int y);
|
||||||
|
|
||||||
/* lua services */
|
/* lua services */
|
||||||
int setCamera(lua_State * L);
|
int setCamera(lua_State * L);
|
||||||
|
1
Video.h
1
Video.h
@ -17,6 +17,7 @@ class Video
|
|||||||
void toggleFullScreen() { SDL_WM_ToggleFullScreen(m_surface); }
|
void toggleFullScreen() { SDL_WM_ToggleFullScreen(m_surface); }
|
||||||
int getWidth() { return m_width; }
|
int getWidth() { return m_width; }
|
||||||
int getHeight() { return m_height; }
|
int getHeight() { return m_height; }
|
||||||
|
SDL_Surface * getSurface() { return m_surface; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int m_defaultWidth;
|
int m_defaultWidth;
|
||||||
|
26
ag.cc
26
ag.cc
@ -359,6 +359,8 @@ namespace ag
|
|||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
lua_pushinteger(L, id);
|
lua_pushinteger(L, id);
|
||||||
lua_setfield(L, -2, "id");
|
lua_setfield(L, -2, "id");
|
||||||
|
lua_pushcfunction(L, textbox::draw);
|
||||||
|
lua_setfield(L, -2, "draw");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -853,4 +855,28 @@ namespace ag
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace textbox
|
||||||
|
{
|
||||||
|
int draw(lua_State * L)
|
||||||
|
{
|
||||||
|
int argc = lua_gettop(L);
|
||||||
|
if (argc == 3
|
||||||
|
&& lua_istable(L, 1)
|
||||||
|
&& lua_isnumber(L, 2)
|
||||||
|
&& lua_isnumber(L, 3))
|
||||||
|
{
|
||||||
|
lua_getfield(L, 1, "id");
|
||||||
|
if (lua_isnumber(L, -1))
|
||||||
|
{
|
||||||
|
int id = lua_tonumber(L, -1);
|
||||||
|
g_engine->drawText(id,
|
||||||
|
lua_tonumber(L, 2),
|
||||||
|
lua_tonumber(L, 3));
|
||||||
|
}
|
||||||
|
lua_pop(L, 1);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
5
ag.h
5
ag.h
@ -61,6 +61,11 @@ namespace ag
|
|||||||
int setColor(lua_State * L);
|
int setColor(lua_State * L);
|
||||||
int setTexture(lua_State * L);
|
int setTexture(lua_State * L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace textbox
|
||||||
|
{
|
||||||
|
int draw(lua_State * L);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
|
||||||
t = ag.createSolidTextBox("Hi there", 0, 0, 1)
|
t = ag.createSolidTextBox("Hi there", 0, 0, 1)
|
||||||
ag.println("t: ", t)
|
t2 = ag.createShadedTextBox("Hi there", 0, 1, 1, 0, 0, 0)
|
||||||
|
t3 = ag.createBlendedTextBox("Hi there", 1, 1, 1)
|
||||||
|
ag.setAutoEndFrame(false)
|
||||||
|
ag.setAutoDrawObjects(false)
|
||||||
|
|
||||||
function update_event()
|
function update_event()
|
||||||
ballx, bally, ballz = ball:getPosition()
|
ballx, bally, ballz = ball:getPosition()
|
||||||
@ -8,6 +11,11 @@ function update_event()
|
|||||||
if (ag.isKeyDown("m")) then
|
if (ag.isKeyDown("m")) then
|
||||||
ball:setPosition(-7, 7.4, 12)
|
ball:setPosition(-7, 7.4, 12)
|
||||||
end
|
end
|
||||||
|
ag.drawObjects()
|
||||||
|
ag.endFrame()
|
||||||
|
t:draw(10, 10)
|
||||||
|
t2:draw(10, 40)
|
||||||
|
t3:draw(10, 90)
|
||||||
end
|
end
|
||||||
|
|
||||||
function key_down_event(key)
|
function key_down_event(key)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user