added ag::drawPoint()
git-svn-id: svn://anubis/anaglym/trunk@205 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
cc608d7b83
commit
bb76eb6e9b
15
Engine.cc
15
Engine.cc
@ -664,6 +664,21 @@ void Engine::drawArc(float r, float g, float b, float x, float y,
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
void Engine::drawPoint(float size, float r, float g, float b,
|
||||
float x, float y, float z)
|
||||
{
|
||||
glPushAttrib(GL_ENABLE_BIT);
|
||||
glEnable(GL_POINT_SMOOTH);
|
||||
glEnable(GL_BLEND);
|
||||
glDisable(GL_LIGHTING);
|
||||
glColor3f(r, g, b);
|
||||
glPointSize(size);
|
||||
glBegin(GL_POINTS);
|
||||
glVertex3f(x, y, z);
|
||||
glEnd();
|
||||
glPopAttrib();
|
||||
}
|
||||
|
||||
/* called by SDL when the update timer expires */
|
||||
Uint32 Engine::updateCallback(Uint32 interval, void * param)
|
||||
{
|
||||
|
2
Engine.h
2
Engine.h
@ -160,6 +160,8 @@ class Engine
|
||||
int tex, float rot = 0.0f);
|
||||
void drawArc(float r, float g, float b, float x, float y,
|
||||
float radius, float a1, float a2);
|
||||
void drawPoint(float size, float r, float g, float b,
|
||||
float x, float y, float z);
|
||||
|
||||
/* lua services */
|
||||
int setCamera(lua_State * L);
|
||||
|
1
Video.cc
1
Video.cc
@ -74,6 +74,7 @@ void Video::start(int width, int height, bool fullscreen, bool grab_input,
|
||||
glLoadIdentity();
|
||||
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
}
|
||||
|
||||
|
28
ag.cc
28
ag.cc
@ -28,6 +28,7 @@ namespace ag
|
||||
{ "drawImage", drawImage },
|
||||
{ "drawLine", drawLine },
|
||||
{ "drawObjects", drawObjects },
|
||||
{ "drawPoint", drawPoint },
|
||||
{ "drawRect", drawRect },
|
||||
{ "drawText", drawText },
|
||||
{ "elapsedTime", elapsedTime },
|
||||
@ -445,6 +446,33 @@ namespace ag
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drawPoint(lua_State * L)
|
||||
{
|
||||
int argc = lua_gettop(L);
|
||||
if (argc == 6 || argc == 7)
|
||||
{
|
||||
bool valid = true;
|
||||
for (int i = 1; i <= argc; i++)
|
||||
if (!lua_isnumber(L, i))
|
||||
valid = false;
|
||||
if (valid)
|
||||
{
|
||||
float z = 0.0f;
|
||||
if (argc == 7)
|
||||
z = lua_tonumber(L, 7);
|
||||
g_engine->drawPoint(
|
||||
lua_tonumber(L, 1),
|
||||
lua_tonumber(L, 2),
|
||||
lua_tonumber(L, 3),
|
||||
lua_tonumber(L, 4),
|
||||
lua_tonumber(L, 5),
|
||||
lua_tonumber(L, 6),
|
||||
z);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drawRect(lua_State * L)
|
||||
{
|
||||
int argc = lua_gettop(L);
|
||||
|
1
ag.h
1
ag.h
@ -39,6 +39,7 @@ namespace ag
|
||||
int drawCircle(lua_State * L);
|
||||
int drawImage(lua_State * L);
|
||||
int drawLine(lua_State * L);
|
||||
int drawPoint(lua_State * L);
|
||||
int drawRect(lua_State * L);
|
||||
int drawText(lua_State * L);
|
||||
int fillRect(lua_State * L);
|
||||
|
@ -7,9 +7,35 @@ function setupPins()
|
||||
end
|
||||
end
|
||||
|
||||
function setupStars()
|
||||
stars = {}
|
||||
local dist = 500
|
||||
for i = 1, 1000 do
|
||||
local star = {}
|
||||
local rx = math.random() * math.pi * 2
|
||||
local ry = (math.random() - 0.5) * math.pi
|
||||
star.x = dist * math.cos(ry) * math.cos(rx)
|
||||
star.y = dist * math.cos(ry) * math.sin(rx)
|
||||
star.z = dist * math.sin(ry)
|
||||
star.size = math.random(2, 8)
|
||||
stars[i] = star
|
||||
end
|
||||
end
|
||||
|
||||
function drawStars()
|
||||
for i = 1, #stars do
|
||||
ag.drawPoint(stars[i].size, 1, 1, 1, stars[i].x, stars[i].y, stars[i].z)
|
||||
end
|
||||
end
|
||||
|
||||
function init_event()
|
||||
pins = {}
|
||||
lane = ag.loadModelStatic("bowling_lane")
|
||||
setupPins()
|
||||
setupStars()
|
||||
ag.setCamera(0, -20, 5, 0, 20, 0)
|
||||
end
|
||||
|
||||
function update_event()
|
||||
drawStars()
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user