updated from love-android

This commit is contained in:
Martin Felis
2014-01-12 22:25:39 +01:00
parent 78cb9c5539
commit ab51b4cc9b
13 changed files with 68 additions and 43 deletions
+12 -11
View File
@@ -1,17 +1,18 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest package="org.love2d.android" <manifest package="org.love2d.android"
android:versionCode="4" android:versionCode="7"
android:versionName="0.9.0-alpha6" android:versionName="0.9.0-alpha7"
android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android"> android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/><application
android:allowBackup="true"
<application android:label="Löve for Android" android:icon="@drawable/ic_launcher"
android:icon="@drawable/ic_launcher" android:label="Löve for Android"
android:allowBackup="true" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> <activity
<activity android:name="GameActivity" android:name="GameActivity"
android:label="Löve for Android" android:configChanges="orientation|screenSize"
android:screenOrientation="landscape" android:configChanges="orientation|screenSize"> android:label="Löve for Android"
android:screenOrientation="landscape" >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
+1 -1
View File
@@ -78,7 +78,7 @@ Module::~Module()
void Module::registerInstance(Module *instance) void Module::registerInstance(Module *instance)
{ {
if (instance == nullptr) if (instance == nullptr)
throw Exception("Module instance is NULL"); throw Exception("Module instance is null");
std::string name(instance->getName()); std::string name(instance->getName());
-1
View File
@@ -22,7 +22,6 @@
#define LOVE_MODULE_H #define LOVE_MODULE_H
// LOVE // LOVE
#include "runtime.h"
#include "Exception.h" #include "Exception.h"
#include "Object.h" #include "Object.h"
+1 -1
View File
@@ -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 * This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages * warranty. In no event will the authors be held liable for any damages
@@ -31,6 +31,7 @@
#include "common/Module.h" #include "common/Module.h"
#include "common/config.h" #include "common/config.h"
#include "common/int.h" #include "common/int.h"
#include "common/runtime.h"
#include "filesystem/FileData.h" #include "filesystem/FileData.h"
#include "File.h" #include "File.h"
@@ -268,14 +268,30 @@ void Graphics::clear()
void Graphics::present() void Graphics::present()
{ {
// Make sure we don't have a canvas active.
Canvas *c = Canvas::current;
Canvas::bindDefaultCanvas();
if (GLAD_EXT_discard_framebuffer) 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. // 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); glDiscardFramebufferEXT(GL_FRAMEBUFFER, 2, attachments);
} }
currentWindow->swapBuffers(); currentWindow->swapBuffers();
// Restore the currently active canvas, if there is one.
if (c != nullptr)
c->startGrab(c->getAttachedCanvases());
} }
int Graphics::getWidth() const int Graphics::getWidth() const
@@ -305,19 +321,16 @@ void Graphics::setScissor()
glDisable(GL_SCISSOR_TEST); 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(); OpenGL::Viewport scissor = gl.getScissor();
lua_pushinteger(L, scissor.x); x = scissor.x;
lua_pushinteger(L, scissor.y); y = scissor.y;
lua_pushinteger(L, scissor.w); width = scissor.w;
lua_pushinteger(L, scissor.h); height = scissor.h;
return 4; return glIsEnabled(GL_SCISSOR_TEST) == GL_TRUE;
} }
void Graphics::defineStencil() void Graphics::defineStencil()
@@ -348,7 +361,7 @@ void Graphics::discardStencil()
glDisable(GL_STENCIL_TEST); glDisable(GL_STENCIL_TEST);
} }
int Graphics::getMaxImageSize() const int Graphics::getMaxTextureSize() const
{ {
return gl.getMaxTextureSize(); return gl.getMaxTextureSize();
} }
@@ -163,10 +163,10 @@ public:
void setScissor(); void setScissor();
/** /**
* This native Lua function gets the current scissor box in the order of: * Gets the current scissor box.
* x, y, width, height * @return Whether the scissor is enabled.
**/ */
int getScissor(lua_State *L) const; bool getScissor(int &x, int &y, int &width, int &height) const;
/** /**
* Enables the stencil buffer and set stencil function to fill it * Enables the stencil buffer and set stencil function to fill it
@@ -187,10 +187,9 @@ public:
void discardStencil(); void discardStencil();
/** /**
* Gets the maximum supported width or height of Images and Canvases on this * Gets the maximum supported width or height of Textures on this system.
* system.
**/ **/
int getMaxImageSize() const; int getMaxTextureSize() const;
/** /**
* Creates an Image object with padding and/or optimization. * Creates an Image object with padding and/or optimization.
@@ -117,7 +117,9 @@ const void *VertexArray::getPointer(size_t offset) const
// VBO // VBO
VBO::VBO(size_t size, GLenum target, GLenum usage, MemoryBacking backing) 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) , vbo(0)
, memory_map(0) , memory_map(0)
, is_dirty(false) , 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)) if (!(GLAD_ARB_vertex_buffer_object || GLAD_VERSION_1_5 || GLAD_ES_VERSION_2_0))
throw love::Exception("Not supported"); throw love::Exception("Not supported");
// FIXME:
// ES2 can't do glGetBufferSubData.
if (GLAD_ES_VERSION_2_0)
backing = BACKING_FULL;
if (getMemoryBacking() == BACKING_FULL) if (getMemoryBacking() == BACKING_FULL)
memory_map = malloc(getSize()); memory_map = malloc(getSize());
@@ -104,7 +104,16 @@ int w_setScissor(lua_State *L)
int w_getScissor(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) static int setStencil(lua_State *L, bool invert)
@@ -135,9 +144,9 @@ int w_setInvertedStencil(lua_State *L)
return setStencil(L, true); 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; return 1;
} }
@@ -1369,7 +1378,7 @@ static const luaL_Reg functions[] =
{ "getPointSize", w_getPointSize }, { "getPointSize", w_getPointSize },
{ "getPointStyle", w_getPointStyle }, { "getPointStyle", w_getPointStyle },
{ "getMaxPointSize", w_getMaxPointSize }, { "getMaxPointSize", w_getMaxPointSize },
{ "getMaxImageSize", w_getMaxImageSize }, { "getMaxTextureSize", w_getMaxTextureSize },
{ "newScreenshot", w_newScreenshot }, { "newScreenshot", w_newScreenshot },
{ "setCanvas", w_setCanvas }, { "setCanvas", w_setCanvas },
{ "getCanvas", w_getCanvas }, { "getCanvas", w_getCanvas },
@@ -1413,6 +1422,9 @@ static const luaL_Reg functions[] =
{ "shear", w_shear }, { "shear", w_shear },
{ "origin", w_origin }, { "origin", w_origin },
// Deprecated since 0.9.1.
{ "getMaxImageSize", w_getMaxTextureSize },
{ 0, 0 } { 0, 0 }
}; };
@@ -50,7 +50,7 @@ int w_setScissor(lua_State *L);
int w_getScissor(lua_State *L); int w_getScissor(lua_State *L);
int w_setStencil(lua_State *L); int w_setStencil(lua_State *L);
int w_setInvertedStencil(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_newImage(lua_State *L);
int w_newQuad(lua_State *L); int w_newQuad(lua_State *L);
int w_newFont(lua_State *L); int w_newFont(lua_State *L);
@@ -23,6 +23,7 @@
// LOVE // LOVE
#include "common/config.h" #include "common/config.h"
#include "common/runtime.h"
#include "JoystickModule.h" #include "JoystickModule.h"
namespace love namespace love
@@ -22,6 +22,7 @@
#define LOVE_KEYBOARD_WRAP_KEYBOARD_H #define LOVE_KEYBOARD_WRAP_KEYBOARD_H
// LOVE // LOVE
#include "common/runtime.h"
#include "Keyboard.h" #include "Keyboard.h"
namespace love namespace love
+1
View File
@@ -22,6 +22,7 @@
#define LOVE_TIMER_WRAP_TIMER_H #define LOVE_TIMER_WRAP_TIMER_H
// LOVE // LOVE
#include "common/runtime.h"
#include "Timer.h" #include "Timer.h"
namespace love namespace love