Hopefully fixed issue #898, and cleaned up code for love.graphics.getRendererInfo.

This commit is contained in:
Alex Szpakowski
2014-06-19 03:02:37 -03:00
parent 738cc01468
commit 4c67a94ba3
8 changed files with 45 additions and 75 deletions
+20 -21
View File
@@ -1061,31 +1061,30 @@ love::image::ImageData *Graphics::newScreenshot(love::image::Image *image, bool
return img;
}
std::string Graphics::getRendererInfo(Graphics::RendererInfo infotype) const
Graphics::RendererInfo Graphics::getRendererInfo() const
{
const char *infostr = 0;
RendererInfo info;
info.name = "OpenGL";
switch (infotype)
{
case Graphics::RENDERER_INFO_NAME:
default:
infostr = "OpenGL";
break;
case Graphics::RENDERER_INFO_VERSION:
infostr = (const char *) glGetString(GL_VERSION);
break;
case Graphics::RENDERER_INFO_VENDOR:
infostr = (const char *) glGetString(GL_VENDOR);
break;
case Graphics::RENDERER_INFO_DEVICE:
infostr = (const char *) glGetString(GL_RENDERER);
break;
}
const char *str = (const char *) glGetString(GL_VERSION);
if (str)
info.version = str;
else
throw love::Exception("Cannot retrieve renderer version information.");
if (!infostr)
throw love::Exception("Cannot retrieve renderer information.");
str = (const char *) glGetString(GL_VENDOR);
if (str)
info.vendor = str;
else
throw love::Exception("Cannot retrieve renderer vendor information.");
return std::string(infostr);
str = (const char *) glGetString(GL_RENDERER);
if (str)
info.device = str;
else
throw love::Exception("Cannot retrieve renderer device information.");
return info;
}
double Graphics::getSystemLimit(SystemLimit limittype) const
+3 -4
View File
@@ -444,12 +444,11 @@ public:
love::image::ImageData *newScreenshot(love::image::Image *image, bool copyAlpha = true);
/**
* Returns a string containing system-dependent renderer information.
* Returned string can vary greatly between systems! Do not rely on it for
* Returns system-dependent renderer information.
* Returned string s can vary greatly between systems! Do not rely on it for
* anything!
* @param infotype The type of information to return.
**/
std::string getRendererInfo(Graphics::RendererInfo infotype) const;
RendererInfo getRendererInfo() const;
/**
* Gets the system-dependent numeric limit for the specified parameter.
@@ -21,7 +21,6 @@
#include "VertexBuffer.h"
#include "common/Exception.h"
#include "common/config.h"
#include <cstdlib>
#include <cstring>
@@ -23,6 +23,7 @@
#define LOVE_GRAPHICS_OPENGL_VERTEX_BUFFER_H
// LOVE
#include "common/config.h"
#include "graphics/Volatile.h"
// OpenGL
+4 -1
View File
@@ -146,10 +146,13 @@ static const luaL_Reg functions[] =
{ "clear", w_Canvas_clear },
{ "getFormat", w_Canvas_getFormat },
{ "getMSAA", w_Canvas_getMSAA },
{ "getFSAA", w_Canvas_getMSAA }, // For backward-compatibility. TODO: remove!
// Deprecated since 0.9.1.
{ "getType", w_Canvas_getFormat },
// Deprecated since 0.9.2.
{ "getFSAA", w_Canvas_getMSAA },
{ 0, 0 }
};
+6 -13
View File
@@ -1067,20 +1067,13 @@ int w_hasCanvasFormat(lua_State *L)
int w_getRendererInfo(lua_State *L)
{
std::string name, version, vendor, device;
luax_catchexcept(L, [&]() {
name = instance->getRendererInfo(Graphics::RENDERER_INFO_NAME);
version = instance->getRendererInfo(Graphics::RENDERER_INFO_VERSION);
vendor = instance->getRendererInfo(Graphics::RENDERER_INFO_VENDOR);
device = instance->getRendererInfo(Graphics::RENDERER_INFO_DEVICE);
});
luax_pushstring(L, name);
luax_pushstring(L, version);
luax_pushstring(L, vendor);
luax_pushstring(L, device);
Graphics::RendererInfo info;
luax_catchexcept(L, [&](){ info = instance->getRendererInfo(); });
luax_pushstring(L, info.name);
luax_pushstring(L, info.version);
luax_pushstring(L, info.vendor);
luax_pushstring(L, info.device);
return 4;
}