Browse Source

updated from love-android

Martin Felis 12 years ago
parent
commit
ab51b4cc9b

+ 12 - 11
AndroidManifest.xml

@@ -1,17 +1,18 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest package="org.love2d.android"
-      android:versionCode="4"
-      android:versionName="0.9.0-alpha6"
+      android:versionCode="7"
+      android:versionName="0.9.0-alpha7"
       android:installLocation="auto" xmlns:android="http://schemas.android.com/apk/res/android">
-    <uses-permission android:name="android.permission.INTERNET"/>
-
-    <application android:label="Löve for Android"
-                 android:icon="@drawable/ic_launcher"
-                 android:allowBackup="true"
-                 android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
-        <activity android:name="GameActivity"
-                  android:label="Löve for Android"
-                  android:screenOrientation="landscape" android:configChanges="orientation|screenSize">
+    <uses-permission android:name="android.permission.INTERNET"/><application
+        android:allowBackup="true"
+        android:icon="@drawable/ic_launcher"
+        android:label="Löve for Android"
+        android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
+        <activity
+            android:name="GameActivity"
+            android:configChanges="orientation|screenSize"
+            android:label="Löve for Android"
+            android:screenOrientation="landscape" >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />

+ 1 - 1
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());
 

+ 0 - 1
jni/love/src/common/Module.h

@@ -22,7 +22,6 @@
 #define LOVE_MODULE_H
 
 // LOVE
-#include "runtime.h"
 #include "Exception.h"
 #include "Object.h"
 

+ 1 - 1
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

+ 1 - 0
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"
 

+ 24 - 11
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();
 }

+ 6 - 7
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.

+ 3 - 6
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());
 

+ 16 - 4
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 }
 };
 

+ 1 - 1
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);

+ 1 - 0
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

+ 1 - 0
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

+ 1 - 0
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