mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Fixed Object:typeOf for love.physics objects new to 0.8.0, removed vestigial ColorMode code
This commit is contained in:
@@ -59,16 +59,6 @@ bool Graphics::getConstant(BlendMode in, const char *&out)
|
||||
return blendModes.find(in, out);
|
||||
}
|
||||
|
||||
bool Graphics::getConstant(const char *in, ColorMode &out)
|
||||
{
|
||||
return colorModes.find(in, out);
|
||||
}
|
||||
|
||||
bool Graphics::getConstant(ColorMode in, const char *&out)
|
||||
{
|
||||
return colorModes.find(in, out);
|
||||
}
|
||||
|
||||
bool Graphics::getConstant(const char *in, LineStyle &out)
|
||||
{
|
||||
return lineStyles.find(in, out);
|
||||
@@ -149,15 +139,6 @@ StringMap<Graphics::BlendMode, Graphics::BLEND_MAX_ENUM>::Entry Graphics::blendM
|
||||
|
||||
StringMap<Graphics::BlendMode, Graphics::BLEND_MAX_ENUM> Graphics::blendModes(Graphics::blendModeEntries, sizeof(Graphics::blendModeEntries));
|
||||
|
||||
StringMap<Graphics::ColorMode, Graphics::COLOR_MAX_ENUM>::Entry Graphics::colorModeEntries[] =
|
||||
{
|
||||
{ "replace", Graphics::COLOR_REPLACE },
|
||||
{ "modulate", Graphics::COLOR_MODULATE },
|
||||
{ "combine", Graphics::COLOR_COMBINE },
|
||||
};
|
||||
|
||||
StringMap<Graphics::ColorMode, Graphics::COLOR_MAX_ENUM> Graphics::colorModes(Graphics::colorModeEntries, sizeof(Graphics::colorModeEntries));
|
||||
|
||||
StringMap<Graphics::LineStyle, Graphics::LINE_MAX_ENUM>::Entry Graphics::lineStyleEntries[] =
|
||||
{
|
||||
{ "smooth", Graphics::LINE_SMOOTH },
|
||||
|
||||
@@ -61,14 +61,6 @@ public:
|
||||
BLEND_MAX_ENUM
|
||||
};
|
||||
|
||||
enum ColorMode
|
||||
{
|
||||
COLOR_MODULATE = 1,
|
||||
COLOR_REPLACE,
|
||||
COLOR_COMBINE,
|
||||
COLOR_MAX_ENUM
|
||||
};
|
||||
|
||||
enum LineStyle
|
||||
{
|
||||
LINE_ROUGH = 1,
|
||||
@@ -129,9 +121,6 @@ public:
|
||||
static bool getConstant(const char *in, BlendMode &out);
|
||||
static bool getConstant(BlendMode in, const char *&out);
|
||||
|
||||
static bool getConstant(const char *in, ColorMode &out);
|
||||
static bool getConstant(ColorMode in, const char *&out);
|
||||
|
||||
static bool getConstant(const char *in, LineStyle &out);
|
||||
static bool getConstant(LineStyle in, const char *&out);
|
||||
|
||||
@@ -158,9 +147,6 @@ private:
|
||||
static StringMap<BlendMode, BLEND_MAX_ENUM>::Entry blendModeEntries[];
|
||||
static StringMap<BlendMode, BLEND_MAX_ENUM> blendModes;
|
||||
|
||||
static StringMap<ColorMode, COLOR_MAX_ENUM>::Entry colorModeEntries[];
|
||||
static StringMap<ColorMode, COLOR_MAX_ENUM> colorModes;
|
||||
|
||||
static StringMap<LineStyle, LINE_MAX_ENUM>::Entry lineStyleEntries[];
|
||||
static StringMap<LineStyle, LINE_MAX_ENUM> lineStyles;
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ namespace opengl
|
||||
// none, opengl >= 3.0, extensions
|
||||
struct FramebufferStrategy
|
||||
{
|
||||
virtual ~FramebufferStrategy() {}
|
||||
|
||||
/// create a new framebuffer, depth_stencil and texture
|
||||
/**
|
||||
* @param[out] framebuffer Framebuffer name
|
||||
|
||||
@@ -124,9 +124,9 @@ GLuint Shader::compileCode(ShaderType type, const std::string &code)
|
||||
{
|
||||
GLenum err = glGetError();
|
||||
|
||||
if (err == GL_INVALID_ENUM) // invalid or unsupported shader type
|
||||
if (err == GL_INVALID_ENUM)
|
||||
throw love::Exception("Cannot create %s shader object: %s shaders not supported.", typestr, typestr);
|
||||
else // other errors should only happen between glBegin() and glEnd()
|
||||
else
|
||||
throw love::Exception("Cannot create %s shader object.", typestr);
|
||||
}
|
||||
|
||||
@@ -136,14 +136,14 @@ GLuint Shader::compileCode(ShaderType type, const std::string &code)
|
||||
|
||||
glCompileShader(shaderid);
|
||||
|
||||
// Get any warnings the shader compiler may have produced
|
||||
// Get any warnings the shader compiler may have produced.
|
||||
GLint infologlen;
|
||||
glGetShaderiv(shaderid, GL_INFO_LOG_LENGTH, &infologlen);
|
||||
|
||||
GLchar *infolog = new GLchar[infologlen + 1];
|
||||
glGetShaderInfoLog(shaderid, infologlen, NULL, infolog);
|
||||
|
||||
// Save any warnings for later querying
|
||||
// Save any warnings for later querying.
|
||||
if (infologlen > 0)
|
||||
shaderWarnings[type] = infolog;
|
||||
|
||||
@@ -164,7 +164,7 @@ GLuint Shader::compileCode(ShaderType type, const std::string &code)
|
||||
void Shader::createProgram(const std::vector<GLuint> &shaderids)
|
||||
{
|
||||
program = glCreateProgram();
|
||||
if (program == 0) // should only fail when called between glBegin() and glEnd()
|
||||
if (program == 0)
|
||||
throw love::Exception("Cannot create shader program object.");
|
||||
|
||||
std::vector<GLuint>::const_iterator it;
|
||||
@@ -173,8 +173,9 @@ void Shader::createProgram(const std::vector<GLuint> &shaderids)
|
||||
|
||||
glLinkProgram(program);
|
||||
|
||||
// flag shaders for auto-deletion when the program object is deleted.
|
||||
for (it = shaderids.begin(); it != shaderids.end(); ++it)
|
||||
glDeleteShader(*it); // flag shaders for auto-deletion when program object is deleted
|
||||
glDeleteShader(*it);
|
||||
|
||||
GLint status;
|
||||
glGetProgramiv(program, GL_LINK_STATUS, &status);
|
||||
@@ -198,6 +199,9 @@ void Shader::mapActiveUniforms()
|
||||
GLsizei bufsize;
|
||||
glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, (GLint *) &bufsize);
|
||||
|
||||
if (bufsize <= 0)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < numuniforms; i++)
|
||||
{
|
||||
GLchar *cname = new GLchar[bufsize];
|
||||
@@ -242,11 +246,13 @@ bool Shader::loadVolatile()
|
||||
|
||||
createProgram(shaderids);
|
||||
|
||||
// Retreive all active uniform variables in this shader from OpenGL.
|
||||
mapActiveUniforms();
|
||||
|
||||
if (current == this)
|
||||
{
|
||||
current = NULL; // make sure glUseProgram gets called
|
||||
// make sure glUseProgram gets called.
|
||||
current = NULL;
|
||||
attach();
|
||||
}
|
||||
|
||||
@@ -497,7 +503,7 @@ void Shader::sendMatrix(const std::string &name, int size, const GLfloat *m, int
|
||||
if (size < 2 || size > 4)
|
||||
{
|
||||
throw love::Exception("Invalid matrix size: %dx%d "
|
||||
"(can only set 2x2, 3x3 or 4x4 matrices).", size,size);
|
||||
"(can only set 2x2, 3x3 or 4x4 matrices.)", size,size);
|
||||
}
|
||||
|
||||
const Uniform &u = getUniform(name);
|
||||
@@ -584,9 +590,13 @@ int Shader::getTextureUnit(const std::string &name)
|
||||
|
||||
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);
|
||||
if (tmp == NULL)
|
||||
const char *tmp = 0;
|
||||
|
||||
// GL_SHADING_LANGUAGE_VERSION isn't available in OpenGL < 2.0.
|
||||
if (GL_VERSION_2_0)
|
||||
tmp = (const char *) glGetString(GL_SHADING_LANGUAGE_VERSION);
|
||||
|
||||
if (tmp == 0)
|
||||
return "0.0";
|
||||
|
||||
// the version string always begins with a version number of the format
|
||||
|
||||
@@ -1594,7 +1594,7 @@ int w_shear(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_origin(lua_State *L)
|
||||
int w_origin(lua_State * /*L*/)
|
||||
{
|
||||
instance->origin();
|
||||
return 0;
|
||||
|
||||
@@ -47,8 +47,8 @@ template <typename T>
|
||||
static T *_getScalars(lua_State *L, int count, size_t &dimension)
|
||||
{
|
||||
dimension = 1;
|
||||
|
||||
T *values = new T[count];
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
if (lua_isnumber(L, 3 + i))
|
||||
|
||||
Reference in New Issue
Block a user