From 3c5c4ee604263175de270cd2134207a0369a4a31 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Sun, 24 Jul 2011 15:37:02 +0200 Subject: [PATCH] Add SpriteBatch support to love.graphics.isSupported --- src/modules/graphics/Graphics.cpp | 3 ++- src/modules/graphics/Graphics.h | 1 + src/modules/graphics/opengl/SpriteBatch.cpp | 5 +++++ src/modules/graphics/opengl/SpriteBatch.h | 2 ++ src/modules/graphics/opengl/wrap_Graphics.cpp | 4 ++++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/modules/graphics/Graphics.cpp b/src/modules/graphics/Graphics.cpp index 92ec20d9e..644f3e513 100644 --- a/src/modules/graphics/Graphics.cpp +++ b/src/modules/graphics/Graphics.cpp @@ -152,7 +152,8 @@ namespace graphics StringMap::Entry Graphics::supportEntries[] = { { "framebuffers", Graphics::SUPPORT_FRAMEBUFFERS }, - { "pixeleffects", Graphics::SUPPORT_PIXELEFFECTS } + { "pixeleffects", Graphics::SUPPORT_PIXELEFFECTS }, + { "spritebatches", Graphics::SUPPORT_SPRITEBATCHES } }; StringMap Graphics::support(Graphics::supportEntries, sizeof(Graphics::supportEntries)); diff --git a/src/modules/graphics/Graphics.h b/src/modules/graphics/Graphics.h index e48edaca1..29837489c 100644 --- a/src/modules/graphics/Graphics.h +++ b/src/modules/graphics/Graphics.h @@ -82,6 +82,7 @@ namespace graphics { SUPPORT_FRAMEBUFFERS = 1, SUPPORT_PIXELEFFECTS, + SUPPORT_SPRITEBATCHES, SUPPORT_MAX_ENUM }; diff --git a/src/modules/graphics/opengl/SpriteBatch.cpp b/src/modules/graphics/opengl/SpriteBatch.cpp index 83ed4e2f8..041aa7b0e 100644 --- a/src/modules/graphics/opengl/SpriteBatch.cpp +++ b/src/modules/graphics/opengl/SpriteBatch.cpp @@ -70,6 +70,11 @@ namespace opengl delete color; } + bool SpriteBatch::isSupported() + { + return (GLEE_ARB_vertex_buffer_object || GLEE_VERSION_1_5); + } + bool SpriteBatch::loadVolatile() { // Find out which OpenGL VBO usage hint to use. diff --git a/src/modules/graphics/opengl/SpriteBatch.h b/src/modules/graphics/opengl/SpriteBatch.h index fdc868e82..58599ea1a 100644 --- a/src/modules/graphics/opengl/SpriteBatch.h +++ b/src/modules/graphics/opengl/SpriteBatch.h @@ -90,6 +90,8 @@ namespace opengl SpriteBatch(Image * image, int size, int usage); virtual ~SpriteBatch(); + static bool isSupported(); + // Implements Volatile. bool loadVolatile(); void unloadVolatile(); diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index 208dcc376..416373cc4 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -761,6 +761,10 @@ namespace opengl if (!PixelEffect::isSupported()) supported = false; break; + case Graphics::SUPPORT_SPRITEBATCHES: + if (!SpriteBatch::isSupported()) + supported = false; + break; default: supported = false; }