From ab51b4cc9bc0275ca4c09487f16b9e7781b00499 Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Sun, 12 Jan 2014 22:25:39 +0100 Subject: [PATCH] updated from love-android --- AndroidManifest.xml | 23 ++++++------ jni/love/src/common/Module.cpp | 2 +- jni/love/src/common/Module.h | 1 - jni/love/src/love.cpp | 2 +- .../modules/filesystem/physfs/Filesystem.h | 1 + .../src/modules/graphics/opengl/Graphics.cpp | 35 +++++++++++++------ .../src/modules/graphics/opengl/Graphics.h | 13 ++++--- .../modules/graphics/opengl/VertexBuffer.cpp | 9 ++--- .../modules/graphics/opengl/wrap_Graphics.cpp | 20 ++++++++--- .../modules/graphics/opengl/wrap_Graphics.h | 2 +- .../joystick/sdl/wrap_JoystickModule.h | 1 + jni/love/src/modules/keyboard/wrap_Keyboard.h | 1 + jni/love/src/modules/timer/wrap_Timer.h | 1 + 13 files changed, 68 insertions(+), 43 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 5f3c47ae..17f0f387 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,17 +1,18 @@ - - - - + + diff --git a/jni/love/src/common/Module.cpp b/jni/love/src/common/Module.cpp index 9f58f065..8b025e72 100644 --- a/jni/love/src/common/Module.cpp +++ b/jni/love/src/common/Module.cpp @@ -78,7 +78,7 @@ Module::~Module() void Module::registerInstance(Module *instance) { if (instance == nullptr) - throw Exception("Module instance is NULL"); + throw Exception("Module instance is null"); std::string name(instance->getName()); diff --git a/jni/love/src/common/Module.h b/jni/love/src/common/Module.h index 7ae1e608..feea22af 100644 --- a/jni/love/src/common/Module.h +++ b/jni/love/src/common/Module.h @@ -22,7 +22,6 @@ #define LOVE_MODULE_H // LOVE -#include "runtime.h" #include "Exception.h" #include "Object.h" diff --git a/jni/love/src/love.cpp b/jni/love/src/love.cpp index 3dce2787..c87c7baa 100644 --- a/jni/love/src/love.cpp +++ b/jni/love/src/love.cpp @@ -1,5 +1,5 @@ /** - * Copyright (c) 2006-2013 LOVE Development Team + * Copyright (c) 2006-2014 LOVE Development Team * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages diff --git a/jni/love/src/modules/filesystem/physfs/Filesystem.h b/jni/love/src/modules/filesystem/physfs/Filesystem.h index aaf892a3..a6ef9af5 100644 --- a/jni/love/src/modules/filesystem/physfs/Filesystem.h +++ b/jni/love/src/modules/filesystem/physfs/Filesystem.h @@ -31,6 +31,7 @@ #include "common/Module.h" #include "common/config.h" #include "common/int.h" +#include "common/runtime.h" #include "filesystem/FileData.h" #include "File.h" diff --git a/jni/love/src/modules/graphics/opengl/Graphics.cpp b/jni/love/src/modules/graphics/opengl/Graphics.cpp index ff01d858..94df82e7 100644 --- a/jni/love/src/modules/graphics/opengl/Graphics.cpp +++ b/jni/love/src/modules/graphics/opengl/Graphics.cpp @@ -268,14 +268,30 @@ void Graphics::clear() void Graphics::present() { + // Make sure we don't have a canvas active. + Canvas *c = Canvas::current; + Canvas::bindDefaultCanvas(); + if (GLAD_EXT_discard_framebuffer) { + GLenum attachments[] = {GL_STENCIL_EXT, GL_DEPTH_EXT}; + + if (gl.getDefaultFBO() != 0) + { + // A non-zero FBO needs different attachment enums. + attachments[0] = GL_STENCIL_ATTACHMENT; + attachments[1] = GL_DEPTH_ATTACHMENT; + } + // Hint for the driver that it doesn't need to save these buffers. - GLenum attachments[] = {GL_STENCIL_ATTACHMENT, GL_DEPTH_ATTACHMENT}; glDiscardFramebufferEXT(GL_FRAMEBUFFER, 2, attachments); } currentWindow->swapBuffers(); + + // Restore the currently active canvas, if there is one. + if (c != nullptr) + c->startGrab(c->getAttachedCanvases()); } int Graphics::getWidth() const @@ -305,19 +321,16 @@ void Graphics::setScissor() glDisable(GL_SCISSOR_TEST); } -int Graphics::getScissor(lua_State *L) const +bool Graphics::getScissor(int &x, int &y, int &width, int &height) const { - if (glIsEnabled(GL_SCISSOR_TEST) == GL_FALSE) - return 0; - OpenGL::Viewport scissor = gl.getScissor(); - lua_pushinteger(L, scissor.x); - lua_pushinteger(L, scissor.y); - lua_pushinteger(L, scissor.w); - lua_pushinteger(L, scissor.h); + x = scissor.x; + y = scissor.y; + width = scissor.w; + height = scissor.h; - return 4; + return glIsEnabled(GL_SCISSOR_TEST) == GL_TRUE; } void Graphics::defineStencil() @@ -348,7 +361,7 @@ void Graphics::discardStencil() glDisable(GL_STENCIL_TEST); } -int Graphics::getMaxImageSize() const +int Graphics::getMaxTextureSize() const { return gl.getMaxTextureSize(); } diff --git a/jni/love/src/modules/graphics/opengl/Graphics.h b/jni/love/src/modules/graphics/opengl/Graphics.h index c4f7969e..24be1d07 100644 --- a/jni/love/src/modules/graphics/opengl/Graphics.h +++ b/jni/love/src/modules/graphics/opengl/Graphics.h @@ -163,10 +163,10 @@ public: void setScissor(); /** - * This native Lua function gets the current scissor box in the order of: - * x, y, width, height - **/ - int getScissor(lua_State *L) const; + * Gets the current scissor box. + * @return Whether the scissor is enabled. + */ + bool getScissor(int &x, int &y, int &width, int &height) const; /** * Enables the stencil buffer and set stencil function to fill it @@ -187,10 +187,9 @@ public: void discardStencil(); /** - * Gets the maximum supported width or height of Images and Canvases on this - * system. + * Gets the maximum supported width or height of Textures on this system. **/ - int getMaxImageSize() const; + int getMaxTextureSize() const; /** * Creates an Image object with padding and/or optimization. diff --git a/jni/love/src/modules/graphics/opengl/VertexBuffer.cpp b/jni/love/src/modules/graphics/opengl/VertexBuffer.cpp index 25a3c6f2..2c10a0ef 100644 --- a/jni/love/src/modules/graphics/opengl/VertexBuffer.cpp +++ b/jni/love/src/modules/graphics/opengl/VertexBuffer.cpp @@ -117,7 +117,9 @@ const void *VertexArray::getPointer(size_t offset) const // VBO VBO::VBO(size_t size, GLenum target, GLenum usage, MemoryBacking backing) - : VertexBuffer(size, target, usage, backing) + // FIXME: + // ES2 can't do glGetBufferSubData. + : VertexBuffer(size, target, usage, GLAD_ES_VERSION_2_0 ? BACKING_FULL : backing) , vbo(0) , memory_map(0) , is_dirty(false) @@ -125,11 +127,6 @@ VBO::VBO(size_t size, GLenum target, GLenum usage, MemoryBacking backing) if (!(GLAD_ARB_vertex_buffer_object || GLAD_VERSION_1_5 || GLAD_ES_VERSION_2_0)) throw love::Exception("Not supported"); - // FIXME: - // ES2 can't do glGetBufferSubData. - if (GLAD_ES_VERSION_2_0) - backing = BACKING_FULL; - if (getMemoryBacking() == BACKING_FULL) memory_map = malloc(getSize()); diff --git a/jni/love/src/modules/graphics/opengl/wrap_Graphics.cpp b/jni/love/src/modules/graphics/opengl/wrap_Graphics.cpp index 7c3a8199..28573db1 100644 --- a/jni/love/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/jni/love/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -104,7 +104,16 @@ int w_setScissor(lua_State *L) int w_getScissor(lua_State *L) { - return instance->getScissor(L); + int x, y, w, h; + if (!instance->getScissor(x, y, w, h)) + return 0; + + lua_pushinteger(L, x); + lua_pushinteger(L, y); + lua_pushinteger(L, w); + lua_pushinteger(L, h); + + return 4; } static int setStencil(lua_State *L, bool invert) @@ -135,9 +144,9 @@ int w_setInvertedStencil(lua_State *L) return setStencil(L, true); } -int w_getMaxImageSize(lua_State *L) +int w_getMaxTextureSize(lua_State *L) { - lua_pushinteger(L, instance->getMaxImageSize()); + lua_pushinteger(L, instance->getMaxTextureSize()); return 1; } @@ -1369,7 +1378,7 @@ static const luaL_Reg functions[] = { "getPointSize", w_getPointSize }, { "getPointStyle", w_getPointStyle }, { "getMaxPointSize", w_getMaxPointSize }, - { "getMaxImageSize", w_getMaxImageSize }, + { "getMaxTextureSize", w_getMaxTextureSize }, { "newScreenshot", w_newScreenshot }, { "setCanvas", w_setCanvas }, { "getCanvas", w_getCanvas }, @@ -1413,6 +1422,9 @@ static const luaL_Reg functions[] = { "shear", w_shear }, { "origin", w_origin }, + // Deprecated since 0.9.1. + { "getMaxImageSize", w_getMaxTextureSize }, + { 0, 0 } }; diff --git a/jni/love/src/modules/graphics/opengl/wrap_Graphics.h b/jni/love/src/modules/graphics/opengl/wrap_Graphics.h index fc5459b5..24098b80 100644 --- a/jni/love/src/modules/graphics/opengl/wrap_Graphics.h +++ b/jni/love/src/modules/graphics/opengl/wrap_Graphics.h @@ -50,7 +50,7 @@ int w_setScissor(lua_State *L); int w_getScissor(lua_State *L); int w_setStencil(lua_State *L); int w_setInvertedStencil(lua_State *L); -int w_getMaxImageSize(lua_State *L); +int w_getMaxTextureSize(lua_State *L); int w_newImage(lua_State *L); int w_newQuad(lua_State *L); int w_newFont(lua_State *L); diff --git a/jni/love/src/modules/joystick/sdl/wrap_JoystickModule.h b/jni/love/src/modules/joystick/sdl/wrap_JoystickModule.h index 70f6f906..24de3264 100644 --- a/jni/love/src/modules/joystick/sdl/wrap_JoystickModule.h +++ b/jni/love/src/modules/joystick/sdl/wrap_JoystickModule.h @@ -23,6 +23,7 @@ // LOVE #include "common/config.h" +#include "common/runtime.h" #include "JoystickModule.h" namespace love diff --git a/jni/love/src/modules/keyboard/wrap_Keyboard.h b/jni/love/src/modules/keyboard/wrap_Keyboard.h index c87d55f0..717f241c 100644 --- a/jni/love/src/modules/keyboard/wrap_Keyboard.h +++ b/jni/love/src/modules/keyboard/wrap_Keyboard.h @@ -22,6 +22,7 @@ #define LOVE_KEYBOARD_WRAP_KEYBOARD_H // LOVE +#include "common/runtime.h" #include "Keyboard.h" namespace love diff --git a/jni/love/src/modules/timer/wrap_Timer.h b/jni/love/src/modules/timer/wrap_Timer.h index 4f7616e9..698d3864 100644 --- a/jni/love/src/modules/timer/wrap_Timer.h +++ b/jni/love/src/modules/timer/wrap_Timer.h @@ -22,6 +22,7 @@ #define LOVE_TIMER_WRAP_TIMER_H // LOVE +#include "common/runtime.h" #include "Timer.h" namespace love