Merged default into Mesh

--HG--
branch : Mesh
This commit is contained in:
Alex Szpakowski
2013-09-29 04:58:26 -03:00
28 changed files with 364 additions and 182 deletions
+5 -5
View File
@@ -215,10 +215,10 @@ Font::Glyph *Font::addGlyph(uint32 glyph)
g->texture = t;
const GlyphVertex verts[4] = {
{0, 0, float(textureX)/float(textureWidth), float(textureY)/float(textureHeight)},
{w, 0, float(textureX+w)/float(textureWidth), float(textureY)/float(textureHeight)},
{w, h, float(textureX+w)/float(textureWidth), float(textureY+h)/float(textureHeight)},
{0, h, float(textureX)/float(textureWidth), float(textureY+h)/float(textureHeight)},
{ 0.0f, 0.0f, float(textureX)/float(textureWidth), float(textureY)/float(textureHeight)},
{float(w), 0.0f, float(textureX+w)/float(textureWidth), float(textureY)/float(textureHeight)},
{float(w), float(h), float(textureX+w)/float(textureWidth), float(textureY+h)/float(textureHeight)},
{ 0.0f, float(h), float(textureX)/float(textureWidth), float(textureY+h)/float(textureHeight)},
};
// copy vertex data to the glyph and set proper bearing
@@ -550,7 +550,7 @@ int Font::getDescent() const
float Font::getBaseline() const
{
// 1.25 is magic line height for true type fonts
return (type == FONT_TRUETYPE) ? floor(getHeight() / 1.25f + 0.5f) : 0.0f;
return (type == FONT_TRUETYPE) ? floorf(getHeight() / 1.25f + 0.5f) : 0.0f;
}
bool Font::hasGlyph(uint32 glyph) const
+8 -24
View File
@@ -242,22 +242,6 @@ int Graphics::getHeight() const
return height;
}
int Graphics::getRenderWidth() const
{
if (Canvas::current)
return Canvas::current->getWidth();
return getWidth();
}
int Graphics::getRenderHeight() const
{
if (Canvas::current)
return Canvas::current->getHeight();
return getHeight();
}
bool Graphics::isCreated() const
{
return created;
@@ -741,7 +725,7 @@ void Graphics::printf(const std::string &str, float x, float y, float wrap, Alig
glPushMatrix();
static Matrix t;
t.setTransformation(ceil(x), ceil(y), angle, sx, sy, ox, oy, kx, ky);
t.setTransformation(ceilf(x), ceilf(y), angle, sx, sy, ox, oy, kx, ky);
glMultMatrixf((const GLfloat *)t.getElements());
x = y = 0.0f;
@@ -760,10 +744,10 @@ void Graphics::printf(const std::string &str, float x, float y, float wrap, Alig
switch (align)
{
case ALIGN_RIGHT:
currentFont->print(*line_iter, ceil(x + (wrap - width)), ceil(y), 0.0f);
currentFont->print(*line_iter, ceilf(x + (wrap - width)), ceilf(y), 0.0f);
break;
case ALIGN_CENTER:
currentFont->print(*line_iter, ceil(x + (wrap - width) / 2), ceil(y), 0.0f);
currentFont->print(*line_iter, ceilf(x + (wrap - width) / 2), ceilf(y), 0.0f);
break;
case ALIGN_JUSTIFY:
num_spaces = std::count(line_iter->begin(), line_iter->end(), ' ');
@@ -771,11 +755,11 @@ void Graphics::printf(const std::string &str, float x, float y, float wrap, Alig
extra_spacing = (wrap - width) / float(num_spaces);
else
extra_spacing = 0.0f;
currentFont->print(*line_iter, ceil(x), ceil(y), extra_spacing);
currentFont->print(*line_iter, ceilf(x), ceilf(y), extra_spacing);
break;
case ALIGN_LEFT:
default:
currentFont->print(*line_iter, ceil(x), ceil(y), 0.0f);
currentFont->print(*line_iter, ceilf(x), ceilf(y), 0.0f);
break;
}
y += currentFont->getHeight() * currentFont->getLineHeight();
@@ -808,19 +792,19 @@ void Graphics::polyline(const float *coords, size_t count)
if (lineJoin == LINE_JOIN_NONE)
{
NoneJoinPolyline line;
line.render(coords, count, lineWidth * .5f, pixel_size_stack.back(), lineStyle == LINE_SMOOTH);
line.render(coords, count, lineWidth * .5f, float(pixel_size_stack.back()), lineStyle == LINE_SMOOTH);
line.draw();
}
else if (lineJoin == LINE_JOIN_BEVEL)
{
BevelJoinPolyline line;
line.render(coords, count, lineWidth * .5f, pixel_size_stack.back(), lineStyle == LINE_SMOOTH);
line.render(coords, count, lineWidth * .5f, float(pixel_size_stack.back()), lineStyle == LINE_SMOOTH);
line.draw();
}
else // LINE_JOIN_MITER
{
MiterJoinPolyline line;
line.render(coords, count, lineWidth * .5f, pixel_size_stack.back(), lineStyle == LINE_SMOOTH);
line.render(coords, count, lineWidth * .5f, float(pixel_size_stack.back()), lineStyle == LINE_SMOOTH);
line.draw();
}
}
-3
View File
@@ -456,9 +456,6 @@ public:
private:
int getRenderWidth() const;
int getRenderHeight() const;
Font *currentFont;
love::window::Window *currentWindow;
+12 -7
View File
@@ -233,7 +233,7 @@ void ParticleSystem::initParticle(particle *p)
min = speedMin;
max = speedMax;
float speed = (float) rng.random(min, max);
p->speed = love::Vector(cos(p->direction), sin(p->direction));
p->speed = love::Vector(cosf(p->direction), sinf(p->direction));
p->speed *= speed;
p->linearAcceleration.x = (float) rng.random(linearAccelerationMin.x, linearAccelerationMax.x);
@@ -652,11 +652,16 @@ void ParticleSystem::setColor(const std::vector<Color> &newColors)
std::vector<Color> ParticleSystem::getColor() const
{
// We store colors as floats...
// The particle system stores colors as floats...
std::vector<Color> ncolors(colors.size());
for (size_t i = 0; i < colors.size(); ++i)
ncolors[i] = Color(colors[i].r, colors[i].g, colors[i].b, colors[i].a);
{
ncolors[i].r = (unsigned char) (colors[i].r * 255);
ncolors[i].g = (unsigned char) (colors[i].g * 255);
ncolors[i].b = (unsigned char) (colors[i].b * 255);
ncolors[i].a = (unsigned char) (colors[i].a * 255);
}
return ncolors;
}
@@ -764,10 +769,10 @@ void ParticleSystem::draw(float x, float y, float angle, float sx, float sy, flo
pVerts[v].t = imageVerts[v].t;
// particle colors are stored as floats (0-1) but vertex colors are stored as unsigned bytes (0-255)
pVerts[v].r = p->color.r*255;
pVerts[v].g = p->color.g*255;
pVerts[v].b = p->color.b*255;
pVerts[v].a = p->color.a*255;
pVerts[v].r = (unsigned char) (p->color.r*255);
pVerts[v].g = (unsigned char) (p->color.g*255);
pVerts[v].b = (unsigned char) (p->color.b*255);
pVerts[v].a = (unsigned char) (p->color.a*255);
}
pVerts += 4;
+1 -1
View File
@@ -27,7 +27,7 @@
#include "OpenGL.h"
// treat adjacent segments with angles between their directions <5 degree as straight
static const float LINES_PARALLEL_EPS = 0.05;
static const float LINES_PARALLEL_EPS = 0.05f;
namespace love
{
@@ -0,0 +1,214 @@
/**
* Copyright (c) 2006-2013 LOVE Development Team
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
**/
// LOVE
#include "wrap_Geometry.h"
#include "common/Exception.h"
namespace love
{
namespace graphics
{
namespace opengl
{
Geometry *luax_checkgeometry(lua_State *L, int idx)
{
return luax_checktype<Geometry>(L, idx, "Geometry", GRAPHICS_GEOMETRY_T);
}
int w_Geometry_getVertexCount(lua_State *L)
{
Geometry *geom = luax_checkgeometry(L, 1);
lua_pushinteger(L, geom->getVertexCount());
return 1;
}
int w_Geometry_getVertex(lua_State *L)
{
Geometry *geom = luax_checkgeometry(L, 1);
size_t i = size_t(luaL_checkinteger(L, 2));
EXCEPT_GUARD(
const Vertex &v = geom->getVertex(i-1);
lua_pushnumber(L, v.x);
lua_pushnumber(L, v.y);
lua_pushnumber(L, v.s);
lua_pushnumber(L, v.t);
lua_pushnumber(L, v.r);
lua_pushnumber(L, v.g);
lua_pushnumber(L, v.b);
lua_pushnumber(L, v.a);
)
return 8;
}
int w_Geometry_setVertex(lua_State *L)
{
Geometry *geom = luax_checkgeometry(L, 1);
size_t i = size_t(luaL_checkinteger(L, 2));
Vertex v;
if (lua_istable(L, 3))
{
for (int i = 1; i <= 8; i++)
lua_rawgeti(L, 3, i);
v.x = (float) luaL_checknumber(L, -8);
v.y = (float) luaL_checknumber(L, -7);
v.s = (float) luaL_checknumber(L, -6);
v.t = (float) luaL_checknumber(L, -5);
v.r = (unsigned char) luaL_optinteger(L, -4, 255);
v.g = (unsigned char) luaL_optinteger(L, -3, 255);
v.b = (unsigned char) luaL_optinteger(L, -2, 255);
v.a = (unsigned char) luaL_optinteger(L, -1, 255);
lua_pop(L, 8);
}
else
{
v.x = (float) luaL_checknumber(L, 3);
v.y = (float) luaL_checknumber(L, 4);
v.s = (float) luaL_checknumber(L, 5);
v.t = (float) luaL_checknumber(L, 6);
v.r = (unsigned char) luaL_optinteger(L, 7, 255);
v.g = (unsigned char) luaL_optinteger(L, 8, 255);
v.b = (unsigned char) luaL_optinteger(L, 9, 255);
v.a = (unsigned char) luaL_optinteger(L, 10, 255);
}
EXCEPT_GUARD(geom->setVertex(i-1, v);)
if (v.r != 255 || v.g != 255 || v.b != 255 || v.a != 255)
geom->setVertexColors(true);
return 0;
}
int w_Geometry_setVertexColors(lua_State *L)
{
Geometry *geom = luax_checkgeometry(L, 1);
geom->setVertexColors(luax_toboolean(L, 2));
return 0;
}
int w_Geometry_hasVertexColors(lua_State *L)
{
Geometry *geom = luax_checkgeometry(L, 1);
luax_pushboolean(L, geom->hasVertexColors());
return 1;
}
int w_Geometry_getDrawMode(lua_State *L)
{
Geometry *geom = luax_checkgeometry(L, 1);
Geometry::DrawMode mode = geom->getDrawMode();
const char *str;
if (!Geometry::getConstant(mode, str))
return luaL_error(L, "Unknown Geometry draw mode");
lua_pushstring(L, str);
return 1;
}
int w_Geometry_getVertexMap(lua_State *L)
{
Geometry *g = luax_checkgeometry(L, 1);
size_t elemcount = g->getElementCount();
const uint16 *elements = g->getElementArray();
if (elemcount == 0)
elemcount = g->getVertexCount();
lua_createtable(L, elemcount, 0);
for (size_t i = 0; i < elemcount; i++)
{
if (elements)
lua_pushinteger(L, elements[i] + 1);
else
lua_pushinteger(L, i + 1);
lua_rawseti(L, -2, i + 1);
}
return 1;
}
int w_Geometry_setVertexMap(lua_State *L)
{
Geometry *g = luax_checkgeometry(L, 1);
for (int i = lua_gettop(L); i >= 2; i--)
{
if (lua_isnil(L, i))
lua_pop(L, 1);
else
break;
}
bool is_table = lua_istable(L, 2);
int nargs = is_table ? lua_objlen(L, 2) : lua_gettop(L) - 1;
std::vector<uint16> vertexmap;
vertexmap.reserve(nargs);
for (int i = 0; i < nargs; i++)
{
if (is_table)
{
lua_rawgeti(L, 2, i + 1);
vertexmap.push_back(uint16(luaL_checkinteger(L, -1) - 1));
lua_pop(L, 1);
}
else
vertexmap.push_back(uint16(luaL_checkinteger(L, i + 2) - 1));
}
EXCEPT_GUARD(g->setElementArray(&vertexmap[0], vertexmap.size());)
return 0;
}
static const luaL_Reg w_Geometry_functions[] =
{
{ "getVertexCount", w_Geometry_getVertexCount },
{ "getVertex", w_Geometry_getVertex },
{ "setVertex", w_Geometry_setVertex },
{ "setVertexColors", w_Geometry_setVertexColors },
{ "hasVertexColors", w_Geometry_hasVertexColors },
{ "getDrawMode", w_Geometry_getDrawMode },
{ "getVertexMap", w_Geometry_getVertexMap },
{ "setVertexMap", w_Geometry_setVertexMap },
{ 0, 0 }
};
extern "C" int luaopen_geometry(lua_State *L)
{
return luax_register_type(L, "Geometry", w_Geometry_functions);
}
} // opengl
} // graphics
} // love
@@ -304,7 +304,7 @@ int w_newParticleSystem(lua_State *L)
if (size < 1.0 || size > ParticleSystem::MAX_PARTICLES)
return luaL_error(L, "Invalid ParticleSystem size");
EXCEPT_GUARD(t = instance->newParticleSystem(image, size);)
EXCEPT_GUARD(t = instance->newParticleSystem(image, int(size));)
luax_pushtype(L, "ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_T, t);
return 1;
@@ -688,7 +688,7 @@ int w_setDefaultMipmapFilter(lua_State *L)
return luaL_error(L, "Invalid filter mode: %s", str);
}
float sharpness = luaL_optnumber(L, 2, 0);
float sharpness = (float) luaL_optnumber(L, 2, 0);
instance->setDefaultMipmapFilter(filter, sharpness);
@@ -49,6 +49,7 @@ int w_getDimensions(lua_State *L);
int w_setScissor(lua_State *L);
int w_getScissor(lua_State *L);
int w_setStencil(lua_State *L);
int w_setInvertedStencil(lua_State *L);
int w_getMaxImageSize(lua_State *L);
int w_newImage(lua_State *L);
int w_newQuad(lua_State *L);
@@ -99,6 +100,7 @@ int w_line(lua_State *L);
int w_rectangle(lua_State *L);
int w_circle(lua_State *L);
int w_arc(lua_State *L);
int w_polygon(lua_State *L);
int w_push(lua_State *L);
int w_pop(lua_State *L);
int w_rotate(lua_State *L);
+1 -1
View File
@@ -104,7 +104,7 @@ int w_Image_setMipmapFilter(lua_State *L)
EXCEPT_GUARD(t->setFilter(f);)
float sharpness = luaL_optnumber(L, 3, 0);
float sharpness = (float) luaL_optnumber(L, 3, 0);
t->setMipmapSharpness(sharpness);
return 0;
+1 -1
View File
@@ -37,7 +37,7 @@ int w_Image_getWidth(lua_State *L);
int w_Image_getHeight(lua_State *L);
int w_Image_getDimensions(lua_State *L);
int w_Image_setFilter(lua_State *L);
int w_image_getFilter(lua_State *L);
int w_Image_getFilter(lua_State *L);
int w_Image_setMipmapFilter(lua_State *L);
int w_Image_getMipmapFilter(lua_State *L);
int w_Image_setWrap(lua_State *L);
@@ -457,10 +457,10 @@ int w_ParticleSystem_setColors(lua_State *L)
// push args[i+2][j+1] onto the stack
lua_rawgeti(L, i + 2, j + 1);
int r = luaL_checkint(L, -4);
int g = luaL_checkint(L, -3);
int b = luaL_checkint(L, -2);
int a = luaL_optint(L, -1, 255);
unsigned char r = (unsigned char) luaL_checkinteger(L, -4);
unsigned char g = (unsigned char) luaL_checkinteger(L, -3);
unsigned char b = (unsigned char) luaL_checkinteger(L, -2);
unsigned char a = (unsigned char) luaL_optinteger(L, -1, 255);
// pop the color components from the stack
lua_pop(L, 4);
@@ -483,10 +483,10 @@ int w_ParticleSystem_setColors(lua_State *L)
if (nColors == 1)
{
int r = luaL_checkint(L, 2);
int g = luaL_checkint(L, 3);
int b = luaL_checkint(L, 4);
int a = luaL_optint(L, 5, 255);
unsigned char r = (unsigned char) luaL_checkinteger(L, 2);
unsigned char g = (unsigned char) luaL_checkinteger(L, 3);
unsigned char b = (unsigned char) luaL_checkinteger(L, 4);
unsigned char a = (unsigned char) luaL_optinteger(L, 5, 255);
t->setColor(Color(r,g,b,a));
}
else
@@ -494,10 +494,10 @@ int w_ParticleSystem_setColors(lua_State *L)
std::vector<Color> colors(nColors);
for (size_t i = 0; i < nColors; ++i)
{
int r = luaL_checkint(L, 1 + i*4 + 1);
int g = luaL_checkint(L, 1 + i*4 + 2);
int b = luaL_checkint(L, 1 + i*4 + 3);
int a = luaL_checkint(L, 1 + i*4 + 4);
unsigned char r = (unsigned char) luaL_checkinteger(L, 1 + i*4 + 1);
unsigned char g = (unsigned char) luaL_checkinteger(L, 1 + i*4 + 2);
unsigned char b = (unsigned char) luaL_checkinteger(L, 1 + i*4 + 3);
unsigned char a = (unsigned char) luaL_checkinteger(L, 1 + i*4 + 4);
colors[i] = Color(r,g,b,a);
}
t->setColor(colors);
@@ -37,6 +37,7 @@ int w_Shader_sendInt(lua_State *L);
int w_Shader_sendFloat(lua_State *L);
int w_Shader_sendMatrix(lua_State *L);
int w_Shader_sendImage(lua_State *L);
int w_Shader_sendCanvas(lua_State *L);
int w_Shader_send(lua_State *L);
extern "C" int luaopen_shader(lua_State *L);
@@ -154,19 +154,19 @@ int w_SpriteBatch_setColor(lua_State *L)
for (int i = 1; i <= 4; i++)
lua_rawgeti(L, 2, i);
c.r = (unsigned char) luaL_checkint(L, -4);
c.g = (unsigned char) luaL_checkint(L, -3);
c.b = (unsigned char) luaL_checkint(L, -2);
c.a = (unsigned char) luaL_optint(L, -1, 255);
c.r = (unsigned char) luaL_checkinteger(L, -4);
c.g = (unsigned char) luaL_checkinteger(L, -3);
c.b = (unsigned char) luaL_checkinteger(L, -2);
c.a = (unsigned char) luaL_optinteger(L, -1, 255);
lua_pop(L, 4);
}
else
{
c.r = (unsigned char)luaL_checkint(L, 2);
c.g = (unsigned char)luaL_checkint(L, 3);
c.b = (unsigned char)luaL_checkint(L, 4);
c.a = (unsigned char)luaL_optint(L, 5, 255);
c.r = (unsigned char)luaL_checkinteger(L, 2);
c.g = (unsigned char)luaL_checkinteger(L, 3);
c.b = (unsigned char)luaL_checkinteger(L, 4);
c.a = (unsigned char)luaL_optinteger(L, 5, 255);
}
t->setColor(c);
+10 -10
View File
@@ -69,8 +69,8 @@ int w_BezierCurve_setControlPoint(lua_State *L)
{
BezierCurve *curve = luax_checkbeziercurve(L, 1);
int idx = luaL_checkinteger(L, 2);
double vx = luaL_checknumber(L, 3);
double vy = luaL_checknumber(L, 4);
float vx = (float) luaL_checknumber(L, 3);
float vy = (float) luaL_checknumber(L, 4);
if (idx > 0) // 1-indexing
idx--;
@@ -82,8 +82,8 @@ int w_BezierCurve_setControlPoint(lua_State *L)
int w_BezierCurve_insertControlPoint(lua_State *L)
{
BezierCurve *curve = luax_checkbeziercurve(L, 1);
double vx = luaL_checknumber(L, 2);
double vy = luaL_checknumber(L, 3);
float vx = (float) luaL_checknumber(L, 2);
float vy = (float) luaL_checknumber(L, 3);
int idx = luaL_optinteger(L, 4, -1);
if (idx > 0) // 1-indexing
@@ -96,8 +96,8 @@ int w_BezierCurve_insertControlPoint(lua_State *L)
int w_BezierCurve_translate(lua_State *L)
{
BezierCurve *curve = luax_checkbeziercurve(L, 1);
double dx = luaL_checknumber(L, 2);
double dy = luaL_checknumber(L, 3);
float dx = (float) luaL_checknumber(L, 2);
float dy = (float) luaL_checknumber(L, 3);
curve->translate(Vector(dx,dy));
return 0;
}
@@ -106,8 +106,8 @@ int w_BezierCurve_rotate(lua_State *L)
{
BezierCurve *curve = luax_checkbeziercurve(L, 1);
double phi = luaL_checknumber(L, 2);
double ox = luaL_optnumber(L, 3, 0);
double oy = luaL_optnumber(L, 4, 0);
float ox = (float) luaL_optnumber(L, 3, 0);
float oy = (float) luaL_optnumber(L, 4, 0);
curve->rotate(phi, Vector(ox,oy));
return 0;
}
@@ -116,8 +116,8 @@ int w_BezierCurve_scale(lua_State *L)
{
BezierCurve *curve = luax_checkbeziercurve(L, 1);
double s = luaL_checknumber(L, 2);
double ox = luaL_optnumber(L, 3, 0);
double oy = luaL_optnumber(L, 4, 0);
float ox = (float) luaL_optnumber(L, 3, 0);
float oy = (float) luaL_optnumber(L, 4, 0);
curve->scale(s, Vector(ox,oy));
return 0;
}
+22 -22
View File
@@ -106,8 +106,8 @@ int w_newBezierCurve(lua_State *L)
lua_rawgeti(L, 1, i+1);
Vector v;
v.x = luaL_checknumber(L, -2);
v.y = luaL_checknumber(L, -1);
v.x = (float) luaL_checknumber(L, -2);
v.y = (float) luaL_checknumber(L, -1);
points.push_back(v);
lua_pop(L, 2);
@@ -120,8 +120,8 @@ int w_newBezierCurve(lua_State *L)
for (size_t i = 1; i <= top; i += 2)
{
Vector v;
v.x = luaL_checknumber(L, i);
v.y = luaL_checknumber(L, i+1);
v.x = (float) luaL_checknumber(L, i);
v.y = (float) luaL_checknumber(L, i+1);
points.push_back(v);
}
}
@@ -144,8 +144,8 @@ int w_triangulate(lua_State *L)
lua_rawgeti(L, 1, i+1);
Vertex v;
v.x = luaL_checknumber(L, -2);
v.y = luaL_checknumber(L, -1);
v.x = (float) luaL_checknumber(L, -2);
v.y = (float) luaL_checknumber(L, -1);
vertices.push_back(v);
lua_pop(L, 2);
@@ -158,8 +158,8 @@ int w_triangulate(lua_State *L)
for (size_t i = 1; i <= top; i += 2)
{
Vertex v;
v.x = luaL_checknumber(L, i);
v.y = luaL_checknumber(L, i+1);
v.x = (float) luaL_checknumber(L, i);
v.y = (float) luaL_checknumber(L, i+1);
vertices.push_back(v);
}
}
@@ -214,8 +214,8 @@ int w_isConvex(lua_State *L)
lua_rawgeti(L, 1, i+1);
Vertex v;
v.x = luaL_checknumber(L, -2);
v.y = luaL_checknumber(L, -1);
v.x = (float) luaL_checknumber(L, -2);
v.y = (float) luaL_checknumber(L, -1);
vertices.push_back(v);
lua_pop(L, 2);
@@ -228,8 +228,8 @@ int w_isConvex(lua_State *L)
for (size_t i = 1; i <= top; i += 2)
{
Vertex v;
v.x = luaL_checknumber(L, i);
v.y = luaL_checknumber(L, i+1);
v.x = (float) luaL_checknumber(L, i);
v.y = (float) luaL_checknumber(L, i+1);
vertices.push_back(v);
}
}
@@ -246,26 +246,26 @@ int w_noise(lua_State *L)
switch (lua_gettop(L))
{
case 1:
x = luaL_checknumber(L, 1);
x = (float) luaL_checknumber(L, 1);
val = Math::instance.noise(x);
break;
case 2:
x = luaL_checknumber(L, 1);
y = luaL_checknumber(L, 2);
x = (float) luaL_checknumber(L, 1);
y = (float) luaL_checknumber(L, 2);
val = Math::instance.noise(x, y);
break;
case 3:
x = luaL_checknumber(L, 1);
y = luaL_checknumber(L, 2);
z = luaL_checknumber(L, 3);
x = (float) luaL_checknumber(L, 1);
y = (float) luaL_checknumber(L, 2);
z = (float) luaL_checknumber(L, 3);
val = Math::instance.noise(x, y, z);
break;
case 4:
default:
x = luaL_checknumber(L, 1);
y = luaL_checknumber(L, 2);
z = luaL_checknumber(L, 3);
w = luaL_checknumber(L, 4);
x = (float) luaL_checknumber(L, 1);
y = (float) luaL_checknumber(L, 2);
z = (float) luaL_checknumber(L, 3);
w = (float) luaL_checknumber(L, 4);
val = Math::instance.noise(x, y, z, w);
break;
}
+2 -2
View File
@@ -42,10 +42,10 @@ public:
BUTTON_LEFT,
BUTTON_MIDDLE,
BUTTON_RIGHT,
BUTTON_WHEELUP,
BUTTON_WHEELDOWN,
BUTTON_X1,
BUTTON_X2,
BUTTON_WHEELUP,
BUTTON_WHEELDOWN,
BUTTON_MAX_ENUM
};
+1 -1
View File
@@ -130,7 +130,7 @@ void Mouse::setVisible(bool visible)
bool Mouse::isDown(Button *buttonlist) const
{
Uint8 buttonstate = SDL_GetMouseState(0, 0);
Uint32 buttonstate = SDL_GetMouseState(0, 0);
for (Button button = *buttonlist; button != BUTTON_MAX_ENUM; button = *(++buttonlist))
{
+6 -6
View File
@@ -140,18 +140,18 @@ bool Fixture::isValid() const
void Fixture::setFilterData(int *v)
{
b2Filter f;
f.categoryBits = (unsigned short)v[0];
f.maskBits = (unsigned short)v[1];
f.groupIndex = v[2];
f.categoryBits = (uint16) v[0];
f.maskBits = (uint16) v[1];
f.groupIndex = (int16) v[2];
fixture->SetFilterData(f);
}
void Fixture::getFilterData(int *v)
{
b2Filter f = fixture->GetFilterData();
v[0] = (int)f.categoryBits;
v[1] = (int)f.maskBits;
v[2] = f.groupIndex;
v[0] = (int) f.categoryBits;
v[1] = (int) f.maskBits;
v[2] = (int) f.groupIndex;
}
int Fixture::setCategory(lua_State *L)
+4 -4
View File
@@ -34,13 +34,13 @@ namespace lullaby
/**
* CALLBACK FUNCTIONS
**/
int vorbisClose(void * /* ptr to the data that the vorbis files need*/)
static int vorbisClose(void * /* ptr to the data that the vorbis files need*/)
{
// Does nothing (handled elsewhere)
return 1;
}
size_t vorbisRead(void *ptr /* ptr to the data that the vorbis files need*/,
static size_t vorbisRead(void *ptr /* ptr to the data that the vorbis files need*/,
size_t byteSize /* how big a byte is*/,
size_t sizeToRead /* How much we can read*/,
void *datasource /* this is a pointer to the data we passed into ov_open_callbacks (our SOggFile struct*/)
@@ -72,7 +72,7 @@ size_t vorbisRead(void *ptr /* ptr to the data that the vorbis files need*/,
return actualSizeToRead;
}
int vorbisSeek(void *datasource /* ptr to the data that the vorbis files need*/,
static int vorbisSeek(void *datasource /* ptr to the data that the vorbis files need*/,
ogg_int64_t offset /*offset from the point we wish to seek to*/,
int whence /*where we want to seek to*/)
{
@@ -116,7 +116,7 @@ int vorbisSeek(void *datasource /* ptr to the data that the vorbis files need*/,
return 0;
}
long vorbisTell(void *datasource /* ptr to the data that the vorbis files need*/)
static long vorbisTell(void *datasource /* ptr to the data that the vorbis files need*/)
{
SOggFile *vorbisData;
vorbisData = (SOggFile *) datasource;
+7 -8
View File
@@ -31,14 +31,13 @@ namespace sound
{
SoundData *luax_checksounddata(lua_State *L, int idx);
int w_getSize(lua_State *L);
int w_getChannels(lua_State *L);
int w_getBitDepth(lua_State *L);
int w_getSampleRate(lua_State *L);
int w_getSampleCount(lua_State *L);
int w_getDuration(lua_State *L);
int w_setSample(lua_State *L);
int w_getSample(lua_State *L);
int w_SoundData_getChannels(lua_State *L);
int w_SoundData_getBitDepth(lua_State *L);
int w_SoundData_getSampleRate(lua_State *L);
int w_SoundData_getSampleCount(lua_State *L);
int w_SoundData_getDuration(lua_State *L);
int w_SoundData_setSample(lua_State *L);
int w_SoundData_getSample(lua_State *L);
extern "C" int luaopen_sounddata(lua_State *L);
} // sound