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
+1 -1
View File
@@ -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());
-1
View File
@@ -22,7 +22,6 @@
#define LOVE_MODULE_H
// LOVE
#include "runtime.h"
#include "Exception.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
* warranty. In no event will the authors be held liable for any damages
@@ -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"
@@ -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();
}
@@ -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.
@@ -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());
@@ -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 }
};
@@ -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);
@@ -23,6 +23,7 @@
// LOVE
#include "common/config.h"
#include "common/runtime.h"
#include "JoystickModule.h"
namespace love
@@ -22,6 +22,7 @@
#define LOVE_KEYBOARD_WRAP_KEYBOARD_H
// LOVE
#include "common/runtime.h"
#include "Keyboard.h"
namespace love
+1
View File
@@ -22,6 +22,7 @@
#define LOVE_TIMER_WRAP_TIMER_H
// LOVE
#include "common/runtime.h"
#include "Timer.h"
namespace love