diff --git a/src/modules/graphics/Graphics.cpp b/src/modules/graphics/Graphics.cpp index 76c96b54c..1b86bcdee 100644 --- a/src/modules/graphics/Graphics.cpp +++ b/src/modules/graphics/Graphics.cpp @@ -99,16 +99,6 @@ bool Graphics::getConstant(Support in, const char *&out) return support.find(in, out); } -bool Graphics::getConstant(const char *in, RendererInfo &out) -{ - return rendererInfo.find(in, out); -} - -bool Graphics::getConstant(RendererInfo in, const char *&out) -{ - return rendererInfo.find(in, out); -} - bool Graphics::getConstant(const char *in, SystemLimit &out) { return systemLimits.find(in, out); @@ -192,16 +182,6 @@ StringMap::Entry Graphics::suppor StringMap Graphics::support(Graphics::supportEntries, sizeof(Graphics::supportEntries)); -StringMap::Entry Graphics::rendererInfoEntries[] = -{ - { "name", Graphics::RENDERER_INFO_NAME }, - { "version", Graphics::RENDERER_INFO_VERSION }, - { "vendor", Graphics::RENDERER_INFO_VENDOR }, - { "device", Graphics::RENDERER_INFO_DEVICE }, -}; - -StringMap Graphics::rendererInfo(Graphics::rendererInfoEntries, sizeof(Graphics::rendererInfoEntries)); - StringMap::Entry Graphics::systemLimitEntries[] = { {"pointsize", Graphics::LIMIT_POINT_SIZE}, diff --git a/src/modules/graphics/Graphics.h b/src/modules/graphics/Graphics.h index caafdcd92..715abe36b 100644 --- a/src/modules/graphics/Graphics.h +++ b/src/modules/graphics/Graphics.h @@ -25,6 +25,9 @@ #include "common/Module.h" #include "common/StringMap.h" +// C++ +#include + namespace love { namespace graphics @@ -100,15 +103,6 @@ public: SUPPORT_MAX_ENUM }; - enum RendererInfo - { - RENDERER_INFO_NAME, - RENDERER_INFO_VERSION, - RENDERER_INFO_VENDOR, - RENDERER_INFO_DEVICE, - RENDERER_INFO_MAX_ENUM - }; - enum SystemLimit { LIMIT_POINT_SIZE, @@ -119,6 +113,14 @@ public: LIMIT_MAX_ENUM }; + struct RendererInfo + { + std::string name; + std::string version; + std::string vendor; + std::string device; + }; + virtual ~Graphics(); /** @@ -160,9 +162,6 @@ public: static bool getConstant(const char *in, Support &out); static bool getConstant(Support in, const char *&out); - static bool getConstant(const char *in, RendererInfo &out); - static bool getConstant(RendererInfo in, const char *&out); - static bool getConstant(const char *in, SystemLimit &out); static bool getConstant(SystemLimit in, const char *&out); @@ -189,9 +188,6 @@ private: static StringMap::Entry supportEntries[]; static StringMap support; - static StringMap::Entry rendererInfoEntries[]; - static StringMap rendererInfo; - static StringMap::Entry systemLimitEntries[]; static StringMap systemLimits; diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 09e8c8301..728a0c195 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -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 diff --git a/src/modules/graphics/opengl/Graphics.h b/src/modules/graphics/opengl/Graphics.h index f21aa2801..b2ba4dfe2 100644 --- a/src/modules/graphics/opengl/Graphics.h +++ b/src/modules/graphics/opengl/Graphics.h @@ -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. diff --git a/src/modules/graphics/opengl/VertexBuffer.cpp b/src/modules/graphics/opengl/VertexBuffer.cpp index 9ec772865..43c9282f9 100644 --- a/src/modules/graphics/opengl/VertexBuffer.cpp +++ b/src/modules/graphics/opengl/VertexBuffer.cpp @@ -21,7 +21,6 @@ #include "VertexBuffer.h" #include "common/Exception.h" -#include "common/config.h" #include #include diff --git a/src/modules/graphics/opengl/VertexBuffer.h b/src/modules/graphics/opengl/VertexBuffer.h index cfaa42db1..dc207e777 100644 --- a/src/modules/graphics/opengl/VertexBuffer.h +++ b/src/modules/graphics/opengl/VertexBuffer.h @@ -23,6 +23,7 @@ #define LOVE_GRAPHICS_OPENGL_VERTEX_BUFFER_H // LOVE +#include "common/config.h" #include "graphics/Volatile.h" // OpenGL diff --git a/src/modules/graphics/opengl/wrap_Canvas.cpp b/src/modules/graphics/opengl/wrap_Canvas.cpp index a145305c6..8d00e4dbe 100644 --- a/src/modules/graphics/opengl/wrap_Canvas.cpp +++ b/src/modules/graphics/opengl/wrap_Canvas.cpp @@ -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 } }; diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index 877867c93..d64f939d4 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -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; }