Renamed all instances of 'ShaderEffect' (previously 'PixelEffect') to 'Shader'.

This commit is contained in:
Alexander Szpakowski
2013-01-16 07:21:41 -04:00
parent 331c883c77
commit e24d721381
20 changed files with 209 additions and 204 deletions
+2 -2
View File
@@ -157,8 +157,8 @@ StringMap<Graphics::Support, Graphics::SUPPORT_MAX_ENUM>::Entry Graphics::suppor
{
{ "canvas", Graphics::SUPPORT_CANVAS },
{ "hdrcanvas", Graphics::SUPPORT_HDR_CANVAS },
{ "shadereffect", Graphics::SUPPORT_SHADEREFFECT },
{ "pixeleffect", Graphics::SUPPORT_SHADEREFFECT }, // for compatibility
{ "shader", Graphics::SUPPORT_SHADER },
{ "pixeleffect", Graphics::SUPPORT_SHADER }, // for compatibility
{ "npot", Graphics::SUPPORT_NPOT },
{ "subtractive", Graphics::SUPPORT_SUBTRACTIVE },
{ "mipmap", Graphics::SUPPORT_MIPMAP },
+1 -1
View File
@@ -86,7 +86,7 @@ public:
{
SUPPORT_CANVAS = 1,
SUPPORT_HDR_CANVAS,
SUPPORT_SHADEREFFECT,
SUPPORT_SHADER,
SUPPORT_NPOT,
SUPPORT_SUBTRACTIVE,
SUPPORT_MIPMAP,
+1 -1
View File
@@ -95,7 +95,7 @@ public:
static void bindDefaultCanvas();
private:
friend class ShaderEffect;
friend class Shader;
GLuint getTextureName() const
{
return img;
+7 -7
View File
@@ -193,7 +193,7 @@ void Graphics::reset()
DisplayState s;
discardStencil();
Canvas::bindDefaultCanvas();
ShaderEffect::detach();
Shader::detach();
restoreState(s);
}
@@ -453,21 +453,21 @@ Canvas *Graphics::newCanvas(int width, int height, Canvas::TextureType texture_t
return NULL; // never reached
}
ShaderEffect *Graphics::newShaderEffect(const ShaderEffect::ShaderSources &shadersources)
Shader *Graphics::newShader(const Shader::ShaderSources &shadersources)
{
ShaderEffect *effect = NULL;
Shader *shader = NULL;
try
{
effect = new ShaderEffect(shadersources);
shader = new Shader(shadersources);
}
catch(love::Exception &)
{
if (effect)
delete effect;
if (shader)
delete shader;
throw;
}
return effect;
return shader;
}
void Graphics::setColor(const Color &c)
+2 -2
View File
@@ -43,7 +43,7 @@
#include "SpriteBatch.h"
#include "ParticleSystem.h"
#include "Canvas.h"
#include "ShaderEffect.h"
#include "Shader.h"
namespace love
{
@@ -270,7 +270,7 @@ public:
Canvas *newCanvas(int width, int height, Canvas::TextureType texture_type = Canvas::TYPE_NORMAL);
ShaderEffect *newShaderEffect(const ShaderEffect::ShaderSources &shadersources);
Shader *newShader(const Shader::ShaderSources &shadersources);
/**
* Sets the foreground color.
+1 -1
View File
@@ -125,7 +125,7 @@ private:
void drawv(const Matrix &t, const vertex *v) const;
friend class ShaderEffect;
friend class Shader;
GLuint getTextureName() const
{
return texture;
@@ -20,7 +20,7 @@
#include <algorithm>
#include "ShaderEffect.h"
#include "Shader.h"
#include "Graphics.h"
namespace love
@@ -36,38 +36,38 @@ namespace
// reattaches the originally active program when destroyed
struct TemporaryAttacher
{
TemporaryAttacher(ShaderEffect *effect)
: cureffect(effect)
, preveffect(ShaderEffect::current)
TemporaryAttacher(Shader *shader)
: curshader(shader)
, prevshader(Shader::current)
{
cureffect->attach(true);
curshader->attach(true);
}
~TemporaryAttacher()
{
if (preveffect != NULL)
preveffect->attach();
if (prevshader != NULL)
prevshader->attach();
else
ShaderEffect::detach();
Shader::detach();
}
ShaderEffect *cureffect;
ShaderEffect *preveffect;
Shader *curshader;
Shader *prevshader;
};
} // anonymous namespace
ShaderEffect *ShaderEffect::current = NULL;
Shader *Shader::current = NULL;
GLint ShaderEffect::_maxtextureunits = 0;
std::vector<int> ShaderEffect::_texturecounters;
GLint Shader::_maxtextureunits = 0;
std::vector<int> Shader::_texturecounters;
ShaderEffect::ShaderEffect(const ShaderSources &shadersources)
Shader::Shader(const ShaderSources &shadersources)
: _shadersources(shadersources)
, _program(0)
{
if (shadersources.empty())
throw love::Exception("Cannot create shader effect: no source code!");
throw love::Exception("Cannot create shader: no source code!");
GLint maxtextureunits;
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxtextureunits);
@@ -81,7 +81,7 @@ ShaderEffect::ShaderEffect(const ShaderSources &shadersources)
loadVolatile();
}
ShaderEffect::~ShaderEffect()
Shader::~Shader()
{
if (current == this)
detach();
@@ -89,7 +89,7 @@ ShaderEffect::~ShaderEffect()
unloadVolatile();
}
GLuint ShaderEffect::createShader(ShaderType type, const std::string &code)
GLuint Shader::compileShaderCode(ShaderType type, const std::string &code)
{
GLenum glshadertype;
const char *shadertypename = NULL;
@@ -158,13 +158,13 @@ GLuint ShaderEffect::createShader(ShaderType type, const std::string &code)
delete[] errorlog;
glDeleteShader(shaderid);
throw love::Exception("Cannot compile %s shader:\n%s", shadertypename, tmp.c_str());
throw love::Exception("Cannot compile %s shader code:\n%s", shadertypename, tmp.c_str());
}
return shaderid;
}
void ShaderEffect::createProgram(const std::vector<GLuint> &shaderids)
void Shader::createProgram(const std::vector<GLuint> &shaderids)
{
_program = glCreateProgram();
if (_program == 0) // should only fail when called between glBegin() and glEnd()
@@ -191,7 +191,7 @@ void ShaderEffect::createProgram(const std::vector<GLuint> &shaderids)
}
}
bool ShaderEffect::loadVolatile()
bool Shader::loadVolatile()
{
// zero out active texture list
_activetextureunits.clear();
@@ -202,12 +202,12 @@ bool ShaderEffect::loadVolatile()
ShaderSources::const_iterator source;
for (source = _shadersources.begin(); source != _shadersources.end(); ++source)
{
GLuint shaderid = createShader(source->first, source->second);
GLuint shaderid = compileShaderCode(source->first, source->second);
shaderids.push_back(shaderid);
}
if (shaderids.empty())
throw love::Exception("Cannot create shader effect: no valid source code!");
throw love::Exception("Cannot create shader: no valid source code!");
createProgram(shaderids);
@@ -220,7 +220,7 @@ bool ShaderEffect::loadVolatile()
return true;
}
void ShaderEffect::unloadVolatile()
void Shader::unloadVolatile()
{
if (current == this)
glUseProgram(0);
@@ -245,7 +245,7 @@ void ShaderEffect::unloadVolatile()
_uniforms.clear();
}
std::string ShaderEffect::getWarnings() const
std::string Shader::getWarnings() const
{
GLint strlen, nullpos;
glGetProgramiv(_program, GL_INFO_LOG_LENGTH, &strlen);
@@ -260,7 +260,7 @@ std::string ShaderEffect::getWarnings() const
return warnings;
}
void ShaderEffect::attach(bool temporary)
void Shader::attach(bool temporary)
{
if (current != this)
glUseProgram(_program);
@@ -280,7 +280,7 @@ void ShaderEffect::attach(bool temporary)
}
}
void ShaderEffect::detach()
void Shader::detach()
{
if (current != NULL)
glUseProgram(0);
@@ -288,7 +288,7 @@ void ShaderEffect::detach()
current = NULL;
}
void ShaderEffect::sendFloat(const std::string &name, int size, const GLfloat *vec, int count)
void Shader::sendFloat(const std::string &name, int size, const GLfloat *vec, int count)
{
TemporaryAttacher attacher(this);
GLint location = getUniformLocation(name);
@@ -317,7 +317,7 @@ void ShaderEffect::sendFloat(const std::string &name, int size, const GLfloat *v
checkSetUniformError();
}
void ShaderEffect::sendMatrix(const std::string &name, int size, const GLfloat *m, int count)
void Shader::sendMatrix(const std::string &name, int size, const GLfloat *m, int count)
{
TemporaryAttacher attacher(this);
GLint location = getUniformLocation(name);
@@ -346,7 +346,7 @@ void ShaderEffect::sendMatrix(const std::string &name, int size, const GLfloat *
checkSetUniformError();
}
void ShaderEffect::sendTexture(const std::string &name, GLuint texture)
void Shader::sendTexture(const std::string &name, GLuint texture)
{
TemporaryAttacher attacher(this);
GLint location = getUniformLocation(name);
@@ -370,17 +370,17 @@ void ShaderEffect::sendTexture(const std::string &name, GLuint texture)
_activetextureunits[textureunit-1] = texture;
}
void ShaderEffect::sendImage(const std::string &name, const Image &image)
void Shader::sendImage(const std::string &name, const Image &image)
{
sendTexture(name, image.getTextureName());
}
void ShaderEffect::sendCanvas(const std::string &name, const Canvas &canvas)
void Shader::sendCanvas(const std::string &name, const Canvas &canvas)
{
sendTexture(name, canvas.getTextureName());
}
GLint ShaderEffect::getUniformLocation(const std::string &name)
GLint Shader::getUniformLocation(const std::string &name)
{
std::map<std::string, GLint>::const_iterator it = _uniforms.find(name);
if (it != _uniforms.end())
@@ -398,7 +398,7 @@ GLint ShaderEffect::getUniformLocation(const std::string &name)
return location;
}
int ShaderEffect::getTextureUnit(const std::string &name)
int Shader::getTextureUnit(const std::string &name)
{
std::map<std::string, GLint>::const_iterator it = _textureunitpool.find(name);
@@ -427,7 +427,7 @@ int ShaderEffect::getTextureUnit(const std::string &name)
return textureunit;
}
void ShaderEffect::checkSetUniformError()
void Shader::checkSetUniformError()
{
GLenum error_code = glGetError();
if (GL_INVALID_OPERATION == error_code)
@@ -440,7 +440,7 @@ void ShaderEffect::checkSetUniformError()
}
}
std::string ShaderEffect::getGLSLVersion()
std::string Shader::getGLSLVersion()
{
// GL_SHADING_LANGUAGE_VERSION may not be available in OpenGL < 2.0.
const char *tmp = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
@@ -457,7 +457,7 @@ std::string ShaderEffect::getGLSLVersion()
return versionString.substr(0, minorEndPos);
}
bool ShaderEffect::isSupported()
bool Shader::isSupported()
{
return GLEE_VERSION_2_0 && getGLSLVersion() >= "1.2";
}
@@ -18,8 +18,8 @@
* 3. This notice may not be removed or altered from any source distribution.
**/
#ifndef LOVE_GRAPHICS_EFFECT_H
#define LOVE_GRAPHICS_EFFECT_H
#ifndef LOVE_GRAPHICS_SHADER_H
#define LOVE_GRAPHICS_SHADER_H
#include "common/Object.h"
#include <string>
@@ -36,14 +36,14 @@ namespace graphics
namespace opengl
{
// A GLSL shader
class ShaderEffect : public Object, public Volatile
class Shader : public Object, public Volatile
{
public:
// pointer to currently active ShaderEffect.
static ShaderEffect *current;
// pointer to currently active Shader.
static Shader *current;
// Only vertex and fragment shaders have guaranteed support in all ShaderEffects.
// Only vertex and fragment shaders have guaranteed support in all Shaders.
enum ShaderType
{
TYPE_VERTEX,
@@ -58,37 +58,37 @@ public:
typedef std::map<ShaderType, std::string> ShaderSources;
/**
* Creates a new ShaderEffect using a list of source codes.
* Creates a new Shader using a list of source codes.
* Sources must contain at least one vertex or fragment shader.
**/
ShaderEffect(const ShaderSources &shadersources);
Shader(const ShaderSources &shadersources);
virtual ~ShaderEffect();
virtual ~Shader();
// Implements Volatile
virtual bool loadVolatile();
virtual void unloadVolatile();
/**
* Binds this ShaderEffect's program to be used when rendering.
* Binds this Shader's program to be used when rendering.
*
* @param temporary True if we just want to send values to the shader with no intention of rendering.
**/
void attach(bool temporary = false);
/**
* Detach the currently bound ShaderEffect.
* Detach the currently bound Shader.
* Causes OpenGL to use fixed functionality in place of shader programs.
**/
static void detach();
/**
* Returns any warnings this ShaderEffect may have generated.
* Returns any warnings this Shader may have generated.
**/
std::string getWarnings() const;
/**
* Send at least one float or vector value to this ShaderEffect as a uniform.
* Send at least one float or vector value to this Shader as a uniform.
*
* @param name The name of the uniform variable in the source code.
* @param size Number of elements in each vector to send.
@@ -99,7 +99,7 @@ public:
void sendFloat(const std::string &name, int size, const GLfloat *vec, int count);
/**
* Send at least one matrix to this ShaderEffect as a uniform.
* Send at least one matrix to this Shader as a uniform.
*
* @param name The name of the uniform variable in the source code.
* @param size Number of rows/columns in the matrix.
@@ -109,14 +109,14 @@ public:
void sendMatrix(const std::string &name, int size, const GLfloat *m, int count);
/**
* Send an image to this ShaderEffect as a uniform.
* Send an image to this Shader as a uniform.
*
* @param name The name of the uniform variable in the source code.
**/
void sendImage(const std::string &name, const Image &image);
/**
* Send a canvas to this ShaderEffect as a uniform.
* Send a canvas to this Shader as a uniform.
*
* @param name The name of the uniform variable in the source code.
**/
@@ -130,14 +130,14 @@ private:
GLint getUniformLocation(const std::string &name);
void checkSetUniformError();
GLuint createShader(ShaderType type, const std::string &code);
GLuint compileShaderCode(ShaderType type, const std::string &code);
void createProgram(const std::vector<GLuint> &shaderids);
int getTextureUnit(const std::string &name);
void sendTexture(const std::string &name, GLuint texture);
// list of all shader code attached to this ShaderEffect
// list of all shader code attached to this Shader
ShaderSources _shadersources;
GLuint _program; // volatile
@@ -160,4 +160,4 @@ private:
} // graphics
} // love
#endif // LOVE_GRAPHICS_EFFECT_H
#endif // LOVE_GRAPHICS_SHADER_H
+24 -24
View File
@@ -433,10 +433,10 @@ int w_newCanvas(lua_State *L)
return 1;
}
int w_newShaderEffect(lua_State *L)
int w_newShader(lua_State *L)
{
if (!ShaderEffect::isSupported())
return luaL_error(L, "Sorry, your graphics card does not support shader effects.");
if (!Shader::isSupported())
return luaL_error(L, "Sorry, your graphics card does not support shaders.");
try
{
@@ -452,28 +452,28 @@ int w_newShaderEffect(lua_State *L)
// call effectCodeToGLSL, returned values will be at the top of the stack
lua_pcall(L, 2, 2, 0);
ShaderEffect::ShaderSources sources;
Shader::ShaderSources sources;
// vertex shader code
if (lua_isstring(L, -2))
{
std::string vertcode(luaL_checkstring(L, -2));
sources[ShaderEffect::TYPE_VERTEX] = vertcode;
sources[Shader::TYPE_VERTEX] = vertcode;
}
// fragment shader code
if (lua_isstring(L, -1))
{
std::string fragcode(luaL_checkstring(L, -1));
sources[ShaderEffect::TYPE_FRAGMENT] = fragcode;
sources[Shader::TYPE_FRAGMENT] = fragcode;
}
ShaderEffect *effect = instance->newShaderEffect(sources);
luax_newtype(L, "ShaderEffect", GRAPHICS_SHADEREFFECT_T, (void *)effect);
Shader *shader = instance->newShader(sources);
luax_newtype(L, "Shader", GRAPHICS_SHADER_T, (void *)shader);
}
catch(const love::Exception &e)
{
// memory is freed in Graphics::newShaderEffect
// memory is freed in Graphics::newShader
luax_getfunction(L, "graphics", "_transformGLSLErrorMessages");
lua_pushstring(L, e.what());
lua_pcall(L, 1, 1, 0);
@@ -818,26 +818,26 @@ int w_getCanvas(lua_State *L)
return 1;
}
int w_setShaderEffect(lua_State *L)
int w_setShader(lua_State *L)
{
if (lua_isnoneornil(L,1))
{
ShaderEffect::detach();
Shader::detach();
return 0;
}
ShaderEffect *effect = luax_checkshadereffect(L, 1);
effect->attach();
Shader *shader = luax_checkshader(L, 1);
shader->attach();
return 0;
}
int w_getShaderEffect(lua_State *L)
int w_getShader(lua_State *L)
{
ShaderEffect *effect = ShaderEffect::current;
if (effect)
Shader *shader = Shader::current;
if (shader)
{
effect->retain();
luax_newtype(L, "ShaderEffect", GRAPHICS_SHADEREFFECT_T, (void *) effect);
shader->retain();
luax_newtype(L, "Shader", GRAPHICS_SHADER_T, (void *) shader);
}
else
lua_pushnil(L);
@@ -865,8 +865,8 @@ int w_isSupported(lua_State *L)
if (!Canvas::isHdrSupported())
supported = false;
break;
case Graphics::SUPPORT_SHADEREFFECT:
if (!ShaderEffect::isSupported())
case Graphics::SUPPORT_SHADER:
if (!Shader::isSupported())
supported = false;
break;
case Graphics::SUPPORT_NPOT:
@@ -1285,7 +1285,7 @@ static const luaL_Reg functions[] =
{ "newSpriteBatch", w_newSpriteBatch },
{ "newParticleSystem", w_newParticleSystem },
{ "newCanvas", w_newCanvas },
{ "newShaderEffect", w_newShaderEffect },
{ "newShader", w_newShader },
{ "setColor", w_setColor },
{ "getColor", w_getColor },
@@ -1316,8 +1316,8 @@ static const luaL_Reg functions[] =
{ "setCanvas", w_setCanvas },
{ "getCanvas", w_getCanvas },
{ "setShaderEffect", w_setShaderEffect },
{ "getShaderEffect", w_getShaderEffect },
{ "setShader", w_setShader },
{ "getShader", w_getShader },
{ "isSupported", w_isSupported },
@@ -1378,7 +1378,7 @@ static const lua_CFunction types[] =
luaopen_spritebatch,
luaopen_particlesystem,
luaopen_canvas,
luaopen_shadereffect,
luaopen_shader,
0
};
+4 -4
View File
@@ -28,7 +28,7 @@
#include "wrap_SpriteBatch.h"
#include "wrap_ParticleSystem.h"
#include "wrap_Canvas.h"
#include "wrap_ShaderEffect.h"
#include "wrap_Shader.h"
#include "Graphics.h"
namespace love
@@ -63,7 +63,7 @@ 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_newShaderEffect(lua_State *L);
int w_newShader(lua_State *L);
int w_setColor(lua_State *L);
int w_getColor(lua_State *L);
int w_setBackgroundColor(lua_State *L);
@@ -90,8 +90,8 @@ int w_getMaxPointSize(lua_State *L);
int w_newScreenshot(lua_State *L);
int w_setCanvas(lua_State *L);
int w_getCanvas(lua_State *L);
int w_setShaderEffect(lua_State *L);
int w_getShaderEffect(lua_State *L);
int w_setShader(lua_State *L);
int w_getShader(lua_State *L);
int w_isSupported(lua_State *L);
int w_draw(lua_State *L);
int w_drawq(lua_State *L);
@@ -18,7 +18,7 @@
* 3. This notice may not be removed or altered from any source distribution.
**/
#include "wrap_ShaderEffect.h"
#include "wrap_Shader.h"
#include "wrap_Image.h"
#include "wrap_Canvas.h"
#include <string>
@@ -31,19 +31,19 @@ namespace graphics
namespace opengl
{
ShaderEffect *luax_checkshadereffect(lua_State *L, int idx)
Shader *luax_checkshader(lua_State *L, int idx)
{
return luax_checktype<ShaderEffect>(L, idx, "ShaderEffect", GRAPHICS_SHADEREFFECT_T);
return luax_checktype<Shader>(L, idx, "Shader", GRAPHICS_SHADER_T);
}
int w_ShaderEffect_getWarnings(lua_State *L)
int w_Shader_getWarnings(lua_State *L)
{
ShaderEffect *effect = luax_checkshadereffect(L, 1);
lua_pushstring(L, effect->getWarnings().c_str());
Shader *shader = luax_checkshader(L, 1);
lua_pushstring(L, shader->getWarnings().c_str());
return 1;
}
static int _sendScalars(lua_State *L, ShaderEffect *effect, const char *name, int count)
static int _sendScalars(lua_State *L, Shader *shader, const char *name, int count)
{
float *values = new float[count];
for (int i = 0; i < count; ++i)
@@ -62,7 +62,7 @@ static int _sendScalars(lua_State *L, ShaderEffect *effect, const char *name, in
try
{
effect->sendFloat(name, 1, values, count);
shader->sendFloat(name, 1, values, count);
}
catch(love::Exception &e)
{
@@ -74,7 +74,7 @@ static int _sendScalars(lua_State *L, ShaderEffect *effect, const char *name, in
return 0;
}
static int _sendVectors(lua_State *L, ShaderEffect *effect, const char *name, int count)
static int _sendVectors(lua_State *L, Shader *shader, const char *name, int count)
{
size_t dimension = lua_objlen(L, 3);
float *values = new float[count * dimension];
@@ -106,7 +106,7 @@ static int _sendVectors(lua_State *L, ShaderEffect *effect, const char *name, in
try
{
effect->sendFloat(name, dimension, values, count);
shader->sendFloat(name, dimension, values, count);
}
catch(love::Exception &e)
{
@@ -118,9 +118,9 @@ static int _sendVectors(lua_State *L, ShaderEffect *effect, const char *name, in
return 0;
}
int w_ShaderEffect_sendFloat(lua_State *L)
int w_Shader_sendFloat(lua_State *L)
{
ShaderEffect *effect = luax_checkshadereffect(L, 1);
Shader *shader = luax_checkshader(L, 1);
const char *name = luaL_checkstring(L, 2);
int count = lua_gettop(L) - 2;
@@ -128,17 +128,17 @@ int w_ShaderEffect_sendFloat(lua_State *L)
return luaL_error(L, "No variable to send.");
if (lua_isnumber(L, 3) || lua_isboolean(L, 3))
return _sendScalars(L, effect, name, count);
return _sendScalars(L, shader, name, count);
else if (lua_istable(L, 3))
return _sendVectors(L, effect, name, count);
return _sendVectors(L, shader, name, count);
return luaL_typerror(L, 3, "number, boolean, or table");
}
int w_ShaderEffect_sendMatrix(lua_State *L)
int w_Shader_sendMatrix(lua_State *L)
{
int count = lua_gettop(L) - 2;
ShaderEffect *effect = luax_checkshadereffect(L, 1);
Shader *shader = luax_checkshader(L, 1);
const char *name = luaL_checkstring(L, 2);
if (!lua_istable(L, 3))
@@ -180,7 +180,7 @@ int w_ShaderEffect_sendMatrix(lua_State *L)
try
{
effect->sendMatrix(name, dimension, values, count);
shader->sendMatrix(name, dimension, values, count);
}
catch(love::Exception &e)
{
@@ -192,15 +192,15 @@ int w_ShaderEffect_sendMatrix(lua_State *L)
return 0;
}
int w_ShaderEffect_sendImage(lua_State *L)
int w_Shader_sendImage(lua_State *L)
{
ShaderEffect *effect = luax_checkshadereffect(L, 1);
Shader *shader = luax_checkshader(L, 1);
const char *name = luaL_checkstring(L, 2);
Image *img = luax_checkimage(L, 3);
try
{
effect->sendImage(name, *img);
shader->sendImage(name, *img);
}
catch(love::Exception &e)
{
@@ -210,15 +210,15 @@ int w_ShaderEffect_sendImage(lua_State *L)
return 0;
}
int w_ShaderEffect_sendCanvas(lua_State *L)
int w_Shader_sendCanvas(lua_State *L)
{
ShaderEffect *effect = luax_checkshadereffect(L, 1);
Shader *shader = luax_checkshader(L, 1);
const char *name = luaL_checkstring(L, 2);
Canvas *canvas = luax_checkcanvas(L, 3);
try
{
effect->sendCanvas(name, *canvas);
shader->sendCanvas(name, *canvas);
}
catch(love::Exception &e)
{
@@ -231,17 +231,17 @@ int w_ShaderEffect_sendCanvas(lua_State *L)
static const luaL_Reg functions[] =
{
{ "getWarnings", w_ShaderEffect_getWarnings },
{ "sendFloat", w_ShaderEffect_sendFloat },
{ "sendMatrix", w_ShaderEffect_sendMatrix },
{ "sendImage", w_ShaderEffect_sendImage },
{ "sendCanvas", w_ShaderEffect_sendCanvas },
{ "getWarnings", w_Shader_getWarnings },
{ "sendFloat", w_Shader_sendFloat },
{ "sendMatrix", w_Shader_sendMatrix },
{ "sendImage", w_Shader_sendImage },
{ "sendCanvas", w_Shader_sendCanvas },
{ 0, 0 }
};
extern "C" int luaopen_shadereffect(lua_State *L)
extern "C" int luaopen_shader(lua_State *L)
{
return luax_register_type(L, "ShaderEffect", functions);
return luax_register_type(L, "Shader", functions);
}
} // opengl
@@ -22,7 +22,7 @@
#define LOVE_GRAPHICS_OPENGL_WRAP_PROGRAM_H
#include "common/runtime.h"
#include "ShaderEffect.h"
#include "Shader.h"
namespace love
{
@@ -31,12 +31,12 @@ namespace graphics
namespace opengl
{
ShaderEffect *luax_checkshadereffect(lua_State *L, int idx);
int w_ShaderEffect_getWarnings(lua_State *L);
int w_ShaderEffect_sendFloat(lua_State *L);
int w_ShaderEffect_sendMatrix(lua_State *L);
int w_ShaderEffect_sendImage(lua_State *L);
extern "C" int luaopen_shadereffect(lua_State *L);
Shader *luax_checkshader(lua_State *L, int idx);
int w_Shader_getWarnings(lua_State *L);
int w_Shader_sendFloat(lua_State *L);
int w_Shader_sendMatrix(lua_State *L);
int w_Shader_sendImage(lua_State *L);
extern "C" int luaopen_shader(lua_State *L);
} // opengl
} // graphics