Moved most constants into relevant classes.

This commit is contained in:
rude
2009-07-26 23:05:26 +02:00
parent dcb3dfd83d
commit e0115a384e
25 changed files with 901 additions and 555 deletions
+79
View File
@@ -0,0 +1,79 @@
/**
* Copyright (c) 2006-2009 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_GRAPHICS_H
#define LOVE_GRAPHICS_GRAPHICS_H
// LOVE
#include <common/Module.h>
namespace love
{
namespace graphics
{
class Graphics : public Module
{
public:
enum DrawMode
{
DRAW_LINE,
DRAW_FILL
};
enum AlignMode
{
ALIGN_LEFT,
ALIGN_CENTER,
ALIGN_RIGHT
};
enum BlendMode
{
BLEND_ALPHA,
BLEND_ADDITIVE
};
enum ColorMode
{
COLOR_MODULATE,
COLOR_REPLACE
};
enum LineStyle
{
LINE_ROUGH,
LINE_SMOOTH
};
enum PointStyle
{
POINT_ROUGH,
POINT_SMOOTH
};
virtual ~Graphics(){};
}; // Graphics
} // graphics
} // love
#endif // LOVE_GRAPHICS_GRAPHICS_H
+68
View File
@@ -0,0 +1,68 @@
/**
* Copyright (c) 2006-2009 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_IMAGE_H
#define LOVE_GRAPHICS_IMAGE_H
// LOVE
#include <graphics/Volatile.h>
#include <graphics/Drawable.h>
namespace love
{
namespace graphics
{
class Image : public Drawable, public Volatile
{
public:
enum WrapMode
{
WRAP_CLAMP,
WRAP_REPEAT
};
enum FilterMode
{
FILTER_LINEAR,
FILTER_NEAREST
};
struct Filter
{
FilterMode min;
FilterMode mag;
};
struct Wrap
{
WrapMode s;
WrapMode t;
};
virtual ~Image(){};
}; // Image
} // graphics
} // love
#endif // LOVE_GRAPHICS_IMAGE_H
+52 -67
View File
@@ -22,7 +22,6 @@
// LOVE
#include <common/config.h>
#include <common/constants.h>
namespace love
{
@@ -76,29 +75,29 @@ namespace opengl
float color[4];
//get the color
glGetFloatv(GL_CURRENT_COLOR, color);
s.color[0] = (GLubyte)(color[0]*255.0f);
s.color[1] = (GLubyte)(color[1]*255.0f);
s.color[2] = (GLubyte)(color[2]*255.0f);
s.color[3] = (GLubyte)(color[3]*255.0f);
s.color.r = (GLubyte)(color[0]*255.0f);
s.color.g = (GLubyte)(color[1]*255.0f);
s.color.b = (GLubyte)(color[2]*255.0f);
s.color.a = (GLubyte)(color[3]*255.0f);
//get the background color
glGetFloatv(GL_COLOR_CLEAR_VALUE, color);
s.backgroundColor[0] = (GLubyte)(color[0]*255.0f);
s.backgroundColor[1] = (GLubyte)(color[1]*255.0f);
s.backgroundColor[2] = (GLubyte)(color[2]*255.0f);
s.backgroundColor[3] = (GLubyte)(color[3]*255.0f);
s.backgroundColor.r = (GLubyte)(color[0]*255.0f);
s.backgroundColor.g = (GLubyte)(color[1]*255.0f);
s.backgroundColor.b = (GLubyte)(color[2]*255.0f);
s.backgroundColor.a = (GLubyte)(color[3]*255.0f);
//store modes here
int mode;
//get blend mode
glGetIntegerv(GL_BLEND_DST, &mode);
//following syntax seems better than if-else every time
s.blendMode = (mode == GL_ONE) ? BLEND_ADDITIVE : BLEND_NORMAL;
s.blendMode = (mode == GL_ONE) ? Graphics::BLEND_ADDITIVE : Graphics::BLEND_ALPHA;
//get color mode
glGetTexEnviv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, &mode);
s.colorMode = (mode == GL_MODULATE) ? COLOR_MODULATE : COLOR_NORMAL;
s.colorMode = (mode == GL_MODULATE) ? Graphics::COLOR_MODULATE : Graphics::COLOR_REPLACE;
//get the line width (directly to corresponding variable)
glGetFloatv(GL_LINE_WIDTH, &s.lineWidth);
//get line style
s.lineStyle = (glIsEnabled(GL_LINE_SMOOTH) == GL_TRUE) ? LINE_SMOOTH : LINE_ROUGH;
s.lineStyle = (glIsEnabled(GL_LINE_SMOOTH) == GL_TRUE) ? Graphics::LINE_SMOOTH : Graphics::LINE_ROUGH;
//get line stipple
s.stipple = (glIsEnabled(GL_LINE_SMOOTH) == GL_TRUE) ? true : false;
if (s.stipple)
@@ -111,7 +110,7 @@ namespace opengl
//get the point size
glGetFloatv(GL_POINT_SIZE, &s.pointSize);
//get point style
s.pointStyle = (glIsEnabled(GL_POINT_SMOOTH) == GL_TRUE) ? POINT_SMOOTH : POINT_ROUGH;
s.pointStyle = (glIsEnabled(GL_POINT_SMOOTH) == GL_TRUE) ? Graphics::POINT_SMOOTH : Graphics::POINT_ROUGH;
//get scissor status
s.scissor = (glIsEnabled(GL_SCISSOR_TEST) == GL_TRUE) ? true : false;
//do we have scissor, if so, store the box
@@ -122,8 +121,8 @@ namespace opengl
void Graphics::restoreState(const DisplayState & s)
{
setColor(s.color[0], s.color[1], s.color[2], s.color[3]);
setBackgroundColor(s.backgroundColor[0], s.backgroundColor[1], s.backgroundColor[2]);
setColor(s.color);
setBackgroundColor(s.backgroundColor);
setBlendMode(s.blendMode);
setColorMode(s.colorMode);
setLine(s.lineWidth, s.lineStyle);
@@ -401,11 +400,6 @@ namespace opengl
return new Frame(x, y, w, h, sw, sh);
}
Color * Graphics::newColor(int r, int g, int b, int a)
{
return new Color(r, g, b, a);
}
Font * Graphics::newFont(love::filesystem::File * file, int size)
{
Font * font = new TrueTypeFont(file, size);
@@ -434,58 +428,49 @@ namespace opengl
return font;
}
Animation * Graphics::newAnimation(Image * image)
{
return new Animation(image);
}
Animation * Graphics::newAnimation(Image * image, float fw, float fh, float delay, int num)
{
return new Animation(image, fw, fh, delay, num);
}
/*
SpriteBatch * Graphics::newSpriteBatch(Image * image, int size, int usage)
{
return new SpriteBatch(image, size, usage);
}
*/
VertexBuffer * Graphics::newVertexBuffer(Image * image, int size, int type, int usage)
{
return new VertexBuffer(image, size, type, usage);
}
void Graphics::setColor( int r, int g, int b, int a)
void Graphics::setColor(Color c)
{
glColor4ub(r, g, b, a);
glColor4ubv(&c.r);
}
void Graphics::setColor( Color * color )
{
glColor4ub(color->getRed(), color->getGreen(), color->getBlue(), color->getAlpha());
}
Color * Graphics::getColor()
Color Graphics::getColor()
{
float c[4];
glGetFloatv(GL_CURRENT_COLOR, c);
return new Color((int)(255.0f*c[0]), (int)(255.0f*c[1]), (int)(255.0f*c[2]), (int)(255.0f*c[3]));
Color t;
t.r = (unsigned char)(255.0f*c[0]);
t.g = (unsigned char)(255.0f*c[1]);
t.b = (unsigned char)(255.0f*c[2]);
t.a = (unsigned char)(255.0f*c[3]);
return t;
}
void Graphics::setBackgroundColor( int r, int g, int b )
void Graphics::setBackgroundColor(Color c)
{
glClearColor( (float)r/255.0f, (float)g/255.0f, (float)b/255.0f, 1.0f);
glClearColor((float)c.r/255.0f, (float)c.g/255.0f, (float)c.b/255.0f, 1.0f);
}
void Graphics::setBackgroundColor( Color * color )
{
glClearColor( (float)color->getRed()/255.0f, (float)color->getGreen()/255.0f, (float)color->getBlue()/255.0f, 1.0f);
}
Color * Graphics::getBackgroundColor()
Color Graphics::getBackgroundColor()
{
float c[4];
glGetFloatv(GL_COLOR_CLEAR_VALUE, c);
return new Color((int)(255.0f*c[0]), (int)(255.0f*c[1]), (int)(255.0f*c[2]), (int)(255.0f*c[3]));
Color t;
t.r = (unsigned char)(255.0f*c[0]);
t.g = (unsigned char)(255.0f*c[1]);
t.b = (unsigned char)(255.0f*c[2]);
t.a = (unsigned char)(255.0f*c[3]);
return t;
}
void Graphics::setFont( Font * font )
@@ -517,7 +502,7 @@ namespace opengl
{
if(mode == BLEND_ADDITIVE)
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
else // mode == BLEND_NORMAL
else // mode == BLEND_ALPHA
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
@@ -525,7 +510,7 @@ namespace opengl
{
if(mode == COLOR_MODULATE)
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
else // mode = COLOR_NORMAL
else // mode = COLOR_REPLACE
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
}
@@ -538,7 +523,7 @@ namespace opengl
if(src == GL_SRC_ALPHA && dst == GL_ONE)
return BLEND_ADDITIVE;
else // src == GL_SRC_ALPHA && dst == GL_ONE_MINUS_SRC_ALPHA
return BLEND_NORMAL;
return BLEND_ALPHA;
}
int Graphics::getColorMode()
@@ -549,7 +534,7 @@ namespace opengl
if(mode == GL_MODULATE)
return COLOR_MODULATE;
else // // mode == GL_REPLACE
return COLOR_NORMAL;
return COLOR_REPLACE;
}
void Graphics::setLineWidth( float width )
@@ -856,7 +841,7 @@ namespace opengl
switch(type)
{
case love::DRAW_LINE:
case DRAW_LINE:
glBegin(GL_LINE_LOOP);
glVertex2f(x1, y1);
glVertex2f(x2, y2);
@@ -865,7 +850,7 @@ namespace opengl
break;
default:
case love::DRAW_FILL:
case DRAW_FILL:
glBegin(GL_TRIANGLES);
glVertex2f(x1, y1);
glVertex2f(x2, y2);
@@ -886,7 +871,7 @@ namespace opengl
switch(type)
{
case love::DRAW_LINE:
case DRAW_LINE:
glBegin(GL_LINE_LOOP);
glVertex2f(x, y);
glVertex2f(x, y+h);
@@ -896,7 +881,7 @@ namespace opengl
break;
default:
case love::DRAW_FILL:
case DRAW_FILL:
glBegin(GL_QUADS);
glVertex2f(x, y);
glVertex2f(x, y+h);
@@ -918,7 +903,7 @@ namespace opengl
switch(type)
{
case love::DRAW_LINE:
case DRAW_LINE:
glBegin(GL_LINE_LOOP);
glVertex2f(x1, y1);
glVertex2f(x2, y2);
@@ -928,7 +913,7 @@ namespace opengl
break;
default:
case love::DRAW_FILL:
case DRAW_FILL:
glBegin(GL_QUADS);
glVertex2f(x1, y1);
glVertex2f(x2, y2);
@@ -956,7 +941,7 @@ namespace opengl
switch(type)
{
case love::DRAW_LINE:
case DRAW_LINE:
glBegin(GL_LINE_LOOP);
for(float i = 0; i < two_pi; i+= angle_shift)
@@ -966,7 +951,7 @@ namespace opengl
break;
default:
case love::DRAW_FILL:
case DRAW_FILL:
glBegin(GL_TRIANGLE_FAN);
for(float i = 0; i < two_pi; i+= angle_shift)
@@ -1017,7 +1002,7 @@ namespace opengl
glDisable(GL_CULL_FACE);
glDisable(GL_TEXTURE_2D);
glBegin((mode==love::DRAW_LINE) ? GL_LINE_LOOP : GL_POLYGON);
glBegin((mode==DRAW_LINE) ? GL_LINE_LOOP : GL_POLYGON);
switch(luatype)
{
@@ -1075,7 +1060,7 @@ namespace opengl
// Get rendering mode. (line/fill)
int mode = (int)lua_tonumber(L, 1);
GLenum glmode = (mode==love::DRAW_LINE) ? GL_LINE_LOOP : GL_POLYGON;
GLenum glmode = (mode==DRAW_LINE) ? GL_LINE_LOOP : GL_POLYGON;
// Get the type of the second argument.
int luatype = lua_type(L, 2);
+35 -80
View File
@@ -31,15 +31,11 @@
#include <SDL_opengl.h>
// LOVE
#include <common/Module.h>
#include <graphics/Graphics.h>
#include "Image.h"
#include "Animation.h"
#include "Color.h"
#include "TrueTypeFont.h"
#include "ImageFont.h"
#include "ParticleSystem.h"
#include "SpriteBatch.h"
#include "VertexBuffer.h"
#include "ImageFont.h"
#include "Frame.h"
namespace love
@@ -48,6 +44,11 @@ namespace graphics
{
namespace opengl
{
struct Color
{
unsigned char r, b, g, a;
};
struct DisplayMode
{
int width, height; // The size of the screen.
@@ -63,22 +64,23 @@ namespace opengl
struct DisplayState
{
// Colors.
GLubyte color[4];
GLubyte backgroundColor[4];
Color color;
Color backgroundColor;
// Blend and color modes.
int blendMode, colorMode;
Graphics::BlendMode blendMode;
Graphics::ColorMode colorMode;
// Line.
float lineWidth;
int lineStyle;
Graphics::LineStyle lineStyle;
bool stipple;
int stippleRepeat;
int stipplePattern;
// Point.
float pointSize;
int pointStyle;
Graphics::PointStyle pointStyle;
// Scissor.
bool scissor;
@@ -87,27 +89,27 @@ namespace opengl
// Default values.
DisplayState()
{
color[0] = 255;
color[1] = 255;
color[2] = 255;
color[3] = 255;
backgroundColor[0] = 0;
backgroundColor[1] = 0;
backgroundColor[2] = 0;
backgroundColor[3] = 255;
blendMode = BLEND_NORMAL;
colorMode = COLOR_NORMAL;
color.r = 255;
color.g = 255;
color.b = 255;
color.a = 255;
backgroundColor.r = 0;
backgroundColor.g = 0;
backgroundColor.b = 0;
backgroundColor.a = 255;
blendMode = Graphics::BLEND_ALPHA;
colorMode = Graphics::COLOR_MODULATE;
lineWidth = 1.0f;
lineStyle = LINE_SMOOTH;
lineStyle = Graphics::LINE_SMOOTH;
stipple = false;
pointSize = 1.0f;
pointStyle = POINT_SMOOTH;
pointStyle = Graphics::POINT_SMOOTH;
scissor = false;
}
};
class Graphics : public Module
class Graphics : public love::graphics::Graphics
{
private:
@@ -115,8 +117,9 @@ namespace opengl
DisplayMode currentMode;
public:
Graphics();
~Graphics();
virtual ~Graphics();
// Implements Module.
const char * getName() const;
@@ -129,7 +132,6 @@ namespace opengl
* @param height The window height.
**/
bool checkMode(int width, int height, bool fullscreen);
DisplayState saveState();
@@ -227,11 +229,6 @@ namespace opengl
**/
int getScissor(lua_State * L);
/**
* Creates a new Color object.
**/
Color * newColor( int r, int g, int b, int a );
/**
* Creates an Image object with padding and/or optimization.
**/
@@ -253,59 +250,28 @@ namespace opengl
**/
Font * newImageFont(Image * image, const char * glyphs, float spacing = 1);
/**
* Creates an Animation object with no frames.
**/
Animation * newAnimation(Image * image);
/**
* Creates an Animation object with generated frames in a grid.
**/
Animation * newAnimation(Image * image, float fw, float fh, float delay, int num = 0);
/**
* Creates a ParticleSystem object with the specified buffer size and using the specified sprite.
**/
//pParticleSystem newParticleSystem(Image * image, unsigned int size);
/**
* Creates a PointParticleSystem object with the specified buffer size and sprite.
* @param mode This should be love::POINT_SPRITE.
**/
//pParticleSystem newParticleSystem(Image * image, unsigned int size, int mode);
SpriteBatch * newSpriteBatch(Image * image, int size, int usage);
VertexBuffer * newVertexBuffer(Image * image, int size, int type, int usage);
//SpriteBatch * newSpriteBatch(Image * image, int size, int usage);
/**
* Sets the foreground color.
**/
void setColor(Color * color);
/**
* Sets the foreground color.
**/
void setColor( int r, int g, int b, int a = 255);
void setColor(Color c);
/**
* Gets current color.
**/
Color * getColor();
Color getColor();
/**
* Sets the background Color.
**/
void setBackgroundColor( Color * color );
/**
* Sets the background Color.
**/
void setBackgroundColor( int r, int g, int b );
void setBackgroundColor(Color c);
/**
* Gets the current background color.
* @param c Array of size 3 (r,g,b).
**/
Color * getBackgroundColor();
Color getBackgroundColor();
/**
* Sets the current font.
@@ -473,17 +439,6 @@ namespace opengl
**/
void printf( const char * str, float x, float y, float wrap, int align = 0 );
/**
* Draws an Image at the specified coordinates, with rotation and
* scaling along both axes.
* @param x The x-coordinate.
* @param y The y-coordinate.
* @param angle The amount of rotation.
* @param sx The scale factor along the x-axis. (1 = normal).
* @param sy The scale factor along the y-axis. (1 = normal).
**/
//void draw(Drawable * drawable, float x, float y, float angle, float sx, float sy);
/**
* Draws a point at (x,y).
* @param x Point along x-axis.
+1
View File
@@ -31,6 +31,7 @@
#include <common/math.h>
// OpenGL
#include "GLee.h"
#include <SDL/SDL_opengl.h>
namespace love
+36 -126
View File
@@ -128,20 +128,6 @@ namespace opengl
return instance->getScissor(L);
}
int _wrap_newColor(lua_State * L)
{
int r = luaL_checkinteger(L, 1);
int g = luaL_checkinteger(L, 2);
int b = luaL_checkinteger(L, 3);
int a = luaL_optint(L, 4, 255);
Color * t = instance->newColor(r, g, b, a);
luax_newtype(L, "Color", LOVE_GRAPHICS_COLOR_BITS, (void*)t);
return 1;
}
int _wrap_newImage(lua_State * L)
{
// Convert to File, if necessary.
@@ -185,45 +171,6 @@ namespace opengl
return 1;
}
int _wrap_newAnimation(lua_State * L)
{
// If string -> file
if(lua_isstring(L, 1))
luax_strtofile(L, 1);
// file -> imagedata
if(luax_istype(L, 1, LOVE_FILESYSTEM_FILE_BITS))
luax_convobj(L, 1, "image", "newImageData");
// imagedata -> image
if(luax_istype(L, 1, LOVE_IMAGE_IMAGE_DATA_BITS))
luax_convobj(L, 1, "graphics", "newImage");
// Check the value.
Image * image = luax_checktype<Image>(L, 1, "Image", LOVE_GRAPHICS_IMAGE_BITS);
Animation * animation = 0;
if(lua_gettop(L) == 1)
{
animation = instance->newAnimation(image);
}
else
{
float fw = (float)luaL_checknumber(L, 2);
float fh = (float)luaL_checknumber(L, 3);
float delay = (float)luaL_checknumber(L, 4);
int num = luaL_optint(L, 5, 0);
animation = instance->newAnimation(image, fw, fh, delay, num);
}
if(animation == 0)
return luaL_error(L, "Could not load the Animation");
luax_newtype(L, "Animation", LOVE_GRAPHICS_ANIMATION_BITS, (void*)animation);
return 1;
}
int _wrap_newFont(lua_State * L)
{
// Convert to File, if necessary.
@@ -271,6 +218,7 @@ namespace opengl
return 1;
}
/*
int _wrap_newSpriteBatch(lua_State * L)
{
Image * image = luax_checktype<Image>(L, 1, "Image", LOVE_GRAPHICS_IMAGE_BITS);
@@ -280,83 +228,48 @@ namespace opengl
luax_newtype(L, "SpriteBatch", LOVE_GRAPHICS_SPRITE_BATCH_BITS, (void*)t);
return 1;
}
int _wrap_newVertexBuffer(lua_State * L)
{
Image * image;
int type, usage, size;
if(luax_istype(L, 1, LOVE_GRAPHICS_IMAGE_BITS))
{
image = luax_checktype<Image>(L, 1, "Image", LOVE_GRAPHICS_IMAGE_BITS);
size = luaL_optint(L, 2, 100);
type = luaL_optint(L, 3, TYPE_TRIANGLES);
usage = luaL_optint(L, 4, USAGE_ARRAY);
}
else if(lua_isnumber(L, 1))
{
image = 0;
size = luaL_optint(L, 1, 100);
type = luaL_optint(L, 2, TYPE_TRIANGLES);
usage = luaL_optint(L, 3, USAGE_ARRAY);
}
else return luaL_error(L, "Expected type image or number");
VertexBuffer * t = instance->newVertexBuffer(image, size, type, usage);
luax_newtype(L, "VertexBuffer", LOVE_GRAPHICS_VERTEX_BUFFER_BITS, (void*)t);
return 1;
}
*/
int _wrap_setColor(lua_State * L)
{
if(luax_istype(L, 1, LOVE_GRAPHICS_COLOR_BITS))
{
Color * color = luax_checktype<Color>(L, 1, "Color", LOVE_GRAPHICS_COLOR_BITS);
instance->setColor(color);
return 0;
}
int r = luaL_checkint(L, 1);
int g = luaL_checkint(L, 2);
int b = luaL_checkint(L, 3);
int a = luaL_optint(L, 4, 255);
instance->setColor(r, g, b, a);
return 1;
Color c;
c.r = (unsigned char)luaL_checkint(L, 1);
c.g = (unsigned char)luaL_checkint(L, 2);
c.b = (unsigned char)luaL_checkint(L, 3);
c.a = (unsigned char)luaL_optint(L, 4, 255);
instance->setColor(c);
return 0;
}
int _wrap_getColor(lua_State * L)
{
Color * color = instance->getColor();
luax_newtype(L, "Color", LOVE_GRAPHICS_COLOR_BITS, (void*)color);
return 1;
Color c = instance->getColor();
lua_pushinteger(L, c.r);
lua_pushinteger(L, c.g);
lua_pushinteger(L, c.b);
lua_pushinteger(L, c.a);
return 4;
}
int _wrap_setBackgroundColor(lua_State * L)
{
if(luax_istype(L, 1, LOVE_GRAPHICS_COLOR_BITS))
{
Color * color = luax_checktype<Color>(L, 1, "Color", LOVE_GRAPHICS_COLOR_BITS);
instance->setBackgroundColor(color);
return 0;
}
int r = luaL_checkint(L, 1);
int g = luaL_checkint(L, 1);
int b = luaL_checkint(L, 1);
instance->setBackgroundColor(r, g, b);
return 1;
Color c;
c.r = (unsigned char)luaL_checkint(L, 1);
c.g = (unsigned char)luaL_checkint(L, 2);
c.b = (unsigned char)luaL_checkint(L, 3);
c.a = 255;
instance->setBackgroundColor(c);
return 0;
}
int _wrap_getBackgroundColor(lua_State * L)
{
Color * color = instance->getBackgroundColor();
luax_newtype(L, "Color", LOVE_GRAPHICS_COLOR_BITS, (void*)color);
return 1;
Color c = instance->getBackgroundColor();
lua_pushinteger(L, c.r);
lua_pushinteger(L, c.g);
lua_pushinteger(L, c.b);
lua_pushinteger(L, c.a);
return 4;
}
int _wrap_setFont(lua_State * L)
@@ -436,7 +349,7 @@ namespace opengl
int _wrap_setLine(lua_State * L)
{
float width = (float)luaL_checknumber(L, 1);
int style = luaL_optint(L, 2, LINE_SMOOTH);
int style = luaL_optint(L, 2, Graphics::LINE_SMOOTH);
instance->setLine(width, style);
return 0;
}
@@ -489,7 +402,7 @@ namespace opengl
int _wrap_setPoint(lua_State * L)
{
float size = (float)luaL_checknumber(L, 1);
int style = luaL_optint(L, 2, POINT_SMOOTH);
int style = luaL_optint(L, 2, Graphics::POINT_SMOOTH);
instance->setPoint(size, style);
return 0;
}
@@ -741,14 +654,11 @@ namespace opengl
{ "clear", _wrap_clear },
{ "present", _wrap_present },
{ "newColor", _wrap_newColor },
{ "newImage", _wrap_newImage },
{ "newFrame", _wrap_newFrame },
{ "newAnimation", _wrap_newAnimation },
{ "newFont", _wrap_newFont },
{ "newImageFont", _wrap_newImageFont },
{ "newSpriteBatch", _wrap_newSpriteBatch },
{ "newVertexBuffer", _wrap_newVertexBuffer },
//{ "newSpriteBatch", _wrap_newSpriteBatch },
{ "setColor", _wrap_setColor },
{ "getColor", _wrap_getColor },
@@ -815,14 +725,14 @@ namespace opengl
// Types for this module.
const lua_CFunction wrap_Graphics_types[] = {
wrap_Color_open,
//wrap_Color_open,
wrap_Font_open,
wrap_Image_open,
wrap_Frame_open,
wrap_Animation_open,
wrap_ParticleSystem_open,
wrap_SpriteBatch_open,
wrap_VertexBuffer_open,
//wrap_Animation_open,
//wrap_ParticleSystem_open,
//wrap_SpriteBatch_open,
//wrap_VertexBuffer_open,
0
};
@@ -22,13 +22,8 @@
#define LOVE_GRAPHICS_OPENGL_WRAP_GRAPHICS_H
// LOVE
#include "wrap_Color.h"
#include "wrap_Font.h"
#include "wrap_Image.h"
#include "wrap_Animation.h"
#include "wrap_ParticleSystem.h"
#include "wrap_SpriteBatch.h"
#include "wrap_VertexBuffer.h"
#include "wrap_Frame.h"
#include "Graphics.h"
+5 -4
View File
@@ -48,10 +48,11 @@ namespace opengl
int _wrap_Image_setFilter(lua_State * L)
{
Image * t = luax_checkimage(L, 1);
int min = luaL_checkint(L, 2);
int mag = luaL_checkint(L, 3);
t->setFilter(min, mag);
Image * t = luax_checkimage(L, 1);
Image::Filter f;
f.min = (Image::FilterMode)luaL_checkint(L, 2);
f.mag = (Image::FilterMode)luaL_checkint(L, 3);
t->setFilter(f);
return 1;
}