From d8dab9c429650f96d355046ac368699ad0634e18 Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Wed, 2 Oct 2013 22:40:09 +0200 Subject: [PATCH] Start ifdef'ing out RGSS2 functionality --- src/bitmap.cpp | 4 ++++ src/bitmap.h | 4 ++-- src/globalstate.cpp | 14 ++++++++++---- src/globalstate.h | 7 +++++-- src/shader.cpp | 38 ++++++++++++++++++++++---------------- src/shader.h | 24 +++++++++++++----------- 6 files changed, 56 insertions(+), 35 deletions(-) diff --git a/src/bitmap.cpp b/src/bitmap.cpp index 7aed90e..490d671 100644 --- a/src/bitmap.cpp +++ b/src/bitmap.cpp @@ -439,6 +439,8 @@ void Bitmap::fillRect(const IntRect &rect, const Vec4 &color) modified(); } +#ifdef RGSS2 + void Bitmap::gradientFillRect(int x, int y, int width, int height, const Vec4 &color1, const Vec4 &color2, @@ -652,6 +654,8 @@ void Bitmap::radialBlur(int angle, int divisions) modified(); } +#endif + void Bitmap::clear() { GUARD_DISPOSED; diff --git a/src/bitmap.h b/src/bitmap.h index bf48edd..119808b 100644 --- a/src/bitmap.h +++ b/src/bitmap.h @@ -61,7 +61,7 @@ public: const Vec4 &color); void fillRect(const IntRect &rect, const Vec4 &color); - /* RGSS2 */ +#ifdef RGSS2 void gradientFillRect(int x, int y, int width, int height, const Vec4 &color1, const Vec4 &color2, @@ -77,7 +77,7 @@ public: void blur(); void radialBlur(int angle, int divisions); - /* ----- */ +#endif void clear(); diff --git a/src/globalstate.cpp b/src/globalstate.cpp index 8cc1697..82cb9d9 100644 --- a/src/globalstate.cpp +++ b/src/globalstate.cpp @@ -69,16 +69,19 @@ struct GlobalStatePrivate SimpleColorShader simpleColorShader; SimpleAlphaShader simpleAlphaShader; SimpleSpriteShader simpleSpriteShader; - SimpleMatrixShader simpleMatrixShader; SpriteShader spriteShader; PlaneShader planeShader; FlashMapShader flashMapShader; TransShader transShader; SimpleTransShader sTransShader; HueShader hueShader; - BlurShader blurShader; BltShader bltShader; +#ifdef RGSS2 + SimpleMatrixShader simpleMatrixShader; + BlurShader blurShader; +#endif + TexPool texPool; FontPool fontPool; @@ -190,19 +193,22 @@ GSATT(SimpleShader&, simpleShader) GSATT(SimpleColorShader&, simpleColorShader) GSATT(SimpleAlphaShader&, simpleAlphaShader) GSATT(SimpleSpriteShader&, simpleSpriteShader) -GSATT(SimpleMatrixShader&, simpleMatrixShader) GSATT(SpriteShader&, spriteShader) GSATT(PlaneShader&, planeShader) GSATT(FlashMapShader&, flashMapShader) GSATT(TransShader&, transShader) GSATT(SimpleTransShader&, sTransShader) GSATT(HueShader&, hueShader) -GSATT(BlurShader&, blurShader) GSATT(BltShader&, bltShader) GSATT(TexPool&, texPool) GSATT(FontPool&, fontPool) GSATT(Quad&, gpQuad) +#ifdef RGSS2 +GSATT(SimpleMatrixShader&, simpleMatrixShader) +GSATT(BlurShader&, blurShader) +#endif + void GlobalState::setBindingData(void *data) { p->bindingData = data; diff --git a/src/globalstate.h b/src/globalstate.h index ae33b46..099e79e 100644 --- a/src/globalstate.h +++ b/src/globalstate.h @@ -88,16 +88,19 @@ struct GlobalState SimpleColorShader &simpleColorShader(); SimpleAlphaShader &simpleAlphaShader(); SimpleSpriteShader &simpleSpriteShader(); - SimpleMatrixShader &simpleMatrixShader(); SpriteShader &spriteShader(); PlaneShader &planeShader(); FlashMapShader &flashMapShader(); TransShader &transShader(); SimpleTransShader &sTransShader(); HueShader &hueShader(); - BlurShader &blurShader(); BltShader &bltShader(); +#ifdef RGSS2 + SimpleMatrixShader &simpleMatrixShader(); + BlurShader &blurShader(); +#endif + TexPool &texPool(); FontPool &fontPool(); diff --git a/src/shader.cpp b/src/shader.cpp index faefb7d..7d20037 100644 --- a/src/shader.cpp +++ b/src/shader.cpp @@ -37,13 +37,16 @@ #include "../simpleColor.frag.xxd" #include "../simpleAlpha.frag.xxd" #include "../flashMap.frag.xxd" -#include "../blur.frag.xxd" #include "../simple.vert.xxd" #include "../simpleColor.vert.xxd" #include "../sprite.vert.xxd" + +#ifdef RGSS2 +#include "../blur.frag.xxd" #include "../simpleMatrix.vert.xxd" #include "../blurH.vert.xxd" #include "../blurV.vert.xxd" +#endif #define INIT_SHADER(vert, frag) \ @@ -230,21 +233,6 @@ void SimpleSpriteShader::setSpriteMat(const float value[16]) } -SimpleMatrixShader::SimpleMatrixShader() -{ - INIT_SHADER(simpleMatrix, simpleAlpha); - - ShaderBase::init(); - - GET_U(matrix); -} - -void SimpleMatrixShader::setMatrix(const float value[16]) -{ - glUniformMatrix4fv(u_matrix, 1, GL_FALSE, value); -} - - TransShader::TransShader() { INIT_SHADER(simple, trans); @@ -425,6 +413,23 @@ void HueShader::setInputTexture(TEX::ID tex) } +#ifdef RGSS2 + +SimpleMatrixShader::SimpleMatrixShader() +{ + INIT_SHADER(simpleMatrix, simpleAlpha); + + ShaderBase::init(); + + GET_U(matrix); +} + +void SimpleMatrixShader::setMatrix(const float value[16]) +{ + glUniformMatrix4fv(u_matrix, 1, GL_FALSE, value); +} + + BlurShader::HPass::HPass() { INIT_SHADER(blurH, blur); @@ -439,6 +444,7 @@ BlurShader::VPass::VPass() ShaderBase::init(); } +#endif BltShader::BltShader() diff --git a/src/shader.h b/src/shader.h index fe319c2..81c3c11 100644 --- a/src/shader.h +++ b/src/shader.h @@ -118,17 +118,6 @@ private: GLint u_spriteMat; }; -class SimpleMatrixShader : public ShaderBase -{ -public: - SimpleMatrixShader(); - - void setMatrix(const float value[16]); - -private: - GLint u_matrix; -}; - class TransShader : public ShaderBase { public: @@ -210,6 +199,18 @@ private: GLint u_hueAdjust, u_inputTexture; }; +#ifdef RGSS2 +class SimpleMatrixShader : public ShaderBase +{ +public: + SimpleMatrixShader(); + + void setMatrix(const float value[16]); + +private: + GLint u_matrix; +}; + /* Gaussian blur */ struct BlurShader { @@ -228,6 +229,7 @@ struct BlurShader HPass pass1; VPass pass2; }; +#endif /* Bitmap blit */ class BltShader : public ShaderBase