mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Automated formatting fix
This commit is contained in:
@@ -1,33 +1,33 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#include "DrawQable.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
|
||||
DrawQable::~DrawQable()
|
||||
{
|
||||
}
|
||||
|
||||
} // graphics
|
||||
} // love
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#include "DrawQable.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
|
||||
DrawQable::~DrawQable()
|
||||
{
|
||||
}
|
||||
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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
|
||||
@@ -43,7 +43,7 @@ namespace graphics
|
||||
|
||||
/**
|
||||
* Draws the object with the specified transformation.
|
||||
*
|
||||
*
|
||||
* @param quad The Quad to use to draw the object.
|
||||
* @param x The position of the object along the x-axis.
|
||||
* @param y The position of the object along the y-axis.
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#include "Drawable.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
|
||||
Drawable::~Drawable()
|
||||
{
|
||||
}
|
||||
|
||||
} // graphics
|
||||
} // love
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#include "Drawable.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
|
||||
Drawable::~Drawable()
|
||||
{
|
||||
}
|
||||
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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
|
||||
@@ -43,7 +43,7 @@ namespace graphics
|
||||
|
||||
/**
|
||||
* Draws the object with the specified transformation.
|
||||
*
|
||||
*
|
||||
* @param x The position of the object along the x-axis.
|
||||
* @param y The position of the object along the y-axis.
|
||||
* @param angle The angle of the object (in radians).
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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
|
||||
@@ -35,43 +35,43 @@ namespace graphics
|
||||
Image::~Image()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool Image::getConstant(const char * in, FilterMode & out)
|
||||
{
|
||||
return filterModes.find(in, out);
|
||||
}
|
||||
|
||||
|
||||
bool Image::getConstant(FilterMode in, const char *& out)
|
||||
{
|
||||
return filterModes.find(in, out);
|
||||
}
|
||||
|
||||
|
||||
bool Image::getConstant(const char * in, WrapMode & out)
|
||||
{
|
||||
return wrapModes.find(in, out);
|
||||
}
|
||||
|
||||
|
||||
bool Image::getConstant(WrapMode in, const char *& out)
|
||||
{
|
||||
return wrapModes.find(in, out);
|
||||
}
|
||||
|
||||
StringMap<Image::FilterMode, Image::FILTER_MAX_ENUM>::Entry Image::filterModeEntries[] =
|
||||
|
||||
StringMap<Image::FilterMode, Image::FILTER_MAX_ENUM>::Entry Image::filterModeEntries[] =
|
||||
{
|
||||
{ "linear", Image::FILTER_LINEAR },
|
||||
{ "nearest", Image::FILTER_NEAREST },
|
||||
};
|
||||
|
||||
|
||||
StringMap<Image::FilterMode, Image::FILTER_MAX_ENUM> Image::filterModes(Image::filterModeEntries, sizeof(Image::filterModeEntries));
|
||||
|
||||
StringMap<Image::WrapMode, Image::WRAP_MAX_ENUM>::Entry Image::wrapModeEntries[] =
|
||||
StringMap<Image::WrapMode, Image::WRAP_MAX_ENUM>::Entry Image::wrapModeEntries[] =
|
||||
{
|
||||
{ "clamp", Image::WRAP_CLAMP },
|
||||
{ "repeat", Image::WRAP_REPEAT },
|
||||
};
|
||||
|
||||
|
||||
StringMap<Image::WrapMode, Image::WRAP_MAX_ENUM> Image::wrapModes(Image::wrapModeEntries, sizeof(Image::wrapModeEntries));
|
||||
|
||||
|
||||
|
||||
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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
|
||||
@@ -30,14 +30,14 @@ namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
|
||||
|
||||
class Image : public DrawQable, public Volatile
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
enum WrapMode
|
||||
{
|
||||
WRAP_CLAMP = 1,
|
||||
WRAP_CLAMP = 1,
|
||||
WRAP_REPEAT,
|
||||
WRAP_MAX_ENUM
|
||||
};
|
||||
@@ -64,21 +64,21 @@ namespace graphics
|
||||
};
|
||||
|
||||
virtual ~Image();
|
||||
|
||||
|
||||
static bool getConstant(const char * in, FilterMode & out);
|
||||
static bool getConstant(FilterMode in, const char *& out);
|
||||
static bool getConstant(const char * in, WrapMode & out);
|
||||
static bool getConstant(WrapMode in, const char *& out);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
static StringMap<FilterMode, FILTER_MAX_ENUM>::Entry filterModeEntries[];
|
||||
static StringMap<FilterMode, FILTER_MAX_ENUM> filterModes;
|
||||
static StringMap<WrapMode, WRAP_MAX_ENUM>::Entry wrapModeEntries[];
|
||||
static StringMap<WrapMode, WRAP_MAX_ENUM> wrapModes;
|
||||
|
||||
}; // Image
|
||||
|
||||
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#include "Quad.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
Quad::Quad()
|
||||
{
|
||||
}
|
||||
|
||||
Quad::~Quad()
|
||||
{
|
||||
}
|
||||
|
||||
} // graphics
|
||||
} // love
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#include "Quad.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
Quad::Quad()
|
||||
{
|
||||
}
|
||||
|
||||
Quad::~Quad()
|
||||
{
|
||||
}
|
||||
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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
|
||||
@@ -37,7 +37,7 @@ namespace graphics
|
||||
Volatile::~Volatile()
|
||||
{
|
||||
// Remove the pointer to this object.
|
||||
all.remove(this);
|
||||
all.remove(this);
|
||||
}
|
||||
|
||||
bool Volatile::loadAll()
|
||||
@@ -45,7 +45,7 @@ namespace graphics
|
||||
bool success = true;
|
||||
std::list<Volatile *>::iterator i = all.begin();
|
||||
|
||||
while( i != all.end() )
|
||||
while ( i != all.end() )
|
||||
{
|
||||
success = success && (*i)->loadVolatile();
|
||||
i++;
|
||||
@@ -58,7 +58,7 @@ namespace graphics
|
||||
{
|
||||
std::list<Volatile *>::iterator i = all.begin();
|
||||
|
||||
while( i != all.end() )
|
||||
while ( i != all.end() )
|
||||
{
|
||||
(*i)->unloadVolatile();
|
||||
i++;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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
|
||||
@@ -59,7 +59,7 @@ namespace graphics
|
||||
/**
|
||||
* Loads the part(s) of the object which is destroyed when
|
||||
* the display mode is changed.
|
||||
*
|
||||
*
|
||||
* @return True if successful, false on errors.
|
||||
**/
|
||||
virtual bool loadVolatile() = 0;
|
||||
@@ -70,11 +70,11 @@ namespace graphics
|
||||
**/
|
||||
virtual void unloadVolatile() = 0;
|
||||
|
||||
// Static:
|
||||
// Static:
|
||||
|
||||
/**
|
||||
* Calls \c loadVolatile() on each element in the list of volatiles.
|
||||
*
|
||||
*
|
||||
* @return True if all elements succeeded, false if one or more failed.
|
||||
**/
|
||||
static bool loadAll();
|
||||
|
||||
@@ -29,8 +29,8 @@ namespace love
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
// strategy for fbo creation, interchangable at runtime:
|
||||
// none, opengl >= 3.0, extensions
|
||||
struct FramebufferStrategy {
|
||||
@@ -159,20 +159,21 @@ namespace opengl
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
FramebufferStrategy* strategy = NULL;
|
||||
|
||||
|
||||
FramebufferStrategy strategyNone;
|
||||
|
||||
|
||||
FramebufferStrategyGL3 strategyGL3;
|
||||
|
||||
|
||||
FramebufferStrategyEXT strategyEXT;
|
||||
|
||||
|
||||
Canvas* Canvas::current = NULL;
|
||||
|
||||
static void loadStrategy()
|
||||
{
|
||||
if (!strategy) {
|
||||
if (!strategy)
|
||||
{
|
||||
if (GLEE_VERSION_3_0 || GLEE_ARB_framebuffer_object)
|
||||
strategy = &strategyGL3;
|
||||
else if (GLEE_EXT_framebuffer_object && GLEE_EXT_packed_depth_stencil)
|
||||
@@ -240,15 +241,15 @@ namespace opengl
|
||||
glPushAttrib(GL_VIEWPORT_BIT | GL_TRANSFORM_BIT);
|
||||
strategy->bindFBO(fbo);
|
||||
glViewport(0, 0, width, height);
|
||||
|
||||
|
||||
// Reset the projection matrix
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
|
||||
// Set up orthographic view (no depth)
|
||||
glOrtho(0.0, width, height, 0.0, -1.0, 1.0);
|
||||
|
||||
|
||||
// Switch back to modelview matrix
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
@@ -293,7 +294,7 @@ namespace opengl
|
||||
|
||||
drawv(t, vertices);
|
||||
}
|
||||
|
||||
|
||||
void Canvas::drawq(love::graphics::Quad * quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const
|
||||
{
|
||||
static Matrix t;
|
||||
@@ -326,7 +327,7 @@ namespace opengl
|
||||
memcpy(dst -= row, src += row, row);
|
||||
|
||||
love::image::ImageData* img = image->newImageData(width, height, (void*)screenshot);
|
||||
|
||||
|
||||
delete[] screenshot;
|
||||
delete[] pixels;
|
||||
|
||||
@@ -395,7 +396,7 @@ namespace opengl
|
||||
clear(c);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Canvas::unloadVolatile()
|
||||
{
|
||||
settings.filter = getFilter();
|
||||
@@ -412,15 +413,15 @@ namespace opengl
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
|
||||
void Canvas::drawv(const Matrix & t, const vertex * v) const
|
||||
{
|
||||
glPushMatrix();
|
||||
|
||||
|
||||
glMultMatrixf((const GLfloat*)t.getElements());
|
||||
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, img);
|
||||
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)&v[0].x);
|
||||
@@ -428,7 +429,7 @@ namespace opengl
|
||||
glDrawArrays(GL_QUADS, 0, 4);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace opengl
|
||||
* @copydoc DrawQable::drawq()
|
||||
**/
|
||||
void drawq(love::graphics::Quad * quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
|
||||
|
||||
|
||||
love::image::ImageData * getImageData(love::image::Image * image);
|
||||
|
||||
void setFilter(const Image::Filter &f);
|
||||
@@ -94,7 +94,7 @@ namespace opengl
|
||||
Image::Filter filter;
|
||||
Image::Wrap wrap;
|
||||
} settings;
|
||||
|
||||
|
||||
void drawv(const Matrix & t, const vertex * v) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace opengl
|
||||
rasterizer->release();
|
||||
unloadVolatile();
|
||||
}
|
||||
|
||||
|
||||
void Font::createTexture()
|
||||
{
|
||||
texture_x = texture_y = rowHeight = 0;
|
||||
@@ -62,7 +62,7 @@ namespace opengl
|
||||
glGenTextures(1, &t);
|
||||
textures.push_back(t);
|
||||
glBindTexture(GL_TEXTURE_2D, t);
|
||||
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
||||
(filter.mag == Image::FILTER_LINEAR) ? GL_LINEAR : GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||
@@ -70,22 +70,23 @@ namespace opengl
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
GLint format = (type == FONT_TRUETYPE ? GL_LUMINANCE_ALPHA : GL_RGBA);
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RGBA,
|
||||
(GLsizei)TEXTURE_WIDTH,
|
||||
(GLsizei)TEXTURE_HEIGHT,
|
||||
0,
|
||||
format,
|
||||
GL_UNSIGNED_BYTE,
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RGBA,
|
||||
(GLsizei)TEXTURE_WIDTH,
|
||||
(GLsizei)TEXTURE_HEIGHT,
|
||||
0,
|
||||
format,
|
||||
GL_UNSIGNED_BYTE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
Font::Glyph * Font::addGlyph(int glyph)
|
||||
{
|
||||
Glyph * g = new Glyph;
|
||||
g->list = glGenLists(1);
|
||||
if (g->list == 0) { // opengl failed to generate the list
|
||||
if (g->list == 0)
|
||||
{ // opengl failed to generate the list
|
||||
delete g;
|
||||
return NULL;
|
||||
}
|
||||
@@ -93,18 +94,20 @@ namespace opengl
|
||||
g->spacing = gd->getAdvance();
|
||||
int w = gd->getWidth();
|
||||
int h = gd->getHeight();
|
||||
if (texture_x + w > TEXTURE_WIDTH) { // out of space - new row!
|
||||
if (texture_x + w > TEXTURE_WIDTH)
|
||||
{ // out of space - new row!
|
||||
texture_x = 0;
|
||||
texture_y += rowHeight;
|
||||
rowHeight = 0;
|
||||
}
|
||||
if (texture_y + h > TEXTURE_HEIGHT) { // totally out of space - new texture!
|
||||
if (texture_y + h > TEXTURE_HEIGHT)
|
||||
{ // totally out of space - new texture!
|
||||
createTexture();
|
||||
}
|
||||
GLuint t = textures.back();
|
||||
glBindTexture(GL_TEXTURE_2D, t);
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, texture_x, texture_y, w, h, (type == FONT_TRUETYPE ? GL_LUMINANCE_ALPHA : GL_RGBA), GL_UNSIGNED_BYTE, gd->getData());
|
||||
|
||||
|
||||
Quad::Viewport v;
|
||||
v.x = (float) texture_x;
|
||||
v.y = (float) texture_y;
|
||||
@@ -112,12 +115,12 @@ namespace opengl
|
||||
v.h = (float) h;
|
||||
Quad * q = new Quad(v, (const float) TEXTURE_WIDTH, (const float) TEXTURE_HEIGHT);
|
||||
const vertex * verts = q->getVertices();
|
||||
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&verts[0].x);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&verts[0].s);
|
||||
|
||||
|
||||
glNewList(g->list, GL_COMPILE);
|
||||
glBindTexture(GL_TEXTURE_2D, t);
|
||||
glPushMatrix();
|
||||
@@ -125,16 +128,16 @@ namespace opengl
|
||||
glDrawArrays(GL_QUADS, 0, 4);
|
||||
glPopMatrix();
|
||||
glEndList();
|
||||
|
||||
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
|
||||
delete q;
|
||||
delete gd;
|
||||
|
||||
|
||||
texture_x += w;
|
||||
rowHeight = std::max(rowHeight, h);
|
||||
|
||||
|
||||
glyphs[glyph] = g;
|
||||
return g;
|
||||
}
|
||||
@@ -156,9 +159,11 @@ namespace opengl
|
||||
{
|
||||
utf8::iterator<std::string::iterator> i (text.begin(), text.begin(), text.end());
|
||||
utf8::iterator<std::string::iterator> end (text.end(), text.begin(), text.end());
|
||||
while (i != end) {
|
||||
while (i != end)
|
||||
{
|
||||
int g = *i++;
|
||||
if (g == '\n') { // wrap newline, but do not print it
|
||||
if (g == '\n')
|
||||
{ // wrap newline, but do not print it
|
||||
glTranslatef(-dx, floor(getHeight() * getLineHeight() + 0.5f), 0);
|
||||
dx = 0.0f;
|
||||
continue;
|
||||
@@ -194,16 +199,17 @@ namespace opengl
|
||||
|
||||
int Font::getWidth(const std::string & line)
|
||||
{
|
||||
if(line.size() == 0) return 0;
|
||||
if (line.size() == 0) return 0;
|
||||
int temp = 0;
|
||||
|
||||
|
||||
Glyph * g;
|
||||
|
||||
try
|
||||
{
|
||||
utf8::iterator<std::string::const_iterator> i (line.begin(), line.begin(), line.end());
|
||||
utf8::iterator<std::string::const_iterator> end (line.end(), line.begin(), line.end());
|
||||
while (i != end) {
|
||||
while (i != end)
|
||||
{
|
||||
int c = *i++;
|
||||
g = glyphs[c];
|
||||
if (!g) g = addGlyph(c);
|
||||
@@ -240,7 +246,8 @@ namespace opengl
|
||||
//split text at newlines
|
||||
istringstream iss( text );
|
||||
string line;
|
||||
while (getline(iss, line, '\n')) {
|
||||
while (getline(iss, line, '\n'))
|
||||
{
|
||||
// split line into words
|
||||
vector<string> words;
|
||||
istringstream word_iss(line);
|
||||
@@ -252,12 +259,14 @@ namespace opengl
|
||||
float oldwidth = 0.0f;
|
||||
ostringstream string_builder;
|
||||
vector<string>::const_iterator word_iter;
|
||||
for (word_iter = words.begin(); word_iter != words.end(); ++word_iter) {
|
||||
for (word_iter = words.begin(); word_iter != words.end(); ++word_iter)
|
||||
{
|
||||
string word( *word_iter );
|
||||
width += getWidth( word );
|
||||
|
||||
// on wordwrap, push line to line buffer and clear string builder
|
||||
if (width >= wrap && oldwidth > 0) {
|
||||
if (width >= wrap && oldwidth > 0)
|
||||
{
|
||||
int realw = width;
|
||||
lines_to_draw.push_back( string_builder.str() );
|
||||
string_builder.str( "" );
|
||||
@@ -313,14 +322,16 @@ namespace opengl
|
||||
// nuke everything from orbit
|
||||
std::map<int, Glyph *>::iterator it = glyphs.begin();
|
||||
Glyph * g;
|
||||
while (it != glyphs.end()) {
|
||||
while (it != glyphs.end())
|
||||
{
|
||||
g = it->second;
|
||||
glDeleteLists(g->list, 1);
|
||||
delete g;
|
||||
glyphs.erase(it++);
|
||||
}
|
||||
std::vector<GLuint>::iterator iter = textures.begin();
|
||||
while (iter != textures.end()) {
|
||||
while (iter != textures.end())
|
||||
{
|
||||
glDeleteTextures(1, (GLuint*)&*iter);
|
||||
iter++;
|
||||
}
|
||||
|
||||
@@ -42,20 +42,20 @@ namespace opengl
|
||||
class Font : public Object, public Volatile
|
||||
{
|
||||
private:
|
||||
|
||||
|
||||
enum FontType
|
||||
{
|
||||
FONT_TRUETYPE = 1,
|
||||
FONT_IMAGE,
|
||||
FONT_UNKNOWN
|
||||
};
|
||||
|
||||
|
||||
struct Glyph
|
||||
{
|
||||
GLuint list;
|
||||
int spacing;
|
||||
};
|
||||
|
||||
|
||||
love::font::Rasterizer * rasterizer;
|
||||
|
||||
int height;
|
||||
@@ -65,13 +65,13 @@ namespace opengl
|
||||
std::map<int, Glyph *> glyphs; // maps glyphs to display lists
|
||||
FontType type;
|
||||
Image::Filter filter;
|
||||
|
||||
|
||||
static const int TEXTURE_WIDTH = 512;
|
||||
static const int TEXTURE_HEIGHT = 512;
|
||||
|
||||
|
||||
int texture_x, texture_y;
|
||||
int rowHeight;
|
||||
|
||||
|
||||
void createTexture();
|
||||
Glyph * addGlyph(int glyph);
|
||||
|
||||
@@ -166,10 +166,10 @@ namespace opengl
|
||||
* Returns the spacing modifier.
|
||||
**/
|
||||
float getSpacing() const;
|
||||
|
||||
|
||||
// Implements Volatile.
|
||||
bool loadVolatile();
|
||||
void unloadVolatile();
|
||||
void unloadVolatile();
|
||||
|
||||
}; // Font
|
||||
|
||||
|
||||
@@ -48,13 +48,13 @@ namespace opengl
|
||||
// Window should be centered.
|
||||
SDL_putenv(const_cast<char *>("SDL_VIDEO_CENTERED=center"));
|
||||
|
||||
if(SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
|
||||
throw Exception(SDL_GetError());
|
||||
}
|
||||
|
||||
Graphics::~Graphics()
|
||||
{
|
||||
if(currentFont != 0)
|
||||
if (currentFont != 0)
|
||||
currentFont->release();
|
||||
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
@@ -156,7 +156,7 @@ namespace opengl
|
||||
// love.mouse.getX() < 800 when switching from 800x600 to a
|
||||
// higher resolution)
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
if(SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
|
||||
{
|
||||
std::cout << "Could not init SDL_VIDEO: " << SDL_GetError() << std::endl;
|
||||
return false;
|
||||
@@ -173,7 +173,7 @@ namespace opengl
|
||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 1);
|
||||
|
||||
// FSAA
|
||||
if(fsaa > 0)
|
||||
if (fsaa > 0)
|
||||
{
|
||||
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ) ;
|
||||
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, fsaa ) ;
|
||||
@@ -183,14 +183,14 @@ namespace opengl
|
||||
// Fullscreen?
|
||||
Uint32 sdlflags = fullscreen ? (SDL_OPENGL | SDL_FULLSCREEN) : SDL_OPENGL;
|
||||
|
||||
if(!isCreated())
|
||||
if (!isCreated())
|
||||
setCaption("");
|
||||
|
||||
// Have SDL set the video mode.
|
||||
if(SDL_SetVideoMode(width, height, 32, sdlflags ) == 0)
|
||||
if (SDL_SetVideoMode(width, height, 32, sdlflags ) == 0)
|
||||
{
|
||||
bool failed = true;
|
||||
if(fsaa > 0)
|
||||
if (fsaa > 0)
|
||||
{
|
||||
// FSAA might have failed, disable it and try again
|
||||
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
|
||||
@@ -202,7 +202,7 @@ namespace opengl
|
||||
failed = SDL_SetVideoMode(width, height, 32, sdlflags ) == 0;
|
||||
}
|
||||
}
|
||||
if(failed)
|
||||
if (failed)
|
||||
{
|
||||
std::cerr << "Could not set video mode: " << SDL_GetError() << std::endl;
|
||||
return false;
|
||||
@@ -258,7 +258,7 @@ namespace opengl
|
||||
// Reset modelview matrix
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
|
||||
// Set pixel row alignment
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
|
||||
|
||||
@@ -275,12 +275,12 @@ namespace opengl
|
||||
currentMode.vsync = (real_vsync != 0);
|
||||
|
||||
// Reload all volatile objects.
|
||||
if(!Volatile::loadAll())
|
||||
if (!Volatile::loadAll())
|
||||
std::cerr << "Could not reload all volatile objects." << std::endl;
|
||||
|
||||
// Restore the display state.
|
||||
restoreState(tempState);
|
||||
|
||||
|
||||
// Get the maximum number of matrices
|
||||
// subtract a few to give the engine some room.
|
||||
glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &matrixLimit);
|
||||
@@ -392,14 +392,14 @@ namespace opengl
|
||||
{
|
||||
SDL_Rect ** modes = SDL_ListModes(0, SDL_OPENGL | SDL_FULLSCREEN);
|
||||
|
||||
if(modes == (SDL_Rect **)0 || modes == (SDL_Rect **)-1)
|
||||
if (modes == (SDL_Rect **)0 || modes == (SDL_Rect **)-1)
|
||||
return 0;
|
||||
|
||||
int index = 1;
|
||||
|
||||
lua_newtable(L);
|
||||
|
||||
for(int i=0;modes[i];++i)
|
||||
for (int i=0;modes[i];++i)
|
||||
{
|
||||
lua_pushinteger(L, index);
|
||||
lua_newtable(L);
|
||||
@@ -437,7 +437,7 @@ namespace opengl
|
||||
|
||||
int Graphics::getScissor(lua_State * L)
|
||||
{
|
||||
if(glIsEnabled(GL_SCISSOR_TEST) == GL_FALSE)
|
||||
if (glIsEnabled(GL_SCISSOR_TEST) == GL_FALSE)
|
||||
return 0;
|
||||
|
||||
GLint scissor[4];
|
||||
@@ -478,13 +478,17 @@ namespace opengl
|
||||
// Create the image.
|
||||
Image * image = new Image(data);
|
||||
bool success;
|
||||
try {
|
||||
try
|
||||
{
|
||||
success = image->load();
|
||||
} catch (love::Exception & e) {
|
||||
}
|
||||
catch (love::Exception & e)
|
||||
{
|
||||
image->release();
|
||||
throw love::Exception(e.what());
|
||||
}
|
||||
if (!success) {
|
||||
if (!success)
|
||||
{
|
||||
image->release();
|
||||
return 0;
|
||||
}
|
||||
@@ -509,7 +513,7 @@ namespace opengl
|
||||
Font * font = new Font(r, filter);
|
||||
|
||||
// Load it and check for errors.
|
||||
if(!font)
|
||||
if (!font)
|
||||
{
|
||||
delete font;
|
||||
return 0;
|
||||
@@ -521,9 +525,12 @@ namespace opengl
|
||||
SpriteBatch * Graphics::newSpriteBatch(Image * image, int size, int usage)
|
||||
{
|
||||
SpriteBatch * t = NULL;
|
||||
try {
|
||||
try
|
||||
{
|
||||
t = new SpriteBatch(image, size, usage);
|
||||
} catch (love::Exception& e) {
|
||||
}
|
||||
catch (love::Exception& e)
|
||||
{
|
||||
if (t) delete t;
|
||||
throw e;
|
||||
}
|
||||
@@ -584,9 +591,12 @@ namespace opengl
|
||||
PixelEffect * Graphics::newPixelEffect(const std::string& code)
|
||||
{
|
||||
PixelEffect * effect = NULL;
|
||||
try {
|
||||
try
|
||||
{
|
||||
effect = new PixelEffect(code);
|
||||
} catch (love::Exception& e) {
|
||||
}
|
||||
catch (love::Exception& e)
|
||||
{
|
||||
if (effect)
|
||||
delete effect;
|
||||
throw(e);
|
||||
@@ -634,12 +644,12 @@ namespace opengl
|
||||
|
||||
void Graphics::setFont( Font * font )
|
||||
{
|
||||
if(currentFont != 0)
|
||||
if (currentFont != 0)
|
||||
currentFont->release();
|
||||
|
||||
currentFont = font;
|
||||
|
||||
if(font != 0)
|
||||
if (font != 0)
|
||||
currentFont->retain();
|
||||
}
|
||||
|
||||
@@ -669,7 +679,7 @@ namespace opengl
|
||||
|
||||
void Graphics::setColorMode ( Graphics::ColorMode mode )
|
||||
{
|
||||
if(mode == COLOR_MODULATE)
|
||||
if (mode == COLOR_MODULATE)
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
else // mode = COLOR_REPLACE
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
@@ -689,7 +699,7 @@ namespace opengl
|
||||
|
||||
if (equation == GL_FUNC_REVERSE_SUBTRACT) // && src == GL_SRC_ALPHA && dst == GL_ONE
|
||||
return BLEND_SUBTRACTIVE;
|
||||
else if(src == GL_SRC_ALPHA && dst == GL_ONE) // && equation == GL_FUNC_ADD
|
||||
else if (src == GL_SRC_ALPHA && dst == GL_ONE) // && equation == GL_FUNC_ADD
|
||||
return BLEND_ADDITIVE;
|
||||
else if (src == GL_SRC_ALPHA && dst == GL_ONE_MINUS_SRC_ALPHA) // && equation == GL_FUNC_ADD
|
||||
return BLEND_ALPHA;
|
||||
@@ -697,7 +707,7 @@ namespace opengl
|
||||
return BLEND_MULTIPLICATIVE;
|
||||
else if (src == GL_ONE && dst == GL_ONE_MINUS_SRC_ALPHA) // && equation == GL_FUNC_ADD
|
||||
return BLEND_PREMULTIPLIED;
|
||||
|
||||
|
||||
return BLEND_MAX_ENUM; // Should never be reached.
|
||||
}
|
||||
|
||||
@@ -706,7 +716,7 @@ namespace opengl
|
||||
GLint mode;
|
||||
glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &mode);
|
||||
|
||||
if(mode == GL_MODULATE)
|
||||
if (mode == GL_MODULATE)
|
||||
return COLOR_MODULATE;
|
||||
else // // mode == GL_REPLACE
|
||||
return COLOR_REPLACE;
|
||||
@@ -727,7 +737,7 @@ namespace opengl
|
||||
//// XXX: actually enables antialiasing for _all_ polygons.
|
||||
//// may need investigation if wanted or not
|
||||
//// maybe rename to something else?
|
||||
//if(style == LINE_ROUGH)
|
||||
//if (style == LINE_ROUGH)
|
||||
// glDisable (GL_POLYGON_SMOOTH);
|
||||
//else // type == LINE_SMOOTH
|
||||
//{
|
||||
@@ -741,7 +751,7 @@ namespace opengl
|
||||
{
|
||||
setLineWidth(width);
|
||||
|
||||
if(style == 0)
|
||||
if (style == 0)
|
||||
return;
|
||||
setLineStyle(style);
|
||||
}
|
||||
@@ -755,7 +765,7 @@ namespace opengl
|
||||
|
||||
Graphics::LineStyle Graphics::getLineStyle()
|
||||
{
|
||||
//if(glIsEnabled(GL_POLYGON_SMOOTH) == GL_TRUE)
|
||||
//if (glIsEnabled(GL_POLYGON_SMOOTH) == GL_TRUE)
|
||||
// return LINE_SMOOTH;
|
||||
//else
|
||||
return LINE_ROUGH;
|
||||
@@ -768,7 +778,7 @@ namespace opengl
|
||||
|
||||
void Graphics::setPointStyle( Graphics::PointStyle style )
|
||||
{
|
||||
if( style == POINT_SMOOTH )
|
||||
if ( style == POINT_SMOOTH )
|
||||
glEnable(GL_POINT_SMOOTH);
|
||||
else // love::POINT_ROUGH
|
||||
glDisable(GL_POINT_SMOOTH);
|
||||
@@ -776,7 +786,7 @@ namespace opengl
|
||||
|
||||
void Graphics::setPoint( float size, Graphics::PointStyle style )
|
||||
{
|
||||
if( style == POINT_SMOOTH )
|
||||
if ( style == POINT_SMOOTH )
|
||||
glEnable(GL_POINT_SMOOTH);
|
||||
else // POINT_ROUGH
|
||||
glDisable(GL_POINT_SMOOTH);
|
||||
@@ -793,7 +803,7 @@ namespace opengl
|
||||
|
||||
Graphics::PointStyle Graphics::getPointStyle()
|
||||
{
|
||||
if(glIsEnabled(GL_POINT_SMOOTH) == GL_TRUE)
|
||||
if (glIsEnabled(GL_POINT_SMOOTH) == GL_TRUE)
|
||||
return POINT_SMOOTH;
|
||||
else
|
||||
return POINT_ROUGH;
|
||||
@@ -808,7 +818,7 @@ namespace opengl
|
||||
|
||||
void Graphics::print( const char * str, float x, float y , float angle, float sx, float sy, float ox, float oy, float kx, float ky)
|
||||
{
|
||||
if(currentFont != 0)
|
||||
if (currentFont != 0)
|
||||
{
|
||||
std::string text(str);
|
||||
currentFont->print(text, x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
@@ -826,7 +836,8 @@ namespace opengl
|
||||
|
||||
// now for the actual printing
|
||||
vector<string>::const_iterator line_iter, line_end = lines_to_draw.end();
|
||||
for (line_iter = lines_to_draw.begin(); line_iter != line_end; ++line_iter) {
|
||||
for (line_iter = lines_to_draw.begin(); line_iter != line_end; ++line_iter)
|
||||
{
|
||||
float width = static_cast<float>(currentFont->getWidth( *line_iter ));
|
||||
switch (align) {
|
||||
case ALIGN_RIGHT:
|
||||
@@ -875,7 +886,8 @@ namespace opengl
|
||||
d2 *= halfwidth;
|
||||
|
||||
// lines parallel -> assume intersection at displacement points
|
||||
if (fabs(det_norm) <= .03) {
|
||||
if (fabs(det_norm) <= .03)
|
||||
{
|
||||
vertices[pos] = q - d2;
|
||||
vertices[pos + 1] = q + d2;
|
||||
return;
|
||||
@@ -903,7 +915,8 @@ namespace opengl
|
||||
if (looping) q = Vector(coords[count-4], coords[count-3]);
|
||||
else q = r * 2 - Vector(coords[2], coords[3]);
|
||||
|
||||
for (size_t i = 0; i+3 < count; i += 2) {
|
||||
for (size_t i = 0; i+3 < count; i += 2)
|
||||
{
|
||||
p = q;
|
||||
q = r;
|
||||
r = Vector(coords[i+2], coords[i+3]);
|
||||
@@ -946,12 +959,13 @@ namespace opengl
|
||||
void Graphics::circle(DrawMode mode, float x, float y, float radius, int points)
|
||||
{
|
||||
float two_pi = static_cast<float>(LOVE_M_PI * 2);
|
||||
if(points <= 0) points = 1;
|
||||
if (points <= 0) points = 1;
|
||||
float angle_shift = (two_pi / points);
|
||||
float phi = .0f;
|
||||
|
||||
float *coords = new float[2 * (points + 1)];
|
||||
for (int i = 0; i < points; ++i, phi += angle_shift) {
|
||||
for (int i = 0; i < points; ++i, phi += angle_shift)
|
||||
{
|
||||
coords[2*i] = x + radius * cos(phi);
|
||||
coords[2*i+1] = y + radius * sin(phi);
|
||||
}
|
||||
@@ -963,7 +977,7 @@ namespace opengl
|
||||
|
||||
delete[] coords;
|
||||
}
|
||||
|
||||
|
||||
void Graphics::arc(DrawMode mode, float x, float y, float radius, float angle1, float angle2, int points)
|
||||
{
|
||||
angle1 = fmod(angle1, 2.0f * (float)LOVE_M_PI);
|
||||
@@ -974,23 +988,27 @@ namespace opengl
|
||||
angle2 += (float)LOVE_M_PI * 2.0f;
|
||||
|
||||
|
||||
if(points <= 0) points = 1;
|
||||
if (points <= 0) points = 1;
|
||||
float angle_shift = ((angle2 - angle1) / points);
|
||||
float phi = angle1;
|
||||
|
||||
// GL_POLYGON can only fill-draw convex polygons, so we need to do stuff manually here
|
||||
if (mode == DRAW_LINE) {
|
||||
if (mode == DRAW_LINE)
|
||||
{
|
||||
float *coords = new float[(points + 3) * 2];
|
||||
coords[0] = coords[2 * points + 4] = x;
|
||||
coords[1] = coords[2 * points + 5] = y;
|
||||
for (int i = 0; i <= points; ++i, phi += angle_shift) {
|
||||
for (int i = 0; i <= points; ++i, phi += angle_shift)
|
||||
{
|
||||
coords[2 * (i+1)] = x + radius * cos(phi);
|
||||
coords[2 * (i+1) + 1] = y - radius * sin(phi);
|
||||
}
|
||||
polyline(coords, (points + 3) * 2); // artifacts at sharp angles if set to looping
|
||||
|
||||
delete[] coords;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
glVertex2f(x, y);
|
||||
@@ -1009,9 +1027,12 @@ namespace opengl
|
||||
{
|
||||
// coords is an array of a closed loop of vertices, i.e.
|
||||
// coords[count-2] = coords[0], coords[count-1] = coords[1]
|
||||
if (mode == DRAW_LINE) {
|
||||
if (mode == DRAW_LINE)
|
||||
{
|
||||
polyline(coords, count, true);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(2, GL_FLOAT, 0, (const GLvoid*)coords);
|
||||
@@ -1039,7 +1060,8 @@ namespace opengl
|
||||
|
||||
GLubyte *src = pixels - row, *dst = screenshot + size;
|
||||
|
||||
for (int i = 0; i < h; ++i) {
|
||||
for (int i = 0; i < h; ++i)
|
||||
{
|
||||
memcpy(dst-=row, src+=row, row);
|
||||
}
|
||||
|
||||
|
||||
@@ -498,7 +498,7 @@ namespace opengl
|
||||
* @param points Number of points to use to draw the circle.
|
||||
**/
|
||||
void circle(DrawMode mode, float x, float y, float radius, int points = 10);
|
||||
|
||||
|
||||
/**
|
||||
* Draws an arc using the specified arguments.
|
||||
* @param mode The mode of drawing (line/filled).
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace opengl
|
||||
|
||||
Image::~Image()
|
||||
{
|
||||
if(data != 0)
|
||||
if (data != 0)
|
||||
data->release();
|
||||
unload();
|
||||
}
|
||||
@@ -262,7 +262,7 @@ namespace opengl
|
||||
|
||||
void Image::bind() const
|
||||
{
|
||||
if(texture != 0)
|
||||
if (texture != 0)
|
||||
glBindTexture(GL_TEXTURE_2D,texture);
|
||||
}
|
||||
|
||||
@@ -293,12 +293,12 @@ namespace opengl
|
||||
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
|
||||
float p2width = next_p2(width);
|
||||
float p2height = next_p2(height);
|
||||
float s = width/p2width;
|
||||
float t = height/p2height;
|
||||
|
||||
|
||||
vertices[1].t = t;
|
||||
vertices[2].t = t;
|
||||
vertices[2].s = s;
|
||||
@@ -313,7 +313,7 @@ namespace opengl
|
||||
GL_RGBA,
|
||||
GL_UNSIGNED_BYTE,
|
||||
0);
|
||||
|
||||
|
||||
glTexSubImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
0,
|
||||
@@ -339,7 +339,7 @@ namespace opengl
|
||||
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RGBA8,
|
||||
@@ -361,7 +361,7 @@ namespace opengl
|
||||
settings.filter = getFilter();
|
||||
settings.wrap = getWrap();
|
||||
// Delete the hardware texture.
|
||||
if(texture != 0)
|
||||
if (texture != 0)
|
||||
{
|
||||
glDeleteTextures(1, (GLuint*)&texture);
|
||||
texture = 0;
|
||||
|
||||
@@ -67,22 +67,22 @@ namespace opengl
|
||||
|
||||
ParticleSystem::~ParticleSystem()
|
||||
{
|
||||
if(this->sprite != 0)
|
||||
if (this->sprite != 0)
|
||||
this->sprite->release();
|
||||
|
||||
if(pStart != 0)
|
||||
if (pStart != 0)
|
||||
delete [] pStart;
|
||||
}
|
||||
|
||||
void ParticleSystem::add()
|
||||
{
|
||||
if(isFull()) return;
|
||||
if (isFull()) return;
|
||||
|
||||
float min,max;
|
||||
|
||||
min = particleLifeMin;
|
||||
max = particleLifeMax;
|
||||
if(min == max)
|
||||
if (min == max)
|
||||
pLast->life = min;
|
||||
else
|
||||
pLast->life = (rand() / (float(RAND_MAX)+1)) * (max - min) + min;
|
||||
@@ -132,7 +132,7 @@ namespace opengl
|
||||
|
||||
void ParticleSystem::remove(particle * p)
|
||||
{
|
||||
if(!isEmpty())
|
||||
if (!isEmpty())
|
||||
{
|
||||
*p = *(--pLast);
|
||||
}
|
||||
@@ -140,7 +140,7 @@ namespace opengl
|
||||
|
||||
void ParticleSystem::setSprite(Image * image)
|
||||
{
|
||||
if(sprite != 0)
|
||||
if (sprite != 0)
|
||||
sprite->release();
|
||||
|
||||
sprite = image;
|
||||
@@ -170,7 +170,7 @@ namespace opengl
|
||||
void ParticleSystem::setParticleLife(float min, float max)
|
||||
{
|
||||
particleLifeMin = min;
|
||||
if(max == 0)
|
||||
if (max == 0)
|
||||
particleLifeMax = min;
|
||||
else
|
||||
particleLifeMax = max;
|
||||
@@ -387,7 +387,7 @@ namespace opengl
|
||||
|
||||
void ParticleSystem::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const
|
||||
{
|
||||
if(sprite == 0) return; // just in case of failure
|
||||
if (sprite == 0) return; // just in case of failure
|
||||
|
||||
glPushMatrix();
|
||||
glPushAttrib(GL_CURRENT_BIT);
|
||||
@@ -397,7 +397,7 @@ namespace opengl
|
||||
glMultMatrixf((const GLfloat*)t.getElements());
|
||||
|
||||
particle * p = pStart;
|
||||
while(p != pLast)
|
||||
while (p != pLast)
|
||||
{
|
||||
glPushMatrix();
|
||||
|
||||
@@ -418,30 +418,30 @@ namespace opengl
|
||||
particle * p = pStart;
|
||||
|
||||
// Make some more particles.
|
||||
if(active)
|
||||
if (active)
|
||||
{
|
||||
float rate = 1.0f / emissionRate; // the amount of time between each particle emit
|
||||
emitCounter += dt;
|
||||
while(emitCounter > rate)
|
||||
while (emitCounter > rate)
|
||||
{
|
||||
add();
|
||||
emitCounter -= rate;
|
||||
}
|
||||
/*int particles = (int)(emissionRate * dt);
|
||||
for(int i = 0; i != particles; i++)
|
||||
for (int i = 0; i != particles; i++)
|
||||
add();*/
|
||||
|
||||
life -= dt;
|
||||
if(lifetime != -1 && life < 0)
|
||||
if (lifetime != -1 && life < 0)
|
||||
stop();
|
||||
}
|
||||
|
||||
while(p != pLast)
|
||||
while (p != pLast)
|
||||
{
|
||||
// Decrease lifespan.
|
||||
p->life -= dt;
|
||||
|
||||
if(p->life > 0)
|
||||
if (p->life > 0)
|
||||
{
|
||||
|
||||
// Temp variables.
|
||||
@@ -509,7 +509,7 @@ namespace opengl
|
||||
{
|
||||
remove(p);
|
||||
|
||||
if(p >= pLast)
|
||||
if (p >= pLast)
|
||||
return;
|
||||
} // else
|
||||
} // while
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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
|
||||
@@ -143,7 +143,7 @@ namespace opengl
|
||||
float spinStart;
|
||||
float spinEnd;
|
||||
float spinVariation;
|
||||
|
||||
|
||||
// Offsets
|
||||
float offsetX;
|
||||
float offsetY;
|
||||
@@ -339,14 +339,14 @@ namespace opengl
|
||||
* @param color The color.
|
||||
**/
|
||||
void setColor(const Color& color);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the particles' offsets for rotation.
|
||||
* @param x The x offset.
|
||||
* @param y The y offset.
|
||||
**/
|
||||
void setOffset(float x, float y);
|
||||
|
||||
|
||||
/**
|
||||
* Sets the color of the particles.
|
||||
* @param newColors Array of colors
|
||||
@@ -372,17 +372,17 @@ namespace opengl
|
||||
* Returns the directional spread of the emitter (in degrees).
|
||||
**/
|
||||
float getSpread() const;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the X offset of the particles.
|
||||
**/
|
||||
float getOffsetX() const;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the Y offset of the particles.
|
||||
**/
|
||||
float getOffsetY() const;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the amount of particles that are currently active in the system.
|
||||
**/
|
||||
|
||||
@@ -78,7 +78,8 @@ namespace opengl
|
||||
|
||||
GLuint shader = glCreateShader(GL_FRAGMENT_SHADER);
|
||||
// should only fail if this is called between a glBegin()/glEnd() pair
|
||||
if (shader == 0) {
|
||||
if (shader == 0)
|
||||
{
|
||||
glDeleteProgram(_program);
|
||||
throw love::Exception("Cannot create shader object.");
|
||||
}
|
||||
@@ -91,7 +92,8 @@ namespace opengl
|
||||
|
||||
GLint compile_ok;
|
||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &compile_ok);
|
||||
if (GL_FALSE == compile_ok) {
|
||||
if (GL_FALSE == compile_ok)
|
||||
{
|
||||
// get compiler error
|
||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &strlen);
|
||||
char *error_str = new char[strlen];
|
||||
@@ -112,7 +114,8 @@ namespace opengl
|
||||
glAttachShader(_program, shader);
|
||||
glLinkProgram(_program);
|
||||
glGetProgramiv(_program, GL_LINK_STATUS, &link_ok);
|
||||
if (GL_FALSE == link_ok) {
|
||||
if (GL_FALSE == link_ok)
|
||||
{
|
||||
// this should not happen if compiling is ok, but one can never be too careful
|
||||
// get linker error
|
||||
std::string tmp(getWarnings());
|
||||
@@ -189,7 +192,8 @@ namespace opengl
|
||||
TemporaryAttacher attacher(this);
|
||||
GLint location = getUniformLocation(name);
|
||||
|
||||
if (size < 1 || size > 4) {
|
||||
if (size < 1 || size > 4)
|
||||
{
|
||||
throw love::Exception("Invalid variable size: %d (expected 1-4).", size);
|
||||
}
|
||||
|
||||
@@ -218,7 +222,8 @@ namespace opengl
|
||||
TemporaryAttacher attacher(this);
|
||||
GLint location = getUniformLocation(name);
|
||||
|
||||
if (size < 2 || size > 4) {
|
||||
if (size < 2 || size > 4)
|
||||
{
|
||||
throw love::Exception("Invalid matrix size: %dx%d "
|
||||
"(can only set 2x2, 3x3 or 4x4 matrices).", size,size);
|
||||
}
|
||||
@@ -283,7 +288,8 @@ namespace opengl
|
||||
return it->second;
|
||||
|
||||
GLint location = glGetUniformLocation(_program, name.c_str());
|
||||
if (location == -1) {
|
||||
if (location == -1)
|
||||
{
|
||||
throw love::Exception(
|
||||
"Cannot get location of shader variable `%s'.\n"
|
||||
"A common error is to define but not use the variable.", name.c_str());
|
||||
@@ -296,7 +302,8 @@ namespace opengl
|
||||
void PixelEffect::checkSetUniformError()
|
||||
{
|
||||
GLenum error_code = glGetError();
|
||||
if (GL_INVALID_OPERATION == error_code) {
|
||||
if (GL_INVALID_OPERATION == error_code)
|
||||
{
|
||||
throw love::Exception(
|
||||
"Invalid operation:\n"
|
||||
"- Trying to send the wrong value type to shader variable, or\n"
|
||||
|
||||
@@ -1,123 +1,124 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#include "Quad.h"
|
||||
#include <common/Matrix.h>
|
||||
|
||||
// GLee
|
||||
#include "GLee.h"
|
||||
|
||||
// STD
|
||||
#include <cstring> // For memcpy
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
Quad::Quad(const Viewport & v, float sw, float sh)
|
||||
: sw(sw), sh(sh)
|
||||
{
|
||||
memset(vertices, 255, sizeof(vertex)*NUM_VERTICES);
|
||||
refresh(v, sw, sh);
|
||||
}
|
||||
|
||||
Quad::~Quad()
|
||||
{
|
||||
}
|
||||
|
||||
void Quad::refresh(const Viewport & v, float sw, float sh)
|
||||
{
|
||||
if (!GLEE_ARB_texture_non_power_of_two)
|
||||
{
|
||||
sw = next_p2(sw);
|
||||
sh = next_p2(sh);
|
||||
}
|
||||
viewport = v;
|
||||
|
||||
vertices[0].x = 0;
|
||||
vertices[0].y = 0;
|
||||
vertices[1].x = 0;
|
||||
vertices[1].y = v.h;
|
||||
vertices[2].x = v.w;
|
||||
vertices[2].y = v.h;
|
||||
vertices[3].x = v.w;
|
||||
vertices[3].y = 0;
|
||||
|
||||
vertices[0].s = v.x/sw;
|
||||
vertices[0].t = v.y/sh;
|
||||
vertices[1].s = v.x/sw;
|
||||
vertices[1].t = (v.y+v.h)/sh;
|
||||
vertices[2].s = (v.x+v.w)/sw;
|
||||
vertices[2].t = (v.y+v.h)/sh;
|
||||
vertices[3].s = (v.x+v.w)/sw;
|
||||
vertices[3].t = v.y/sh;
|
||||
}
|
||||
|
||||
void Quad::setViewport(const Quad::Viewport & v)
|
||||
{
|
||||
refresh(v, sw, sh);
|
||||
}
|
||||
|
||||
Quad::Viewport Quad::getViewport() const
|
||||
{
|
||||
return viewport;
|
||||
}
|
||||
|
||||
void Quad::flip(bool x, bool y)
|
||||
{
|
||||
vertex temp[4];
|
||||
if (x)
|
||||
{
|
||||
memcpy(temp, vertices, sizeof(vertex)*NUM_VERTICES);
|
||||
vertices[0].s = temp[3].s; vertices[0].t = temp[3].t;
|
||||
vertices[1].s = temp[2].s; vertices[1].t = temp[2].t;
|
||||
vertices[2].s = temp[1].s; vertices[2].t = temp[1].t;
|
||||
vertices[3].s = temp[0].s; vertices[3].t = temp[0].t;
|
||||
}
|
||||
if (y)
|
||||
{
|
||||
memcpy(temp, vertices, sizeof(vertex)*NUM_VERTICES);
|
||||
vertices[0].s = temp[1].s; vertices[0].t = temp[1].t;
|
||||
vertices[1].s = temp[0].s; vertices[1].t = temp[0].t;
|
||||
vertices[2].s = temp[3].s; vertices[2].t = temp[3].t;
|
||||
vertices[3].s = temp[2].s; vertices[3].t = temp[2].t;
|
||||
}
|
||||
}
|
||||
|
||||
void Quad::mirror(bool x, bool y)
|
||||
{
|
||||
for (size_t i = 0; i < NUM_VERTICES; ++i) {
|
||||
if (x)
|
||||
vertices[i].s = 1.0 - vertices[i].s;
|
||||
if (y)
|
||||
vertices[i].s = 1.0 - vertices[i].s;
|
||||
}
|
||||
}
|
||||
|
||||
const vertex * Quad::getVertices() const
|
||||
{
|
||||
return vertices;
|
||||
}
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#include "Quad.h"
|
||||
#include <common/Matrix.h>
|
||||
|
||||
// GLee
|
||||
#include "GLee.h"
|
||||
|
||||
// STD
|
||||
#include <cstring> // For memcpy
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
Quad::Quad(const Viewport & v, float sw, float sh)
|
||||
: sw(sw), sh(sh)
|
||||
{
|
||||
memset(vertices, 255, sizeof(vertex)*NUM_VERTICES);
|
||||
refresh(v, sw, sh);
|
||||
}
|
||||
|
||||
Quad::~Quad()
|
||||
{
|
||||
}
|
||||
|
||||
void Quad::refresh(const Viewport & v, float sw, float sh)
|
||||
{
|
||||
if (!GLEE_ARB_texture_non_power_of_two)
|
||||
{
|
||||
sw = next_p2(sw);
|
||||
sh = next_p2(sh);
|
||||
}
|
||||
viewport = v;
|
||||
|
||||
vertices[0].x = 0;
|
||||
vertices[0].y = 0;
|
||||
vertices[1].x = 0;
|
||||
vertices[1].y = v.h;
|
||||
vertices[2].x = v.w;
|
||||
vertices[2].y = v.h;
|
||||
vertices[3].x = v.w;
|
||||
vertices[3].y = 0;
|
||||
|
||||
vertices[0].s = v.x/sw;
|
||||
vertices[0].t = v.y/sh;
|
||||
vertices[1].s = v.x/sw;
|
||||
vertices[1].t = (v.y+v.h)/sh;
|
||||
vertices[2].s = (v.x+v.w)/sw;
|
||||
vertices[2].t = (v.y+v.h)/sh;
|
||||
vertices[3].s = (v.x+v.w)/sw;
|
||||
vertices[3].t = v.y/sh;
|
||||
}
|
||||
|
||||
void Quad::setViewport(const Quad::Viewport & v)
|
||||
{
|
||||
refresh(v, sw, sh);
|
||||
}
|
||||
|
||||
Quad::Viewport Quad::getViewport() const
|
||||
{
|
||||
return viewport;
|
||||
}
|
||||
|
||||
void Quad::flip(bool x, bool y)
|
||||
{
|
||||
vertex temp[4];
|
||||
if (x)
|
||||
{
|
||||
memcpy(temp, vertices, sizeof(vertex)*NUM_VERTICES);
|
||||
vertices[0].s = temp[3].s; vertices[0].t = temp[3].t;
|
||||
vertices[1].s = temp[2].s; vertices[1].t = temp[2].t;
|
||||
vertices[2].s = temp[1].s; vertices[2].t = temp[1].t;
|
||||
vertices[3].s = temp[0].s; vertices[3].t = temp[0].t;
|
||||
}
|
||||
if (y)
|
||||
{
|
||||
memcpy(temp, vertices, sizeof(vertex)*NUM_VERTICES);
|
||||
vertices[0].s = temp[1].s; vertices[0].t = temp[1].t;
|
||||
vertices[1].s = temp[0].s; vertices[1].t = temp[0].t;
|
||||
vertices[2].s = temp[3].s; vertices[2].t = temp[3].t;
|
||||
vertices[3].s = temp[2].s; vertices[3].t = temp[2].t;
|
||||
}
|
||||
}
|
||||
|
||||
void Quad::mirror(bool x, bool y)
|
||||
{
|
||||
for (size_t i = 0; i < NUM_VERTICES; ++i)
|
||||
{
|
||||
if (x)
|
||||
vertices[i].s = 1.0 - vertices[i].s;
|
||||
if (y)
|
||||
vertices[i].s = 1.0 - vertices[i].s;
|
||||
}
|
||||
}
|
||||
|
||||
const vertex * Quad::getVertices() const
|
||||
{
|
||||
return vertices;
|
||||
}
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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
|
||||
@@ -102,7 +102,7 @@ namespace opengl
|
||||
int SpriteBatch::add(float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index /*= -1*/)
|
||||
{
|
||||
// Only do this if there's a free slot.
|
||||
if((index == -1 && next >= size) || index < -1 || index >= size)
|
||||
if ((index == -1 && next >= size) || index < -1 || index >= size)
|
||||
return -1;
|
||||
|
||||
// Needed for colors.
|
||||
@@ -127,7 +127,7 @@ namespace opengl
|
||||
int SpriteBatch::addq(Quad * quad, float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index /*= -1*/)
|
||||
{
|
||||
// Only do this if there's a free slot.
|
||||
if((index == -1 && next >= size) || index < -1 || index >= next)
|
||||
if ((index == -1 && next >= size) || index < -1 || index >= next)
|
||||
return -1;
|
||||
|
||||
// Needed for colors.
|
||||
@@ -178,7 +178,7 @@ namespace opengl
|
||||
|
||||
void SpriteBatch::setColor(const Color & color)
|
||||
{
|
||||
if(!this->color)
|
||||
if (!this->color)
|
||||
this->color = new Color(color);
|
||||
else
|
||||
*(this->color) = color;
|
||||
@@ -218,7 +218,7 @@ namespace opengl
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(vertex), array_buf->getPointer(vertex_offset));
|
||||
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), array_buf->getPointer(texel_offset));
|
||||
|
||||
glDrawElements(GL_TRIANGLES, next*6, GL_UNSIGNED_SHORT, element_buf->getPointer(0));
|
||||
|
||||
@@ -1,138 +1,138 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_SPRITE_BATCH_H
|
||||
#define LOVE_GRAPHICS_OPENGL_SPRITE_BATCH_H
|
||||
|
||||
// C
|
||||
#include <cstring>
|
||||
|
||||
// LOVE
|
||||
#include <common/math.h>
|
||||
#include <common/Object.h>
|
||||
#include <common/Vector.h>
|
||||
#include <common/Matrix.h>
|
||||
#include <common/StringMap.h>
|
||||
#include <graphics/Drawable.h>
|
||||
#include <graphics/Volatile.h>
|
||||
#include <graphics/Color.h>
|
||||
|
||||
// OpenGL
|
||||
#include "GLee.h"
|
||||
#include <SDL/SDL_opengl.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
// Forward declarations.
|
||||
class Image;
|
||||
class Quad;
|
||||
class VertexBuffer;
|
||||
|
||||
class SpriteBatch : public Drawable
|
||||
{
|
||||
private:
|
||||
|
||||
Image * image;
|
||||
|
||||
// Max number of sprites in the batch.
|
||||
int size;
|
||||
|
||||
// The next free element.
|
||||
int next;
|
||||
|
||||
vertex sprite[4];
|
||||
|
||||
// Current color. This color, if present, will be applied to the next
|
||||
// added quad.
|
||||
Color * color;
|
||||
|
||||
VertexBuffer *array_buf;
|
||||
VertexBuffer *element_buf;
|
||||
|
||||
public:
|
||||
|
||||
enum UsageHint
|
||||
{
|
||||
USAGE_DYNAMIC = 1,
|
||||
USAGE_STATIC,
|
||||
USAGE_STREAM,
|
||||
USAGE_MAX_ENUM
|
||||
};
|
||||
|
||||
SpriteBatch(Image * image, int size, int usage);
|
||||
virtual ~SpriteBatch();
|
||||
|
||||
int add(float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index = -1);
|
||||
int addq(Quad * quad, float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index = -1);
|
||||
void clear();
|
||||
|
||||
void * lock();
|
||||
void unlock();
|
||||
|
||||
void setImage(Image * newimage);
|
||||
|
||||
/**
|
||||
* Set the current color for this SpriteBatch. The geometry added
|
||||
* after this call will use this color. Note that global color
|
||||
* will not longer apply to the SpriteBatch if this is used.
|
||||
*
|
||||
* @param color The color to use for the following geometry.
|
||||
*/
|
||||
void setColor(const Color & color);
|
||||
|
||||
/**
|
||||
* Disable per-quad colors for this SpriteBatch. The next call to
|
||||
* draw will use the global color for all sprites.
|
||||
*/
|
||||
void setColor();
|
||||
|
||||
// Implements Drawable.
|
||||
void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
|
||||
|
||||
static bool getConstant(const char * in, UsageHint & out);
|
||||
static bool getConstant(UsageHint in, const char *& out);
|
||||
|
||||
private:
|
||||
|
||||
void addv(const vertex * v, int index);
|
||||
|
||||
/**
|
||||
* Set the color for vertices.
|
||||
*
|
||||
* @param v The vertices to set the color for. Must be an array of
|
||||
* of size 4.
|
||||
* @param color The color to assign to each vertex.
|
||||
*/
|
||||
void setColorv(vertex * v, const Color & color);
|
||||
|
||||
static StringMap<UsageHint, USAGE_MAX_ENUM>::Entry usageHintEntries[];
|
||||
static StringMap<UsageHint, USAGE_MAX_ENUM> usageHints;
|
||||
|
||||
}; // SpriteBatch
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_SPRITE_BATCH_H
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_SPRITE_BATCH_H
|
||||
#define LOVE_GRAPHICS_OPENGL_SPRITE_BATCH_H
|
||||
|
||||
// C
|
||||
#include <cstring>
|
||||
|
||||
// LOVE
|
||||
#include <common/math.h>
|
||||
#include <common/Object.h>
|
||||
#include <common/Vector.h>
|
||||
#include <common/Matrix.h>
|
||||
#include <common/StringMap.h>
|
||||
#include <graphics/Drawable.h>
|
||||
#include <graphics/Volatile.h>
|
||||
#include <graphics/Color.h>
|
||||
|
||||
// OpenGL
|
||||
#include "GLee.h"
|
||||
#include <SDL/SDL_opengl.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
// Forward declarations.
|
||||
class Image;
|
||||
class Quad;
|
||||
class VertexBuffer;
|
||||
|
||||
class SpriteBatch : public Drawable
|
||||
{
|
||||
private:
|
||||
|
||||
Image * image;
|
||||
|
||||
// Max number of sprites in the batch.
|
||||
int size;
|
||||
|
||||
// The next free element.
|
||||
int next;
|
||||
|
||||
vertex sprite[4];
|
||||
|
||||
// Current color. This color, if present, will be applied to the next
|
||||
// added quad.
|
||||
Color * color;
|
||||
|
||||
VertexBuffer *array_buf;
|
||||
VertexBuffer *element_buf;
|
||||
|
||||
public:
|
||||
|
||||
enum UsageHint
|
||||
{
|
||||
USAGE_DYNAMIC = 1,
|
||||
USAGE_STATIC,
|
||||
USAGE_STREAM,
|
||||
USAGE_MAX_ENUM
|
||||
};
|
||||
|
||||
SpriteBatch(Image * image, int size, int usage);
|
||||
virtual ~SpriteBatch();
|
||||
|
||||
int add(float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index = -1);
|
||||
int addq(Quad * quad, float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index = -1);
|
||||
void clear();
|
||||
|
||||
void * lock();
|
||||
void unlock();
|
||||
|
||||
void setImage(Image * newimage);
|
||||
|
||||
/**
|
||||
* Set the current color for this SpriteBatch. The geometry added
|
||||
* after this call will use this color. Note that global color
|
||||
* will not longer apply to the SpriteBatch if this is used.
|
||||
*
|
||||
* @param color The color to use for the following geometry.
|
||||
*/
|
||||
void setColor(const Color & color);
|
||||
|
||||
/**
|
||||
* Disable per-quad colors for this SpriteBatch. The next call to
|
||||
* draw will use the global color for all sprites.
|
||||
*/
|
||||
void setColor();
|
||||
|
||||
// Implements Drawable.
|
||||
void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
|
||||
|
||||
static bool getConstant(const char * in, UsageHint & out);
|
||||
static bool getConstant(UsageHint in, const char *& out);
|
||||
|
||||
private:
|
||||
|
||||
void addv(const vertex * v, int index);
|
||||
|
||||
/**
|
||||
* Set the color for vertices.
|
||||
*
|
||||
* @param v The vertices to set the color for. Must be an array of
|
||||
* of size 4.
|
||||
* @param color The color to assign to each vertex.
|
||||
*/
|
||||
void setColorv(vertex * v, const Color & color);
|
||||
|
||||
static StringMap<UsageHint, USAGE_MAX_ENUM>::Entry usageHintEntries[];
|
||||
static StringMap<UsageHint, USAGE_MAX_ENUM> usageHints;
|
||||
|
||||
}; // SpriteBatch
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_SPRITE_BATCH_H
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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
|
||||
@@ -41,7 +41,8 @@ namespace opengl
|
||||
// Try to create a VBO.
|
||||
return new VBO(size, target, usage);
|
||||
|
||||
} catch (const love::Exception &e)
|
||||
}
|
||||
catch (const love::Exception &e)
|
||||
{
|
||||
(void)e;
|
||||
|
||||
@@ -196,7 +197,7 @@ namespace opengl
|
||||
|
||||
// Copy the old buffer only if 'restore' was requested.
|
||||
const GLvoid *src = restore ? buffer_copy : 0;
|
||||
|
||||
|
||||
// Note that if 'src' is '0', no data will be copied.
|
||||
glBufferDataARB(getTarget(), getSize(), src, getUsage());
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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
|
||||
@@ -17,271 +17,271 @@
|
||||
* misrepresented as being the original software.
|
||||
* 3. This notice may not be removed or altered from any source distribution.
|
||||
**/
|
||||
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_VERTEX_BUFFER_H
|
||||
#define LOVE_GRAPHICS_OPENGL_VERTEX_BUFFER_H
|
||||
|
||||
// LOVE
|
||||
#include <graphics/Volatile.h>
|
||||
|
||||
// OpenGL
|
||||
#include "GLee.h"
|
||||
#include <SDL/SDL_opengl.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
/**
|
||||
* VertexBuffer is an abstraction over VBOs (Vertex Buffer Objecys), which
|
||||
* falls back to regular vertex arrays if VBOs are not supported.
|
||||
*
|
||||
* This allows code to take advantage of VBOs where available, but still
|
||||
* work on older systems where it's *not* available. Everyone's happy.
|
||||
*
|
||||
* The class is (for now) meant for internal use.
|
||||
*/
|
||||
class VertexBuffer
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Create a new VertexBuffer (either a plain vertex array, or a VBO),
|
||||
* based on what's supported on the system.
|
||||
*
|
||||
* If VBOs are not supported, a plain vertex array will automatically
|
||||
* be created and returned instead.
|
||||
*
|
||||
* @param size The size of the VertexBuffer (in bytes).
|
||||
* @param target GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER.
|
||||
* @param usage GL_DYNAMIC_DRAW, etc.
|
||||
* @return A new VertexBuffer.
|
||||
*/
|
||||
static VertexBuffer *Create(int size, GLenum target, GLenum usage);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param size The size of the VertexBuffer in bytes.
|
||||
* @param target The target VertexBuffer object, e.g. GL_ARRAY_BUFFER.
|
||||
* @param usage Usage hint, e.g. GL_DYNAMIC_DRAW.
|
||||
*/
|
||||
VertexBuffer(int size, GLenum target, GLenum usage);
|
||||
|
||||
/**
|
||||
* Destructor. Does nothing, but must be declared virtual.
|
||||
*/
|
||||
virtual ~VertexBuffer();
|
||||
|
||||
/**
|
||||
* Get the size of the VertexBuffer, in bytes.
|
||||
*
|
||||
* @return The size of the VertexBuffer.
|
||||
*/
|
||||
int getSize() const { return size; }
|
||||
|
||||
/**
|
||||
* Get the target buffer object.
|
||||
*
|
||||
* @return The target buffer object, e.g. GL_ARRAY_BUFFER.
|
||||
*/
|
||||
GLenum getTarget() const { return target; }
|
||||
|
||||
/**
|
||||
* Get the usage hint for this VertexBuffer.
|
||||
*
|
||||
* @return The usage hint, e.g. GL_DYNAMIC_DRAW.
|
||||
*/
|
||||
GLenum getUsage() const { return usage; }
|
||||
|
||||
/**
|
||||
* Map the VertexBuffer to client memory.
|
||||
*
|
||||
* This can be faster for large changes to the buffer. For smaller
|
||||
* changes, see fill().
|
||||
*
|
||||
* The VertexBuffer must be bound to use this function.
|
||||
*
|
||||
* @param access GL_READ_ONLY, GL_WRITE_ONLY, GL_READ_WRITE.
|
||||
* @return A pointer to memory which represents the buffer.
|
||||
*/
|
||||
virtual void *map(GLenum access) = 0;
|
||||
|
||||
/**
|
||||
* Unmap a previously mapped VertexBuffer. The buffer must be unmapped
|
||||
* when used to draw elements.
|
||||
*
|
||||
* The VertexBuffer must be bound to use this function.
|
||||
*/
|
||||
virtual void unmap() = 0;
|
||||
|
||||
/**
|
||||
* Bind the VertexBuffer to the specified target.
|
||||
* (GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER).
|
||||
*
|
||||
* @param target GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER.
|
||||
*/
|
||||
virtual void bind() = 0;
|
||||
|
||||
/**
|
||||
* Unbind a prevously bound VertexBuffer.
|
||||
*/
|
||||
virtual void unbind() = 0;
|
||||
|
||||
/**
|
||||
* Fill a portion of the buffer with data.
|
||||
*
|
||||
* The VertexBuffer must be bound to use this function.
|
||||
*
|
||||
* @param offset The offset in the VertexBuffer to store the data.
|
||||
* @param size The size of the incoming data.
|
||||
* @param data Pointer to memory to copy data from.
|
||||
*/
|
||||
virtual void fill(int offset, int size, const void *data) = 0;
|
||||
|
||||
/**
|
||||
* Get a pointer which represents the specified byte offset.
|
||||
*
|
||||
* @param offset The byte offset. (0 is first byte).
|
||||
* @return A pointer which represents the offset.
|
||||
*/
|
||||
virtual const void *getPointer(int offset) const = 0;
|
||||
|
||||
/**
|
||||
* This helper class can bind a VertexArray temporarily, and
|
||||
* automatically un-bind when it's destroyed.
|
||||
*/
|
||||
class Bind
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Bind a VertexBuffer.
|
||||
*/
|
||||
Bind(VertexBuffer &buf);
|
||||
|
||||
/**
|
||||
* Unbinds a VertexBuffer.
|
||||
*/
|
||||
~Bind();
|
||||
|
||||
private:
|
||||
|
||||
// VertexBuffer to work on.
|
||||
VertexBuffer &buf;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
// The size of the buffer, in bytes.
|
||||
int size;
|
||||
|
||||
// The target buffer object. (GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER).
|
||||
GLenum target;
|
||||
|
||||
// Usage hint. GL_[DYNAMIC, STATIC, STREAM]_DRAW.
|
||||
GLenum usage;
|
||||
};
|
||||
|
||||
/**
|
||||
* Implementation of VertexBuffer which uses plain arrays to store the data.
|
||||
*
|
||||
* This implementation should be supported everywhere, and acts as a fallback
|
||||
* on systems which do not support VBOs.
|
||||
*/
|
||||
class VertexArray : public VertexBuffer
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @copydoc VertexBuffer(int, GLenum, GLenum)
|
||||
*/
|
||||
VertexArray(int size, GLenum target, GLenum usage);
|
||||
|
||||
/**
|
||||
* Frees the data we've allocated.
|
||||
*/
|
||||
virtual ~VertexArray();
|
||||
|
||||
// Implements VertexBuffer.
|
||||
virtual void *map(GLenum access);
|
||||
virtual void unmap();
|
||||
virtual void bind();
|
||||
virtual void unbind();
|
||||
virtual void fill(int offset, int size, const void *data);
|
||||
virtual const void *getPointer(int offset) const ;
|
||||
|
||||
private:
|
||||
// Holds the data.
|
||||
char *buf;
|
||||
};
|
||||
|
||||
/**
|
||||
* Vertex Buffer Object (VBO) implementation of VertexBuffer.
|
||||
*
|
||||
* This will be used on all systems that support it. It's in general
|
||||
* faster than vertex arrays, but especially in use-cases where there
|
||||
* is no need to update the data every frame.
|
||||
*/
|
||||
class VBO : public VertexBuffer, public Volatile
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @copydoc VertexBuffer(int, GLenum, GLenum)
|
||||
*/
|
||||
VBO(int size, GLenum target, GLenum usage);
|
||||
|
||||
/**
|
||||
* Deletes the VBOs from OpenGL.
|
||||
*/
|
||||
virtual ~VBO();
|
||||
|
||||
// Implements VertexBuffer.
|
||||
virtual void *map(GLenum access);
|
||||
virtual void unmap();
|
||||
virtual void bind();
|
||||
virtual void unbind();
|
||||
virtual void fill(int offset, int size, const void *data);
|
||||
virtual const void *getPointer(int offset) const ;
|
||||
|
||||
// Implements Volatile.
|
||||
bool loadVolatile();
|
||||
void unloadVolatile();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Creates the VBO, and optionally restores data we saved earlier.
|
||||
*
|
||||
* @param restore True to restore data previously saved with 'unload'.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
bool load(bool restore);
|
||||
|
||||
/**
|
||||
* Optionally save the data in the VBO, then delete it.
|
||||
*
|
||||
* @param save True to save the data before deleting.
|
||||
*/
|
||||
void unload(bool save);
|
||||
|
||||
// The VBO identifier. Assigned by OpenGL.
|
||||
GLuint vbo;
|
||||
|
||||
// *May* contain data saved by 'unload'.
|
||||
char *buffer_copy;
|
||||
|
||||
// A pointer to mapped memory. Zero if memory is currently
|
||||
// not mapped.
|
||||
void *mapped;
|
||||
};
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_SPRITE_BATCH_H
|
||||
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_VERTEX_BUFFER_H
|
||||
#define LOVE_GRAPHICS_OPENGL_VERTEX_BUFFER_H
|
||||
|
||||
// LOVE
|
||||
#include <graphics/Volatile.h>
|
||||
|
||||
// OpenGL
|
||||
#include "GLee.h"
|
||||
#include <SDL/SDL_opengl.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
/**
|
||||
* VertexBuffer is an abstraction over VBOs (Vertex Buffer Objecys), which
|
||||
* falls back to regular vertex arrays if VBOs are not supported.
|
||||
*
|
||||
* This allows code to take advantage of VBOs where available, but still
|
||||
* work on older systems where it's *not* available. Everyone's happy.
|
||||
*
|
||||
* The class is (for now) meant for internal use.
|
||||
*/
|
||||
class VertexBuffer
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Create a new VertexBuffer (either a plain vertex array, or a VBO),
|
||||
* based on what's supported on the system.
|
||||
*
|
||||
* If VBOs are not supported, a plain vertex array will automatically
|
||||
* be created and returned instead.
|
||||
*
|
||||
* @param size The size of the VertexBuffer (in bytes).
|
||||
* @param target GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER.
|
||||
* @param usage GL_DYNAMIC_DRAW, etc.
|
||||
* @return A new VertexBuffer.
|
||||
*/
|
||||
static VertexBuffer *Create(int size, GLenum target, GLenum usage);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param size The size of the VertexBuffer in bytes.
|
||||
* @param target The target VertexBuffer object, e.g. GL_ARRAY_BUFFER.
|
||||
* @param usage Usage hint, e.g. GL_DYNAMIC_DRAW.
|
||||
*/
|
||||
VertexBuffer(int size, GLenum target, GLenum usage);
|
||||
|
||||
/**
|
||||
* Destructor. Does nothing, but must be declared virtual.
|
||||
*/
|
||||
virtual ~VertexBuffer();
|
||||
|
||||
/**
|
||||
* Get the size of the VertexBuffer, in bytes.
|
||||
*
|
||||
* @return The size of the VertexBuffer.
|
||||
*/
|
||||
int getSize() const { return size; }
|
||||
|
||||
/**
|
||||
* Get the target buffer object.
|
||||
*
|
||||
* @return The target buffer object, e.g. GL_ARRAY_BUFFER.
|
||||
*/
|
||||
GLenum getTarget() const { return target; }
|
||||
|
||||
/**
|
||||
* Get the usage hint for this VertexBuffer.
|
||||
*
|
||||
* @return The usage hint, e.g. GL_DYNAMIC_DRAW.
|
||||
*/
|
||||
GLenum getUsage() const { return usage; }
|
||||
|
||||
/**
|
||||
* Map the VertexBuffer to client memory.
|
||||
*
|
||||
* This can be faster for large changes to the buffer. For smaller
|
||||
* changes, see fill().
|
||||
*
|
||||
* The VertexBuffer must be bound to use this function.
|
||||
*
|
||||
* @param access GL_READ_ONLY, GL_WRITE_ONLY, GL_READ_WRITE.
|
||||
* @return A pointer to memory which represents the buffer.
|
||||
*/
|
||||
virtual void *map(GLenum access) = 0;
|
||||
|
||||
/**
|
||||
* Unmap a previously mapped VertexBuffer. The buffer must be unmapped
|
||||
* when used to draw elements.
|
||||
*
|
||||
* The VertexBuffer must be bound to use this function.
|
||||
*/
|
||||
virtual void unmap() = 0;
|
||||
|
||||
/**
|
||||
* Bind the VertexBuffer to the specified target.
|
||||
* (GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER).
|
||||
*
|
||||
* @param target GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER.
|
||||
*/
|
||||
virtual void bind() = 0;
|
||||
|
||||
/**
|
||||
* Unbind a prevously bound VertexBuffer.
|
||||
*/
|
||||
virtual void unbind() = 0;
|
||||
|
||||
/**
|
||||
* Fill a portion of the buffer with data.
|
||||
*
|
||||
* The VertexBuffer must be bound to use this function.
|
||||
*
|
||||
* @param offset The offset in the VertexBuffer to store the data.
|
||||
* @param size The size of the incoming data.
|
||||
* @param data Pointer to memory to copy data from.
|
||||
*/
|
||||
virtual void fill(int offset, int size, const void *data) = 0;
|
||||
|
||||
/**
|
||||
* Get a pointer which represents the specified byte offset.
|
||||
*
|
||||
* @param offset The byte offset. (0 is first byte).
|
||||
* @return A pointer which represents the offset.
|
||||
*/
|
||||
virtual const void *getPointer(int offset) const = 0;
|
||||
|
||||
/**
|
||||
* This helper class can bind a VertexArray temporarily, and
|
||||
* automatically un-bind when it's destroyed.
|
||||
*/
|
||||
class Bind
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Bind a VertexBuffer.
|
||||
*/
|
||||
Bind(VertexBuffer &buf);
|
||||
|
||||
/**
|
||||
* Unbinds a VertexBuffer.
|
||||
*/
|
||||
~Bind();
|
||||
|
||||
private:
|
||||
|
||||
// VertexBuffer to work on.
|
||||
VertexBuffer &buf;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
// The size of the buffer, in bytes.
|
||||
int size;
|
||||
|
||||
// The target buffer object. (GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER).
|
||||
GLenum target;
|
||||
|
||||
// Usage hint. GL_[DYNAMIC, STATIC, STREAM]_DRAW.
|
||||
GLenum usage;
|
||||
};
|
||||
|
||||
/**
|
||||
* Implementation of VertexBuffer which uses plain arrays to store the data.
|
||||
*
|
||||
* This implementation should be supported everywhere, and acts as a fallback
|
||||
* on systems which do not support VBOs.
|
||||
*/
|
||||
class VertexArray : public VertexBuffer
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @copydoc VertexBuffer(int, GLenum, GLenum)
|
||||
*/
|
||||
VertexArray(int size, GLenum target, GLenum usage);
|
||||
|
||||
/**
|
||||
* Frees the data we've allocated.
|
||||
*/
|
||||
virtual ~VertexArray();
|
||||
|
||||
// Implements VertexBuffer.
|
||||
virtual void *map(GLenum access);
|
||||
virtual void unmap();
|
||||
virtual void bind();
|
||||
virtual void unbind();
|
||||
virtual void fill(int offset, int size, const void *data);
|
||||
virtual const void *getPointer(int offset) const ;
|
||||
|
||||
private:
|
||||
// Holds the data.
|
||||
char *buf;
|
||||
};
|
||||
|
||||
/**
|
||||
* Vertex Buffer Object (VBO) implementation of VertexBuffer.
|
||||
*
|
||||
* This will be used on all systems that support it. It's in general
|
||||
* faster than vertex arrays, but especially in use-cases where there
|
||||
* is no need to update the data every frame.
|
||||
*/
|
||||
class VBO : public VertexBuffer, public Volatile
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* @copydoc VertexBuffer(int, GLenum, GLenum)
|
||||
*/
|
||||
VBO(int size, GLenum target, GLenum usage);
|
||||
|
||||
/**
|
||||
* Deletes the VBOs from OpenGL.
|
||||
*/
|
||||
virtual ~VBO();
|
||||
|
||||
// Implements VertexBuffer.
|
||||
virtual void *map(GLenum access);
|
||||
virtual void unmap();
|
||||
virtual void bind();
|
||||
virtual void unbind();
|
||||
virtual void fill(int offset, int size, const void *data);
|
||||
virtual const void *getPointer(int offset) const ;
|
||||
|
||||
// Implements Volatile.
|
||||
bool loadVolatile();
|
||||
void unloadVolatile();
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Creates the VBO, and optionally restores data we saved earlier.
|
||||
*
|
||||
* @param restore True to restore data previously saved with 'unload'.
|
||||
* @return True on success, false otherwise.
|
||||
*/
|
||||
bool load(bool restore);
|
||||
|
||||
/**
|
||||
* Optionally save the data in the VBO, then delete it.
|
||||
*
|
||||
* @param save True to save the data before deleting.
|
||||
*/
|
||||
void unload(bool save);
|
||||
|
||||
// The VBO identifier. Assigned by OpenGL.
|
||||
GLuint vbo;
|
||||
|
||||
// *May* contain data saved by 'unload'.
|
||||
char *buffer_copy;
|
||||
|
||||
// A pointer to mapped memory. Zero if memory is currently
|
||||
// not mapped.
|
||||
void *mapped;
|
||||
};
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_SPRITE_BATCH_H
|
||||
|
||||
@@ -36,7 +36,8 @@ namespace opengl
|
||||
{
|
||||
// As startGrab() clears the framebuffer, better not allow
|
||||
// grabbing inside another grabbing
|
||||
if (Canvas::current != NULL) {
|
||||
if (Canvas::current != NULL)
|
||||
{
|
||||
Canvas::bindDefaultCanvas();
|
||||
return luaL_error(L, "Current render target not the default canvas!");
|
||||
}
|
||||
@@ -130,12 +131,15 @@ namespace opengl
|
||||
{
|
||||
Canvas * canvas = luax_checkcanvas(L, 1);
|
||||
Color c;
|
||||
if (lua_isnoneornil(L, 2)) {
|
||||
if (lua_isnoneornil(L, 2))
|
||||
{
|
||||
c.r = 0;
|
||||
c.g = 0;
|
||||
c.b = 0;
|
||||
c.a = 0;
|
||||
} else if (lua_istable(L, 2)) {
|
||||
}
|
||||
else if (lua_istable(L, 2))
|
||||
{
|
||||
lua_pushinteger(L, 1);
|
||||
lua_gettable(L, 2);
|
||||
c.r = (unsigned char)luaL_checkint(L, -1);
|
||||
@@ -149,7 +153,9 @@ namespace opengl
|
||||
lua_gettable(L, 2);
|
||||
c.g = (unsigned char)luaL_optint(L, -1, 255);
|
||||
lua_pop(L, 4);
|
||||
} else {
|
||||
}
|
||||
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);
|
||||
|
||||
@@ -1,108 +1,108 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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_Font.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
Font * luax_checkfont(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<Font>(L, idx, "Font", GRAPHICS_FONT_T);
|
||||
}
|
||||
|
||||
int w_Font_getHeight(lua_State * L)
|
||||
{
|
||||
Font * t = luax_checkfont(L, 1);
|
||||
lua_pushnumber(L, t->getHeight());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Font_getWidth(lua_State * L)
|
||||
{
|
||||
Font * t = luax_checkfont(L, 1);
|
||||
const char * str = luaL_checkstring(L, 2);
|
||||
try
|
||||
{
|
||||
lua_pushinteger(L, t->getWidth(str));
|
||||
}
|
||||
catch (love::Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Font_getWrap(lua_State * L)
|
||||
{
|
||||
Font * t = luax_checkfont(L, 1);
|
||||
const char * str = luaL_checkstring(L, 2);
|
||||
float wrap = (float) luaL_checknumber(L, 3);
|
||||
int max_width = 0, numlines = 0;
|
||||
try
|
||||
{
|
||||
std::vector<std::string> lines = t->getWrap(str, wrap, &max_width);
|
||||
numlines = lines.size();
|
||||
}
|
||||
catch (love::Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
lua_pushinteger(L, max_width);
|
||||
lua_pushinteger(L, numlines);
|
||||
return 2;
|
||||
}
|
||||
|
||||
int w_Font_setLineHeight(lua_State * L)
|
||||
{
|
||||
Font * t = luax_checkfont(L, 1);
|
||||
float h = (float)luaL_checknumber(L, 2);
|
||||
t->setLineHeight(h);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_Font_getLineHeight(lua_State * L)
|
||||
{
|
||||
Font * t = luax_checkfont(L, 1);
|
||||
lua_pushnumber(L, t->getLineHeight());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "getHeight", w_Font_getHeight },
|
||||
{ "getWidth", w_Font_getWidth },
|
||||
{ "getWrap", w_Font_getWrap },
|
||||
{ "setLineHeight", w_Font_setLineHeight },
|
||||
{ "getLineHeight", w_Font_getLineHeight },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int luaopen_font(lua_State * L)
|
||||
{
|
||||
return luax_register_type(L, "Font", functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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_Font.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
Font * luax_checkfont(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<Font>(L, idx, "Font", GRAPHICS_FONT_T);
|
||||
}
|
||||
|
||||
int w_Font_getHeight(lua_State * L)
|
||||
{
|
||||
Font * t = luax_checkfont(L, 1);
|
||||
lua_pushnumber(L, t->getHeight());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Font_getWidth(lua_State * L)
|
||||
{
|
||||
Font * t = luax_checkfont(L, 1);
|
||||
const char * str = luaL_checkstring(L, 2);
|
||||
try
|
||||
{
|
||||
lua_pushinteger(L, t->getWidth(str));
|
||||
}
|
||||
catch (love::Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Font_getWrap(lua_State * L)
|
||||
{
|
||||
Font * t = luax_checkfont(L, 1);
|
||||
const char * str = luaL_checkstring(L, 2);
|
||||
float wrap = (float) luaL_checknumber(L, 3);
|
||||
int max_width = 0, numlines = 0;
|
||||
try
|
||||
{
|
||||
std::vector<std::string> lines = t->getWrap(str, wrap, &max_width);
|
||||
numlines = lines.size();
|
||||
}
|
||||
catch (love::Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
lua_pushinteger(L, max_width);
|
||||
lua_pushinteger(L, numlines);
|
||||
return 2;
|
||||
}
|
||||
|
||||
int w_Font_setLineHeight(lua_State * L)
|
||||
{
|
||||
Font * t = luax_checkfont(L, 1);
|
||||
float h = (float)luaL_checknumber(L, 2);
|
||||
t->setLineHeight(h);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_Font_getLineHeight(lua_State * L)
|
||||
{
|
||||
Font * t = luax_checkfont(L, 1);
|
||||
lua_pushnumber(L, t->getLineHeight());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "getHeight", w_Font_getHeight },
|
||||
{ "getWidth", w_Font_getWidth },
|
||||
{ "getWrap", w_Font_getWrap },
|
||||
{ "setLineHeight", w_Font_setLineHeight },
|
||||
{ "getLineHeight", w_Font_getLineHeight },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int luaopen_font(lua_State * L)
|
||||
{
|
||||
return luax_register_type(L, "Font", functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_WRAP_FONT_H
|
||||
#define LOVE_GRAPHICS_OPENGL_WRAP_FONT_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
#include "Font.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
Font * luax_checkfont(lua_State * L, int idx);
|
||||
int w_Font_getHeight(lua_State * L);
|
||||
int w_Font_getWidth(lua_State * L);
|
||||
int w_Font_getWrap(lua_State * L);
|
||||
int w_Font_setLineHeight(lua_State * L);
|
||||
int w_Font_getLineHeight(lua_State * L);
|
||||
int luaopen_font(lua_State * L);
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_WRAP_FONT_H
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_WRAP_FONT_H
|
||||
#define LOVE_GRAPHICS_OPENGL_WRAP_FONT_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
#include "Font.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
Font * luax_checkfont(lua_State * L, int idx);
|
||||
int w_Font_getHeight(lua_State * L);
|
||||
int w_Font_getWidth(lua_State * L);
|
||||
int w_Font_getWrap(lua_State * L);
|
||||
int w_Font_setLineHeight(lua_State * L);
|
||||
int w_Font_getLineHeight(lua_State * L);
|
||||
int luaopen_font(lua_State * L);
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_WRAP_FONT_H
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace opengl
|
||||
|
||||
int w_setScissor(lua_State * L)
|
||||
{
|
||||
if(lua_gettop(L) == 0)
|
||||
if (lua_gettop(L) == 0)
|
||||
{
|
||||
instance->setScissor();
|
||||
return 0;
|
||||
@@ -170,7 +170,8 @@ namespace opengl
|
||||
static int setStencil(lua_State * L, bool invert)
|
||||
{
|
||||
// no argument -> clear mask
|
||||
if (lua_isnoneornil(L, 1)) {
|
||||
if (lua_isnoneornil(L, 1))
|
||||
{
|
||||
instance->discardStencil();
|
||||
return 0;
|
||||
}
|
||||
@@ -198,24 +199,27 @@ namespace opengl
|
||||
int w_newImage(lua_State * L)
|
||||
{
|
||||
// Convert to File, if necessary.
|
||||
if(lua_isstring(L, 1))
|
||||
if (lua_isstring(L, 1))
|
||||
luax_convobj(L, 1, "filesystem", "newFile");
|
||||
|
||||
// Convert to ImageData, if necessary.
|
||||
if(luax_istype(L, 1, FILESYSTEM_FILE_T))
|
||||
if (luax_istype(L, 1, FILESYSTEM_FILE_T))
|
||||
luax_convobj(L, 1, "image", "newImageData");
|
||||
|
||||
love::image::ImageData * data = luax_checktype<love::image::ImageData>(L, 1, "ImageData", IMAGE_IMAGE_DATA_T);
|
||||
|
||||
// Create the image.
|
||||
Image * image = 0;
|
||||
try {
|
||||
try
|
||||
{
|
||||
image = instance->newImage(data);
|
||||
} catch (love::Exception & e) {
|
||||
}
|
||||
catch (love::Exception & e)
|
||||
{
|
||||
luaL_error(L, e.what());
|
||||
}
|
||||
|
||||
if(image == 0)
|
||||
if (image == 0)
|
||||
return luaL_error(L, "Could not load image.");
|
||||
|
||||
|
||||
@@ -247,16 +251,19 @@ namespace opengl
|
||||
{
|
||||
Data * font_data = NULL;
|
||||
// Convert to File, if necessary.
|
||||
if(lua_isstring(L, 1))
|
||||
if (lua_isstring(L, 1))
|
||||
luax_convobj(L, 1, "filesystem", "newFile");
|
||||
|
||||
// Convert to Data, if necessary.
|
||||
if(luax_istype(L, 1, FILESYSTEM_FILE_T)) {
|
||||
if (luax_istype(L, 1, FILESYSTEM_FILE_T))
|
||||
{
|
||||
love::filesystem::File * f = luax_checktype<love::filesystem::File>(L, 1, "File", FILESYSTEM_FILE_T);
|
||||
try {
|
||||
try
|
||||
{
|
||||
font_data = f->read();
|
||||
}
|
||||
catch (love::Exception & e) {
|
||||
catch (love::Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
lua_remove(L, 1); // get rid of the file
|
||||
@@ -265,7 +272,8 @@ namespace opengl
|
||||
}
|
||||
|
||||
// Convert to Rasterizer, if necessary.
|
||||
if(luax_istype(L, 1, DATA_T)) {
|
||||
if (luax_istype(L, 1, DATA_T))
|
||||
{
|
||||
int idxs[] = {1, 2};
|
||||
luax_convobj(L, idxs, 2, "font", "newRasterizer");
|
||||
}
|
||||
@@ -278,7 +286,7 @@ namespace opengl
|
||||
// Create the font.
|
||||
Font * font = instance->newFont(rasterizer);
|
||||
|
||||
if(font == 0)
|
||||
if (font == 0)
|
||||
return luaL_error(L, "Could not load font.");
|
||||
|
||||
// Push the type.
|
||||
@@ -293,9 +301,10 @@ namespace opengl
|
||||
Image::Filter img_filter;
|
||||
|
||||
// Convert to ImageData if necessary.
|
||||
if(lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T) || (luax_istype(L, 1, DATA_T) && !luax_istype(L, 1, IMAGE_IMAGE_DATA_T)))
|
||||
if (lua_isstring(L, 1) || luax_istype(L, 1, FILESYSTEM_FILE_T) || (luax_istype(L, 1, DATA_T) && !luax_istype(L, 1, IMAGE_IMAGE_DATA_T)))
|
||||
luax_convobj(L, 1, "image", "newImageData");
|
||||
else if(luax_istype(L, 1, GRAPHICS_IMAGE_T)) {
|
||||
else if (luax_istype(L, 1, GRAPHICS_IMAGE_T))
|
||||
{
|
||||
Image * i = luax_checktype<Image>(L, 1, "Image", GRAPHICS_IMAGE_T);
|
||||
img_filter = i->getFilter();
|
||||
love::image::ImageData * id = i->getData();
|
||||
@@ -304,7 +313,8 @@ namespace opengl
|
||||
}
|
||||
|
||||
// Convert to Rasterizer if necessary.
|
||||
if(luax_istype(L, 1, IMAGE_IMAGE_DATA_T)) {
|
||||
if (luax_istype(L, 1, IMAGE_IMAGE_DATA_T))
|
||||
{
|
||||
int idxs[] = {1, 2};
|
||||
luax_convobj(L, idxs, 2, "font", "newRasterizer");
|
||||
}
|
||||
@@ -314,7 +324,7 @@ namespace opengl
|
||||
// Create the font.
|
||||
Font * font = instance->newFont(rasterizer, img_filter);
|
||||
|
||||
if(font == 0)
|
||||
if (font == 0)
|
||||
return luaL_error(L, "Could not load font.");
|
||||
|
||||
// Push the type.
|
||||
@@ -334,9 +344,12 @@ namespace opengl
|
||||
usage = SpriteBatch::USAGE_DYNAMIC;
|
||||
}
|
||||
SpriteBatch * t = NULL;
|
||||
try {
|
||||
try
|
||||
{
|
||||
t = instance->newSpriteBatch(image, size, usage);
|
||||
} catch(love::Exception& e) {
|
||||
}
|
||||
catch (love::Exception& e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
luax_newtype(L, "SpriteBatch", GRAPHICS_SPRITE_BATCH_T, (void*)t);
|
||||
@@ -360,9 +373,12 @@ namespace opengl
|
||||
glGetError(); // clear opengl error flag
|
||||
|
||||
Canvas * canvas = NULL;
|
||||
try {
|
||||
try
|
||||
{
|
||||
canvas = instance->newCanvas(width, height);
|
||||
} catch (Exception& e) {
|
||||
}
|
||||
catch (Exception& e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
|
||||
@@ -378,7 +394,8 @@ namespace opengl
|
||||
if (!PixelEffect::isSupported())
|
||||
return luaL_error(L, "Sorry, your graphics card does not support pixel effects.");
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
luaL_checkstring(L, 1);
|
||||
|
||||
luax_getfunction(L, "graphics", "_effectCodeToGLSL");
|
||||
@@ -388,7 +405,9 @@ namespace opengl
|
||||
const char* code = lua_tostring(L, -1);
|
||||
PixelEffect * effect = instance->newPixelEffect(code);
|
||||
luax_newtype(L, "PixelEffect", GRAPHICS_PIXELEFFECT_T, (void*)effect);
|
||||
} catch (const love::Exception& e) {
|
||||
}
|
||||
catch (const love::Exception& e)
|
||||
{
|
||||
// memory is freed in Graphics::newPixelEffect
|
||||
luax_getfunction(L, "graphics", "_transformGLSLErrorMessages");
|
||||
lua_pushstring(L, e.what());
|
||||
@@ -403,7 +422,8 @@ namespace opengl
|
||||
int w_setColor(lua_State * L)
|
||||
{
|
||||
Color c;
|
||||
if (lua_istable(L, 1)) {
|
||||
if (lua_istable(L, 1))
|
||||
{
|
||||
lua_pushinteger(L, 1);
|
||||
lua_gettable(L, -2);
|
||||
c.r = (unsigned char)luaL_checkint(L, -1);
|
||||
@@ -445,7 +465,8 @@ namespace opengl
|
||||
int w_setBackgroundColor(lua_State * L)
|
||||
{
|
||||
Color c;
|
||||
if (lua_istable(L, 1)) {
|
||||
if (lua_istable(L, 1))
|
||||
{
|
||||
lua_pushinteger(L, 1);
|
||||
lua_gettable(L, -2);
|
||||
c.r = (unsigned char)luaL_checkint(L, -1);
|
||||
@@ -494,21 +515,26 @@ namespace opengl
|
||||
bool created = false;
|
||||
|
||||
// If the first parameter isn't a Font, create a new one
|
||||
if (!luax_istype(L, 1, GRAPHICS_FONT_T)) {
|
||||
if (!luax_istype(L, 1, GRAPHICS_FONT_T))
|
||||
{
|
||||
created = true;
|
||||
lua_pushinteger(L, size); // push the size
|
||||
lua_insert(L, 2); // move it to its proper place
|
||||
// Convert to File, if necessary.
|
||||
if(lua_isstring(L, 1))
|
||||
if (lua_isstring(L, 1))
|
||||
luax_convobj(L, 1, "filesystem", "newFile");
|
||||
|
||||
// Convert to Data, if necessary.
|
||||
if(luax_istype(L, 1, FILESYSTEM_FILE_T)) {
|
||||
if (luax_istype(L, 1, FILESYSTEM_FILE_T))
|
||||
{
|
||||
love::filesystem::File * f = luax_checktype<love::filesystem::File>(L, 1, "File", FILESYSTEM_FILE_T);
|
||||
Data * d;
|
||||
try {
|
||||
try
|
||||
{
|
||||
d = f->read();
|
||||
} catch (love::Exception & e) {
|
||||
}
|
||||
catch (love::Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
lua_remove(L, 1); // get rid of the file
|
||||
@@ -517,7 +543,8 @@ namespace opengl
|
||||
}
|
||||
|
||||
// Convert to Rasterizer, if necessary.
|
||||
if(luax_istype(L, 1, DATA_T)) {
|
||||
if (luax_istype(L, 1, DATA_T))
|
||||
{
|
||||
int idxs[] = {1, 2};
|
||||
luax_convobj(L, idxs, 2, "font", "newRasterizer");
|
||||
}
|
||||
@@ -527,7 +554,7 @@ namespace opengl
|
||||
// Create the font.
|
||||
font = instance->newFont(rasterizer);
|
||||
|
||||
if(font == 0)
|
||||
if (font == 0)
|
||||
return luaL_error(L, "Could not load font.");
|
||||
}
|
||||
else font = luax_checktype<Font>(L, 1, "Font", GRAPHICS_FONT_T);
|
||||
@@ -541,7 +568,7 @@ namespace opengl
|
||||
{
|
||||
Font * f = instance->getFont();
|
||||
|
||||
if(f == 0)
|
||||
if (f == 0)
|
||||
return 0;
|
||||
|
||||
f->retain();
|
||||
@@ -553,7 +580,7 @@ namespace opengl
|
||||
{
|
||||
Graphics::BlendMode mode;
|
||||
const char * str = luaL_checkstring(L, 1);
|
||||
if(!Graphics::getConstant(str, mode))
|
||||
if (!Graphics::getConstant(str, mode))
|
||||
return luaL_error(L, "Invalid blend mode: %s", str);
|
||||
|
||||
instance->setBlendMode(mode);
|
||||
@@ -564,7 +591,7 @@ namespace opengl
|
||||
{
|
||||
Graphics::ColorMode mode;
|
||||
const char * str = luaL_checkstring(L, 1);
|
||||
if(!Graphics::getConstant(str, mode))
|
||||
if (!Graphics::getConstant(str, mode))
|
||||
return luaL_error(L, "Invalid color mode: %s", str);
|
||||
|
||||
instance->setColorMode(mode);
|
||||
@@ -594,7 +621,7 @@ namespace opengl
|
||||
{
|
||||
Graphics::BlendMode mode = instance->getBlendMode();
|
||||
const char * str;
|
||||
if(!Graphics::getConstant(mode, str))
|
||||
if (!Graphics::getConstant(mode, str))
|
||||
return luaL_error(L, "Invalid blend mode: %s", str);
|
||||
|
||||
lua_pushstring(L, str);
|
||||
@@ -605,7 +632,7 @@ namespace opengl
|
||||
{
|
||||
Graphics::ColorMode mode = instance->getColorMode();
|
||||
const char * str;
|
||||
if(!Graphics::getConstant(mode, str))
|
||||
if (!Graphics::getConstant(mode, str))
|
||||
return luaL_error(L, "Invalid color mode: %s", str);
|
||||
|
||||
lua_pushstring(L, str);
|
||||
@@ -635,7 +662,7 @@ namespace opengl
|
||||
{
|
||||
Graphics::LineStyle style;
|
||||
const char * str = luaL_checkstring(L, 1);
|
||||
if(!Graphics::getConstant(str, style))
|
||||
if (!Graphics::getConstant(str, style))
|
||||
return luaL_error(L, "Invalid line style: %s", str);
|
||||
|
||||
instance->setLineStyle(style);
|
||||
@@ -648,10 +675,10 @@ namespace opengl
|
||||
|
||||
Graphics::LineStyle style = Graphics::LINE_SMOOTH;
|
||||
|
||||
if(lua_gettop(L) >= 2)
|
||||
if (lua_gettop(L) >= 2)
|
||||
{
|
||||
const char * str = luaL_checkstring(L, 2);
|
||||
if(!Graphics::getConstant(str, style))
|
||||
if (!Graphics::getConstant(str, style))
|
||||
return luaL_error(L, "Invalid line style: %s", str);
|
||||
}
|
||||
|
||||
@@ -685,10 +712,10 @@ namespace opengl
|
||||
{
|
||||
Graphics::PointStyle style = Graphics::POINT_SMOOTH;
|
||||
|
||||
if(lua_gettop(L) >= 2)
|
||||
if (lua_gettop(L) >= 2)
|
||||
{
|
||||
const char * str = luaL_checkstring(L, 1);
|
||||
if(!Graphics::getConstant(str, style))
|
||||
if (!Graphics::getConstant(str, style))
|
||||
return luaL_error(L, "Invalid point style: %s", str);
|
||||
}
|
||||
|
||||
@@ -702,7 +729,7 @@ namespace opengl
|
||||
|
||||
Graphics::PointStyle style;
|
||||
const char * str = luaL_checkstring(L, 2);
|
||||
if(!Graphics::getConstant(str, style))
|
||||
if (!Graphics::getConstant(str, style))
|
||||
return luaL_error(L, "Invalid point style: %s", str);
|
||||
|
||||
instance->setPoint(size, style);
|
||||
@@ -738,7 +765,8 @@ namespace opengl
|
||||
int w_setRenderTarget(lua_State * L)
|
||||
{
|
||||
// called with nil or none -> reset to default buffer
|
||||
if (lua_isnoneornil(L,1)) {
|
||||
if (lua_isnoneornil(L,1))
|
||||
{
|
||||
Canvas::bindDefaultCanvas();
|
||||
return 0;
|
||||
}
|
||||
@@ -753,7 +781,8 @@ namespace opengl
|
||||
int w_getRenderTarget(lua_State * L)
|
||||
{
|
||||
Canvas *canvas = Canvas::current;
|
||||
if (canvas) {
|
||||
if (canvas)
|
||||
{
|
||||
canvas->retain();
|
||||
luax_newtype(L, "Canvas", GRAPHICS_CANVAS_T, (void*) canvas);
|
||||
}
|
||||
@@ -764,7 +793,8 @@ namespace opengl
|
||||
|
||||
int w_setPixelEffect(lua_State * L)
|
||||
{
|
||||
if (lua_isnoneornil(L,1)) {
|
||||
if (lua_isnoneornil(L,1))
|
||||
{
|
||||
PixelEffect::detach();
|
||||
return 0;
|
||||
}
|
||||
@@ -782,7 +812,7 @@ namespace opengl
|
||||
for (unsigned int i = 1; i <= len; i++)
|
||||
{
|
||||
const char * str = luaL_checkstring(L, i);
|
||||
if(!Graphics::getConstant(str, support))
|
||||
if (!Graphics::getConstant(str, support))
|
||||
supported = false;
|
||||
switch(support)
|
||||
{
|
||||
@@ -915,10 +945,10 @@ namespace opengl
|
||||
|
||||
Graphics::AlignMode align = Graphics::ALIGN_LEFT;
|
||||
|
||||
if(lua_gettop(L) >= 5)
|
||||
if (lua_gettop(L) >= 5)
|
||||
{
|
||||
const char * str = luaL_checkstring(L, 5);
|
||||
if(!Graphics::getConstant(str, align))
|
||||
if (!Graphics::getConstant(str, align))
|
||||
return luaL_error(L, "Incorrect alignment: %s", str);
|
||||
}
|
||||
|
||||
@@ -945,7 +975,8 @@ namespace opengl
|
||||
{
|
||||
int args = lua_gettop(L);
|
||||
bool is_table = false;
|
||||
if (args == 1 && lua_istable(L, 1)) {
|
||||
if (args == 1 && lua_istable(L, 1))
|
||||
{
|
||||
args = lua_objlen(L, 1);
|
||||
is_table = true;
|
||||
}
|
||||
@@ -955,14 +986,18 @@ namespace opengl
|
||||
return luaL_error(L, "Need at least two vertices to draw a line");
|
||||
|
||||
float* coords = new float[args];
|
||||
if (is_table) {
|
||||
for (int i = 0; i < args; ++i) {
|
||||
if (is_table)
|
||||
{
|
||||
for (int i = 0; i < args; ++i)
|
||||
{
|
||||
lua_pushnumber(L, i + 1);
|
||||
lua_rawget(L, 1);
|
||||
coords[i] = luax_tofloat(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < args; ++i)
|
||||
coords[i] = luax_tofloat(L, i + 1);
|
||||
}
|
||||
@@ -977,7 +1012,7 @@ namespace opengl
|
||||
{
|
||||
Graphics::DrawMode mode;
|
||||
const char * str = luaL_checkstring(L, 1);
|
||||
if(!Graphics::getConstant(str, mode))
|
||||
if (!Graphics::getConstant(str, mode))
|
||||
return luaL_error(L, "Incorrect draw mode %s", str);
|
||||
|
||||
float x1 = (float)luaL_checknumber(L, 2);
|
||||
@@ -994,7 +1029,7 @@ namespace opengl
|
||||
{
|
||||
Graphics::DrawMode mode;
|
||||
const char * str = luaL_checkstring(L, 1);
|
||||
if(!Graphics::getConstant(str, mode))
|
||||
if (!Graphics::getConstant(str, mode))
|
||||
return luaL_error(L, "Incorrect draw mode %s", str);
|
||||
|
||||
float x = (float)luaL_checknumber(L, 2);
|
||||
@@ -1009,7 +1044,7 @@ namespace opengl
|
||||
{
|
||||
Graphics::DrawMode mode;
|
||||
const char * str = luaL_checkstring(L, 1);
|
||||
if(!Graphics::getConstant(str, mode))
|
||||
if (!Graphics::getConstant(str, mode))
|
||||
return luaL_error(L, "Incorrect draw mode %s", str);
|
||||
|
||||
float x1 = (float)luaL_checknumber(L, 2);
|
||||
@@ -1028,7 +1063,7 @@ namespace opengl
|
||||
{
|
||||
Graphics::DrawMode mode;
|
||||
const char * str = luaL_checkstring(L, 1);
|
||||
if(!Graphics::getConstant(str, mode))
|
||||
if (!Graphics::getConstant(str, mode))
|
||||
return luaL_error(L, "Incorrect draw mode %s", str);
|
||||
|
||||
float x = (float)luaL_checknumber(L, 2);
|
||||
@@ -1042,14 +1077,14 @@ namespace opengl
|
||||
instance->circle(mode, x, y, radius, points);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int w_arc(lua_State * L)
|
||||
{
|
||||
Graphics::DrawMode mode;
|
||||
const char * str = luaL_checkstring(L, 1);
|
||||
if(!Graphics::getConstant(str, mode))
|
||||
if (!Graphics::getConstant(str, mode))
|
||||
return luaL_error(L, "Incorrect draw mode %s", str);
|
||||
|
||||
|
||||
float x = (float)luaL_checknumber(L, 2);
|
||||
float y = (float)luaL_checknumber(L, 3);
|
||||
float radius = (float)luaL_checknumber(L, 4);
|
||||
@@ -1066,12 +1101,13 @@ namespace opengl
|
||||
|
||||
Graphics::DrawMode mode;
|
||||
const char * str = luaL_checkstring(L, 1);
|
||||
if(!Graphics::getConstant(str, mode))
|
||||
if (!Graphics::getConstant(str, mode))
|
||||
return luaL_error(L, "Invalid draw mode: %s", str);
|
||||
|
||||
bool is_table = false;
|
||||
float* coords;
|
||||
if (args == 1 && lua_istable(L, 2)) {
|
||||
if (args == 1 && lua_istable(L, 2))
|
||||
{
|
||||
args = lua_objlen(L, 2);
|
||||
is_table = true;
|
||||
}
|
||||
@@ -1083,14 +1119,18 @@ namespace opengl
|
||||
|
||||
// fetch coords
|
||||
coords = new float[args + 2];
|
||||
if (is_table) {
|
||||
for (int i = 0; i < args; ++i) {
|
||||
if (is_table)
|
||||
{
|
||||
for (int i = 0; i < args; ++i)
|
||||
{
|
||||
lua_pushnumber(L, i + 1);
|
||||
lua_rawget(L, 2);
|
||||
coords[i] = luax_tofloat(L, -1);
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < args; ++i)
|
||||
coords[i] = luax_tofloat(L, i + 2);
|
||||
}
|
||||
@@ -1100,7 +1140,7 @@ namespace opengl
|
||||
coords[args+1] = coords[1];
|
||||
instance->polygon(mode, coords, args+2);
|
||||
delete[] coords;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1282,13 +1322,13 @@ namespace opengl
|
||||
|
||||
int luaopen_love_graphics(lua_State * L)
|
||||
{
|
||||
if(instance == 0)
|
||||
if (instance == 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
instance = new Graphics();
|
||||
}
|
||||
catch(Exception & e)
|
||||
catch (Exception & e)
|
||||
{
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
|
||||
@@ -1,121 +1,121 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_WRAP_GRAPHICS_H
|
||||
#define LOVE_GRAPHICS_OPENGL_WRAP_GRAPHICS_H
|
||||
|
||||
// LOVE
|
||||
#include "wrap_Font.h"
|
||||
#include "wrap_Image.h"
|
||||
#include "wrap_Quad.h"
|
||||
#include "wrap_SpriteBatch.h"
|
||||
#include "wrap_ParticleSystem.h"
|
||||
#include "wrap_Canvas.h"
|
||||
#include "wrap_PixelEffect.h"
|
||||
#include "Graphics.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
int w_checkMode(lua_State * L);
|
||||
int w_setMode(lua_State * L);
|
||||
int w_getMode(lua_State * L);
|
||||
int w_toggleFullscreen(lua_State * L);
|
||||
int w_reset(lua_State * L);
|
||||
int w_clear(lua_State * L);
|
||||
int w_present(lua_State * L);
|
||||
int w_setIcon(lua_State * L);
|
||||
int w_setCaption(lua_State * L);
|
||||
int w_getCaption(lua_State * L);
|
||||
int w_getWidth(lua_State * L);
|
||||
int w_getHeight(lua_State * L);
|
||||
int w_isCreated(lua_State * L);
|
||||
int w_setScissor(lua_State * L);
|
||||
int w_getScissor(lua_State * L);
|
||||
int w_defineMask(lua_State * L);
|
||||
int w_setMask(lua_State * L);
|
||||
int w_newImage(lua_State * L);
|
||||
int w_newQuad(lua_State * L);
|
||||
int w_newFrame(lua_State * L);
|
||||
int w_newFont1(lua_State * L);
|
||||
int w_newImageFont(lua_State * L);
|
||||
int w_newSpriteBatch(lua_State * L);
|
||||
int w_newParticleSystem(lua_State * L);
|
||||
int w_newCanvas(lua_State * L); // comments in function
|
||||
int w_newPixelEffect(lua_State * L);
|
||||
int w_setColor(lua_State * L);
|
||||
int w_getColor(lua_State * L);
|
||||
int w_setBackgroundColor(lua_State * L);
|
||||
int w_getBackgroundColor(lua_State * L);
|
||||
int w_setFont1(lua_State * L);
|
||||
int w_getFont(lua_State * L);
|
||||
int w_setBlendMode(lua_State * L);
|
||||
int w_setColorMode(lua_State * L);
|
||||
int w_setDefaultImageFilter(lua_State * L);
|
||||
int w_getBlendMode(lua_State * L);
|
||||
int w_getColorMode(lua_State * L);
|
||||
int w_getDefaultImageFilter(lua_State * L);
|
||||
int w_setLineWidth(lua_State * L);
|
||||
int w_setLineStyle(lua_State * L);
|
||||
int w_setLine(lua_State * L);
|
||||
int w_setLineStipple(lua_State * L);
|
||||
int w_getLineWidth(lua_State * L);
|
||||
int w_getLineStyle(lua_State * L);
|
||||
int w_getLineStipple(lua_State * L);
|
||||
int w_setPointSize(lua_State * L);
|
||||
int w_setPointStyle(lua_State * L);
|
||||
int w_setPoint(lua_State * L);
|
||||
int w_getPointSize(lua_State * L);
|
||||
int w_getPointStyle(lua_State * L);
|
||||
int w_getMaxPointSize(lua_State * L);
|
||||
int w_newScreenshot(lua_State * L);
|
||||
int w_setRenderTarget(lua_State * L);
|
||||
int w_getRenderTarget(lua_State * L);
|
||||
int w_setPixelEffect(lua_State * L);
|
||||
int w_isSupported(lua_State * L);
|
||||
int w_draw(lua_State * L);
|
||||
int w_drawq(lua_State * L);
|
||||
int w_drawTest(lua_State * L);
|
||||
int w_print1(lua_State * L);
|
||||
int w_printf1(lua_State * L);
|
||||
int w_point(lua_State * L);
|
||||
int w_line(lua_State * L);
|
||||
int w_triangle(lua_State * L);
|
||||
int w_rectangle(lua_State * L);
|
||||
int w_quad(lua_State * L);
|
||||
int w_circle(lua_State * L);
|
||||
int w_arc(lua_State * L);
|
||||
int w_push(lua_State * L);
|
||||
int w_pop(lua_State * L);
|
||||
int w_rotate(lua_State * L);
|
||||
int w_scale(lua_State * L);
|
||||
int w_translate(lua_State * L);
|
||||
int w_shear(lua_State * L);
|
||||
int w_hasFocus(lua_State * L);
|
||||
extern "C" LOVE_EXPORT int luaopen_love_graphics(lua_State * L);
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_WRAP_GRAPHICS_H
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_WRAP_GRAPHICS_H
|
||||
#define LOVE_GRAPHICS_OPENGL_WRAP_GRAPHICS_H
|
||||
|
||||
// LOVE
|
||||
#include "wrap_Font.h"
|
||||
#include "wrap_Image.h"
|
||||
#include "wrap_Quad.h"
|
||||
#include "wrap_SpriteBatch.h"
|
||||
#include "wrap_ParticleSystem.h"
|
||||
#include "wrap_Canvas.h"
|
||||
#include "wrap_PixelEffect.h"
|
||||
#include "Graphics.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
int w_checkMode(lua_State * L);
|
||||
int w_setMode(lua_State * L);
|
||||
int w_getMode(lua_State * L);
|
||||
int w_toggleFullscreen(lua_State * L);
|
||||
int w_reset(lua_State * L);
|
||||
int w_clear(lua_State * L);
|
||||
int w_present(lua_State * L);
|
||||
int w_setIcon(lua_State * L);
|
||||
int w_setCaption(lua_State * L);
|
||||
int w_getCaption(lua_State * L);
|
||||
int w_getWidth(lua_State * L);
|
||||
int w_getHeight(lua_State * L);
|
||||
int w_isCreated(lua_State * L);
|
||||
int w_setScissor(lua_State * L);
|
||||
int w_getScissor(lua_State * L);
|
||||
int w_defineMask(lua_State * L);
|
||||
int w_setMask(lua_State * L);
|
||||
int w_newImage(lua_State * L);
|
||||
int w_newQuad(lua_State * L);
|
||||
int w_newFrame(lua_State * L);
|
||||
int w_newFont1(lua_State * L);
|
||||
int w_newImageFont(lua_State * L);
|
||||
int w_newSpriteBatch(lua_State * L);
|
||||
int w_newParticleSystem(lua_State * L);
|
||||
int w_newCanvas(lua_State * L); // comments in function
|
||||
int w_newPixelEffect(lua_State * L);
|
||||
int w_setColor(lua_State * L);
|
||||
int w_getColor(lua_State * L);
|
||||
int w_setBackgroundColor(lua_State * L);
|
||||
int w_getBackgroundColor(lua_State * L);
|
||||
int w_setFont1(lua_State * L);
|
||||
int w_getFont(lua_State * L);
|
||||
int w_setBlendMode(lua_State * L);
|
||||
int w_setColorMode(lua_State * L);
|
||||
int w_setDefaultImageFilter(lua_State * L);
|
||||
int w_getBlendMode(lua_State * L);
|
||||
int w_getColorMode(lua_State * L);
|
||||
int w_getDefaultImageFilter(lua_State * L);
|
||||
int w_setLineWidth(lua_State * L);
|
||||
int w_setLineStyle(lua_State * L);
|
||||
int w_setLine(lua_State * L);
|
||||
int w_setLineStipple(lua_State * L);
|
||||
int w_getLineWidth(lua_State * L);
|
||||
int w_getLineStyle(lua_State * L);
|
||||
int w_getLineStipple(lua_State * L);
|
||||
int w_setPointSize(lua_State * L);
|
||||
int w_setPointStyle(lua_State * L);
|
||||
int w_setPoint(lua_State * L);
|
||||
int w_getPointSize(lua_State * L);
|
||||
int w_getPointStyle(lua_State * L);
|
||||
int w_getMaxPointSize(lua_State * L);
|
||||
int w_newScreenshot(lua_State * L);
|
||||
int w_setRenderTarget(lua_State * L);
|
||||
int w_getRenderTarget(lua_State * L);
|
||||
int w_setPixelEffect(lua_State * L);
|
||||
int w_isSupported(lua_State * L);
|
||||
int w_draw(lua_State * L);
|
||||
int w_drawq(lua_State * L);
|
||||
int w_drawTest(lua_State * L);
|
||||
int w_print1(lua_State * L);
|
||||
int w_printf1(lua_State * L);
|
||||
int w_point(lua_State * L);
|
||||
int w_line(lua_State * L);
|
||||
int w_triangle(lua_State * L);
|
||||
int w_rectangle(lua_State * L);
|
||||
int w_quad(lua_State * L);
|
||||
int w_circle(lua_State * L);
|
||||
int w_arc(lua_State * L);
|
||||
int w_push(lua_State * L);
|
||||
int w_pop(lua_State * L);
|
||||
int w_rotate(lua_State * L);
|
||||
int w_scale(lua_State * L);
|
||||
int w_translate(lua_State * L);
|
||||
int w_shear(lua_State * L);
|
||||
int w_hasFocus(lua_State * L);
|
||||
extern "C" LOVE_EXPORT int luaopen_love_graphics(lua_State * L);
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_WRAP_GRAPHICS_H
|
||||
|
||||
@@ -1,134 +1,134 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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_Image.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
Image * luax_checkimage(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<Image>(L, idx, "Image", GRAPHICS_IMAGE_T);
|
||||
}
|
||||
|
||||
int w_Image_getWidth(lua_State * L)
|
||||
{
|
||||
Image * t = luax_checkimage(L, 1);
|
||||
lua_pushnumber(L, t->getWidth());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Image_getHeight(lua_State * L)
|
||||
{
|
||||
Image * t = luax_checkimage(L, 1);
|
||||
lua_pushnumber(L, t->getHeight());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Image_setFilter(lua_State * L)
|
||||
{
|
||||
Image * t = luax_checkimage(L, 1);
|
||||
Image::Filter f;
|
||||
Image::FilterMode min;
|
||||
Image::FilterMode mag;
|
||||
const char * minstr = luaL_checkstring(L, 2);
|
||||
const char * magstr = luaL_checkstring(L, 3);
|
||||
if (!Image::getConstant(minstr, min))
|
||||
return luaL_error(L, "Invalid filter mode: %s", minstr);
|
||||
if (!Image::getConstant(magstr, mag))
|
||||
return luaL_error(L, "Invalid filter mode: %s", magstr);
|
||||
|
||||
f.min = min;
|
||||
f.mag = mag;
|
||||
t->setFilter(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_Image_getFilter(lua_State * L)
|
||||
{
|
||||
Image * t = luax_checkimage(L, 1);
|
||||
Image::Filter f = t->getFilter();
|
||||
Image::FilterMode min = f.min;
|
||||
Image::FilterMode mag = f.mag;
|
||||
const char * minstr;
|
||||
const char * magstr;
|
||||
Image::getConstant(min, minstr);
|
||||
Image::getConstant(mag, magstr);
|
||||
lua_pushstring(L, minstr);
|
||||
lua_pushstring(L, magstr);
|
||||
return 2;
|
||||
}
|
||||
|
||||
int w_Image_setWrap(lua_State * L)
|
||||
{
|
||||
Image * i = luax_checkimage(L, 1);
|
||||
Image::Wrap w;
|
||||
Image::WrapMode s;
|
||||
Image::WrapMode t;
|
||||
const char * sstr = luaL_checkstring(L, 2);
|
||||
const char * tstr = luaL_checkstring(L, 3);
|
||||
if (!Image::getConstant(sstr, s))
|
||||
return luaL_error(L, "Invalid wrap mode: %s", sstr);
|
||||
if (!Image::getConstant(tstr, t))
|
||||
return luaL_error(L, "Invalid wrap mode, %s", tstr);
|
||||
|
||||
w.s = s;
|
||||
w.t = t;
|
||||
i->setWrap(w);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_Image_getWrap(lua_State * L)
|
||||
{
|
||||
Image * i = luax_checkimage(L, 1);
|
||||
Image::Wrap w = i->getWrap();
|
||||
Image::WrapMode s = w.s;
|
||||
Image::WrapMode t = w.t;
|
||||
const char * sstr;
|
||||
const char * tstr;
|
||||
Image::getConstant(s, sstr);
|
||||
Image::getConstant(t, tstr);
|
||||
lua_pushstring(L, sstr);
|
||||
lua_pushstring(L, tstr);
|
||||
return 2;
|
||||
}
|
||||
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "getWidth", w_Image_getWidth },
|
||||
{ "getHeight", w_Image_getHeight },
|
||||
{ "setFilter", w_Image_setFilter },
|
||||
{ "getFilter", w_Image_getFilter },
|
||||
{ "setWrap", w_Image_setWrap },
|
||||
{ "getWrap", w_Image_getWrap },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int luaopen_image(lua_State * L)
|
||||
{
|
||||
return luax_register_type(L, "Image", functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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_Image.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
Image * luax_checkimage(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<Image>(L, idx, "Image", GRAPHICS_IMAGE_T);
|
||||
}
|
||||
|
||||
int w_Image_getWidth(lua_State * L)
|
||||
{
|
||||
Image * t = luax_checkimage(L, 1);
|
||||
lua_pushnumber(L, t->getWidth());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Image_getHeight(lua_State * L)
|
||||
{
|
||||
Image * t = luax_checkimage(L, 1);
|
||||
lua_pushnumber(L, t->getHeight());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Image_setFilter(lua_State * L)
|
||||
{
|
||||
Image * t = luax_checkimage(L, 1);
|
||||
Image::Filter f;
|
||||
Image::FilterMode min;
|
||||
Image::FilterMode mag;
|
||||
const char * minstr = luaL_checkstring(L, 2);
|
||||
const char * magstr = luaL_checkstring(L, 3);
|
||||
if (!Image::getConstant(minstr, min))
|
||||
return luaL_error(L, "Invalid filter mode: %s", minstr);
|
||||
if (!Image::getConstant(magstr, mag))
|
||||
return luaL_error(L, "Invalid filter mode: %s", magstr);
|
||||
|
||||
f.min = min;
|
||||
f.mag = mag;
|
||||
t->setFilter(f);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_Image_getFilter(lua_State * L)
|
||||
{
|
||||
Image * t = luax_checkimage(L, 1);
|
||||
Image::Filter f = t->getFilter();
|
||||
Image::FilterMode min = f.min;
|
||||
Image::FilterMode mag = f.mag;
|
||||
const char * minstr;
|
||||
const char * magstr;
|
||||
Image::getConstant(min, minstr);
|
||||
Image::getConstant(mag, magstr);
|
||||
lua_pushstring(L, minstr);
|
||||
lua_pushstring(L, magstr);
|
||||
return 2;
|
||||
}
|
||||
|
||||
int w_Image_setWrap(lua_State * L)
|
||||
{
|
||||
Image * i = luax_checkimage(L, 1);
|
||||
Image::Wrap w;
|
||||
Image::WrapMode s;
|
||||
Image::WrapMode t;
|
||||
const char * sstr = luaL_checkstring(L, 2);
|
||||
const char * tstr = luaL_checkstring(L, 3);
|
||||
if (!Image::getConstant(sstr, s))
|
||||
return luaL_error(L, "Invalid wrap mode: %s", sstr);
|
||||
if (!Image::getConstant(tstr, t))
|
||||
return luaL_error(L, "Invalid wrap mode, %s", tstr);
|
||||
|
||||
w.s = s;
|
||||
w.t = t;
|
||||
i->setWrap(w);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_Image_getWrap(lua_State * L)
|
||||
{
|
||||
Image * i = luax_checkimage(L, 1);
|
||||
Image::Wrap w = i->getWrap();
|
||||
Image::WrapMode s = w.s;
|
||||
Image::WrapMode t = w.t;
|
||||
const char * sstr;
|
||||
const char * tstr;
|
||||
Image::getConstant(s, sstr);
|
||||
Image::getConstant(t, tstr);
|
||||
lua_pushstring(L, sstr);
|
||||
lua_pushstring(L, tstr);
|
||||
return 2;
|
||||
}
|
||||
|
||||
static const luaL_Reg functions[] = {
|
||||
{ "getWidth", w_Image_getWidth },
|
||||
{ "getHeight", w_Image_getHeight },
|
||||
{ "setFilter", w_Image_setFilter },
|
||||
{ "getFilter", w_Image_getFilter },
|
||||
{ "setWrap", w_Image_setWrap },
|
||||
{ "getWrap", w_Image_getWrap },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int luaopen_image(lua_State * L)
|
||||
{
|
||||
return luax_register_type(L, "Image", functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_WRAP_IMAGE_H
|
||||
#define LOVE_GRAPHICS_OPENGL_WRAP_IMAGE_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
#include "Image.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
Image * luax_checkimage(lua_State * L, int idx);
|
||||
int w_Image_getWidth(lua_State * L);
|
||||
int w_Image_getHeight(lua_State * L);
|
||||
int w_Image_setFilter(lua_State * L);
|
||||
int luaopen_image(lua_State * L);
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_WRAP_IMAGE_H
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_WRAP_IMAGE_H
|
||||
#define LOVE_GRAPHICS_OPENGL_WRAP_IMAGE_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
#include "Image.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
Image * luax_checkimage(lua_State * L, int idx);
|
||||
int w_Image_getWidth(lua_State * L);
|
||||
int w_Image_getHeight(lua_State * L);
|
||||
int w_Image_setFilter(lua_State * L);
|
||||
int luaopen_image(lua_State * L);
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_WRAP_IMAGE_H
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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
|
||||
@@ -151,9 +151,12 @@ namespace opengl
|
||||
if (nSizes > 8)
|
||||
return luaL_error(L, "At most eight (8) sizes may be used.");
|
||||
|
||||
if (nSizes == 1) {
|
||||
if (nSizes == 1)
|
||||
{
|
||||
t->setSize(luax_checkfloat(L, 2));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<float> sizes(nSizes);
|
||||
for (size_t i = 0; i < nSizes; ++i)
|
||||
sizes[i] = luax_checkfloat(L, 1 + i + 1);
|
||||
@@ -206,14 +209,18 @@ namespace opengl
|
||||
if (nColors > 8)
|
||||
return luaL_error(L, "At most eight (8) colors may be used.");
|
||||
|
||||
if (nColors == 1) {
|
||||
if (nColors == 1)
|
||||
{
|
||||
t->setColor(Color(luaL_checkint(L,2),
|
||||
luaL_checkint(L,3),
|
||||
luaL_checkint(L,4),
|
||||
luaL_checkint(L,5)));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<Color> colors(nColors);
|
||||
for (size_t i = 0; i < nColors; ++i) {
|
||||
for (size_t i = 0; i < nColors; ++i)
|
||||
{
|
||||
colors[i] = Color(luaL_checkint(L, 1 + i*4 + 1),
|
||||
luaL_checkint(L, 1 + i*4 + 2),
|
||||
luaL_checkint(L, 1 + i*4 + 3),
|
||||
@@ -224,7 +231,7 @@ namespace opengl
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int w_ParticleSystem_setOffset(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
@@ -261,21 +268,21 @@ namespace opengl
|
||||
lua_pushnumber(L, t->getSpread());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int w_ParticleSystem_getOffsetX(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
lua_pushnumber(L, t->getOffsetX());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int w_ParticleSystem_getOffsetY(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
lua_pushnumber(L, t->getOffsetY());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int w_ParticleSystem_count(lua_State * L)
|
||||
{
|
||||
ParticleSystem * t = luax_checkparticlesystem(L, 1);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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
|
||||
|
||||
@@ -46,17 +46,22 @@ namespace opengl
|
||||
static int _sendScalars(lua_State * L, PixelEffect * effect, const char * name, int count)
|
||||
{
|
||||
float * values = new float[count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (!lua_isnumber(L, 3 + i)) {
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
if (!lua_isnumber(L, 3 + i))
|
||||
{
|
||||
delete[] values;
|
||||
return luaL_typerror(L, 3 + i, "number");
|
||||
}
|
||||
values[i] = (float)lua_tonumber(L, 3 + i);
|
||||
}
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
effect->sendFloat(name, 1, values, count);
|
||||
} catch(love::Exception& e) {
|
||||
}
|
||||
catch (love::Exception& e)
|
||||
{
|
||||
delete[] values;
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
@@ -70,12 +75,15 @@ namespace opengl
|
||||
size_t dimension = lua_objlen(L, 3);
|
||||
float * values = new float[count * dimension];
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (!lua_istable(L, 3 + i)) {
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
if (!lua_istable(L, 3 + i))
|
||||
{
|
||||
delete[] values;
|
||||
return luaL_typerror(L, 3 + i, "table");
|
||||
}
|
||||
if (lua_objlen(L, 3 + i) != dimension) {
|
||||
if (lua_objlen(L, 3 + i) != dimension)
|
||||
{
|
||||
delete[] values;
|
||||
return luaL_error(L, "Error in argument %d: Expected table size %d, got %d.",
|
||||
3+i, dimension, lua_objlen(L, 3+i));
|
||||
@@ -88,9 +96,12 @@ namespace opengl
|
||||
lua_pop(L, dimension);
|
||||
}
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
effect->sendFloat(name, dimension, values, count);
|
||||
} catch(love::Exception& e) {
|
||||
}
|
||||
catch (love::Exception& e)
|
||||
{
|
||||
delete[] values;
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
@@ -134,9 +145,11 @@ namespace opengl
|
||||
count, count);
|
||||
|
||||
float * values = new float[dimension * dimension * count];
|
||||
for (int i = 0; i < count; ++i) {
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
lua_getfield(L, 3+i, "dimension");
|
||||
if (lua_tointeger(L, -1) != dimension) {
|
||||
if (lua_tointeger(L, -1) != dimension)
|
||||
{
|
||||
// You unlock this door with the key of imagination. Beyond it is
|
||||
// another dimension: a dimension of sound, a dimension of sight,
|
||||
// a dimension of mind. You're moving into a land of both shadow
|
||||
@@ -156,9 +169,12 @@ namespace opengl
|
||||
lua_pop(L, 1 + dimension);
|
||||
}
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
effect->sendMatrix(name, dimension, values, count);
|
||||
} catch(love::Exception& e) {
|
||||
}
|
||||
catch (love::Exception& e)
|
||||
{
|
||||
delete[] values;
|
||||
return luaL_error(L, e.what());
|
||||
}
|
||||
@@ -173,9 +189,12 @@ namespace opengl
|
||||
const char* name = luaL_checkstring(L, 2);
|
||||
Image* img = luax_checkimage(L, 3);
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
effect->sendImage(name, *img);
|
||||
} catch(love::Exception& e) {
|
||||
}
|
||||
catch (love::Exception& e)
|
||||
{
|
||||
luaL_error(L, e.what());
|
||||
}
|
||||
|
||||
@@ -188,9 +207,12 @@ namespace opengl
|
||||
const char* name = luaL_checkstring(L, 2);
|
||||
Canvas* canvas = luax_checkcanvas(L, 3);
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
effect->sendCanvas(name, *canvas);
|
||||
} catch(love::Exception& e) {
|
||||
}
|
||||
catch (love::Exception& e)
|
||||
{
|
||||
luaL_error(L, e.what());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,79 +1,79 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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_Quad.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
Quad * luax_checkframe(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<Quad>(L, idx, "Quad", GRAPHICS_QUAD_T);
|
||||
}
|
||||
|
||||
int w_Quad_flip(lua_State *L)
|
||||
{
|
||||
Quad * quad = luax_checktype<Quad>(L, 1, "Quad", GRAPHICS_QUAD_T);
|
||||
quad->flip(luax_toboolean(L, 2), luax_toboolean(L, 3));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_Quad_setViewport(lua_State * L)
|
||||
{
|
||||
Quad * quad = luax_checktype<Quad>(L, 1, "Quad", GRAPHICS_QUAD_T);
|
||||
Quad::Viewport v;
|
||||
v.x = (float) luaL_checknumber(L, 2);
|
||||
v.y = (float) luaL_checknumber(L, 3);
|
||||
v.w = (float) luaL_checknumber(L, 4);
|
||||
v.h = (float) luaL_checknumber(L, 5);
|
||||
quad->setViewport(v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_Quad_getViewport(lua_State * L)
|
||||
{
|
||||
Quad * quad = luax_checktype<Quad>(L, 1, "Quad", GRAPHICS_QUAD_T);
|
||||
Quad::Viewport v = quad->getViewport();
|
||||
lua_pushnumber(L, v.x);
|
||||
lua_pushnumber(L, v.y);
|
||||
lua_pushnumber(L, v.w);
|
||||
lua_pushnumber(L, v.h);
|
||||
return 4;
|
||||
}
|
||||
|
||||
static const luaL_Reg w_Quad_functions[] = {
|
||||
{ "flip", w_Quad_flip },
|
||||
{ "setViewport", w_Quad_setViewport },
|
||||
{ "getViewport", w_Quad_getViewport },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int luaopen_frame(lua_State * L)
|
||||
{
|
||||
return luax_register_type(L, "Quad", w_Quad_functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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_Quad.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
Quad * luax_checkframe(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<Quad>(L, idx, "Quad", GRAPHICS_QUAD_T);
|
||||
}
|
||||
|
||||
int w_Quad_flip(lua_State *L)
|
||||
{
|
||||
Quad * quad = luax_checktype<Quad>(L, 1, "Quad", GRAPHICS_QUAD_T);
|
||||
quad->flip(luax_toboolean(L, 2), luax_toboolean(L, 3));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_Quad_setViewport(lua_State * L)
|
||||
{
|
||||
Quad * quad = luax_checktype<Quad>(L, 1, "Quad", GRAPHICS_QUAD_T);
|
||||
Quad::Viewport v;
|
||||
v.x = (float) luaL_checknumber(L, 2);
|
||||
v.y = (float) luaL_checknumber(L, 3);
|
||||
v.w = (float) luaL_checknumber(L, 4);
|
||||
v.h = (float) luaL_checknumber(L, 5);
|
||||
quad->setViewport(v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_Quad_getViewport(lua_State * L)
|
||||
{
|
||||
Quad * quad = luax_checktype<Quad>(L, 1, "Quad", GRAPHICS_QUAD_T);
|
||||
Quad::Viewport v = quad->getViewport();
|
||||
lua_pushnumber(L, v.x);
|
||||
lua_pushnumber(L, v.y);
|
||||
lua_pushnumber(L, v.w);
|
||||
lua_pushnumber(L, v.h);
|
||||
return 4;
|
||||
}
|
||||
|
||||
static const luaL_Reg w_Quad_functions[] = {
|
||||
{ "flip", w_Quad_flip },
|
||||
{ "setViewport", w_Quad_setViewport },
|
||||
{ "getViewport", w_Quad_getViewport },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
int luaopen_frame(lua_State * L)
|
||||
{
|
||||
return luax_register_type(L, "Quad", w_Quad_functions);
|
||||
}
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_WRAP_QUAD_H
|
||||
#define LOVE_GRAPHICS_OPENGL_WRAP_QUAD_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
#include "Quad.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
Quad * luax_checkframe(lua_State * L, int idx);
|
||||
int w_Quad_flip(lua_State *L);
|
||||
int w_Quad_setViewport(lua_State * L);
|
||||
int w_Quad_getViewport(lua_State * L);
|
||||
int luaopen_frame(lua_State * L);
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_WRAP_QUAD_H
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_WRAP_QUAD_H
|
||||
#define LOVE_GRAPHICS_OPENGL_WRAP_QUAD_H
|
||||
|
||||
// LOVE
|
||||
#include <common/runtime.h>
|
||||
#include "Quad.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
Quad * luax_checkframe(lua_State * L, int idx);
|
||||
int w_Quad_flip(lua_State *L);
|
||||
int w_Quad_setViewport(lua_State * L);
|
||||
int w_Quad_getViewport(lua_State * L);
|
||||
int luaopen_frame(lua_State * L);
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_WRAP_QUAD_H
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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
|
||||
@@ -28,7 +28,7 @@ namespace opengl
|
||||
{
|
||||
SpriteBatch * luax_checkspritebatch(lua_State * L, int idx)
|
||||
{
|
||||
return luax_checktype<SpriteBatch>(L, idx, "SpriteBatch", GRAPHICS_SPRITE_BATCH_T);
|
||||
return luax_checktype<SpriteBatch>(L, idx, "SpriteBatch", GRAPHICS_SPRITE_BATCH_T);
|
||||
}
|
||||
|
||||
int w_SpriteBatch_add(lua_State * L)
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_WRAP_SPRITE_BATCH_H
|
||||
#define LOVE_GRAPHICS_OPENGL_WRAP_SPRITE_BATCH_H
|
||||
|
||||
#include <common/runtime.h>
|
||||
#include "SpriteBatch.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
SpriteBatch * luax_checkspritebatch(lua_State * L, int idx);
|
||||
int w_SpriteBatch_add(lua_State * L);
|
||||
int w_SpriteBatch_addq(lua_State * L);
|
||||
int w_SpriteBatch_set(lua_State * L);
|
||||
int w_SpriteBatch_setq(lua_State * L);
|
||||
int w_SpriteBatch_clear(lua_State * L);
|
||||
int w_SpriteBatch_lock(lua_State * L);
|
||||
int w_SpriteBatch_unlock(lua_State * L);
|
||||
int w_SpriteBatch_setImage(lua_State * L);
|
||||
|
||||
int luaopen_spritebatch(lua_State * L);
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_WRAP_SPRITE_BATCH_H
|
||||
/**
|
||||
* Copyright (c) 2006-2011 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.
|
||||
**/
|
||||
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_WRAP_SPRITE_BATCH_H
|
||||
#define LOVE_GRAPHICS_OPENGL_WRAP_SPRITE_BATCH_H
|
||||
|
||||
#include <common/runtime.h>
|
||||
#include "SpriteBatch.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
namespace graphics
|
||||
{
|
||||
namespace opengl
|
||||
{
|
||||
SpriteBatch * luax_checkspritebatch(lua_State * L, int idx);
|
||||
int w_SpriteBatch_add(lua_State * L);
|
||||
int w_SpriteBatch_addq(lua_State * L);
|
||||
int w_SpriteBatch_set(lua_State * L);
|
||||
int w_SpriteBatch_setq(lua_State * L);
|
||||
int w_SpriteBatch_clear(lua_State * L);
|
||||
int w_SpriteBatch_lock(lua_State * L);
|
||||
int w_SpriteBatch_unlock(lua_State * L);
|
||||
int w_SpriteBatch_setImage(lua_State * L);
|
||||
|
||||
int luaopen_spritebatch(lua_State * L);
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
#endif // LOVE_GRAPHICS_OPENGL_WRAP_SPRITE_BATCH_H
|
||||
|
||||
Reference in New Issue
Block a user