added Engine::Quad::setColor() and ag::quad::setColor()
This commit is contained in:
parent
8585f97e91
commit
eb73749f69
@ -1345,6 +1345,7 @@ Engine::Quad::Quad(float cx, float cy, float cz,
|
|||||||
m_offset = 0.0f;
|
m_offset = 0.0f;
|
||||||
m_texture = 0;
|
m_texture = 0;
|
||||||
m_enable_blending = false;
|
m_enable_blending = false;
|
||||||
|
m_color[0] = m_color[1] = m_color[2] = m_color[3] = 1.0f;
|
||||||
dCROSS(m_normal, =, m_v1, m_v2);
|
dCROSS(m_normal, =, m_v1, m_v2);
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
@ -1375,6 +1376,10 @@ int Engine::Quad::render()
|
|||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_2D, m_texture);
|
glBindTexture(GL_TEXTURE_2D, m_texture);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, &m_color[0]);
|
||||||
|
}
|
||||||
if (m_enable_blending)
|
if (m_enable_blending)
|
||||||
{
|
{
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
9
Engine.h
9
Engine.h
@ -183,6 +183,14 @@ class Engine
|
|||||||
m_enable_blending = b;
|
m_enable_blending = b;
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
void setColor(float r, float g, float b, float a)
|
||||||
|
{
|
||||||
|
m_color[0] = r;
|
||||||
|
m_color[1] = g;
|
||||||
|
m_color[2] = b;
|
||||||
|
m_color[3] = a;
|
||||||
|
render();
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
dVector3 m_center;
|
dVector3 m_center;
|
||||||
dVector3 m_v1, m_v2, m_normal;
|
dVector3 m_v1, m_v2, m_normal;
|
||||||
@ -191,6 +199,7 @@ class Engine
|
|||||||
float m_offset;
|
float m_offset;
|
||||||
int m_texture;
|
int m_texture;
|
||||||
bool m_enable_blending;
|
bool m_enable_blending;
|
||||||
|
float m_color[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
Engine(const std::string & path, AV & av);
|
Engine(const std::string & path, AV & av);
|
||||||
|
23
ag.cc
23
ag.cc
@ -736,6 +736,8 @@ fail:
|
|||||||
lua_setfield(L, -2, "id");
|
lua_setfield(L, -2, "id");
|
||||||
lua_pushcfunction(L, quad::setBlending);
|
lua_pushcfunction(L, quad::setBlending);
|
||||||
lua_setfield(L, -2, "setBlending");
|
lua_setfield(L, -2, "setBlending");
|
||||||
|
lua_pushcfunction(L, quad::setColor);
|
||||||
|
lua_setfield(L, -2, "setColor");
|
||||||
lua_pushcfunction(L, quad::setOffset);
|
lua_pushcfunction(L, quad::setOffset);
|
||||||
lua_setfield(L, -2, "setOffset");
|
lua_setfield(L, -2, "setOffset");
|
||||||
lua_pushcfunction(L, quad::setTexture);
|
lua_pushcfunction(L, quad::setTexture);
|
||||||
@ -1660,6 +1662,27 @@ fail:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int setColor(lua_State * L)
|
||||||
|
{
|
||||||
|
int argc = lua_gettop(L);
|
||||||
|
if (argc == 5 && lua_istable(L, 1)
|
||||||
|
&& lua_isnumber(L, 2)
|
||||||
|
&& lua_isnumber(L, 3)
|
||||||
|
&& lua_isnumber(L, 4)
|
||||||
|
&& lua_isnumber(L, 5))
|
||||||
|
{
|
||||||
|
Engine::Quad * q = getQuad(L, 1);
|
||||||
|
if (q != NULL)
|
||||||
|
{
|
||||||
|
q->setColor(lua_tonumber(L, 2),
|
||||||
|
lua_tonumber(L, 3),
|
||||||
|
lua_tonumber(L, 4),
|
||||||
|
lua_tonumber(L, 5));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int setOffset(lua_State * L)
|
int setOffset(lua_State * L)
|
||||||
{
|
{
|
||||||
int argc = lua_gettop(L);
|
int argc = lua_gettop(L);
|
||||||
|
1
ag.h
1
ag.h
@ -102,6 +102,7 @@ namespace ag
|
|||||||
Engine::Quad * getQuad(lua_State * L, int index);
|
Engine::Quad * getQuad(lua_State * L, int index);
|
||||||
|
|
||||||
int setBlending(lua_State * L);
|
int setBlending(lua_State * L);
|
||||||
|
int setColor(lua_State * L);
|
||||||
int setOffset(lua_State * L);
|
int setOffset(lua_State * L);
|
||||||
int setTexture(lua_State * L);
|
int setTexture(lua_State * L);
|
||||||
int setVisible(lua_State * L);
|
int setVisible(lua_State * L);
|
||||||
|
@ -58,8 +58,10 @@ function key_down_event(key)
|
|||||||
elseif (key == "minus") then
|
elseif (key == "minus") then
|
||||||
ag.setCursorVisible(not ag.getCursorVisible())
|
ag.setCursorVisible(not ag.getCursorVisible())
|
||||||
elseif (key == "d") then
|
elseif (key == "d") then
|
||||||
q = ag.createQuad(3, 3, 0, 1, 0, 0, 0, 1, 0)
|
q = ag.createQuad(0.5, 3, 0, 1, 0, 0, 0, 1, 0)
|
||||||
|
q:setColor(0, 0, 1, 0.6)
|
||||||
q:setOffset(1)
|
q:setOffset(1)
|
||||||
|
q:setBlending(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user