From f171a2faf088b7dfba8a53aaa497b8a635610211 Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Wed, 21 Jul 2004 11:50:23 +0000 Subject: [PATCH] Fixed something that looked a bit like a bug. Added controlled crashing when VBO creation fails (though it doesn't seem to help at all). This was SVN commit r791. --- source/ps/Errors.cpp | 187 ++++++++++++++++--------------- source/renderer/VertexBuffer.cpp | 39 +++++-- 2 files changed, 127 insertions(+), 99 deletions(-) diff --git a/source/ps/Errors.cpp b/source/ps/Errors.cpp index 7155688b50..cffc3184ea 100755 --- a/source/ps/Errors.cpp +++ b/source/ps/Errors.cpp @@ -5,6 +5,7 @@ #include "Errors.h" class PSERROR_GUI : public PSERROR {}; +class PSERROR_Renderer : public PSERROR {}; class PSERROR_Scripting : public PSERROR {}; class PSERROR_System : public PSERROR {}; class PSERROR_Xeromyces : public PSERROR {}; @@ -14,6 +15,7 @@ class PSERROR_Scripting_LoadFile : public PSERROR_Scripting {}; class PSERROR_GUI_JSOpenFailed : public PSERROR_GUI { public: PSERROR_GUI_JSOpenFailed(); }; class PSERROR_GUI_TextureLoadFailed : public PSERROR_GUI { public: PSERROR_GUI_TextureLoadFailed(); }; +class PSERROR_Renderer_VBOFailed : public PSERROR_Renderer { public: PSERROR_Renderer_VBOFailed(); }; class PSERROR_Scripting_CallFunctionFailed : public PSERROR_Scripting { public: PSERROR_Scripting_CallFunctionFailed(); }; class PSERROR_Scripting_ContextCreationFailed : public PSERROR_Scripting { public: PSERROR_Scripting_ContextCreationFailed(); }; class PSERROR_Scripting_ConversionFailed : public PSERROR_Scripting { public: PSERROR_Scripting_ConversionFailed(); }; @@ -38,111 +40,117 @@ class PSERROR_Xeromyces_XMLParseError : public PSERROR_Xeromyces { public: PSERR extern const PSRETURN PSRETURN_GUI_JSOpenFailed = 0x01000001; extern const PSRETURN PSRETURN_GUI_TextureLoadFailed = 0x01000002; -extern const PSRETURN PSRETURN_Scripting_DefineType_AlreadyExists = 0x02010001; -extern const PSRETURN PSRETURN_Scripting_DefineType_CreationFailed = 0x02010002; -extern const PSRETURN PSRETURN_Scripting_LoadFile_EvalErrors = 0x02020001; -extern const PSRETURN PSRETURN_Scripting_LoadFile_OpenFailed = 0x02020002; -extern const PSRETURN PSRETURN_Scripting_CallFunctionFailed = 0x02000001; -extern const PSRETURN PSRETURN_Scripting_ContextCreationFailed = 0x02000002; -extern const PSRETURN PSRETURN_Scripting_ConversionFailed = 0x02000003; -extern const PSRETURN PSRETURN_Scripting_CreateObjectFailed = 0x02000004; -extern const PSRETURN PSRETURN_Scripting_DefineConstantFailed = 0x02000005; -extern const PSRETURN PSRETURN_Scripting_GlobalObjectCreationFailed = 0x02000006; -extern const PSRETURN PSRETURN_Scripting_NativeFunctionSetupFailed = 0x02000007; -extern const PSRETURN PSRETURN_Scripting_RegisterFunctionFailed = 0x02000008; -extern const PSRETURN PSRETURN_Scripting_RuntimeCreationFailed = 0x02000009; -extern const PSRETURN PSRETURN_Scripting_StandardClassSetupFailed = 0x0200000a; -extern const PSRETURN PSRETURN_Scripting_TypeDoesNotExist = 0x0200000b; -extern const PSRETURN PSRETURN_System_MapLoadFailed = 0x03000001; -extern const PSRETURN PSRETURN_System_RequiredExtensionsMissing = 0x03000002; -extern const PSRETURN PSRETURN_System_SDLInitFailed = 0x03000003; -extern const PSRETURN PSRETURN_System_VmodeFailed = 0x03000004; -extern const PSRETURN PSRETURN_Xeromyces_XMLOpenFailed = 0x04000001; -extern const PSRETURN PSRETURN_Xeromyces_XMLParseError = 0x04000002; +extern const PSRETURN PSRETURN_Renderer_VBOFailed = 0x02000001; +extern const PSRETURN PSRETURN_Scripting_DefineType_AlreadyExists = 0x03010001; +extern const PSRETURN PSRETURN_Scripting_DefineType_CreationFailed = 0x03010002; +extern const PSRETURN PSRETURN_Scripting_LoadFile_EvalErrors = 0x03020001; +extern const PSRETURN PSRETURN_Scripting_LoadFile_OpenFailed = 0x03020002; +extern const PSRETURN PSRETURN_Scripting_CallFunctionFailed = 0x03000001; +extern const PSRETURN PSRETURN_Scripting_ContextCreationFailed = 0x03000002; +extern const PSRETURN PSRETURN_Scripting_ConversionFailed = 0x03000003; +extern const PSRETURN PSRETURN_Scripting_CreateObjectFailed = 0x03000004; +extern const PSRETURN PSRETURN_Scripting_DefineConstantFailed = 0x03000005; +extern const PSRETURN PSRETURN_Scripting_GlobalObjectCreationFailed = 0x03000006; +extern const PSRETURN PSRETURN_Scripting_NativeFunctionSetupFailed = 0x03000007; +extern const PSRETURN PSRETURN_Scripting_RegisterFunctionFailed = 0x03000008; +extern const PSRETURN PSRETURN_Scripting_RuntimeCreationFailed = 0x03000009; +extern const PSRETURN PSRETURN_Scripting_StandardClassSetupFailed = 0x0300000a; +extern const PSRETURN PSRETURN_Scripting_TypeDoesNotExist = 0x0300000b; +extern const PSRETURN PSRETURN_System_MapLoadFailed = 0x04000001; +extern const PSRETURN PSRETURN_System_RequiredExtensionsMissing = 0x04000002; +extern const PSRETURN PSRETURN_System_SDLInitFailed = 0x04000003; +extern const PSRETURN PSRETURN_System_VmodeFailed = 0x04000004; +extern const PSRETURN PSRETURN_Xeromyces_XMLOpenFailed = 0x05000001; +extern const PSRETURN PSRETURN_Xeromyces_XMLParseError = 0x05000002; extern const PSRETURN MASK__PSRETURN_GUI = 0xff000000; extern const PSRETURN CODE__PSRETURN_GUI = 0x01000000; +extern const PSRETURN MASK__PSRETURN_Renderer = 0xff000000; +extern const PSRETURN CODE__PSRETURN_Renderer = 0x02000000; extern const PSRETURN MASK__PSRETURN_Scripting = 0xff000000; -extern const PSRETURN CODE__PSRETURN_Scripting = 0x02000000; +extern const PSRETURN CODE__PSRETURN_Scripting = 0x03000000; extern const PSRETURN MASK__PSRETURN_System = 0xff000000; -extern const PSRETURN CODE__PSRETURN_System = 0x03000000; +extern const PSRETURN CODE__PSRETURN_System = 0x04000000; extern const PSRETURN MASK__PSRETURN_Xeromyces = 0xff000000; -extern const PSRETURN CODE__PSRETURN_Xeromyces = 0x04000000; +extern const PSRETURN CODE__PSRETURN_Xeromyces = 0x05000000; extern const PSRETURN MASK__PSRETURN_Scripting_DefineType = 0xffff0000; -extern const PSRETURN CODE__PSRETURN_Scripting_DefineType = 0x02010000; +extern const PSRETURN CODE__PSRETURN_Scripting_DefineType = 0x03010000; extern const PSRETURN MASK__PSRETURN_Scripting_LoadFile = 0xffff0000; -extern const PSRETURN CODE__PSRETURN_Scripting_LoadFile = 0x02020000; +extern const PSRETURN CODE__PSRETURN_Scripting_LoadFile = 0x03020000; extern const PSRETURN MASK__PSRETURN_GUI_JSOpenFailed = 0xffffffff; extern const PSRETURN CODE__PSRETURN_GUI_JSOpenFailed = 0x01000001; extern const PSRETURN MASK__PSRETURN_GUI_TextureLoadFailed = 0xffffffff; extern const PSRETURN CODE__PSRETURN_GUI_TextureLoadFailed = 0x01000002; +extern const PSRETURN MASK__PSRETURN_Renderer_VBOFailed = 0xffffffff; +extern const PSRETURN CODE__PSRETURN_Renderer_VBOFailed = 0x02000001; extern const PSRETURN MASK__PSRETURN_Scripting_DefineType_AlreadyExists = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_Scripting_DefineType_AlreadyExists = 0x02010001; +extern const PSRETURN CODE__PSRETURN_Scripting_DefineType_AlreadyExists = 0x03010001; extern const PSRETURN MASK__PSRETURN_Scripting_DefineType_CreationFailed = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_Scripting_DefineType_CreationFailed = 0x02010002; +extern const PSRETURN CODE__PSRETURN_Scripting_DefineType_CreationFailed = 0x03010002; extern const PSRETURN MASK__PSRETURN_Scripting_LoadFile_EvalErrors = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_Scripting_LoadFile_EvalErrors = 0x02020001; +extern const PSRETURN CODE__PSRETURN_Scripting_LoadFile_EvalErrors = 0x03020001; extern const PSRETURN MASK__PSRETURN_Scripting_LoadFile_OpenFailed = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_Scripting_LoadFile_OpenFailed = 0x02020002; +extern const PSRETURN CODE__PSRETURN_Scripting_LoadFile_OpenFailed = 0x03020002; extern const PSRETURN MASK__PSRETURN_Scripting_CallFunctionFailed = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_Scripting_CallFunctionFailed = 0x02000001; +extern const PSRETURN CODE__PSRETURN_Scripting_CallFunctionFailed = 0x03000001; extern const PSRETURN MASK__PSRETURN_Scripting_ContextCreationFailed = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_Scripting_ContextCreationFailed = 0x02000002; +extern const PSRETURN CODE__PSRETURN_Scripting_ContextCreationFailed = 0x03000002; extern const PSRETURN MASK__PSRETURN_Scripting_ConversionFailed = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_Scripting_ConversionFailed = 0x02000003; +extern const PSRETURN CODE__PSRETURN_Scripting_ConversionFailed = 0x03000003; extern const PSRETURN MASK__PSRETURN_Scripting_CreateObjectFailed = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_Scripting_CreateObjectFailed = 0x02000004; +extern const PSRETURN CODE__PSRETURN_Scripting_CreateObjectFailed = 0x03000004; extern const PSRETURN MASK__PSRETURN_Scripting_DefineConstantFailed = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_Scripting_DefineConstantFailed = 0x02000005; +extern const PSRETURN CODE__PSRETURN_Scripting_DefineConstantFailed = 0x03000005; extern const PSRETURN MASK__PSRETURN_Scripting_GlobalObjectCreationFailed = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_Scripting_GlobalObjectCreationFailed = 0x02000006; +extern const PSRETURN CODE__PSRETURN_Scripting_GlobalObjectCreationFailed = 0x03000006; extern const PSRETURN MASK__PSRETURN_Scripting_NativeFunctionSetupFailed = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_Scripting_NativeFunctionSetupFailed = 0x02000007; +extern const PSRETURN CODE__PSRETURN_Scripting_NativeFunctionSetupFailed = 0x03000007; extern const PSRETURN MASK__PSRETURN_Scripting_RegisterFunctionFailed = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_Scripting_RegisterFunctionFailed = 0x02000008; +extern const PSRETURN CODE__PSRETURN_Scripting_RegisterFunctionFailed = 0x03000008; extern const PSRETURN MASK__PSRETURN_Scripting_RuntimeCreationFailed = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_Scripting_RuntimeCreationFailed = 0x02000009; +extern const PSRETURN CODE__PSRETURN_Scripting_RuntimeCreationFailed = 0x03000009; extern const PSRETURN MASK__PSRETURN_Scripting_StandardClassSetupFailed = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_Scripting_StandardClassSetupFailed = 0x0200000a; +extern const PSRETURN CODE__PSRETURN_Scripting_StandardClassSetupFailed = 0x0300000a; extern const PSRETURN MASK__PSRETURN_Scripting_TypeDoesNotExist = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_Scripting_TypeDoesNotExist = 0x0200000b; +extern const PSRETURN CODE__PSRETURN_Scripting_TypeDoesNotExist = 0x0300000b; extern const PSRETURN MASK__PSRETURN_System_MapLoadFailed = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_System_MapLoadFailed = 0x03000001; +extern const PSRETURN CODE__PSRETURN_System_MapLoadFailed = 0x04000001; extern const PSRETURN MASK__PSRETURN_System_RequiredExtensionsMissing = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_System_RequiredExtensionsMissing = 0x03000002; +extern const PSRETURN CODE__PSRETURN_System_RequiredExtensionsMissing = 0x04000002; extern const PSRETURN MASK__PSRETURN_System_SDLInitFailed = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_System_SDLInitFailed = 0x03000003; +extern const PSRETURN CODE__PSRETURN_System_SDLInitFailed = 0x04000003; extern const PSRETURN MASK__PSRETURN_System_VmodeFailed = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_System_VmodeFailed = 0x03000004; +extern const PSRETURN CODE__PSRETURN_System_VmodeFailed = 0x04000004; extern const PSRETURN MASK__PSRETURN_Xeromyces_XMLOpenFailed = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_Xeromyces_XMLOpenFailed = 0x04000001; +extern const PSRETURN CODE__PSRETURN_Xeromyces_XMLOpenFailed = 0x05000001; extern const PSRETURN MASK__PSRETURN_Xeromyces_XMLParseError = 0xffffffff; -extern const PSRETURN CODE__PSRETURN_Xeromyces_XMLParseError = 0x04000002; +extern const PSRETURN CODE__PSRETURN_Xeromyces_XMLParseError = 0x05000002; PSERROR_GUI_JSOpenFailed::PSERROR_GUI_JSOpenFailed() { magic=0x45725221; code=0x01000001; } PSERROR_GUI_TextureLoadFailed::PSERROR_GUI_TextureLoadFailed() { magic=0x45725221; code=0x01000002; } -PSERROR_Scripting_DefineType_AlreadyExists::PSERROR_Scripting_DefineType_AlreadyExists() { magic=0x45725221; code=0x02010001; } -PSERROR_Scripting_DefineType_CreationFailed::PSERROR_Scripting_DefineType_CreationFailed() { magic=0x45725221; code=0x02010002; } -PSERROR_Scripting_LoadFile_EvalErrors::PSERROR_Scripting_LoadFile_EvalErrors() { magic=0x45725221; code=0x02020001; } -PSERROR_Scripting_LoadFile_OpenFailed::PSERROR_Scripting_LoadFile_OpenFailed() { magic=0x45725221; code=0x02020002; } -PSERROR_Scripting_CallFunctionFailed::PSERROR_Scripting_CallFunctionFailed() { magic=0x45725221; code=0x02000001; } -PSERROR_Scripting_ContextCreationFailed::PSERROR_Scripting_ContextCreationFailed() { magic=0x45725221; code=0x02000002; } -PSERROR_Scripting_ConversionFailed::PSERROR_Scripting_ConversionFailed() { magic=0x45725221; code=0x02000003; } -PSERROR_Scripting_CreateObjectFailed::PSERROR_Scripting_CreateObjectFailed() { magic=0x45725221; code=0x02000004; } -PSERROR_Scripting_DefineConstantFailed::PSERROR_Scripting_DefineConstantFailed() { magic=0x45725221; code=0x02000005; } -PSERROR_Scripting_GlobalObjectCreationFailed::PSERROR_Scripting_GlobalObjectCreationFailed() { magic=0x45725221; code=0x02000006; } -PSERROR_Scripting_NativeFunctionSetupFailed::PSERROR_Scripting_NativeFunctionSetupFailed() { magic=0x45725221; code=0x02000007; } -PSERROR_Scripting_RegisterFunctionFailed::PSERROR_Scripting_RegisterFunctionFailed() { magic=0x45725221; code=0x02000008; } -PSERROR_Scripting_RuntimeCreationFailed::PSERROR_Scripting_RuntimeCreationFailed() { magic=0x45725221; code=0x02000009; } -PSERROR_Scripting_StandardClassSetupFailed::PSERROR_Scripting_StandardClassSetupFailed() { magic=0x45725221; code=0x0200000a; } -PSERROR_Scripting_TypeDoesNotExist::PSERROR_Scripting_TypeDoesNotExist() { magic=0x45725221; code=0x0200000b; } -PSERROR_System_MapLoadFailed::PSERROR_System_MapLoadFailed() { magic=0x45725221; code=0x03000001; } -PSERROR_System_RequiredExtensionsMissing::PSERROR_System_RequiredExtensionsMissing() { magic=0x45725221; code=0x03000002; } -PSERROR_System_SDLInitFailed::PSERROR_System_SDLInitFailed() { magic=0x45725221; code=0x03000003; } -PSERROR_System_VmodeFailed::PSERROR_System_VmodeFailed() { magic=0x45725221; code=0x03000004; } -PSERROR_Xeromyces_XMLOpenFailed::PSERROR_Xeromyces_XMLOpenFailed() { magic=0x45725221; code=0x04000001; } -PSERROR_Xeromyces_XMLParseError::PSERROR_Xeromyces_XMLParseError() { magic=0x45725221; code=0x04000002; } +PSERROR_Renderer_VBOFailed::PSERROR_Renderer_VBOFailed() { magic=0x45725221; code=0x02000001; } +PSERROR_Scripting_DefineType_AlreadyExists::PSERROR_Scripting_DefineType_AlreadyExists() { magic=0x45725221; code=0x03010001; } +PSERROR_Scripting_DefineType_CreationFailed::PSERROR_Scripting_DefineType_CreationFailed() { magic=0x45725221; code=0x03010002; } +PSERROR_Scripting_LoadFile_EvalErrors::PSERROR_Scripting_LoadFile_EvalErrors() { magic=0x45725221; code=0x03020001; } +PSERROR_Scripting_LoadFile_OpenFailed::PSERROR_Scripting_LoadFile_OpenFailed() { magic=0x45725221; code=0x03020002; } +PSERROR_Scripting_CallFunctionFailed::PSERROR_Scripting_CallFunctionFailed() { magic=0x45725221; code=0x03000001; } +PSERROR_Scripting_ContextCreationFailed::PSERROR_Scripting_ContextCreationFailed() { magic=0x45725221; code=0x03000002; } +PSERROR_Scripting_ConversionFailed::PSERROR_Scripting_ConversionFailed() { magic=0x45725221; code=0x03000003; } +PSERROR_Scripting_CreateObjectFailed::PSERROR_Scripting_CreateObjectFailed() { magic=0x45725221; code=0x03000004; } +PSERROR_Scripting_DefineConstantFailed::PSERROR_Scripting_DefineConstantFailed() { magic=0x45725221; code=0x03000005; } +PSERROR_Scripting_GlobalObjectCreationFailed::PSERROR_Scripting_GlobalObjectCreationFailed() { magic=0x45725221; code=0x03000006; } +PSERROR_Scripting_NativeFunctionSetupFailed::PSERROR_Scripting_NativeFunctionSetupFailed() { magic=0x45725221; code=0x03000007; } +PSERROR_Scripting_RegisterFunctionFailed::PSERROR_Scripting_RegisterFunctionFailed() { magic=0x45725221; code=0x03000008; } +PSERROR_Scripting_RuntimeCreationFailed::PSERROR_Scripting_RuntimeCreationFailed() { magic=0x45725221; code=0x03000009; } +PSERROR_Scripting_StandardClassSetupFailed::PSERROR_Scripting_StandardClassSetupFailed() { magic=0x45725221; code=0x0300000a; } +PSERROR_Scripting_TypeDoesNotExist::PSERROR_Scripting_TypeDoesNotExist() { magic=0x45725221; code=0x0300000b; } +PSERROR_System_MapLoadFailed::PSERROR_System_MapLoadFailed() { magic=0x45725221; code=0x04000001; } +PSERROR_System_RequiredExtensionsMissing::PSERROR_System_RequiredExtensionsMissing() { magic=0x45725221; code=0x04000002; } +PSERROR_System_SDLInitFailed::PSERROR_System_SDLInitFailed() { magic=0x45725221; code=0x04000003; } +PSERROR_System_VmodeFailed::PSERROR_System_VmodeFailed() { magic=0x45725221; code=0x04000004; } +PSERROR_Xeromyces_XMLOpenFailed::PSERROR_Xeromyces_XMLOpenFailed() { magic=0x45725221; code=0x05000001; } +PSERROR_Xeromyces_XMLParseError::PSERROR_Xeromyces_XMLParseError() { magic=0x45725221; code=0x05000002; } const wchar_t* GetErrorString(PSRETURN code) { @@ -150,27 +158,28 @@ const wchar_t* GetErrorString(PSRETURN code) { case 0x01000001: return L"GUI_JSOpenFailed"; break; case 0x01000002: return L"GUI_TextureLoadFailed"; break; - case 0x02010001: return L"Scripting_DefineType_AlreadyExists"; break; - case 0x02010002: return L"Scripting_DefineType_CreationFailed"; break; - case 0x02020001: return L"Scripting_LoadFile_EvalErrors"; break; - case 0x02020002: return L"Scripting_LoadFile_OpenFailed"; break; - case 0x02000001: return L"Scripting_CallFunctionFailed"; break; - case 0x02000002: return L"Scripting_ContextCreationFailed"; break; - case 0x02000003: return L"Scripting_ConversionFailed"; break; - case 0x02000004: return L"Scripting_CreateObjectFailed"; break; - case 0x02000005: return L"Scripting_DefineConstantFailed"; break; - case 0x02000006: return L"Scripting_GlobalObjectCreationFailed"; break; - case 0x02000007: return L"Scripting_NativeFunctionSetupFailed"; break; - case 0x02000008: return L"Scripting_RegisterFunctionFailed"; break; - case 0x02000009: return L"Scripting_RuntimeCreationFailed"; break; - case 0x0200000a: return L"Scripting_StandardClassSetupFailed"; break; - case 0x0200000b: return L"Scripting_TypeDoesNotExist"; break; - case 0x03000001: return L"System_MapLoadFailed"; break; - case 0x03000002: return L"System_RequiredExtensionsMissing"; break; - case 0x03000003: return L"System_SDLInitFailed"; break; - case 0x03000004: return L"System_VmodeFailed"; break; - case 0x04000001: return L"Xeromyces_XMLOpenFailed"; break; - case 0x04000002: return L"Xeromyces_XMLParseError"; break; + case 0x02000001: return L"Renderer_VBOFailed"; break; + case 0x03010001: return L"Scripting_DefineType_AlreadyExists"; break; + case 0x03010002: return L"Scripting_DefineType_CreationFailed"; break; + case 0x03020001: return L"Scripting_LoadFile_EvalErrors"; break; + case 0x03020002: return L"Scripting_LoadFile_OpenFailed"; break; + case 0x03000001: return L"Scripting_CallFunctionFailed"; break; + case 0x03000002: return L"Scripting_ContextCreationFailed"; break; + case 0x03000003: return L"Scripting_ConversionFailed"; break; + case 0x03000004: return L"Scripting_CreateObjectFailed"; break; + case 0x03000005: return L"Scripting_DefineConstantFailed"; break; + case 0x03000006: return L"Scripting_GlobalObjectCreationFailed"; break; + case 0x03000007: return L"Scripting_NativeFunctionSetupFailed"; break; + case 0x03000008: return L"Scripting_RegisterFunctionFailed"; break; + case 0x03000009: return L"Scripting_RuntimeCreationFailed"; break; + case 0x0300000a: return L"Scripting_StandardClassSetupFailed"; break; + case 0x0300000b: return L"Scripting_TypeDoesNotExist"; break; + case 0x04000001: return L"System_MapLoadFailed"; break; + case 0x04000002: return L"System_RequiredExtensionsMissing"; break; + case 0x04000003: return L"System_SDLInitFailed"; break; + case 0x04000004: return L"System_VmodeFailed"; break; + case 0x05000001: return L"Xeromyces_XMLOpenFailed"; break; + case 0x05000002: return L"Xeromyces_XMLParseError"; break; } return L"Unrecognised error"; } diff --git a/source/renderer/VertexBuffer.cpp b/source/renderer/VertexBuffer.cpp index e872036f8f..bfcaedaaa4 100755 --- a/source/renderer/VertexBuffer.cpp +++ b/source/renderer/VertexBuffer.cpp @@ -10,6 +10,10 @@ #include "ogl.h" #include "Renderer.h" #include "VertexBuffer.h" +#include "ps/CLogger.h" + +ERROR_GROUP(Renderer); +ERROR_TYPE(Renderer, VBOFailed); /////////////////////////////////////////////////////////////////////////////// // shared list of all free batch objects @@ -33,9 +37,20 @@ CVertexBuffer::CVertexBuffer(size_t vertexSize,bool dynamic) // allocate raw buffer if (g_Renderer.m_Caps.m_VBO) { + + // TODO: Detect when VBO failed, then fall back to system memory + // (and copy all old VBOs into there, because it needs to be + // consistent). + + glGetError(); // clear the error state + glGenBuffersARB(1,&m_Handle); glBindBufferARB(GL_ARRAY_BUFFER_ARB,m_Handle); + if (glGetError() != GL_NO_ERROR) throw PSERROR_Renderer_VBOFailed(); + glBufferDataARB(GL_ARRAY_BUFFER_ARB,MAX_VB_SIZE_BYTES,0,m_Dynamic ? GL_STREAM_DRAW_ARB : GL_STATIC_DRAW_ARB); + if (glGetError() != GL_NO_ERROR) throw PSERROR_Renderer_VBOFailed(); + } else { m_SysMem=new u8[MAX_VB_SIZE_BYTES]; } @@ -80,8 +95,8 @@ CVertexBuffer::VBChunk* CVertexBuffer::Allocate(size_t vertexSize,size_t numVert VBChunk* chunk=0; typedef std::list::iterator Iter; for (Iter iter=m_FreeList.begin();iter!=m_FreeList.end();++iter) { - chunk=*iter; - if (numVertices<=chunk->m_Count) { + if (numVertices<=(*iter)->m_Count) { + chunk=*iter; // remove this chunk from the free list size_t size1=m_FreeList.size(); m_FreeList.erase(iter); @@ -98,15 +113,17 @@ CVertexBuffer::VBChunk* CVertexBuffer::Allocate(size_t vertexSize,size_t numVert // split chunk into two; - allocate a new chunk using all unused vertices in the // found chunk, and add it to the free list - VBChunk* newchunk=new VBChunk; - newchunk->m_Owner=this; - newchunk->m_Count=chunk->m_Count-numVertices; - newchunk->m_Index=chunk->m_Index+numVertices; - m_FreeList.push_front(newchunk); + if (chunk->m_Count > numVertices) { + VBChunk* newchunk=new VBChunk; + newchunk->m_Owner=this; + newchunk->m_Count=chunk->m_Count-numVertices; + newchunk->m_Index=chunk->m_Index+numVertices; + m_FreeList.push_front(newchunk); - // resize given chunk, resize total available free vertices - chunk->m_Count=numVertices; - m_FreeVertices-=numVertices; + // resize given chunk, resize total available free vertices + chunk->m_Count=numVertices; + m_FreeVertices-=numVertices; + } // return found chunk return chunk; @@ -174,8 +191,10 @@ void CVertexBuffer::UpdateChunkVertices(VBChunk* chunk,void* data) { if (g_Renderer.m_Caps.m_VBO) { assert(m_Handle); + glGetError(); // clear the error state glBindBufferARB(GL_ARRAY_BUFFER_ARB,m_Handle); glBufferSubDataARB(GL_ARRAY_BUFFER_ARB,chunk->m_Index*m_VertexSize,chunk->m_Count*m_VertexSize,data); + if (glGetError() != GL_NO_ERROR) throw PSERROR_Renderer_VBOFailed(); } else { assert(m_SysMem); memcpy(m_SysMem+chunk->m_Index*m_VertexSize,data,chunk->m_Count*m_VertexSize);