diff --git a/binding-mri/graphics-binding.cpp b/binding-mri/graphics-binding.cpp index dd75bd8..4f10c16 100644 --- a/binding-mri/graphics-binding.cpp +++ b/binding-mri/graphics-binding.cpp @@ -219,8 +219,6 @@ void graphicsBindingInit(){ INIT_GRA_PROP_BIND( Brightness, "brightness" ); - _rb_define_module_function(module, "play_movie", graphicsPlayMovie); - INIT_GRA_PROP_BIND( Fullscreen, "fullscreen" ); INIT_GRA_PROP_BIND( ShowCursor, "show_cursor" ); INIT_GRA_PROP_BIND( Smooth, "smooth" ); diff --git a/src/etc.cpp b/src/etc.cpp index fcfd4fd..b0e4f93 100644 --- a/src/etc.cpp +++ b/src/etc.cpp @@ -29,14 +29,12 @@ #include Color::Color(double red, double green, double blue, double alpha) - : red(red), green(green), blue(blue), alpha(alpha) -{ + : red(red), green(green), blue(blue), alpha(alpha){ updateInternal(); } Color::Color(const Vec4 &norm) - : norm(norm) -{ + : norm(norm){ updateExternal(); } @@ -45,16 +43,14 @@ Color::Color(const Color &o) norm(o.norm) {} -bool Color::operator==(const Color &o) const -{ +bool Color::operator==(const Color &o) const{ return red == o.red && green == o.green && blue == o.blue && alpha == o.alpha; } -const Color &Color::operator=(const Color &o) -{ +const Color &Color::operator=(const Color &o){ red = o.red; green = o.green; blue = o.blue; @@ -64,8 +60,7 @@ const Color &Color::operator=(const Color &o) return o; } -void Color::set(double red, double green, double blue, double alpha) -{ +void Color::set(double red, double green, double blue, double alpha){ this->red = red; this->green = green; this->blue = blue; @@ -74,46 +69,39 @@ void Color::set(double red, double green, double blue, double alpha) updateInternal(); } -void Color::setRed(double value) -{ +void Color::setRed(double value){ red = value; norm.x = clamp(value, 0, 255) / 255; } -void Color::setGreen(double value) -{ +void Color::setGreen(double value){ green = value; norm.y = clamp(value, 0, 255) / 255; } -void Color::setBlue(double value) -{ +void Color::setBlue(double value){ blue = value; norm.z = clamp(value, 0, 255) / 255; } -void Color::setAlpha(double value) -{ +void Color::setAlpha(double value){ alpha = value; norm.w = clamp(value, 0, 255) / 255; } /* Serializable */ -int Color::serialSize() const -{ +int Color::serialSize() const{ return 4 * 8; } -void Color::serialize(char *buffer) const -{ +void Color::serialize(char *buffer) const{ writeDouble(&buffer, red); writeDouble(&buffer, green); writeDouble(&buffer, blue); writeDouble(&buffer, alpha); } -Color *Color::deserialize(const char *data, int len) -{ +Color *Color::deserialize(const char *data, int len){ if (len != 32) throw Exception(Exception::ArgumentError, "Color: Serialized data invalid"); @@ -128,24 +116,21 @@ Color *Color::deserialize(const char *data, int len) return c; } -void Color::updateInternal() -{ +void Color::updateInternal(){ norm.x = red / 255; norm.y = green / 255; norm.z = blue / 255; norm.w = alpha / 255; } -void Color::updateExternal() -{ +void Color::updateExternal(){ red = norm.x * 255; green = norm.y * 255; blue = norm.z * 255; alpha = norm.w * 255; } -SDL_Color Color::toSDLColor() const -{ +SDL_Color Color::toSDLColor() const{ SDL_Color c; c.r = clamp(red, 0, 255); c.g = clamp(green, 0, 255); @@ -157,8 +142,7 @@ SDL_Color Color::toSDLColor() const Tone::Tone(double red, double green, double blue, double gray) - : red(red), green(green), blue(blue), gray(gray) -{ + : red(red), green(green), blue(blue), gray(gray){ updateInternal(); } @@ -167,16 +151,14 @@ Tone::Tone(const Tone &o) norm(o.norm) {} -bool Tone::operator==(const Tone &o) const -{ +bool Tone::operator==(const Tone &o) const{ return red == o.red && green == o.green && blue == o.blue && gray == o.gray; } -void Tone::set(double red, double green, double blue, double gray) -{ +void Tone::set(double red, double green, double blue, double gray){ this->red = red; this->green = green; this->blue = blue; @@ -186,8 +168,7 @@ void Tone::set(double red, double green, double blue, double gray) valueChanged(); } -const Tone& Tone::operator=(const Tone &o) -{ +const Tone& Tone::operator=(const Tone &o){ red = o.red; green = o.green; blue = o.blue; @@ -199,32 +180,28 @@ const Tone& Tone::operator=(const Tone &o) return o; } -void Tone::setRed(double value) -{ +void Tone::setRed(double value){ red = value; norm.x = (float) clamp(value, -255, 255) / 255; valueChanged(); } -void Tone::setGreen(double value) -{ +void Tone::setGreen(double value){ green = value; norm.y = (float) clamp(value, -255, 255) / 255; valueChanged(); } -void Tone::setBlue(double value) -{ +void Tone::setBlue(double value){ blue = value; norm.z = (float) clamp(value, -255, 255) / 255; valueChanged(); } -void Tone::setGray(double value) -{ +void Tone::setGray(double value){ gray = value; norm.w = (float) clamp(value, 0, 255) / 255; @@ -232,21 +209,18 @@ void Tone::setGray(double value) } /* Serializable */ -int Tone::serialSize() const -{ +int Tone::serialSize() const{ return 4 * 8; } -void Tone::serialize(char *buffer) const -{ +void Tone::serialize(char *buffer) const{ writeDouble(&buffer, red); writeDouble(&buffer, green); writeDouble(&buffer, blue); writeDouble(&buffer, gray); } -Tone *Tone::deserialize(const char *data, int len) -{ +Tone *Tone::deserialize(const char *data, int len){ if (len != 32) throw Exception(Exception::ArgumentError, "Tone: Serialized data invalid"); @@ -261,8 +235,7 @@ Tone *Tone::deserialize(const char *data, int len) return t; } -void Tone::updateInternal() -{ +void Tone::updateInternal(){ norm.x = (float) clamp(red, -255, 255) / 255; norm.y = (float) clamp(green, -255, 255) / 255; norm.z = (float) clamp(blue, -255, 255) / 255; @@ -283,29 +256,25 @@ Rect::Rect(const IntRect &r) : x(r.x), y(r.y), width(r.w), height(r.h) {} -bool Rect::operator==(const Rect &o) const -{ +bool Rect::operator==(const Rect &o) const{ return x == o.x && y == o.y && width == o.width && height == o.height; } -void Rect::operator=(const IntRect &rect) -{ +void Rect::operator=(const IntRect &rect){ x = rect.x; y = rect.y; width = rect.w; height = rect.h; } -void Rect::set(int x, int y, int w, int h) -{ +void Rect::set(int x, int y, int w, int h){ if (this->x == x && this->y == y && width == w && - height == h) - { + height == h){ return; } @@ -316,8 +285,7 @@ void Rect::set(int x, int y, int w, int h) valueChanged(); } -const Rect &Rect::operator=(const Rect &o) -{ +const Rect &Rect::operator=(const Rect &o){ x = o.x; y = o.y; width = o.width; @@ -328,8 +296,7 @@ const Rect &Rect::operator=(const Rect &o) return o; } -void Rect::empty() -{ +void Rect::empty(){ if (!(x || y || width || height)) return; @@ -337,13 +304,11 @@ void Rect::empty() valueChanged(); } -bool Rect::isEmpty() const -{ +bool Rect::isEmpty() const{ return !(width && height); } -void Rect::setX(int value) -{ +void Rect::setX(int value){ if (x == value) return; @@ -351,8 +316,7 @@ void Rect::setX(int value) valueChanged(); } -void Rect::setY(int value) -{ +void Rect::setY(int value){ if (y == value) return; @@ -360,8 +324,7 @@ void Rect::setY(int value) valueChanged(); } -void Rect::setWidth(int value) -{ +void Rect::setWidth(int value){ if (width == value) return; @@ -369,8 +332,7 @@ void Rect::setWidth(int value) valueChanged(); } -void Rect::setHeight(int value) -{ +void Rect::setHeight(int value){ if (height == value) return; @@ -378,21 +340,18 @@ void Rect::setHeight(int value) valueChanged(); } -int Rect::serialSize() const -{ +int Rect::serialSize() const{ return 4 * 4; } -void Rect::serialize(char *buffer) const -{ +void Rect::serialize(char *buffer) const{ writeInt32(&buffer, x); writeInt32(&buffer, y); writeInt32(&buffer, width); writeInt32(&buffer, height); } -Rect *Rect::deserialize(const char *data, int len) -{ +Rect *Rect::deserialize(const char *data, int len){ if (len != 16) throw Exception(Exception::ArgumentError, "Rect: Serialized data invalid"); diff --git a/src/filesystem.cpp b/src/filesystem.cpp index c1aaeac..c343c13 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -44,8 +44,7 @@ #include #endif -struct SDLRWIoContext -{ +struct SDLRWIoContext{ SDL_IOStream *ops; std::string filename; @@ -58,8 +57,7 @@ struct SDLRWIoContext "Failed to open file: %s", SDL_GetError()); } - ~SDLRWIoContext() - { + ~SDLRWIoContext(){ SDL_CloseIO(ops); } }; @@ -233,10 +231,7 @@ static int SDL_RWopsCloseFree(void *userdata) * or the full string if srcN == -1. Never writes more * than dstMax, and guarantees dst to be null terminated. * Returns copied bytes (minus terminating null) */ -static size_t -strcpySafe(char *dst, const char *src, - size_t dstMax, int srcN) -{ +static size_t strcpySafe(char *dst, const char *src, size_t dstMax, int srcN){ if (srcN < 0) srcN = strlen(src); @@ -265,11 +260,7 @@ static const char *findExt(const char *filename){ return 0; } -static void -initReadOps(PHYSFS_File *handle, - SDL_IOStream* &ops) - //bool freeOnClose) -{ +static void initReadOps(PHYSFS_File *handle, SDL_IOStream* &ops){ SDL_IOStreamInterface iface; SDL_INIT_INTERFACE(&iface); @@ -309,8 +300,7 @@ struct FileSystemPrivate{ bool havePathCache; }; -FileSystem::FileSystem(bool allowSymlinks) -{ +FileSystem::FileSystem(bool allowSymlinks){ p = new FileSystemPrivate; p->havePathCache = false; @@ -331,8 +321,7 @@ FileSystem::~FileSystem(){ void FileSystem::addPath(const char *path){ /* Try the normal mount first */ - if (!PHYSFS_mount(path, 0, 1)) - { + if (!PHYSFS_mount(path, 0, 1)){ /* If it didn't work, try mounting via a wrapped * SDL_IOStream */ PHYSFS_Io *io = createSDLRWIo(path); @@ -359,8 +348,7 @@ struct CacheEnumData{ #endif } - ~CacheEnumData() - { + ~CacheEnumData(){ #ifdef OS_OSX iconv_close(nfd2nfc); #endif @@ -622,10 +610,7 @@ void FileSystem::openRead(OpenHandler &handler, const char *filename){ throw Exception(Exception::NoFileError, "%s", filename); } -void FileSystem::openReadRaw(SDL_IOStream* &stream, - const char *filename) - //bool freeOnClose) -{ +void FileSystem::openReadRaw(SDL_IOStream* &stream, const char *filename){ PHYSFS_File *handle = PHYSFS_openRead(filename); if (!handle) throw Exception(Exception::NoFileError, "%s", filename); diff --git a/src/gl-debug.cpp b/src/gl-debug.cpp index 7512fa8..19f5daf 100644 --- a/src/gl-debug.cpp +++ b/src/gl-debug.cpp @@ -26,28 +26,23 @@ #include "gl-fun.h" -struct GLDebugLoggerPrivate -{ +struct GLDebugLoggerPrivate{ std::ostream *stream; time_t timestamp; - GLDebugLoggerPrivate(const char *logFilename) - { + GLDebugLoggerPrivate(const char *logFilename){ (void) logFilename; stream = &std::clog; } - ~GLDebugLoggerPrivate() - { - } + ~GLDebugLoggerPrivate(){} void writeTimestamp(){ time(×tamp); *stream << "[GLDEBUG " << ctime(×tamp) << "]"; } - void writeLine(const char *line) - { + void writeLine(const char *line){ *stream << line << "\n"; stream->flush(); } @@ -76,8 +71,7 @@ static void APIENTRY arbDebugFunc(GLenum source, p->writeLine(message); } -GLDebugLogger::GLDebugLogger(const char *filename) -{ +GLDebugLogger::GLDebugLogger(const char *filename){ p = new GLDebugLoggerPrivate(filename); if (gl.DebugMessageCallback) @@ -86,7 +80,6 @@ GLDebugLogger::GLDebugLogger(const char *filename) Debug() << "DebugLogger: no debug extensions found"; } -GLDebugLogger::~GLDebugLogger() -{ +GLDebugLogger::~GLDebugLogger(){ delete p; } diff --git a/src/gl-debug.h b/src/gl-debug.h index f275b6f..c353bb8 100644 --- a/src/gl-debug.h +++ b/src/gl-debug.h @@ -29,8 +29,7 @@ struct GLDebugLoggerPrivate; -class GLDebugLogger -{ +class GLDebugLogger{ public: GLDebugLogger(const char *filename = 0); ~GLDebugLogger(); diff --git a/src/gl-fun.cpp b/src/gl-fun.cpp index 41f2999..428b6fb 100644 --- a/src/gl-fun.cpp +++ b/src/gl-fun.cpp @@ -31,8 +31,7 @@ GLFunctions gl; typedef const GLubyte* (APIENTRYP _PFNGLGETSTRINGIPROC) (GLenum, GLuint); -static void parseExtensionsCore(_PFNGLGETINTEGERVPROC GetIntegerv, BoostSet &out) -{ +static void parseExtensionsCore(_PFNGLGETINTEGERVPROC GetIntegerv, BoostSet &out){ _PFNGLGETSTRINGIPROC GetStringi = (_PFNGLGETSTRINGIPROC) SDL_GL_GetProcAddress("glGetStringi"); @@ -43,8 +42,7 @@ static void parseExtensionsCore(_PFNGLGETINTEGERVPROC GetIntegerv, BoostSet &out) -{ +static void parseExtensionsCompat(_PFNGLGETSTRINGPROC GetString, BoostSet &out){ const char *ext = (const char*) GetString(GL_EXTENSIONS); if (!ext) @@ -53,8 +51,7 @@ static void parseExtensionsCompat(_PFNGLGETSTRINGPROC GetString, BoostSet= 3 || HAVE_EXT(ARB_framebuffer_object)) - { + if (glMajor >= 3 || HAVE_EXT(ARB_framebuffer_object)){ #undef EXT_SUFFIX #define EXT_SUFFIX "" GL_FBO_FUN; GL_FBO_BLIT_FUN; } - else if (gles && glMajor == 2) - { + else if (gles && glMajor == 2){ GL_FBO_FUN; } - else if (HAVE_EXT(EXT_framebuffer_object)) - { + else if (HAVE_EXT(EXT_framebuffer_object)){ #undef EXT_SUFFIX #define EXT_SUFFIX "EXT" GL_FBO_FUN; - if (HAVE_EXT(EXT_framebuffer_blit)) - { + if (HAVE_EXT(EXT_framebuffer_blit)){ GL_FBO_BLIT_FUN; } } - else - { + else{ throw EXC("No FBO support available"); } /* VAO entrypoints */ - if (HAVE_EXT(ARB_vertex_array_object) || glMajor >= 3) - { + if (HAVE_EXT(ARB_vertex_array_object) || glMajor >= 3){ #undef EXT_SUFFIX #define EXT_SUFFIX "" GL_VAO_FUN; } - else if (HAVE_EXT(APPLE_vertex_array_object)) - { + else if (HAVE_EXT(APPLE_vertex_array_object)){ #undef EXT_SUFFIX #define EXT_SUFFIX "APPLE" GL_VAO_FUN; } - else if (HAVE_EXT(OES_vertex_array_object)) - { + else if (HAVE_EXT(OES_vertex_array_object)){ #undef EXT_SUFFIX #define EXT_SUFFIX "OES" GL_VAO_FUN; } /* Debug callback entrypoints */ - if (HAVE_EXT(KHR_debug)) - { + if (HAVE_EXT(KHR_debug)){ #undef EXT_SUFFIX #define EXT_SUFFIX "" GL_DEBUG_KHR_FUN; } - else if (HAVE_EXT(ARB_debug_output)) - { + else if (HAVE_EXT(ARB_debug_output)){ #undef EXT_SUFFIX #define EXT_SUFFIX "ARB" GL_DEBUG_KHR_FUN; } - if (HAVE_EXT(GREMEDY_string_marker)) - { + if (HAVE_EXT(GREMEDY_string_marker)){ #undef EXT_SUFFIX #define EXT_SUFFIX "GREMEDY" GL_GREMEMDY_FUN; diff --git a/src/gl-fun.h b/src/gl-fun.h index 72c726d..6e2af9c 100644 --- a/src/gl-fun.h +++ b/src/gl-fun.h @@ -207,8 +207,7 @@ typedef void (APIENTRYP _PFNGLRELEASESHADERCOMPILERPROC) (void); GL_FUN(StringMarker, _PFNGLSTRINGMARKERPROC) -struct GLFunctions -{ +struct GLFunctions{ #define GL_FUN(name, type) type name; GL_20_FUN diff --git a/src/gl-meta.h b/src/gl-meta.h index 6f9e264..783729d 100644 --- a/src/gl-meta.h +++ b/src/gl-meta.h @@ -73,3 +73,4 @@ void blitEnd(); } #endif // GLMETA_H + diff --git a/src/gl-util.h b/src/gl-util.h index 494c84a..d0d7a3d 100644 --- a/src/gl-util.h +++ b/src/gl-util.h @@ -49,140 +49,115 @@ struct ID \ }; /* 2D Texture */ -namespace TEX -{ +namespace TEX{ DEF_GL_ID - inline ID gen() - { + inline ID gen(){ ID id; gl.GenTextures(1, &id.gl); return id; } - static inline void del(ID id) - { + static inline void del(ID id){ gl.DeleteTextures(1, &id.gl); } - static inline void bind(ID id) - { + static inline void bind(ID id){ gl.BindTexture(GL_TEXTURE_2D, id.gl); } - static inline void unbind() - { + static inline void unbind(){ bind(ID(0)); } - static inline void uploadImage(GLsizei width, GLsizei height, const void *data, GLenum format) - { + static inline void uploadImage(GLsizei width, GLsizei height, const void *data, GLenum format){ gl.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, format, GL_UNSIGNED_BYTE, data); } - static inline void uploadSubImage(GLint x, GLint y, GLsizei width, GLsizei height, const void *data, GLenum format) - { + static inline void uploadSubImage(GLint x, GLint y, GLsizei width, GLsizei height, const void *data, GLenum format){ gl.TexSubImage2D(GL_TEXTURE_2D, 0, x, y, width, height, format, GL_UNSIGNED_BYTE, data); } - static inline void allocEmpty(GLsizei width, GLsizei height) - { + static inline void allocEmpty(GLsizei width, GLsizei height){ gl.TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); } - static inline void setRepeat(bool mode) - { + static inline void setRepeat(bool mode){ gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, mode ? GL_REPEAT : GL_CLAMP_TO_EDGE); gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, mode ? GL_REPEAT : GL_CLAMP_TO_EDGE); } - static inline void setSmooth(bool mode) - { + static inline void setSmooth(bool mode){ gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, mode ? GL_LINEAR : GL_NEAREST); gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mode ? GL_LINEAR : GL_NEAREST); } } /* Framebuffer Object */ -namespace FBO -{ +namespace FBO{ DEF_GL_ID - inline ID gen() - { + inline ID gen(){ ID id; gl.GenFramebuffers(1, &id.gl); return id; } - static inline void del(ID id) - { + static inline void del(ID id){ gl.DeleteFramebuffers(1, &id.gl); } - static inline void bind(ID id) - { + static inline void bind(ID id){ gl.BindFramebuffer(GL_FRAMEBUFFER, id.gl); } - static inline void unbind() - { + static inline void unbind(){ bind(ID(0)); } - static inline void setTarget(TEX::ID target, unsigned colorAttach = 0) - { + static inline void setTarget(TEX::ID target, unsigned colorAttach = 0){ gl.FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + colorAttach, GL_TEXTURE_2D, target.gl, 0); } - static inline void clear() - { + static inline void clear(){ gl.Clear(GL_COLOR_BUFFER_BIT); } } template -struct GenericBO -{ +struct GenericBO{ DEF_GL_ID - static inline ID gen() - { + static inline ID gen(){ ID id; gl.GenBuffers(1, &id.gl); return id; } - static inline void del(ID id) - { + static inline void del(ID id){ gl.DeleteBuffers(1, &id.gl); } - static inline void bind(ID id) - { + static inline void bind(ID id){ gl.BindBuffer(target, id.gl); } - static inline void unbind() - { + static inline void unbind(){ bind(ID(0)); } - static inline void uploadData(GLsizeiptr size, const GLvoid *data, GLenum usage = GL_STATIC_DRAW) - { + static inline void uploadData(GLsizeiptr size, const GLvoid *data, GLenum usage = GL_STATIC_DRAW){ gl.BufferData(target, size, data, usage); } - static inline void uploadSubData(GLintptr offset, GLsizeiptr size, const GLvoid *data) - { + static inline void uploadSubData(GLintptr offset, GLsizeiptr size, const GLvoid *data){ gl.BufferSubData(target, offset, size, data); } - static inline void allocEmpty(GLsizeiptr size, GLenum usage = GL_STATIC_DRAW) - { + static inline void allocEmpty(GLsizeiptr size, GLenum usage = GL_STATIC_DRAW){ uploadData(size, 0, usage); } }; @@ -197,8 +172,7 @@ typedef struct GenericBO IBO; /* Convenience struct wrapping a framebuffer * and a 2D texture as its target */ -struct TEXFBO -{ +struct TEXFBO{ TEX::ID tex; FBO::ID fbo; int width, height; @@ -207,13 +181,11 @@ struct TEXFBO : tex(0), fbo(0), width(0), height(0) {} - bool operator==(const TEXFBO &other) const - { + bool operator==(const TEXFBO &other) const{ return (tex == other.tex) && (fbo == other.fbo); } - static inline void init(TEXFBO &obj) - { + static inline void init(TEXFBO &obj){ obj.tex = TEX::gen(); obj.fbo = FBO::gen(); TEX::bind(obj.tex); @@ -221,28 +193,24 @@ struct TEXFBO TEX::setSmooth(false); } - static inline void allocEmpty(TEXFBO &obj, int width, int height) - { + static inline void allocEmpty(TEXFBO &obj, int width, int height){ TEX::bind(obj.tex); TEX::allocEmpty(width, height); obj.width = width; obj.height = height; } - static inline void linkFBO(TEXFBO &obj) - { + static inline void linkFBO(TEXFBO &obj){ FBO::bind(obj.fbo); FBO::setTarget(obj.tex); } - static inline void fini(TEXFBO &obj) - { + static inline void fini(TEXFBO &obj){ FBO::del(obj.fbo); TEX::del(obj.tex); } - static inline void clear(TEXFBO &obj) - { + static inline void clear(TEXFBO &obj){ obj.tex = TEX::ID(0); obj.fbo = FBO::ID(0); obj.width = obj.height = 0; diff --git a/src/glstate.h b/src/glstate.h index eff0257..43f5894 100644 --- a/src/glstate.h +++ b/src/glstate.h @@ -30,15 +30,12 @@ struct Config; template -struct GLProperty -{ - ~GLProperty() - { +struct GLProperty{ + ~GLProperty(){ assert(stack.size() == 0); } - void init(const T &value) - { + void init(const T &value){ current = value; apply(value); } @@ -46,22 +43,19 @@ struct GLProperty void push() { stack.push(current); } void pop() { if (!stack.empty()) { set(stack.top()); stack.pop(); } } const T &get() { return current; } - void set(const T &value) - { + void set(const T &value){ if (value == current) return; init(value); } - void pushSet(const T &value) - { + void pushSet(const T &value){ push(); set(value); } - void refresh() - { + void refresh(){ apply(current); } private: @@ -72,13 +66,11 @@ private: }; -class GLClearColor : public GLProperty -{ +class GLClearColor : public GLProperty{ void apply(const Vec4 &); }; -class GLScissorBox : public GLProperty -{ +class GLScissorBox : public GLProperty{ public: /* Sets the intersection of the current box with value */ void setIntersect(const IntRect &value); @@ -87,13 +79,11 @@ private: void apply(const IntRect &value); }; -class GLScissorTest : public GLProperty -{ +class GLScissorTest : public GLProperty{ void apply(const bool &value); }; -class GLBlendMode : public GLProperty -{ +class GLBlendMode : public GLProperty{ void apply(const BlendType &value); }; @@ -102,19 +92,16 @@ class GLBlend : public GLProperty void apply(const bool &value); }; -class GLViewport : public GLProperty -{ +class GLViewport : public GLProperty{ void apply(const IntRect &value); }; -class GLProgram : public GLProperty /* GLuint */ -{ +class GLProgram : public GLProperty /* GLuint */{ void apply(const unsigned int &value); }; -class GLState -{ +class GLState{ public: GLClearColor clearColor; GLScissorBox scissorBox; @@ -124,8 +111,7 @@ public: GLViewport viewport; GLProgram program; - struct Caps - { + struct Caps{ int maxTexSize; Caps(); diff --git a/src/graphics.cpp b/src/graphics.cpp index 0991f37..edd883c 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -894,10 +894,6 @@ void Graphics::resizeScreen(int width, int height){ shState->eThread().requestWindowResize(width, height); } -void Graphics::playMovie(const char *filename){ - Debug() << "[playMovie] Graphics.playMovie(" << filename << ") not implemented"; -} - DEF_ATTR_RD_SIMPLE(Graphics, Brightness, int, p->brightness) void Graphics::setBrightness(int value){ diff --git a/src/graphics.h b/src/graphics.h index fccab1f..cb4de50 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -54,7 +54,6 @@ public: int width() const; int height() const; void resizeScreen(int width, int height); - void playMovie(const char *filename); void reset(); diff --git a/src/tileatlas.cpp b/src/tileatlas.cpp index 3d8b3e7..b3521d0 100644 --- a/src/tileatlas.cpp +++ b/src/tileatlas.cpp @@ -21,13 +21,11 @@ #include "tileatlas.h" -namespace TileAtlas -{ +namespace TileAtlas{ /* A Column represents a Rect * with undefined width */ -struct Column -{ +struct Column{ int x, y, h; Column(int x, int y, int h) diff --git a/src/tilemap-common.h b/src/tilemap-common.h index 4b6b2cd..af46a1a 100644 --- a/src/tilemap-common.h +++ b/src/tilemap-common.h @@ -39,28 +39,24 @@ #include -static inline int -wrap(int value, int range){ +static inline int wrap(int value, int range){ int res = value % range; return res < 0 ? res + range : res; } -static inline Vec2i -wrap(const Vec2i &value, int range){ +static inline Vec2i wrap(const Vec2i &value, int range){ return Vec2i(wrap(value.x, range), wrap(value.y, range)); } -static inline int16_t -tableGetWrapped(const Table &t, int x, int y, int z = 0){ +static inline int16_t tableGetWrapped(const Table &t, int x, int y, int z = 0){ return t.get(wrap(x, t.xSize()), wrap(y, t.ySize()), z); } /* Calculate the tile x/y on which this pixel x/y lies */ -static inline Vec2i -getTilePos(const Vec2i &pixelPos){ +static inline Vec2i getTilePos(const Vec2i &pixelPos){ /* Round the pixel position down to the nearest top left * tile boundary, by masking off the lower 5 bits (2^5 = 32). * Then divide by 32 to convert into tile units. */ @@ -209,8 +205,7 @@ private: return; for (int x = 0; x < viewp.w; ++x) - for (int y = 0; y < viewp.h; ++y) - { + for (int y = 0; y < viewp.h; ++y){ Vec4 color; if (!sampleFlashColor(color, x+viewp.x, y+viewp.y)) diff --git a/src/tilemap.cpp b/src/tilemap.cpp index 6d3675f..5df661e 100644 --- a/src/tilemap.cpp +++ b/src/tilemap.cpp @@ -1171,3 +1171,4 @@ void Tilemap::releaseResources(){ delete p; atProxy.p = 0; } + diff --git a/src/window.cpp b/src/window.cpp index fc1739c..e789793 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -323,14 +323,12 @@ struct WindowPrivate { backgroundVert.vert = &vert[i]; /* Background */ - if (bgStretch) - { + if (bgStretch){ Quad::setTexRect(&vert[i*4], backgroundSrc); Quad::setPosRect(&vert[i*4], bgRect); i += 1; } - else - { + else{ i += TileQuads::build(backgroundSrc, bgRect, &vert[i*4]); } @@ -372,13 +370,11 @@ struct WindowPrivate { int newH = baseTex.height; bool resizeNeeded = false; - if (size.x > baseTex.width) - { + if (size.x > baseTex.width){ newW = findNextPow2(size.x); resizeNeeded = true; } - if (size.y > baseTex.height) - { + if (size.y > baseTex.height){ newH = findNextPow2(size.y); resizeNeeded = true; } @@ -438,8 +434,7 @@ struct WindowPrivate { Vertex *vert = controlsQuadArray.vertices.data(); /* Cursor */ - if (!cursorRect->isEmpty()) - { + if (!cursorRect->isEmpty()){ /* Effective cursor rect has 16 xy offset to window */ IntRect effectRect(cursorRect->x+16, cursorRect->y+16, cursorRect->width, cursorRect->height); @@ -458,8 +453,7 @@ struct WindowPrivate { scrollArrows.t = IntRect(scroll.x, 4, 16, 8); scrollArrows.b = IntRect(scroll.x, size.y - 12, 16, 8); - if (contents) - { + if (contents){ if (contentsOffset.x > 0) i += Quad::setTexPosRect(&vert[i*4], scrollArrowSrc.l, scrollArrows.l); @@ -474,8 +468,7 @@ struct WindowPrivate { } /* Pause animation */ - if (pause) - { + if (pause){ pauseAniVert.vert = &vert[i*4]; i += Quad::setTexPosRect(&vert[i*4], pauseAniSrc[pauseAniQuad[pauseAniQuadIdx]], FloatRect((size.x - 16) / 2, size.y - 16, 16, 16)); @@ -491,15 +484,13 @@ struct WindowPrivate { bool updateBaseQuadArray = false; - if (baseVertDirty) - { + if (baseVertDirty){ buildBaseVert(); baseVertDirty = false; updateBaseQuadArray = true; } - if (opacityDirty) - { + if (opacityDirty){ updateBaseAlpha(); opacityDirty = false; updateBaseQuadArray = true; @@ -512,12 +503,10 @@ struct WindowPrivate { * and then draw this texture instead of the quad array */ useBaseTex = opacity < 255; - if (useBaseTex) - { + if (useBaseTex){ ensureBaseTexReady(); - if (baseTexDirty) - { + if (baseTexDirty){ redrawBaseTex(); baseTexDirty = false; } @@ -536,15 +525,12 @@ struct WindowPrivate { shader.applyViewportProj(); shader.setTranslation(position + sceneOffset); - if (useBaseTex) - { + if (useBaseTex){ shader.setTexSize(Vec2i(baseTex.width, baseTex.height)); TEX::bind(baseTex.tex); baseTexQuad.draw(); - } - else - { + }else{ windowskin->bindTex(shader); TEX::setSmooth(true); @@ -561,8 +547,7 @@ struct WindowPrivate { if (size == Vec2i(0, 0)) return; - if (controlsVertDirty) - { + if (controlsVertDirty){ buildControlsVert(); updateControls(); controlsVertDirty = false; @@ -582,8 +567,7 @@ struct WindowPrivate { shader.bind(); shader.applyViewportProj(); - if (!nullOrDisposed(windowskin)) - { + if (!nullOrDisposed(windowskin)){ shader.setTranslation(efPos); /* Draw arrows / cursors */ @@ -595,8 +579,7 @@ struct WindowPrivate { TEX::setSmooth(false); } - if (!nullOrDisposed(contents)) - { + if (!nullOrDisposed(contents)){ /* Draw contents bitmap */ glState.scissorBox.setIntersect(contentsRect);