diff --git a/misc/opengl/GLCommon.h b/misc/opengl/GLCommon.h index 525db8fc5..9c8b6f0ee 100644 --- a/misc/opengl/GLCommon.h +++ b/misc/opengl/GLCommon.h @@ -106,3 +106,5 @@ typedef cc_uintptr GLpointer; #define GL_COMPILE_STATUS 0x8B81 #define GL_LINK_STATUS 0x8B82 #define GL_INFO_LOG_LENGTH 0x8B84 + +#define GL_OUT_OF_MEMORY 0x0505 diff --git a/src/Game.h b/src/Game.h index 867f59c52..f1b9a7bcc 100644 --- a/src/Game.h +++ b/src/Game.h @@ -39,6 +39,8 @@ extern cc_string Game_Mppass; #if defined CC_BUILD_N64 || defined CC_BUILD_PS1 || defined CC_BUILD_SATURN #define DEFAULT_VIEWDIST 20 +#elif defined CC_BUILD_SYMBIAN + #define DEFAULT_VIEWDIST 64 #elif defined CC_BUILD_NDS #define DEFAULT_VIEWDIST 192 #else diff --git a/src/Graphics_GL1.c b/src/Graphics_GL1.c index c7189dcd5..02a21331c 100644 --- a/src/Graphics_GL1.c +++ b/src/Graphics_GL1.c @@ -146,8 +146,13 @@ void* Gfx_LockVb(GfxResourceID vb, VertexFormat fmt, int count) { return FastAllocTempMem(count * strideSizes[fmt]); } -void Gfx_UnlockVb(GfxResourceID vb) { +static cc_bool UnlockVb(GfxResourceID vb) { _glBufferData(GL_ARRAY_BUFFER, tmpSize, tmpData, GL_STATIC_DRAW); +#if defined CC_BUILD_SYMBIAN + return _glGetError() != GL_OUT_OF_MEMORY; +#else + return true; +#endif } diff --git a/src/Graphics_GL11.c b/src/Graphics_GL11.c index 81226ec37..60a75cc58 100644 --- a/src/Graphics_GL11.c +++ b/src/Graphics_GL11.c @@ -91,8 +91,9 @@ void* Gfx_LockVb(GfxResourceID vb, VertexFormat fmt, int count) { return FastAllocTempMem(count * strideSizes[fmt]); } -void Gfx_UnlockVb(GfxResourceID vb) { +static cc_bool UnlockVb(GfxResourceID vb) { UpdateDisplayList(ptr_to_uint(vb), tmpData, tmpFormat, tmpCount); + return true; } GfxResourceID Gfx_CreateVb2(void* vertices, VertexFormat fmt, int count) { diff --git a/src/Graphics_GL2.c b/src/Graphics_GL2.c index 4eefa9174..1803597e8 100644 --- a/src/Graphics_GL2.c +++ b/src/Graphics_GL2.c @@ -118,8 +118,13 @@ void* Gfx_LockVb(GfxResourceID vb, VertexFormat fmt, int count) { return FastAllocTempMem(count * strideSizes[fmt]); } -void Gfx_UnlockVb(GfxResourceID vb) { +static cc_bool UnlockVb(GfxResourceID vb) { glBufferData(GL_ARRAY_BUFFER, tmpSize, tmpData, GL_STATIC_DRAW); +#if defined CC_BUILD_SYMBIAN + return glGetError() != GL_OUT_OF_MEMORY; +#else + return true; +#endif } diff --git a/src/_GLShared.h b/src/_GLShared.h index 978de97ec..40c2afa65 100644 --- a/src/_GLShared.h +++ b/src/_GLShared.h @@ -419,3 +419,13 @@ void Gfx_SetScissor(int x, int y, int w, int h) { _glScissor(x, Game.Height - h - y, w, h); } + +static cc_bool UnlockVb(GfxResourceID vb); + +void Gfx_UnlockVb(GfxResourceID vb) { + for (;;) { + if (UnlockVb(vb)) return; + + if (!Game_ReduceVRAM()) Process_Abort("Out of video memory! (updating static VB)"); + } +}