Compare commits

...

2 Commits

71 changed files with 464 additions and 462 deletions

2
lib/bc

@ -1 +1 @@
Subproject commit e674242b473f6bbd4cbffbe493ba53ca70c6ae20 Subproject commit 4e116bd69a5d0d0c979ef43cf86cbb8181cc19c1

@ -1 +1 @@
Subproject commit 422bc11d30c6761343877677539dc4704ed8e05d Subproject commit cde3ed90ee64986c1721f7db428e841af518cda0

@ -1 +1 @@
Subproject commit 22e9686d64db308a9b480ecf6e1fba43c2563315 Subproject commit ce9c709029f92dc5b0bed2d3739c5013e4b6b903

@ -1 +1 @@
Subproject commit 53eefc969f054941521a64ddb718d3ceb47c77eb Subproject commit 404f2d22ddfddd148461dc1e801c8823085ff7e3

@ -1 +1 @@
Subproject commit 4cd18ccfd0b507fb686e1260b5d4c00a17c9d785 Subproject commit 0c3ceb876666f7b84dc8d4918eadbbc8e380cd5b

View File

@ -7,7 +7,7 @@
#include <bc/Debug.hpp> #include <bc/Debug.hpp>
void MacOnKeyDown(NSEvent* event) { void MacOnKeyDown(NSEvent* event) {
BLIZZARD_ASSERT(false); BC_ASSERT(false);
} }
void MacOnKeyUp(NSEvent* event) { void MacOnKeyUp(NSEvent* event) {

View File

@ -24,8 +24,7 @@
#include <storm/Error.hpp> #include <storm/Error.hpp>
#include <storm/Log.hpp> #include <storm/Log.hpp>
#include <bc/os/Path.hpp> #include <bc/os/Path.hpp>
#include <bc/file/File.hpp> #include <bc/File.hpp>
CVar* Client::g_accountNameVar; CVar* Client::g_accountNameVar;
CVar* Client::g_accountListVar; CVar* Client::g_accountListVar;

View File

@ -6,9 +6,8 @@
#include "console/Client.hpp" #include "console/Client.hpp"
#include "console/CVar.hpp" #include "console/CVar.hpp"
#include "console/Types.hpp" #include "console/Types.hpp"
#include <storm/Memory.hpp> #include <bc/Memory.hpp>
#include <storm/String.hpp> #include <storm/String.hpp>
#include <new>
ClientConnection* g_clientConnection; ClientConnection* g_clientConnection;
@ -59,19 +58,16 @@ ClientServices* ClientServices::GetInstance() {
return ClientServices::s_instance; return ClientServices::s_instance;
} }
auto m = SMemAlloc(sizeof(ClientServices), __FILE__, __LINE__, 0x0); ClientServices::s_instance = NEW(ClientServices);
auto instance = new (m) ClientServices();
ClientServices::s_instance = instance;
return ClientServices::s_instance; return ClientServices::s_instance;
} }
void ClientServices::SetMessageHandler(NETMESSAGE msgId, MESSAGE_HANDLER handler, void* param) { void ClientServices::SetMessageHandler(NETMESSAGE msgId, MESSAGE_HANDLER handler, void* param) {
STORM_ASSERT(ClientServices::s_currentConnection); STORM_ASSERT(ClientServices::s_currentConnection);
STORM_ASSERT(handler); STORM_ASSERT(handler);
s_currentConnection->SetMessageHandler(msgId, handler, param); s_currentConnection->SetMessageHandler(msgId, handler, param);
} }
void ClientServices::GetRealmList() { void ClientServices::GetRealmList() {
// TODO // TODO
} }
@ -116,13 +112,9 @@ const REALM_INFO* ClientServices::GetSelectedRealm() {
void ClientServices::Initialize() { void ClientServices::Initialize() {
if (!g_clientConnection) { if (!g_clientConnection) {
auto adapterMem = SMemAlloc(sizeof(ClientRealmResponseAdapter), __FILE__, __LINE__, 0x0); ClientServices::s_clientRealmResponse = NEW(ClientRealmResponseAdapter);
auto clientRealmResponse = new (adapterMem) ClientRealmResponseAdapter();
ClientServices::s_clientRealmResponse = clientRealmResponse;
auto connectionMem = SMemAlloc(sizeof(ClientConnection), __FILE__, __LINE__, 0x0); g_clientConnection = NEW(ClientConnection, ClientServices::s_clientRealmResponse);
auto clientConnection = new (connectionMem) ClientConnection(ClientServices::s_clientRealmResponse);
g_clientConnection = clientConnection;
} }
ClientServices::s_currentConnection = g_clientConnection; ClientServices::s_currentConnection = g_clientConnection;
@ -153,8 +145,7 @@ void ClientServices::Logon(const char* accountName, const char* password) {
if (useBattlenet) { if (useBattlenet) {
// TODO // TODO
} else { } else {
auto loginMem = SMemAlloc(sizeof(GruntLogin), __FILE__, __LINE__, 0x0); loginObj = NEW(GruntLogin);
loginObj = new (loginMem) GruntLogin();
} }
ClientServices::s_loginObj = loginObj; ClientServices::s_loginObj = loginObj;

View File

@ -14,6 +14,7 @@ target_include_directories(console
target_link_libraries(console target_link_libraries(console
PUBLIC PUBLIC
bc
common common
gx gx
storm storm

View File

@ -209,7 +209,7 @@ int32_t CVar::Load(HOSFILE file) {
auto grown = 0x1fff < size; auto grown = 0x1fff < size;
int32_t result = 0; int32_t result = 0;
size_t bytesRead = 0; uint32_t bytesRead = 0;
if (OsReadFile(file, data, size, &bytesRead) == 0) { if (OsReadFile(file, data, size, &bytesRead) == 0) {
result = 0; result = 0;

View File

@ -250,7 +250,7 @@ void GenerateNodeString(CONSOLELINE* node) {
auto fontHeight = ConsoleGetFontHeight(); auto fontHeight = ConsoleGetFontHeight();
GxuFontCreateString(font, node->buffer, fontHeight, pos, 1.0f, fontHeight, 0.0f, node->fontPointer, GxVJ_Middle, GxHJ_Left, s_baseTextFlags, s_colorArray[node->colorType], s_charSpacing, 1.0f); GxuFontCreateString(font, node->buffer, fontHeight, pos, 1.0f, fontHeight, 0.0f, node->fontPointer, GxVJ_Middle, GxHJ_Left, s_baseTextFlags, s_colorArray[node->colorType], s_charSpacing, 1.0f);
BLIZZARD_ASSERT(node->fontPointer); BC_ASSERT(node->fontPointer);
} }
} }
@ -313,7 +313,7 @@ void PaintText(void* param, const RECTF* rect, const RECTF* visible, float elaps
void UpdateHighlight() { void UpdateHighlight() {
auto font = TextBlockGetFontPtr(s_textFont); auto font = TextBlockGetFontPtr(s_textFont);
BLIZZARD_ASSERT(font); BC_ASSERT(font);
auto len = SStrLen(s_copyText); auto len = SStrLen(s_copyText);

View File

@ -11,6 +11,7 @@ target_include_directories(db
target_link_libraries(db target_link_libraries(db
PUBLIC PUBLIC
bc
common common
storm storm
) )

View File

@ -1,11 +1,11 @@
#ifndef DB_WOW_CLIENT_DB_HPP #ifndef DB_WOW_CLIENT_DB_HPP
#define DB_WOW_CLIENT_DB_HPP #define DB_WOW_CLIENT_DB_HPP
#include "db/IDatabase.hpp"
#include "db/WowClientDB_Common.hpp"
#include <cstring> #include <cstring>
#include <storm/Error.hpp> #include <storm/Error.hpp>
#include <storm/Memory.hpp> #include <bc/Memory.hpp>
#include "db/IDatabase.hpp"
#include "db/WowClientDB_Common.hpp"
template <class T> template <class T>
class WowClientDB : public WowClientDB_Common<T>, IDatabase<T> { class WowClientDB : public WowClientDB_Common<T>, IDatabase<T> {

View File

@ -42,6 +42,7 @@ target_link_libraries(event
client client
gx gx
PUBLIC PUBLIC
bc
common common
storm storm
tempest tempest

View File

@ -136,12 +136,11 @@ void EventRegister(EVENTID id, EVENTHANDLERFUNC handler) {
} }
void EventRegisterEx(EVENTID id, EVENTHANDLERFUNC handler, void* param, float priority) { void EventRegisterEx(EVENTID id, EVENTHANDLERFUNC handler, void* param, float priority) {
STORM_ASSERT(id >= 0); STORM_VALIDATE_BEGIN;
STORM_VALIDATE(id >= 0, ERROR_INVALID_PARAMETER); STORM_VALIDATE(id >= 0);
STORM_ASSERT(id < EVENTIDS); STORM_VALIDATE(id < EVENTIDS);
STORM_VALIDATE(id < EVENTIDS, ERROR_INVALID_PARAMETER); STORM_VALIDATE(handler);
STORM_ASSERT(handler); STORM_VALIDATE_END_VOID;
STORM_VALIDATE(handler, ERROR_INVALID_PARAMETER);
HEVENTCONTEXT hContext = PropGet(PROP_EVENTCONTEXT); HEVENTCONTEXT hContext = PropGet(PROP_EVENTCONTEXT);

View File

@ -192,8 +192,9 @@ void PostSize(EvtContext* context, int32_t w, int32_t h) {
} }
void ProcessInput(const int32_t param[], OSINPUT id, int32_t* shutdown, EvtContext* context) { void ProcessInput(const int32_t param[], OSINPUT id, int32_t* shutdown, EvtContext* context) {
STORM_ASSERT(context); STORM_VALIDATE_BEGIN;
STORM_VALIDATE(context, ERROR_INVALID_PARAMETER); STORM_VALIDATE(context);
STORM_VALIDATE_END_VOID;
switch (id) { switch (id) {
case OS_INPUT_CAPTURE_CHANGED: case OS_INPUT_CAPTURE_CHANGED:
@ -361,8 +362,9 @@ void ConvertPosition(int32_t clientx, int32_t clienty, float* x, float* y) {
} }
void EventSetMouseMode(MOUSEMODE mode, uint32_t holdButton) { void EventSetMouseMode(MOUSEMODE mode, uint32_t holdButton) {
STORM_ASSERT(mode < MOUSE_MODES); STORM_VALIDATE_BEGIN;
STORM_VALIDATE(mode < MOUSE_MODES, ERROR_INVALID_PARAMETER); STORM_VALIDATE(mode < MOUSE_MODES);
STORM_VALIDATE_END_VOID;
auto contextId = *reinterpret_cast<uint32_t*>(PropGet(PROP_EVENTCONTEXT)); auto contextId = *reinterpret_cast<uint32_t*>(PropGet(PROP_EVENTCONTEXT));
int32_t findMask; int32_t findMask;
@ -468,8 +470,9 @@ void IEvtInputInitialize() {
} }
int32_t IEvtInputProcess(EvtContext* context, int32_t* shutdown) { int32_t IEvtInputProcess(EvtContext* context, int32_t* shutdown) {
STORM_ASSERT(context); STORM_VALIDATE_BEGIN;
STORM_VALIDATE(context, ERROR_INVALID_PARAMETER, 0); STORM_VALIDATE(context);
STORM_VALIDATE_END;
int32_t v4 = 0; int32_t v4 = 0;
OSINPUT id; OSINPUT id;
@ -484,8 +487,9 @@ int32_t IEvtInputProcess(EvtContext* context, int32_t* shutdown) {
} }
void IEvtInputSetMouseMode(EvtContext* context, MOUSEMODE mode, uint32_t holdButton) { void IEvtInputSetMouseMode(EvtContext* context, MOUSEMODE mode, uint32_t holdButton) {
STORM_ASSERT(context); STORM_VALIDATE_BEGIN;
STORM_VALIDATE(context, ERROR_INVALID_PARAMETER); STORM_VALIDATE(context);
STORM_VALIDATE_END;
if ((Input::s_buttonState & holdButton) == holdButton) { if ((Input::s_buttonState & holdButton) == holdButton) {
Input::s_mouseHoldButton = holdButton; Input::s_mouseHoldButton = holdButton;

View File

@ -145,7 +145,9 @@ void IEvtQueueRegister(EvtContext* context, EVENTID id, int32_t (*handler)(const
} }
int32_t IEvtQueueCheckSyncKeyState(EvtContext* context, KEY key) { int32_t IEvtQueueCheckSyncKeyState(EvtContext* context, KEY key) {
STORM_VALIDATE(context, ERROR_INVALID_PARAMETER, 0); STORM_VALIDATE_BEGIN;
STORM_VALIDATE(context);
STORM_VALIDATE_END;
context->m_critsect.Enter(); context->m_critsect.Enter();

View File

@ -12,7 +12,7 @@
#include <common/Call.hpp> #include <common/Call.hpp>
#include <common/Prop.hpp> #include <common/Prop.hpp>
#include <common/Time.hpp> #include <common/Time.hpp>
#include <storm/Memory.hpp> #include <bc/Memory.hpp>
#include <storm/String.hpp> #include <storm/String.hpp>
#include <storm/Thread.hpp> #include <storm/Thread.hpp>
@ -37,8 +37,7 @@ HEVENTCONTEXT IEvtSchedulerCreateContext(int32_t interactive, int32_t (*initiali
callContext = OsCallInitializeContext(contextName); callContext = OsCallInitializeContext(contextName);
} }
auto m = SMemAlloc(sizeof(EvtContext), __FILE__, __LINE__, 0x0); auto context = NEW(EvtContext,
auto context = new (m) EvtContext(
interactive != 0 ? 2 : 0, interactive != 0 ? 2 : 0,
idleTime, idleTime,
interactive != 0 ? 1000 : 1, interactive != 0 ? 1000 : 1,

View File

@ -561,8 +561,9 @@ int32_t OsInputGet(OSINPUT* id, int32_t* param0, int32_t* param1, int32_t* param
} }
void OsInputSetMouseMode(OS_MOUSE_MODE mode) { void OsInputSetMouseMode(OS_MOUSE_MODE mode) {
STORM_ASSERT(mode < OS_MOUSE_MODES); STORM_VALIDATE_BEGIN;
STORM_VALIDATE(mode < OS_MOUSE_MODES, ERROR_INVALID_PARAMETER); STORM_VALIDATE(mode < OS_MOUSE_MODES);
STORM_VALIDATE_END_VOID;
if (Input::s_osMouseMode == mode) { if (Input::s_osMouseMode == mode) {
return; return;

View File

@ -2,7 +2,7 @@
#include "gx/Transform.hpp" #include "gx/Transform.hpp"
#include <storm/Memory.hpp> #include <bc/Memory.hpp>
#include <tempest/Matrix.hpp> #include <tempest/Matrix.hpp>

View File

@ -22,6 +22,7 @@ target_link_libraries(gameui
ui ui
util util
PUBLIC PUBLIC
bc
common common
storm storm
tempest tempest

View File

@ -22,5 +22,6 @@ target_link_libraries(glue
ui ui
util util
PUBLIC PUBLIC
bc
storm storm
) )

View File

@ -2,8 +2,7 @@
#include "client/ClientServices.hpp" #include "client/ClientServices.hpp"
#include "db/Db.hpp" #include "db/Db.hpp"
#include "ui/FrameScript.hpp" #include "ui/FrameScript.hpp"
#include <new> #include <bc/Memory.hpp>
#include <storm/Memory.hpp>
#include <storm/String.hpp> #include <storm/String.hpp>
float CRealmList::s_avgLoad; float CRealmList::s_avgLoad;
@ -15,8 +14,7 @@ void CRealmList::Initialize() {
CRealmList::s_categories.SetCount(g_cfg_CategoriesDB.GetNumRecords()); CRealmList::s_categories.SetCount(g_cfg_CategoriesDB.GetNumRecords());
for (int32_t i = 0; i < g_cfg_CategoriesDB.GetNumRecords(); i++) { for (int32_t i = 0; i < g_cfg_CategoriesDB.GetNumRecords(); i++) {
auto m = SMemAlloc(sizeof(RealmCategory), __FILE__, __LINE__, 0x0); auto category = NEW(RealmCategory);
auto category = new (m) RealmCategory();
CRealmList::s_categories[i] = category; CRealmList::s_categories[i] = category;
CRealmList::s_categories[i]->m_category = g_cfg_CategoriesDB.GetRecordByIndex(i); CRealmList::s_categories[i]->m_category = g_cfg_CategoriesDB.GetRecordByIndex(i);

View File

@ -353,7 +353,7 @@ void GxPrimVertexPtr(uint32_t vertexCount, const C3Vector* pos, uint32_t posStri
} }
void GxPrimLockVertexPtrs(uint32_t vertexCount, const C3Vector* pos, uint32_t posStride, const C3Vector* normal, uint32_t normalStride, const CImVector* color, uint32_t colorStride, const uint8_t* bone, uint32_t boneStride, const C2Vector* tex0, uint32_t tex0Stride, const C2Vector* tex1, uint32_t tex1Stride) { void GxPrimLockVertexPtrs(uint32_t vertexCount, const C3Vector* pos, uint32_t posStride, const C3Vector* normal, uint32_t normalStride, const CImVector* color, uint32_t colorStride, const uint8_t* bone, uint32_t boneStride, const C2Vector* tex0, uint32_t tex0Stride, const C2Vector* tex1, uint32_t tex1Stride) {
BLIZZARD_ASSERT(Buffer::s_lockVertexCount == 0); BC_ASSERT(Buffer::s_lockVertexCount == 0);
Buffer::s_lockVertexCount = vertexCount; Buffer::s_lockVertexCount = vertexCount;
GxPrimVertexPtr(vertexCount, pos, posStride, normal, normalStride, color, colorStride, tex0, tex0Stride, tex1, tex1Stride); GxPrimVertexPtr(vertexCount, pos, posStride, normal, normalStride, color, colorStride, tex0, tex0Stride, tex1, tex1Stride);

View File

@ -15,7 +15,7 @@
#include <limits> #include <limits>
#include <new> #include <new>
#include <storm/Error.hpp> #include <storm/Error.hpp>
#include <storm/Memory.hpp> #include <bc/Memory.hpp>
#if defined(WHOA_SYSTEM_WIN) #if defined(WHOA_SYSTEM_WIN)
#include "gx/d3d/CGxDeviceD3d.hpp" #include "gx/d3d/CGxDeviceD3d.hpp"
@ -124,8 +124,7 @@ void CGxDevice::Log(const CGxFormat& format) {
#if defined(WHOA_SYSTEM_WIN) #if defined(WHOA_SYSTEM_WIN)
CGxDevice* CGxDevice::NewD3d() { CGxDevice* CGxDevice::NewD3d() {
auto m = SMemAlloc(sizeof(CGxDeviceD3d), __FILE__, __LINE__, 0x0); return NEW(CGxDeviceD3d);
return new (m) CGxDeviceD3d();
} }
CGxDevice* CGxDevice::NewD3d9Ex() { CGxDevice* CGxDevice::NewD3d9Ex() {
@ -136,8 +135,7 @@ CGxDevice* CGxDevice::NewD3d9Ex() {
#if defined(WHOA_SYSTEM_MAC) #if defined(WHOA_SYSTEM_MAC)
CGxDevice* CGxDevice::NewGLL() { CGxDevice* CGxDevice::NewGLL() {
auto m = SMemAlloc(sizeof(CGxDeviceGLL), __FILE__, __LINE__, 0x0); return NEW(CGxDeviceGLL);
return new (m) CGxDeviceGLL();
} }
#endif #endif
@ -147,8 +145,7 @@ CGxDevice* CGxDevice::NewOpenGl() {
#if defined(WHOA_BUILD_GLSDL) #if defined(WHOA_BUILD_GLSDL)
CGxDevice* CGxDevice::NewGLSDL() { CGxDevice* CGxDevice::NewGLSDL() {
auto m = SMemAlloc(sizeof(CGxDeviceGLSDL), __FILE__, __LINE__, 0x0); return NEW(CGxDeviceGLSDL);
return new (m) CGxDeviceGLSDL();
} }
#endif #endif
@ -190,8 +187,7 @@ CGxDevice::CGxDevice() {
} }
CGxBuf* CGxDevice::BufCreate(CGxPool* pool, uint32_t itemSize, uint32_t itemCount, uint32_t index) { CGxBuf* CGxDevice::BufCreate(CGxPool* pool, uint32_t itemSize, uint32_t itemCount, uint32_t index) {
auto m = SMemAlloc(sizeof(CGxBuf), __FILE__, __LINE__, 0x0); auto buf = NEW(CGxBuf, pool, itemSize, itemCount, index);
auto buf = new (m) CGxBuf(pool, itemSize, itemCount, index);
pool->m_bufList.LinkToTail(buf); pool->m_bufList.LinkToTail(buf);
@ -904,8 +900,7 @@ void CGxDevice::PrimVertexPtr(CGxBuf* buf, EGxVertexBufferFormat format) {
} }
CGxPool* CGxDevice::PoolCreate(EGxPoolTarget target, EGxPoolUsage usage, uint32_t size, EGxPoolHintBits hint, const char* name) { CGxPool* CGxDevice::PoolCreate(EGxPoolTarget target, EGxPoolUsage usage, uint32_t size, EGxPoolHintBits hint, const char* name) {
auto m = SMemAlloc(sizeof(CGxPool), __FILE__, __LINE__, 0x0); auto pool = NEW(CGxPool, target, usage, size, hint, name);
auto pool = new (m) CGxPool(target, usage, size, hint, name);
this->m_poolList.LinkToTail(pool); this->m_poolList.LinkToTail(pool);
@ -1160,8 +1155,7 @@ void CGxDevice::ShaderCreate(CGxShader* shaders[], EGxShTarget target, const cha
} }
int32_t CGxDevice::TexCreate(EGxTexTarget target, uint32_t width, uint32_t height, uint32_t depth, EGxTexFormat format, EGxTexFormat dataFormat, CGxTexFlags flags, void* userArg, void (*userFunc)(EGxTexCommand, uint32_t, uint32_t, uint32_t, uint32_t, void*, uint32_t&, const void*&), const char* name, CGxTex*& texId) { int32_t CGxDevice::TexCreate(EGxTexTarget target, uint32_t width, uint32_t height, uint32_t depth, EGxTexFormat format, EGxTexFormat dataFormat, CGxTexFlags flags, void* userArg, void (*userFunc)(EGxTexCommand, uint32_t, uint32_t, uint32_t, uint32_t, void*, uint32_t&, const void*&), const char* name, CGxTex*& texId) {
auto m = SMemAlloc(sizeof(CGxTex), __FILE__, __LINE__, 0); auto tex = NEW(CGxTex,
auto tex = new (m) CGxTex(
target, target,
width, width,
height, height,
@ -1185,9 +1179,7 @@ int32_t CGxDevice::TexCreate(EGxTexTarget target, uint32_t width, uint32_t heigh
void CGxDevice::TexDestroy(CGxTex* texId) { void CGxDevice::TexDestroy(CGxTex* texId) {
// TODO // TODO
if (texId) { DEL(texId);
delete texId;
}
} }
void CGxDevice::TexMarkForUpdate(CGxTex* texId, const CiRect& updateRect, int32_t immediate) { void CGxDevice::TexMarkForUpdate(CGxTex* texId, const CiRect& updateRect, int32_t immediate) {

View File

@ -42,8 +42,9 @@ CGxDevice* GxDevCreate(EGxApi api, int32_t (*windowProc)(void* window, uint32_t
break; break;
} }
if (device == nullptr) { if (!device) {
STORM_PANIC("GxDevCreate: failed to create graphics device %d", api); SErrPrepareAppFatal(__FILE__, __LINE__);
SErrDisplayAppFatal("GxDevCreate: failed to create graphics device %d", api);
} }
// STORM_ASSERT(device != nullptr); // STORM_ASSERT(device != nullptr);

View File

@ -21,7 +21,7 @@ void GxDrawLockedElements(EGxPrim primType, uint32_t indexCount, const uint16_t*
batch.m_start = 0; batch.m_start = 0;
batch.m_count = indexCount; batch.m_count = indexCount;
BLIZZARD_ASSERT(batch.m_count > 0); BC_ASSERT(batch.m_count > 0);
g_theGxDevicePtr->Draw(&batch, 1); g_theGxDevicePtr->Draw(&batch, 1);
} }

View File

@ -10,9 +10,8 @@
#include "gx/Shader.hpp" #include "gx/Shader.hpp"
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
#include <new> #include <bc/Memory.hpp>
#include <storm/Error.hpp> #include <storm/Error.hpp>
#include <storm/Memory.hpp>
#include <storm/String.hpp> #include <storm/String.hpp>
#include <storm/Unicode.hpp> #include <storm/Unicode.hpp>
#include <tempest/Math.hpp> #include <tempest/Math.hpp>
@ -247,8 +246,7 @@ CGxStringBatch* GxuFontCreateBatch(bool a1, bool a2) {
batch = s_unusedBatches.Head(); batch = s_unusedBatches.Head();
s_unusedBatches.UnlinkNode(batch); s_unusedBatches.UnlinkNode(batch);
} else { } else {
auto m = SMemAlloc(sizeof(CGxStringBatch), __FILE__, __LINE__, 0x8); batch = NEW_ZERO(CGxStringBatch);
batch = new (m) CGxStringBatch();
} }
if (a1) { if (a1) {
@ -679,7 +677,7 @@ int32_t IGxuFontGlyphRenderGlyph(FT_Face face, uint32_t pixelHeight, uint32_t co
dummyGlyph = 1; dummyGlyph = 1;
} }
void* data = SMemAlloc(dataSize, __FILE__, __LINE__, 0x0); void* data = ALLOC(dataSize);
if (data) { if (data) {
memset(data, 0, dataSize); memset(data, 0, dataSize);
@ -737,6 +735,7 @@ float ScreenToPixelWidth(int32_t billboarded, float width) {
return CMath::fint_n(pixelCoords); return CMath::fint_n(pixelCoords);
} }
// TODO: name this
float Sub6C2280(FT_Face face, float height) { float Sub6C2280(FT_Face face, float height) {
int32_t numFixedSizes = face->num_fixed_sizes; int32_t numFixedSizes = face->num_fixed_sizes;
@ -774,8 +773,7 @@ HTEXTBLOCK TextBlockCreate(HTEXTFONT font, const char* text, const CImVector& co
STORM_ASSERT(font); STORM_ASSERT(font);
STORM_ASSERT(text); STORM_ASSERT(text);
auto m = SMemAlloc(sizeof(TEXTBLOCK), __FILE__, __LINE__, 0x0); auto textBlock = NEW(TEXTBLOCK);
auto textBlock = new (m) TEXTBLOCK();
C3Vector position = { 0.0f, 0.0f, pos.z }; C3Vector position = { 0.0f, 0.0f, pos.z };
DDCToNDC(pos.x, pos.y, &position.x, &position.y); DDCToNDC(pos.x, pos.y, &position.x, &position.y);

View File

@ -7,9 +7,8 @@
#include "util/SFile.hpp" #include "util/SFile.hpp"
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
#include <new> #include <bc/Memory.hpp>
#include <storm/Error.hpp> #include <storm/Error.hpp>
#include <storm/Memory.hpp>
#include <storm/String.hpp> #include <storm/String.hpp>
namespace Texture { namespace Texture {
@ -805,7 +804,7 @@ CTexture* CreateBlpSync(int32_t createFlags, char* fileName, char* fileExt, CGxT
size_t fileSize = SFile::GetFileSize(file, 0); size_t fileSize = SFile::GetFileSize(file, 0);
void* buf = SMemAlloc(fileSize, __FILE__, __LINE__, 0); void* buf = ALLOC(fileSize);
if (!SFile::Read(file, buf, fileSize, nullptr, nullptr, nullptr)) { if (!SFile::Read(file, buf, fileSize, nullptr, nullptr, nullptr)) {
// nullsub_3(); // nullsub_3();
@ -817,7 +816,7 @@ CTexture* CreateBlpSync(int32_t createFlags, char* fileName, char* fileExt, CGxT
SFile::Close(file); SFile::Close(file);
SMemFree(buf, __FILE__, __LINE__, 0); FREE(buf);
return texture; return texture;
} }
@ -979,8 +978,7 @@ HTEXTURE TextureCreate(uint32_t width, uint32_t height, EGxTexFormat format, EGx
} }
HTEXTURE TextureCreate(EGxTexTarget target, uint32_t width, uint32_t height, uint32_t depth, EGxTexFormat format, EGxTexFormat dataFormat, CGxTexFlags texFlags, void* userArg, TEXTURE_CALLBACK* userFunc, const char* a10, int32_t a11) { HTEXTURE TextureCreate(EGxTexTarget target, uint32_t width, uint32_t height, uint32_t depth, EGxTexFormat format, EGxTexFormat dataFormat, CGxTexFlags texFlags, void* userArg, TEXTURE_CALLBACK* userFunc, const char* a10, int32_t a11) {
auto m = SMemAlloc(sizeof(CTexture), __FILE__, __LINE__, 0x0); auto texture = NEW(CTexture);
auto texture = new (m) CTexture();
if (a11) { if (a11) {
texFlags.m_filter = CTexture::s_filterMode; texFlags.m_filter = CTexture::s_filterMode;
@ -1010,8 +1008,7 @@ HTEXTURE TextureCreateSolid(const CImVector& color) {
return textureHandle; return textureHandle;
} }
auto m = SMemAlloc(sizeof(CTexture), __FILE__, __LINE__, 0x0); auto texture = NEW(CTexture);
auto texture = new (m) CTexture();
FillInSolidTexture(color, texture); FillInSolidTexture(color, texture);
textureHandle = HandleCreate(texture); textureHandle = HandleCreate(texture);

View File

@ -6,8 +6,7 @@
#include "gx/Gx.hpp" #include "gx/Gx.hpp"
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
#include <new> #include <bc/Memory.hpp>
#include <storm/Memory.hpp>
#include <storm/String.hpp> #include <storm/String.hpp>
#include <tempest/Math.hpp> #include <tempest/Math.hpp>
@ -15,16 +14,13 @@ TEXTLINETEXTURE* TEXTLINETEXTURE::NewTextLineTexture() {
// TODO // TODO
// Allocate off of TEXTLINETEXTURE::s_freeTextLineTextures // Allocate off of TEXTLINETEXTURE::s_freeTextLineTextures
auto m = SMemAlloc(sizeof(TEXTLINETEXTURE), __FILE__, __LINE__, 0x0); return NEW(TEXTLINETEXTURE);
return new (m) TEXTLINETEXTURE();
} }
void TEXTLINETEXTURE::Recycle(TEXTLINETEXTURE* ptr) { void TEXTLINETEXTURE::Recycle(TEXTLINETEXTURE* ptr) {
// TODO if (TEXTLINETEXTURE::s_recycledBytes <= 0x80000) // TODO if (TEXTLINETEXTURE::s_recycledBytes <= 0x80000)
if (ptr) { DEL(ptr);
delete ptr;
}
} }
void TEXTLINETEXTURE::WriteGeometry(CGxVertexPCT* buf, const CImVector& fontColor, const C2Vector& shadowOffset, const CImVector& shadowColor, const C3Vector& viewTranslation, bool a7, bool a8, int32_t ofs, int32_t size) { void TEXTLINETEXTURE::WriteGeometry(CGxVertexPCT* buf, const CImVector& fontColor, const C2Vector& shadowOffset, const CImVector& shadowColor, const C3Vector& viewTranslation, bool a7, bool a8, int32_t ofs, int32_t size) {
@ -118,8 +114,7 @@ CGxString* CGxString::GetNewString(int32_t linkOnList) {
return string; return string;
} }
auto m = SMemAlloc(sizeof(CGxString), __FILE__, __LINE__, 0x8); string = NEW_ZERO(CGxString);
string = new (m) CGxString();
if (linkOnList) { if (linkOnList) {
g_strings.LinkToTail(string); g_strings.LinkToTail(string);
@ -331,11 +326,11 @@ int32_t CGxString::Initialize(float fontHeight, const C3Vector& position, float
uint32_t textLen = SStrLen(text) + 1; uint32_t textLen = SStrLen(text) + 1;
if (textLen > this->m_textLen) { if (textLen > this->m_textLen) {
if (this->m_text) { if (this->m_text) {
SMemFree(this->m_text, __FILE__, __LINE__, 0x0); FREE(this->m_text);
} }
this->m_textLen = textLen; this->m_textLen = textLen;
this->m_text = static_cast<char*>(SMemAlloc(textLen, __FILE__, __LINE__, 0x0)); this->m_text = static_cast<char*>(ALLOC(textLen));
} }
SStrCopy(this->m_text, text, this->m_textLen); SStrCopy(this->m_text, text, this->m_textLen);

View File

@ -1,5 +1,5 @@
#include "gx/font/FreeTypeInternal.hpp" #include "gx/font/FreeTypeInternal.hpp"
#include <storm/Memory.hpp> #include <bc/Memory.hpp>
void* FreeTypeAllocFunction(FT_Memory memory, long size) { void* FreeTypeAllocFunction(FT_Memory memory, long size) {
return SMemAlloc(size, __FILE__, __LINE__, 0); return SMemAlloc(size, __FILE__, __LINE__, 0);

View File

@ -586,7 +586,7 @@ void CGxDeviceGLL::IRsSendToHw(EGxRenderState which) {
int32_t mode = static_cast<int32_t>(state->m_value); int32_t mode = static_cast<int32_t>(state->m_value);
// TODO // TODO
// BLIZZARD_ASSERT(mode <= GxCullState_CCW); // BC_ASSERT(mode <= GxCullState_CCW);
this->m_glDevice.SetCullMode(cullMode[mode]); this->m_glDevice.SetCullMode(cullMode[mode]);
@ -720,7 +720,7 @@ void CGxDeviceGLL::IShaderBindPixel(CGxShader* sh) {
this->IShaderCreatePixel(sh); this->IShaderCreatePixel(sh);
} }
BLIZZARD_ASSERT(sh->Valid()); BC_ASSERT(sh->Valid());
this->m_glDevice.SetShader(GLShader::ePixelShader, static_cast<GLShader*>(sh->apiSpecific)); this->m_glDevice.SetShader(GLShader::ePixelShader, static_cast<GLShader*>(sh->apiSpecific));
} }
@ -737,7 +737,7 @@ void CGxDeviceGLL::IShaderBindVertex(CGxShader* sh) {
this->IShaderCreateVertex(sh); this->IShaderCreateVertex(sh);
} }
BLIZZARD_ASSERT(sh->Valid()); BC_ASSERT(sh->Valid());
this->m_glDevice.SetShader(GLShader::eVertexShader, static_cast<GLShader*>(sh->apiSpecific)); this->m_glDevice.SetShader(GLShader::eVertexShader, static_cast<GLShader*>(sh->apiSpecific));
} }
@ -779,7 +779,7 @@ void CGxDeviceGLL::IShaderCreate(CGxShader* sh) {
} }
void CGxDeviceGLL::IShaderCreatePixel(CGxShader* ps) { void CGxDeviceGLL::IShaderCreatePixel(CGxShader* ps) {
BLIZZARD_ASSERT(!ps->loaded); BC_ASSERT(!ps->loaded);
ps->loaded = 1; ps->loaded = 1;
ps->valid = 0; ps->valid = 0;
@ -805,7 +805,7 @@ void CGxDeviceGLL::IShaderCreatePixel(CGxShader* ps) {
} }
void CGxDeviceGLL::IShaderCreateVertex(CGxShader* vs) { void CGxDeviceGLL::IShaderCreateVertex(CGxShader* vs) {
BLIZZARD_ASSERT(!vs->loaded); BC_ASSERT(!vs->loaded);
vs->loaded = 1; vs->loaded = 1;
vs->valid = 0; vs->valid = 0;
@ -1067,7 +1067,7 @@ void CGxDeviceGLL::ITexUpload(CGxTex* texId) {
texels texels
); );
BLIZZARD_ASSERT(texels != nullptr || texId->m_flags.m_renderTarget); BC_ASSERT(texels != nullptr || texId->m_flags.m_renderTarget);
if (!texId->m_flags.m_renderTarget) { if (!texId->m_flags.m_renderTarget) {
GLMipmap* mipmap = static_cast<GLTexture*>(texId->m_apiSpecificData)->GetMipmap(mipLevel - baseMip, CGxDeviceGLL::s_glCubeMapFaces[face]); GLMipmap* mipmap = static_cast<GLTexture*>(texId->m_apiSpecificData)->GetMipmap(mipLevel - baseMip, CGxDeviceGLL::s_glCubeMapFaces[face]);
@ -1082,8 +1082,8 @@ void CGxDeviceGLL::ITexUpload(CGxTex* texId) {
lockRect.maxY = std::min(lockRect.maxY, static_cast<int32_t>(height)); lockRect.maxY = std::min(lockRect.maxY, static_cast<int32_t>(height));
lockRect.maxX = std::min(lockRect.maxX, static_cast<int32_t>(width)); lockRect.maxX = std::min(lockRect.maxX, static_cast<int32_t>(width));
BLIZZARD_ASSERT(lockRect.minX >= 0 && lockRect.maxX <= static_cast<int32_t>(width)); BC_ASSERT(lockRect.minX >= 0 && lockRect.maxX <= static_cast<int32_t>(width));
BLIZZARD_ASSERT(lockRect.minY >= 0 && lockRect.maxY <= static_cast<int32_t>(height)); BC_ASSERT(lockRect.minY >= 0 && lockRect.maxY <= static_cast<int32_t>(height));
GLRect rect = { GLRect rect = {
lockRect.minX, lockRect.minX,
@ -1326,7 +1326,7 @@ int32_t CGxDeviceGLL::StereoEnabled() {
} }
void CGxDeviceGLL::TexDestroy(CGxTex* texId) { void CGxDeviceGLL::TexDestroy(CGxTex* texId) {
BLIZZARD_ASSERT(texId); BC_ASSERT(texId);
auto texture = static_cast<GLTexture*>(texId->m_apiSpecificData); auto texture = static_cast<GLTexture*>(texId->m_apiSpecificData);

View File

@ -52,10 +52,10 @@ GLBuffer::GLBuffer() : GLObject() {
} }
char* GLBuffer::Map(uint32_t offset, uint32_t size, eMapFlag flag) { char* GLBuffer::Map(uint32_t offset, uint32_t size, eMapFlag flag) {
BLIZZARD_ASSERT((offset + size) <= this->m_Size); BC_ASSERT((offset + size) <= this->m_Size);
BLIZZARD_ASSERT(this->m_Usage == GL_STATIC_DRAW || flag != GLMap_None); BC_ASSERT(this->m_Usage == GL_STATIC_DRAW || flag != GLMap_None);
BLIZZARD_ASSERT(this->m_MapFlag == GLMap_NotMapped); BC_ASSERT(this->m_MapFlag == GLMap_NotMapped);
BLIZZARD_ASSERT(flag >= GLMap_None && flag < GLMap_Count); BC_ASSERT(flag >= GLMap_None && flag < GLMap_Count);
this->m_MapOffset = offset; this->m_MapOffset = offset;
this->m_MapSize = offset + size == 0 ? this->m_Size : size; this->m_MapSize = offset + size == 0 ? this->m_Size : size;
@ -67,7 +67,7 @@ char* GLBuffer::Map(uint32_t offset, uint32_t size, eMapFlag flag) {
if (flag == GLMap_Unk2) { if (flag == GLMap_Unk2) {
if (this->m_Usage - GL_DYNAMIC_DRAW <= 1) { if (this->m_Usage - GL_DYNAMIC_DRAW <= 1) {
BLIZZARD_ASSERT(offset == 0); BC_ASSERT(offset == 0);
} }
glBufferData(this->m_Type, this->m_Size, nullptr, this->m_Usage); glBufferData(this->m_Type, this->m_Size, nullptr, this->m_Usage);
@ -76,7 +76,7 @@ char* GLBuffer::Map(uint32_t offset, uint32_t size, eMapFlag flag) {
void* data = glMapBuffer(this->m_Type, GLBuffer::s_FlagToAccess[flag]); void* data = glMapBuffer(this->m_Type, GLBuffer::s_FlagToAccess[flag]);
this->m_Data = reinterpret_cast<char*>(data); this->m_Data = reinterpret_cast<char*>(data);
BLIZZARD_ASSERT(this->m_Data != nullptr); BC_ASSERT(this->m_Data != nullptr);
} }
return this->m_Data + offset; return this->m_Data + offset;
@ -103,7 +103,7 @@ void GLBuffer::ReleaseObject() {
} }
void GLBuffer::Unmap(uint32_t size) { void GLBuffer::Unmap(uint32_t size) {
BLIZZARD_ASSERT((this->m_MapOffset + size) <= m_Size); BC_ASSERT((this->m_MapOffset + size) <= m_Size);
GLDevice* device = GLDevice::Get(); GLDevice* device = GLDevice::Get();
device->BindBuffer(this, GL_ZERO); device->BindBuffer(this, GL_ZERO);
@ -123,7 +123,7 @@ void GLBuffer::Unmap(uint32_t size) {
} }
GLboolean result = glUnmapBuffer(this->m_Type); GLboolean result = glUnmapBuffer(this->m_Type);
BLIZZARD_ASSERT(result); BC_ASSERT(result);
this->m_MapFlag = GLMap_NotMapped; this->m_MapFlag = GLMap_NotMapped;
} }

View File

@ -121,7 +121,7 @@ bool GLContext::IsCurrentContext() {
} }
void GLContext::MakeCurrent(bool a2) { void GLContext::MakeCurrent(bool a2) {
BLIZZARD_ASSERT(this->m_Context->context != nullptr); BC_ASSERT(this->m_Context->context != nullptr);
if (a2) { if (a2) {
NSOpenGLContext* v6 = GLContext::GetNSOpenGLCurrentContext(); NSOpenGLContext* v6 = GLContext::GetNSOpenGLCurrentContext();
@ -213,17 +213,17 @@ void GLContext::SetContextFormat(GLTextureFormat a2, uint32_t sampleCount) {
break; break;
default: default:
BLIZZARD_ASSERT(false); BC_ASSERT(false);
break; break;
} }
if (sampleCount > 1) { if (sampleCount > 1) {
BLIZZARD_ASSERT(sampleCount % 2 == 0); BC_ASSERT(sampleCount % 2 == 0);
BLIZZARD_ASSERT(formatAttributes[13] == 0); BC_ASSERT(formatAttributes[13] == 0);
BLIZZARD_ASSERT(formatAttributes[14] == 0); BC_ASSERT(formatAttributes[14] == 0);
BLIZZARD_ASSERT(formatAttributes[15] == 0); BC_ASSERT(formatAttributes[15] == 0);
BLIZZARD_ASSERT(formatAttributes[16] == 0); BC_ASSERT(formatAttributes[16] == 0);
BLIZZARD_ASSERT(formatAttributes[17] == 0); BC_ASSERT(formatAttributes[17] == 0);
formatAttributes[13] = NSOpenGLPFASampleBuffers; formatAttributes[13] = NSOpenGLPFASampleBuffers;
formatAttributes[14] = 1; formatAttributes[14] = 1;
@ -237,14 +237,14 @@ void GLContext::SetContextFormat(GLTextureFormat a2, uint32_t sampleCount) {
initWithAttributes: formatAttributes initWithAttributes: formatAttributes
]; ];
BLIZZARD_ASSERT(context.pixelFormat != nullptr); BC_ASSERT(context.pixelFormat != nullptr);
context.context = [[NSOpenGLContext alloc] context.context = [[NSOpenGLContext alloc]
initWithFormat: context.pixelFormat initWithFormat: context.pixelFormat
shareContext: GLContext::s_MainContext shareContext: GLContext::s_MainContext
]; ];
BLIZZARD_ASSERT(context.context != nullptr); BC_ASSERT(context.context != nullptr);
this->m_Context = &context; this->m_Context = &context;
@ -256,7 +256,7 @@ void GLContext::SetContextFormat(GLTextureFormat a2, uint32_t sampleCount) {
auto result = this->m_MTGLEnabled auto result = this->m_MTGLEnabled
? CGLEnable(contextObj, kCGLCEMPEngine) ? CGLEnable(contextObj, kCGLCEMPEngine)
: CGLDisable(contextObj, kCGLCEMPEngine); : CGLDisable(contextObj, kCGLCEMPEngine);
BLIZZARD_ASSERT(result == kCGLNoError); BC_ASSERT(result == kCGLNoError);
if (this->m_Window) { if (this->m_Window) {
this->m_Window->SetOpenGLContext(this); this->m_Window->SetOpenGLContext(this);

View File

@ -157,7 +157,7 @@ void GLDevice::SetOption(GLDeviceOption option, bool enable) {
} }
default: { default: {
BLIZZARD_ASSERT(false); BC_ASSERT(false);
} }
} }
} }
@ -993,8 +993,8 @@ void GLDevice::ApplyTransforms() {
} }
void GLDevice::BindBuffer(GLBuffer* buffer, GLEnum target) { void GLDevice::BindBuffer(GLBuffer* buffer, GLEnum target) {
BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); BC_ASSERT(this->m_Context.IsCurrentContext());
BLIZZARD_ASSERT(buffer != nullptr || target != GL_ZERO); BC_ASSERT(buffer != nullptr || target != GL_ZERO);
GLEnum bindTarget = target == GL_ZERO ? buffer->m_Type : target; GLEnum bindTarget = target == GL_ZERO ? buffer->m_Type : target;
GLuint bindName = buffer == nullptr ? 0 : buffer->m_BufferID; GLuint bindName = buffer == nullptr ? 0 : buffer->m_BufferID;
@ -1010,7 +1010,7 @@ void GLDevice::BindBuffer(GLBuffer* buffer, GLEnum target) {
} else if (bindTarget == GL_PIXEL_UNPACK_BUFFER) { } else if (bindTarget == GL_PIXEL_UNPACK_BUFFER) {
bindIndex = 3; bindIndex = 3;
} else { } else {
BLIZZARD_ASSERT(false); BC_ASSERT(false);
} }
if (bindTarget == GL_ARRAY_BUFFER) { if (bindTarget == GL_ARRAY_BUFFER) {
@ -1032,7 +1032,7 @@ void GLDevice::BindBuffer(GLBuffer* buffer, GLEnum target) {
} }
void GLDevice::BindFramebuffer(GLFramebuffer* framebuffer) { void GLDevice::BindFramebuffer(GLFramebuffer* framebuffer) {
BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); BC_ASSERT(this->m_Context.IsCurrentContext());
GLuint v3; GLuint v3;
@ -1055,8 +1055,8 @@ void GLDevice::BindGLSLProgram(GLGLSLProgram* a2) {
} }
void GLDevice::BindShader(GLShader* shader) { void GLDevice::BindShader(GLShader* shader) {
BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); BC_ASSERT(this->m_Context.IsCurrentContext());
BLIZZARD_ASSERT(shader); BC_ASSERT(shader);
if (shader->var5 == GL_FRAGMENT_PROGRAM_ARB) { if (shader->var5 == GL_FRAGMENT_PROGRAM_ARB) {
if (this->m_States.binding.pixelProgram != shader->m_ShaderID) { if (this->m_States.binding.pixelProgram != shader->m_ShaderID) {
@ -1069,19 +1069,19 @@ void GLDevice::BindShader(GLShader* shader) {
this->m_States.binding.vertexProgram = shader->m_ShaderID; this->m_States.binding.vertexProgram = shader->m_ShaderID;
} }
} else { } else {
BLIZZARD_ASSERT(false); BC_ASSERT(false);
} }
} }
void GLDevice::BindTexture(GLEnum textureType, GLTexture* texture) { void GLDevice::BindTexture(GLEnum textureType, GLTexture* texture) {
BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); BC_ASSERT(this->m_Context.IsCurrentContext());
BLIZZARD_ASSERT(texture == nullptr || textureType == texture->m_TextureType); BC_ASSERT(texture == nullptr || textureType == texture->m_TextureType);
uint32_t textureID = texture ? texture->m_TextureID : 0; uint32_t textureID = texture ? texture->m_TextureID : 0;
uint32_t index = GLLTextureTypeToIndex(textureType); uint32_t index = GLLTextureTypeToIndex(textureType);
BLIZZARD_ASSERT(this->m_States.binding.texture[index][this->m_States.binding.currentActiveTexture] != textureID); BC_ASSERT(this->m_States.binding.texture[index][this->m_States.binding.currentActiveTexture] != textureID);
BLIZZARD_ASSERT(this->m_BoundTextures[index][this->m_States.binding.currentActiveTexture] != texture); BC_ASSERT(this->m_BoundTextures[index][this->m_States.binding.currentActiveTexture] != texture);
GLTexture* boundTexture = this->m_BoundTextures[index][this->m_States.binding.currentActiveTexture]; GLTexture* boundTexture = this->m_BoundTextures[index][this->m_States.binding.currentActiveTexture];
if (boundTexture) { if (boundTexture) {
@ -1125,7 +1125,7 @@ void GLDevice::BindTexture(GLEnum textureType, GLTexture* texture) {
} }
void GLDevice::BindVertexArray(GLVertexArray* a2) { void GLDevice::BindVertexArray(GLVertexArray* a2) {
BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); BC_ASSERT(this->m_Context.IsCurrentContext());
int32_t v4 = a2 ? a2->m_VertexArrayID : 0; int32_t v4 = a2 ? a2->m_VertexArrayID : 0;
@ -1137,8 +1137,8 @@ void GLDevice::BindVertexArray(GLVertexArray* a2) {
} }
void GLDevice::BlitFramebuffer(GLMipmap* src, const GLRect* srcRect, GLMipmap* dst, const GLRect* dstRect, GLEnum mask, GLEnum filter) { void GLDevice::BlitFramebuffer(GLMipmap* src, const GLRect* srcRect, GLMipmap* dst, const GLRect* dstRect, GLEnum mask, GLEnum filter) {
BLIZZARD_ASSERT(mask == GL_COLOR_BUFFER_BIT); BC_ASSERT(mask == GL_COLOR_BUFFER_BIT);
BLIZZARD_ASSERT(src != nullptr); BC_ASSERT(src != nullptr);
GLRect fullSrcRect = { GLRect fullSrcRect = {
0, 0,
@ -1154,9 +1154,9 @@ void GLDevice::BlitFramebuffer(GLMipmap* src, const GLRect* srcRect, GLMipmap* d
dst ? dst->GetHeight() : this->m_Context.GetHeight() dst ? dst->GetHeight() : this->m_Context.GetHeight()
}; };
BLIZZARD_ASSERT(filter == GL_NEAREST); BC_ASSERT(filter == GL_NEAREST);
// TODO // TODO
// BLIZZARD_ASSERT(srcRect == nullptr || *srcRect == fullSrcRect); // BC_ASSERT(srcRect == nullptr || *srcRect == fullSrcRect);
// TODO // TODO
// - non-shader code path // - non-shader code path
@ -1377,18 +1377,18 @@ void GLDevice::BlitFramebuffer(GLMipmap* src, const GLRect* srcRect, GLMipmap* d
} }
void GLDevice::CheckDepthTarget() { void GLDevice::CheckDepthTarget() {
BLIZZARD_ASSERT(this->m_CurrentTargetColor[0] == nullptr || this->m_CurrentTargetColor[0]->GetTexture()->IsValid()); BC_ASSERT(this->m_CurrentTargetColor[0] == nullptr || this->m_CurrentTargetColor[0]->GetTexture()->IsValid());
BLIZZARD_ASSERT(this->m_CurrentTargetColor[1] == nullptr || this->m_CurrentTargetColor[1]->GetTexture()->IsValid()); BC_ASSERT(this->m_CurrentTargetColor[1] == nullptr || this->m_CurrentTargetColor[1]->GetTexture()->IsValid());
BLIZZARD_ASSERT(this->m_CurrentTargetColor[2] == nullptr || this->m_CurrentTargetColor[2]->GetTexture()->IsValid()); BC_ASSERT(this->m_CurrentTargetColor[2] == nullptr || this->m_CurrentTargetColor[2]->GetTexture()->IsValid());
BLIZZARD_ASSERT(this->m_CurrentTargetColor[3] == nullptr || this->m_CurrentTargetColor[3]->GetTexture()->IsValid()); BC_ASSERT(this->m_CurrentTargetColor[3] == nullptr || this->m_CurrentTargetColor[3]->GetTexture()->IsValid());
BLIZZARD_ASSERT(this->m_CurrentTargetDepth == nullptr || this->m_CurrentDepthBuffer != nullptr); BC_ASSERT(this->m_CurrentTargetDepth == nullptr || this->m_CurrentDepthBuffer != nullptr);
if (!this->m_CurrentDepthBuffer) { if (!this->m_CurrentDepthBuffer) {
return; return;
} }
BLIZZARD_ASSERT(this->m_CurrentDepthBuffer->GetTexture()->IsValid()); BC_ASSERT(this->m_CurrentDepthBuffer->GetTexture()->IsValid());
auto currentTargetColor = this->m_CurrentTargetColor[0]; auto currentTargetColor = this->m_CurrentTargetColor[0];
auto currentDepthBuffer = this->m_CurrentDepthBuffer; auto currentDepthBuffer = this->m_CurrentDepthBuffer;
@ -1540,8 +1540,8 @@ void GLDevice::Clear(uint32_t clearMask, const GLColor4f& clearColor, double cle
} }
void GLDevice::CopyTex(uint32_t a2, uint32_t a3, GLMipmap* dst, const GLRect* framebufferRect) { void GLDevice::CopyTex(uint32_t a2, uint32_t a3, GLMipmap* dst, const GLRect* framebufferRect) {
BLIZZARD_ASSERT(framebufferRect->width == dst->GetWidth()); BC_ASSERT(framebufferRect->width == dst->GetWidth());
BLIZZARD_ASSERT(framebufferRect->height == dst->GetHeight()); BC_ASSERT(framebufferRect->height == dst->GetHeight());
dst->m_Texture->Bind(nullptr, false); dst->m_Texture->Bind(nullptr, false);
@ -1636,7 +1636,7 @@ const GLStates::VertexArrayObject& GLDevice::GetVertexArrayStates() {
} }
void GLDevice::GLLDraw(GLEnum mode, uint32_t start, uint32_t end, uint32_t a5, uint32_t a6, uint32_t count) { void GLDevice::GLLDraw(GLEnum mode, uint32_t start, uint32_t end, uint32_t a5, uint32_t a6, uint32_t count) {
BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); BC_ASSERT(this->m_Context.IsCurrentContext());
this->CheckDepthTarget(); this->CheckDepthTarget();
@ -1698,7 +1698,7 @@ void GLDevice::GLLDraw(GLEnum mode, uint32_t start, uint32_t end, uint32_t a5,
} else if (format == GL_UNSIGNED_INT) { } else if (format == GL_UNSIGNED_INT) {
v18 = 2; v18 = 2;
} else { } else {
BLIZZARD_ASSERT(!"buffer uses unknown format"); BC_ASSERT(!"buffer uses unknown format");
} }
void* indices = GLBuffer::m_UsingVBO void* indices = GLBuffer::m_UsingVBO
@ -2016,7 +2016,7 @@ void GLDevice::LoadDefaultStates() {
} }
void GLDevice::ResetBackbuffer(uint32_t width, uint32_t height, GLTextureFormat colorFormat, GLTextureFormat depthFormat, uint32_t sampleCount) { void GLDevice::ResetBackbuffer(uint32_t width, uint32_t height, GLTextureFormat colorFormat, GLTextureFormat depthFormat, uint32_t sampleCount) {
BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); BC_ASSERT(this->m_Context.IsCurrentContext());
if ( if (
this->m_BackBufferColor this->m_BackBufferColor
@ -2113,7 +2113,7 @@ void GLDevice::ResetBackbuffer(uint32_t width, uint32_t height, GLTextureFormat
this->SetDepthTestEnable(1); this->SetDepthTestEnable(1);
} }
BLIZZARD_ASSERT(this->m_CurrentTarget->IsValid()); BC_ASSERT(this->m_CurrentTarget->IsValid());
this->Clear(0x4500, GLColor4f::BLACK, 1.0, 0); this->Clear(0x4500, GLColor4f::BLACK, 1.0, 0);
} }
@ -2135,7 +2135,7 @@ void GLDevice::Resize(uint32_t width, uint32_t height) {
} }
void GLDevice::RestoreTextures() { void GLDevice::RestoreTextures() {
BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); BC_ASSERT(this->m_Context.IsCurrentContext());
for (int32_t i = 0; i < 16; i++) { for (int32_t i = 0; i < 16; i++) {
GLTexture* texture = this->m_Textures[i]; GLTexture* texture = this->m_Textures[i];
@ -2182,7 +2182,7 @@ void GLDevice::SetAlphaBlendEnable(bool enable) {
void GLDevice::SetAlphaTest(GLEnum func, float ref) { void GLDevice::SetAlphaTest(GLEnum func, float ref) {
if (this->m_States.fixedFunc.alphaTestFunc != func || this->m_States.fixedFunc.alphaTestRef != ref) { if (this->m_States.fixedFunc.alphaTestFunc != func || this->m_States.fixedFunc.alphaTestRef != ref) {
BLIZZARD_ASSERT(ref <= 1.0f); BC_ASSERT(ref <= 1.0f);
glAlphaFunc(func, ref); glAlphaFunc(func, ref);
this->m_States.fixedFunc.alphaTestFunc = func; this->m_States.fixedFunc.alphaTestFunc = func;
@ -2391,12 +2391,12 @@ void GLDevice::SetFogParam(GLEnum param, float value) {
this->m_States.fixedFunc.fogDensity = value; this->m_States.fixedFunc.fogDensity = value;
} }
} else { } else {
BLIZZARD_ASSERT(false); BC_ASSERT(false);
} }
} }
void GLDevice::SetIndexBuffer(GLBuffer* buffer) { void GLDevice::SetIndexBuffer(GLBuffer* buffer) {
BLIZZARD_ASSERT(buffer == nullptr || buffer->m_IndexFormat != GL_ZERO); BC_ASSERT(buffer == nullptr || buffer->m_IndexFormat != GL_ZERO);
this->m_DefaultVertexArrayObject.m_Properties.m_IndexBuffer = buffer; this->m_DefaultVertexArrayObject.m_Properties.m_IndexBuffer = buffer;
} }
@ -2424,7 +2424,7 @@ void GLDevice::SetModelView(GLEnum transform) {
} }
if (transform != GL_MODELVIEW) { if (transform != GL_MODELVIEW) {
BLIZZARD_ASSERT(false); BC_ASSERT(false);
} }
auto& world = this->m_States.fixedFunc.transforms.world; auto& world = this->m_States.fixedFunc.transforms.world;
@ -2445,7 +2445,7 @@ void GLDevice::SetModelView(GLEnum transform) {
modelView.isDirty = true; modelView.isDirty = true;
} else { } else {
// TODO assign model * view to modelView // TODO assign model * view to modelView
BLIZZARD_ASSERT(!"Unimplemented"); BC_ASSERT(!"Unimplemented");
} }
if (this->m_States.fixedFunc.transforms.matrixMode != GL_MODELVIEW) { if (this->m_States.fixedFunc.transforms.matrixMode != GL_MODELVIEW) {
@ -2473,8 +2473,8 @@ void GLDevice::SetShader(GLShader::ShaderType shaderType, GLShader* shader) {
// TODO // TODO
} }
BLIZZARD_ASSERT(shader->IsEnabled()); BC_ASSERT(shader->IsEnabled());
BLIZZARD_ASSERT(shader->GetShaderType() == shaderType); BC_ASSERT(shader->GetShaderType() == shaderType);
this->BindShader(shader); this->BindShader(shader);
} }
@ -2506,12 +2506,12 @@ void GLDevice::SetShader(GLShader::ShaderType shaderType, GLShader* shader) {
this->m_PixelShader = shader; this->m_PixelShader = shader;
} else { } else {
BLIZZARD_ASSERT(!"Unknown shader type!"); BC_ASSERT(!"Unknown shader type!");
} }
} }
void GLDevice::SetShaderConstants(GLShader::ShaderType shaderType, uint32_t index, const float* constants, uint32_t count) { void GLDevice::SetShaderConstants(GLShader::ShaderType shaderType, uint32_t index, const float* constants, uint32_t count) {
BLIZZARD_ASSERT(count != 0); BC_ASSERT(count != 0);
GLShader* shader = nullptr; GLShader* shader = nullptr;
@ -2537,12 +2537,12 @@ void GLDevice::SetShaderConstants(GLShader::ShaderType shaderType, uint32_t inde
void GLDevice::SetShaderConstantsInternal(GLShader::ShaderType shaderType, uint32_t index, const float* constants, uint32_t count) { void GLDevice::SetShaderConstantsInternal(GLShader::ShaderType shaderType, uint32_t index, const float* constants, uint32_t count) {
if (shaderType == GLShader::eVertexShader) { if (shaderType == GLShader::eVertexShader) {
BLIZZARD_ASSERT((index + count) <= std::extent<decltype(this->m_States.shader.vertexShaderConst)>::value); BC_ASSERT((index + count) <= std::extent<decltype(this->m_States.shader.vertexShaderConst)>::value);
memcpy(&this->m_States.shader.vertexShaderConst[index], constants, (sizeof(float) * 4) * count); memcpy(&this->m_States.shader.vertexShaderConst[index], constants, (sizeof(float) * 4) * count);
BLIZZARD_ASSERT(index <= 0xFFFF); BC_ASSERT(index <= 0xFFFF);
BLIZZARD_ASSERT(count <= 0xFFFF); BC_ASSERT(count <= 0xFFFF);
uint16_t start = std::min(static_cast<uint16_t>(index), this->m_DirtyVertexShaderConsts.start); uint16_t start = std::min(static_cast<uint16_t>(index), this->m_DirtyVertexShaderConsts.start);
uint16_t end = std::max(static_cast<uint16_t>(index + count), this->m_DirtyVertexShaderConsts.end); uint16_t end = std::max(static_cast<uint16_t>(index + count), this->m_DirtyVertexShaderConsts.end);
@ -2550,12 +2550,12 @@ void GLDevice::SetShaderConstantsInternal(GLShader::ShaderType shaderType, uint3
this->m_DirtyVertexShaderConsts.start = start; this->m_DirtyVertexShaderConsts.start = start;
this->m_DirtyVertexShaderConsts.end = end; this->m_DirtyVertexShaderConsts.end = end;
} else if (shaderType == GLShader::ePixelShader) { } else if (shaderType == GLShader::ePixelShader) {
BLIZZARD_ASSERT((index + count) <= std::extent<decltype(this->m_States.shader.pixelShaderConst)>::value); BC_ASSERT((index + count) <= std::extent<decltype(this->m_States.shader.pixelShaderConst)>::value);
memcpy(&this->m_States.shader.pixelShaderConst[index], constants, (sizeof(float) * 4) * count); memcpy(&this->m_States.shader.pixelShaderConst[index], constants, (sizeof(float) * 4) * count);
BLIZZARD_ASSERT(index <= 0xFFFF); BC_ASSERT(index <= 0xFFFF);
BLIZZARD_ASSERT(count <= 0xFFFF); BC_ASSERT(count <= 0xFFFF);
uint16_t start = std::min(static_cast<uint16_t>(index), this->m_DirtyPixelShaderConsts.start); uint16_t start = std::min(static_cast<uint16_t>(index), this->m_DirtyPixelShaderConsts.start);
uint16_t end = std::max(static_cast<uint16_t>(index + count), this->m_DirtyPixelShaderConsts.end); uint16_t end = std::max(static_cast<uint16_t>(index + count), this->m_DirtyPixelShaderConsts.end);
@ -2564,16 +2564,16 @@ void GLDevice::SetShaderConstantsInternal(GLShader::ShaderType shaderType, uint3
this->m_DirtyPixelShaderConsts.end = end; this->m_DirtyPixelShaderConsts.end = end;
} else { } else {
// TODO // TODO
// BLIZZARD_ASSERT(false, "Unknown shader type %d!", shaderType); // BC_ASSERT(false, "Unknown shader type %d!", shaderType);
} }
} }
void GLDevice::SetTexture(uint32_t stage, GLTexture* texture) { void GLDevice::SetTexture(uint32_t stage, GLTexture* texture) {
if (stage > 15) { if (stage > 15) {
BLIZZARD_ASSERT(!"setting an unsupported texture stage to a non-NULL texture"); BC_ASSERT(!"setting an unsupported texture stage to a non-NULL texture");
} }
BLIZZARD_ASSERT(texture == nullptr || texture->IsValid()); BC_ASSERT(texture == nullptr || texture->IsValid());
uint32_t textureID = 0; uint32_t textureID = 0;
GLEnum textureType = GL_TEXTURE_2D; GLEnum textureType = GL_TEXTURE_2D;
@ -2614,7 +2614,7 @@ void GLDevice::SetTransform(GLEnum transform, const float* a3) {
} else if (transform >= GL_TEXTURE0 && transform <= GL_TEXTURE7) { } else if (transform >= GL_TEXTURE0 && transform <= GL_TEXTURE7) {
t = &this->m_States.fixedFunc.transforms.texture[transform - GL_TEXTURE0]; t = &this->m_States.fixedFunc.transforms.texture[transform - GL_TEXTURE0];
} else { } else {
BLIZZARD_ASSERT(false); BC_ASSERT(false);
} }
if (*t != a3) { if (*t != a3) {
@ -2639,8 +2639,8 @@ void GLDevice::SetUnpackClientStorage(bool enable) {
} }
void GLDevice::SetVertexBuffer(uint32_t index, GLBuffer* buffer, uint32_t offset, uint32_t stride) { void GLDevice::SetVertexBuffer(uint32_t index, GLBuffer* buffer, uint32_t offset, uint32_t stride) {
BLIZZARD_ASSERT(index < GL_MAX_STREAM); BC_ASSERT(index < GL_MAX_STREAM);
BLIZZARD_ASSERT(buffer == nullptr || buffer->m_IndexFormat == GL_ZERO); BC_ASSERT(buffer == nullptr || buffer->m_IndexFormat == GL_ZERO);
auto properties = &this->m_DefaultVertexArrayObject.m_Properties; auto properties = &this->m_DefaultVertexArrayObject.m_Properties;
properties->m_VertexBuffer[index] = buffer; properties->m_VertexBuffer[index] = buffer;
@ -2649,7 +2649,7 @@ void GLDevice::SetVertexBuffer(uint32_t index, GLBuffer* buffer, uint32_t offset
} }
void GLDevice::SetVertexFormat(GLVertexFormat* format) { void GLDevice::SetVertexFormat(GLVertexFormat* format) {
BLIZZARD_ASSERT(format->m_Size <= kMAX_VERTEX_ATTRIBS); BC_ASSERT(format->m_Size <= kMAX_VERTEX_ATTRIBS);
this->m_DefaultVertexArrayObject.m_Properties.m_VertexBufferFormat = format; this->m_DefaultVertexArrayObject.m_Properties.m_VertexBufferFormat = format;
} }

View File

@ -10,10 +10,10 @@ GLFramebuffer* GLFramebuffer::Create(bool a1) {
if (!a1) { if (!a1) {
// TODO // TODO
// BLIZZARD_ASSERT(framebuffer->m_FramebufferID >= PoolStats<GLFramebuffer>::NAME_POOL_FIRST_NAME); // BC_ASSERT(framebuffer->m_FramebufferID >= PoolStats<GLFramebuffer>::NAME_POOL_FIRST_NAME);
} }
BLIZZARD_ASSERT(framebuffer->m_NumAttach == 0); BC_ASSERT(framebuffer->m_NumAttach == 0);
framebuffer->m_Width = 0; framebuffer->m_Width = 0;
framebuffer->m_Height = 0; framebuffer->m_Height = 0;
@ -29,7 +29,7 @@ GLFramebuffer::GLFramebuffer(bool a1) : GLObject() {
} }
void GLFramebuffer::Attach(GLMipmap* image, GLenum a3, int32_t a4) { void GLFramebuffer::Attach(GLMipmap* image, GLenum a3, int32_t a4) {
BLIZZARD_ASSERT(this->m_Device == GLDevice::Get()); BC_ASSERT(this->m_Device == GLDevice::Get());
if (!image) { if (!image) {
this->Detach(a3); this->Detach(a3);
@ -37,7 +37,7 @@ void GLFramebuffer::Attach(GLMipmap* image, GLenum a3, int32_t a4) {
} }
if (a3 == GL_DEPTH_STENCIL) { if (a3 == GL_DEPTH_STENCIL) {
BLIZZARD_ASSERT(image->GetFormat() == GLTF_D24S8); BC_ASSERT(image->GetFormat() == GLTF_D24S8);
this->Attach(image, GL_DEPTH_ATTACHMENT, 0); this->Attach(image, GL_DEPTH_ATTACHMENT, 0);
this->Attach(image, GL_STENCIL_ATTACHMENT, 0); this->Attach(image, GL_STENCIL_ATTACHMENT, 0);
@ -57,7 +57,7 @@ void GLFramebuffer::Attach(GLMipmap* image, GLenum a3, int32_t a4) {
index = a3 - GL_COLOR_ATTACHMENT0; index = a3 - GL_COLOR_ATTACHMENT0;
} }
BLIZZARD_ASSERT(index < MAX_ATTACHMENT); BC_ASSERT(index < MAX_ATTACHMENT);
GLMipmap* oldImage = this->m_Attachments[index]; GLMipmap* oldImage = this->m_Attachments[index];
@ -77,7 +77,7 @@ void GLFramebuffer::Attach(GLMipmap* image, GLenum a3, int32_t a4) {
this->m_Device->Sub38460(0); this->m_Device->Sub38460(0);
} }
BLIZZARD_ASSERT((*image->m_AttachPoints)[m_FramebufferID].framebuffer == this); BC_ASSERT((*image->m_AttachPoints)[m_FramebufferID].framebuffer == this);
} }
void GLFramebuffer::Detach(GLenum a2) { void GLFramebuffer::Detach(GLenum a2) {
@ -96,7 +96,7 @@ void GLFramebuffer::Detach(GLenum a2) {
index = a2 - GL_COLOR_ATTACHMENT0; index = a2 - GL_COLOR_ATTACHMENT0;
} }
BLIZZARD_ASSERT(index < MAX_ATTACHMENT); BC_ASSERT(index < MAX_ATTACHMENT);
GLMipmap* oldImage = this->m_Attachments[index]; GLMipmap* oldImage = this->m_Attachments[index];
@ -129,7 +129,7 @@ GLMipmap* GLFramebuffer::GetAttachment(GLEnum a2) {
index = a2 - GL_COLOR_ATTACHMENT0; index = a2 - GL_COLOR_ATTACHMENT0;
} }
BLIZZARD_ASSERT(index < MAX_ATTACHMENT); BC_ASSERT(index < MAX_ATTACHMENT);
return this->m_Attachments[index]; return this->m_Attachments[index];
} }

View File

@ -19,7 +19,7 @@ void GLMipmap::Attach(GLFramebuffer* framebuffer, GLenum attachPoint, int32_t a4
if (framebufferID >= attachPoints.size()) { if (framebufferID >= attachPoints.size()) {
attachPoints.resize(framebufferID + 1); attachPoints.resize(framebufferID + 1);
} else { } else {
BLIZZARD_ASSERT(attachPoints[framebufferID].framebuffer != framebuffer || attachPoints[framebufferID].point != attachPoint); BC_ASSERT(attachPoints[framebufferID].framebuffer != framebuffer || attachPoints[framebufferID].point != attachPoint);
auto& attach = attachPoints[framebufferID]; auto& attach = attachPoints[framebufferID];
@ -85,8 +85,8 @@ void GLMipmap::Detach(GLFramebuffer* framebuffer, GLenum attachPoint, bool a4) {
auto& attachPoints = *this->m_AttachPoints; auto& attachPoints = *this->m_AttachPoints;
BLIZZARD_ASSERT(attachPoints.size() >= framebufferID); BC_ASSERT(attachPoints.size() >= framebufferID);
BLIZZARD_ASSERT(attachPoints[framebufferID].framebuffer == framebuffer); BC_ASSERT(attachPoints[framebufferID].framebuffer == framebuffer);
if (!a4 && framebufferID) { if (!a4 && framebufferID) {
GLDevice* v12 = GLDevice::Get(); GLDevice* v12 = GLDevice::Get();
@ -105,17 +105,17 @@ void GLMipmap::Detach(GLFramebuffer* framebuffer, GLenum attachPoint, bool a4) {
GLAttachPoint* v9 = &attachPoints[framebufferID]; GLAttachPoint* v9 = &attachPoints[framebufferID];
if (v9->point == GL_DEPTH_STENCIL) { if (v9->point == GL_DEPTH_STENCIL) {
BLIZZARD_ASSERT(this->GetFormat() == GLTF_D24S8); BC_ASSERT(this->GetFormat() == GLTF_D24S8);
if (attachPoint == GL_DEPTH_ATTACHMENT) { if (attachPoint == GL_DEPTH_ATTACHMENT) {
v9->point = GL_STENCIL_ATTACHMENT; v9->point = GL_STENCIL_ATTACHMENT;
} else if (attachPoint == GL_STENCIL_ATTACHMENT) { } else if (attachPoint == GL_STENCIL_ATTACHMENT) {
v9->point = GL_DEPTH_ATTACHMENT; v9->point = GL_DEPTH_ATTACHMENT;
} else { } else {
BLIZZARD_ASSERT(false); BC_ASSERT(false);
} }
} else { } else {
BLIZZARD_ASSERT(attachPoints[framebufferID].point == attachPoint); BC_ASSERT(attachPoints[framebufferID].point == attachPoint);
v9->framebuffer = 0; v9->framebuffer = 0;
v9->point = 0; v9->point = 0;
@ -133,8 +133,8 @@ void GLMipmap::DetachAll() {
auto& attachPoints = *this->m_AttachPoints; auto& attachPoints = *this->m_AttachPoints;
for (int32_t i = 0; i < attachPoints.size(); i++) { for (int32_t i = 0; i < attachPoints.size(); i++) {
BLIZZARD_ASSERT(attachPoints[i].point != GL_ZERO); BC_ASSERT(attachPoints[i].point != GL_ZERO);
BLIZZARD_ASSERT(attachPoints[i].framebuffer->m_FramebufferID == i); BC_ASSERT(attachPoints[i].framebuffer->m_FramebufferID == i);
attachPoints[i].framebuffer->Detach(attachPoints[i].point); attachPoints[i].framebuffer->Detach(attachPoints[i].point);
} }
@ -171,11 +171,11 @@ uint16_t GLMipmap::GetWidth() {
} }
void* GLMipmap::Map(GLEnum mode, const GLBox* area) { void* GLMipmap::Map(GLEnum mode, const GLBox* area) {
BLIZZARD_ASSERT(!this->m_Texture->IsSystemBuffer()); BC_ASSERT(!this->m_Texture->IsSystemBuffer());
BLIZZARD_ASSERT(this->m_Data != nullptr); BC_ASSERT(this->m_Data != nullptr);
BLIZZARD_ASSERT(!this->m_Texture->IsRenderTarget()); BC_ASSERT(!this->m_Texture->IsRenderTarget());
BLIZZARD_ASSERT(mode != GL_ZERO); BC_ASSERT(mode != GL_ZERO);
BLIZZARD_ASSERT(this->m_MapParams == nullptr); BC_ASSERT(this->m_MapParams == nullptr);
if (mode != GL_READ_ONLY) { if (mode != GL_READ_ONLY) {
this->m_Texture->m_MappedMipmaps++; this->m_Texture->m_MappedMipmaps++;
@ -185,13 +185,13 @@ void* GLMipmap::Map(GLEnum mode, const GLBox* area) {
this->m_MapParams = mapParams; this->m_MapParams = mapParams;
if (area) { if (area) {
BLIZZARD_ASSERT(area->width > 0); BC_ASSERT(area->width > 0);
BLIZZARD_ASSERT(area->height > 0); BC_ASSERT(area->height > 0);
BLIZZARD_ASSERT(area->depth > 0); BC_ASSERT(area->depth > 0);
BLIZZARD_ASSERT(!this->GetFormatInfo().m_IsCompressed || ((area->top & 0x3) == 0 && (area->left & 0x3) == 0 && (area->width & 0x3) == 0 && (area->height & 0x3) == 0)); BC_ASSERT(!this->GetFormatInfo().m_IsCompressed || ((area->top & 0x3) == 0 && (area->left & 0x3) == 0 && (area->width & 0x3) == 0 && (area->height & 0x3) == 0));
BLIZZARD_ASSERT((area->height + area->top) <= this->m_Height); BC_ASSERT((area->height + area->top) <= this->m_Height);
BLIZZARD_ASSERT((area->depth + area->front) <= this->m_Depth); BC_ASSERT((area->depth + area->front) <= this->m_Depth);
BLIZZARD_ASSERT((area->width + area->left) <= this->m_Width); BC_ASSERT((area->width + area->left) <= this->m_Width);
mapParams->m_MapArea = { mapParams->m_MapArea = {
area->left, area->left,
@ -232,7 +232,7 @@ void* GLMipmap::Map(GLEnum mode, const GLBox* area) {
int32_t rowPitch = this->GetPitch(); int32_t rowPitch = this->GetPitch();
BLIZZARD_ASSERT(((mapParams->m_MapArea.top * rowPitch) + mapParams->m_MapArea.left * this->GetFormatInfo().m_BytePerPixel) < (this->GetFormatInfo().m_IsCompressed ? this->m_Size << 4 : this->m_Size)); BC_ASSERT(((mapParams->m_MapArea.top * rowPitch) + mapParams->m_MapArea.left * this->GetFormatInfo().m_BytePerPixel) < (this->GetFormatInfo().m_IsCompressed ? this->m_Size << 4 : this->m_Size));
int32_t v22 = rowPitch * this->m_Height; int32_t v22 = rowPitch * this->m_Height;
if (this->GetFormatInfo().m_IsCompressed) { if (this->GetFormatInfo().m_IsCompressed) {
@ -266,7 +266,7 @@ void* GLMipmap::Map(GLEnum mode, const GLRect* rect) {
} }
void GLMipmap::ReleaseObject() { void GLMipmap::ReleaseObject() {
BLIZZARD_ASSERT(this->m_MapParams == nullptr); BC_ASSERT(this->m_MapParams == nullptr);
this->RemoveDebugMipmap(); this->RemoveDebugMipmap();
this->DetachAll(); this->DetachAll();
@ -284,17 +284,17 @@ void GLMipmap::RemoveDebugMipmap() {
} }
void GLMipmap::ResetData(GLEnum target, int32_t level, unsigned char* data) { void GLMipmap::ResetData(GLEnum target, int32_t level, unsigned char* data) {
BLIZZARD_ASSERT(this->m_Target != GL_TEXTURE_3D || !this->GetFormatInfo().m_IsCompressed); BC_ASSERT(this->m_Target != GL_TEXTURE_3D || !this->GetFormatInfo().m_IsCompressed);
this->m_Target = target; this->m_Target = target;
this->m_Level = level; this->m_Level = level;
this->m_Data = data; this->m_Data = data;
BLIZZARD_ASSERT(this->GetFormat() != GLTF_INVALID); BC_ASSERT(this->GetFormat() != GLTF_INVALID);
BLIZZARD_ASSERT(this->GetFormat() < GLTF_NUM_TEXTURE_FORMATS); BC_ASSERT(this->GetFormat() < GLTF_NUM_TEXTURE_FORMATS);
if (!this->m_Texture->IsSystemBuffer() && this->m_Texture->IsRenderTarget()) { if (!this->m_Texture->IsSystemBuffer() && this->m_Texture->IsRenderTarget()) {
BLIZZARD_ASSERT(!this->GetFormatInfo().m_IsCompressed); BC_ASSERT(!this->GetFormatInfo().m_IsCompressed);
this->TexImage(nullptr); this->TexImage(nullptr);
this->m_Unk24 = 1; this->m_Unk24 = 1;
@ -307,7 +307,7 @@ void GLMipmap::ResetSize(uint32_t width, uint32_t height, uint32_t depth) {
this->m_Depth = depth ? depth : 1; this->m_Depth = depth ? depth : 1;
if (this->GetFormatInfo().m_IsCompressed) { if (this->GetFormatInfo().m_IsCompressed) {
BLIZZARD_ASSERT(this->m_Depth == 1); BC_ASSERT(this->m_Depth == 1);
this->m_Width = (this->m_Width + 3) & 0xFFFC; this->m_Width = (this->m_Width + 3) & 0xFFFC;
this->m_Height = (this->m_Height + 3) & 0xFFFC; this->m_Height = (this->m_Height + 3) & 0xFFFC;
@ -333,7 +333,7 @@ void GLMipmap::ResetSize(uint32_t width, uint32_t height, uint32_t depth) {
} }
void GLMipmap::TexImage(const void* pixels) { void GLMipmap::TexImage(const void* pixels) {
BLIZZARD_ASSERT((this->m_Texture->IsRenderTarget() || pixels != nullptr) && GLDevice::Get()->GetVertexArrayStates().buffers[eGLBT_PIXEL_UNPACK] == 0); BC_ASSERT((this->m_Texture->IsRenderTarget() || pixels != nullptr) && GLDevice::Get()->GetVertexArrayStates().buffers[eGLBT_PIXEL_UNPACK] == 0);
if (this->m_Target == GL_TEXTURE_3D) { if (this->m_Target == GL_TEXTURE_3D) {
glTexImage3D( glTexImage3D(
@ -375,7 +375,7 @@ void GLMipmap::TexImage(const void* pixels) {
} }
void GLMipmap::TexSubImage(const GLBox& a2, int32_t size, const void* pixels) { void GLMipmap::TexSubImage(const GLBox& a2, int32_t size, const void* pixels) {
BLIZZARD_ASSERT(!this->m_Texture->IsRenderTarget() && pixels != nullptr && GLDevice::Get()->GetVertexArrayStates().buffers[eGLBT_PIXEL_UNPACK] == 0); BC_ASSERT(!this->m_Texture->IsRenderTarget() && pixels != nullptr && GLDevice::Get()->GetVertexArrayStates().buffers[eGLBT_PIXEL_UNPACK] == 0);
if (this->m_Target == GL_TEXTURE_3D) { if (this->m_Target == GL_TEXTURE_3D) {
glPixelStorei(GL_UNPACK_ROW_LENGTH, this->m_Width); glPixelStorei(GL_UNPACK_ROW_LENGTH, this->m_Width);
@ -429,9 +429,9 @@ void GLMipmap::TexSubImage(const GLBox& a2, int32_t size, const void* pixels) {
} }
void GLMipmap::Unmap() { void GLMipmap::Unmap() {
BLIZZARD_ASSERT(!this->m_Texture->IsRenderTarget()); BC_ASSERT(!this->m_Texture->IsRenderTarget());
BLIZZARD_ASSERT(!this->m_Texture->IsSystemBuffer()); BC_ASSERT(!this->m_Texture->IsSystemBuffer());
BLIZZARD_ASSERT(this->m_MapParams != nullptr); BC_ASSERT(this->m_MapParams != nullptr);
if (this->m_MapParams->m_MapMode == GL_READ_ONLY) { if (this->m_MapParams->m_MapMode == GL_READ_ONLY) {
delete this->m_MapParams; delete this->m_MapParams;
@ -441,7 +441,7 @@ void GLMipmap::Unmap() {
GLDevice* device = GLDevice::Get(); GLDevice* device = GLDevice::Get();
BLIZZARD_ASSERT(this->m_Texture->m_MappedMipmaps > 0); BC_ASSERT(this->m_Texture->m_MappedMipmaps > 0);
if (device->m_TexWorker) { if (device->m_TexWorker) {
device->m_TexWorker->Lock(); device->m_TexWorker->Lock();
@ -459,7 +459,7 @@ void GLMipmap::Unmap() {
} }
void GLMipmap::Unmap(MapParams* mapParams) { void GLMipmap::Unmap(MapParams* mapParams) {
BLIZZARD_ASSERT(mapParams != nullptr); BC_ASSERT(mapParams != nullptr);
this->m_Texture->Bind(nullptr, 0); this->m_Texture->Bind(nullptr, 0);

View File

@ -5,7 +5,7 @@ void GLObject::AddRefTwin() {
} }
uint32_t GLObject::Release() { uint32_t GLObject::Release() {
BLIZZARD_ASSERT(this->m_RefCount > 0); BC_ASSERT(this->m_RefCount > 0);
this->m_RefCount--; this->m_RefCount--;

View File

@ -13,14 +13,14 @@ GLShader* GLShader::Create(ShaderType shaderType, bool hybrid, bool usingCG, con
const char* shaderCode = reinterpret_cast<const char*>(buf); const char* shaderCode = reinterpret_cast<const char*>(buf);
if (*reinterpret_cast<const int32_t*>(buf) == 'GSL1') { if (*reinterpret_cast<const int32_t*>(buf) == 'GSL1') {
BLIZZARD_ASSERT(!usingCG); BC_ASSERT(!usingCG);
const ShaderDataHeader header = *reinterpret_cast<const ShaderDataHeader*>(buf); const ShaderDataHeader header = *reinterpret_cast<const ShaderDataHeader*>(buf);
BLIZZARD_ASSERT(header.shaderType == shaderType); BC_ASSERT(header.shaderType == shaderType);
BLIZZARD_ASSERT(header.size == codeLen); BC_ASSERT(header.size == codeLen);
BLIZZARD_ASSERT(header.codePos >= sizeof(ShaderDataHeader)); BC_ASSERT(header.codePos >= sizeof(ShaderDataHeader));
BLIZZARD_ASSERT(header.codeSize > 0); BC_ASSERT(header.codeSize > 0);
shaderCode = &reinterpret_cast<const char*>(buf)[header.codePos]; shaderCode = &reinterpret_cast<const char*>(buf)[header.codePos];
} }
@ -83,7 +83,7 @@ int32_t GLShader::GetShaderType() {
} }
void GLShader::ImmediateCompile(GLShaderLogInfo* logInfo) { void GLShader::ImmediateCompile(GLShaderLogInfo* logInfo) {
BLIZZARD_ASSERT(!this->GetCode().empty()); BC_ASSERT(!this->GetCode().empty());
this->m_Device = GLDevice::Get(); this->m_Device = GLDevice::Get();
@ -103,7 +103,7 @@ void GLShader::ImmediateCompile(GLShaderLogInfo* logInfo) {
glProgramStringARB(this->var5, GL_PROGRAM_FORMAT_ASCII_ARB, arbLen, arbCode); glProgramStringARB(this->var5, GL_PROGRAM_FORMAT_ASCII_ARB, arbLen, arbCode);
BLIZZARD_ASSERT(this->CheckErrorsARB(logInfo)); BC_ASSERT(this->CheckErrorsARB(logInfo));
} else { } else {
// TODO // TODO
// - handle GLSL shaders // - handle GLSL shaders

View File

@ -19,14 +19,14 @@ void GLTexture::DestroyBindings(void* ptr) {
} }
void GLTexture::Bind(GLDevice* device, bool force) { void GLTexture::Bind(GLDevice* device, bool force) {
BLIZZARD_ASSERT(!this->IsSystemBuffer()); BC_ASSERT(!this->IsSystemBuffer());
BLIZZARD_ASSERT(this->m_Depth != 0); BC_ASSERT(this->m_Depth != 0);
if (!device) { if (!device) {
device = GLDevice::Get(); device = GLDevice::Get();
} }
BLIZZARD_ASSERT(device != nullptr); BC_ASSERT(device != nullptr);
auto& bindings = this->GetBindings(); auto& bindings = this->GetBindings();
uint32_t deviceID = device->GetID(); uint32_t deviceID = device->GetID();
@ -179,10 +179,10 @@ TextureFormatInfo& GLTexture::GetFormatInfo() {
} }
GLMipmap* GLTexture::GetMipmap(uint32_t level, GLEnum face) { GLMipmap* GLTexture::GetMipmap(uint32_t level, GLEnum face) {
BLIZZARD_ASSERT(face >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z); BC_ASSERT(face >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);
BLIZZARD_ASSERT(level < this->m_NumMipmap); BC_ASSERT(level < this->m_NumMipmap);
BLIZZARD_ASSERT(this->m_Mipmaps != nullptr); BC_ASSERT(this->m_Mipmaps != nullptr);
BLIZZARD_ASSERT(this->m_Mipmaps[face - GL_TEXTURE_CUBE_MAP_POSITIVE_X] != nullptr); BC_ASSERT(this->m_Mipmaps[face - GL_TEXTURE_CUBE_MAP_POSITIVE_X] != nullptr);
return &this->m_Mipmaps[face - GL_TEXTURE_CUBE_MAP_POSITIVE_X][level]; return &this->m_Mipmaps[face - GL_TEXTURE_CUBE_MAP_POSITIVE_X][level];
} }
@ -200,7 +200,7 @@ bool GLTexture::IsValid() {
} }
void* GLTexture::Map(uint32_t level, const GLRect* a3, uint32_t& a4, GLEnum a5) { void* GLTexture::Map(uint32_t level, const GLRect* a3, uint32_t& a4, GLEnum a5) {
BLIZZARD_ASSERT(this->m_TextureType != GL_TEXTURE_3D); BC_ASSERT(this->m_TextureType != GL_TEXTURE_3D);
auto mipmap = this->GetMipmap(level, GL_TEXTURE_CUBE_MAP_POSITIVE_X); auto mipmap = this->GetMipmap(level, GL_TEXTURE_CUBE_MAP_POSITIVE_X);
a4 = mipmap->GetPitch(); a4 = mipmap->GetPitch();
@ -208,7 +208,7 @@ void* GLTexture::Map(uint32_t level, const GLRect* a3, uint32_t& a4, GLEnum a5)
} }
void GLTexture::RecreateGLTexture() { void GLTexture::RecreateGLTexture() {
BLIZZARD_ASSERT(GLDevice::Get()->m_TexWorker != nullptr); BC_ASSERT(GLDevice::Get()->m_TexWorker != nullptr);
if (this->m_TextureType == GL_TEXTURE_RECTANGLE_EXT) { if (this->m_TextureType == GL_TEXTURE_RECTANGLE_EXT) {
return; return;
@ -238,7 +238,7 @@ void GLTexture::RecreateGLTexture() {
} }
void GLTexture::ResizeMipmaps() { void GLTexture::ResizeMipmaps() {
BLIZZARD_ASSERT(this->m_Mipmaps == nullptr); BC_ASSERT(this->m_Mipmaps == nullptr);
int32_t numFace = this->m_TextureType == GL_TEXTURE_CUBE_MAP ? 6 : 1; int32_t numFace = this->m_TextureType == GL_TEXTURE_CUBE_MAP ? 6 : 1;
@ -312,7 +312,7 @@ void GLTexture::SetBorderColor(const GLColor4f& color) {
} }
void GLTexture::SetCompareMode(GLEnum compareMode) { void GLTexture::SetCompareMode(GLEnum compareMode) {
BLIZZARD_ASSERT( BC_ASSERT(
this->GetFormatInfo().m_DataFormat == GL_DEPTH_COMPONENT this->GetFormatInfo().m_DataFormat == GL_DEPTH_COMPONENT
|| this->GetFormatInfo().m_DataFormat == GL_DEPTH_STENCIL_EXT || this->GetFormatInfo().m_DataFormat == GL_DEPTH_STENCIL_EXT
|| compareMode == GL_NONE || compareMode == GL_NONE
@ -364,16 +364,16 @@ void GLTexture::SetMinFilterMode(GLEnum mode) {
} }
void GLTexture::SetupTexture() { void GLTexture::SetupTexture() {
BLIZZARD_ASSERT(this->m_NumMipmap == 1 || (this->m_Flags & GLTFLAG_AUTOGEN_MIPMAP) == 0); BC_ASSERT(this->m_NumMipmap == 1 || (this->m_Flags & GLTFLAG_AUTOGEN_MIPMAP) == 0);
BLIZZARD_ASSERT(!this->IsRenderTarget() || this->m_NumMipmap == 1); BC_ASSERT(!this->IsRenderTarget() || this->m_NumMipmap == 1);
BLIZZARD_ASSERT(!this->IsRenderTarget() || (this->m_Flags & GLTFLAG_READ_ACCESS) == 0); BC_ASSERT(!this->IsRenderTarget() || (this->m_Flags & GLTFLAG_READ_ACCESS) == 0);
GLDevice* device = GLDevice::Get(); GLDevice* device = GLDevice::Get();
if (this->GetFormatInfo().m_IsCompressed) { if (this->GetFormatInfo().m_IsCompressed) {
int32_t smallestDim = std::min(this->m_Width, this->m_Height); int32_t smallestDim = std::min(this->m_Width, this->m_Height);
BLIZZARD_ASSERT(smallestDim >= 4); BC_ASSERT(smallestDim >= 4);
if (smallestDim == 4) { if (smallestDim == 4) {
this->m_NumMipmap = 1; this->m_NumMipmap = 1;
@ -451,7 +451,7 @@ void GLTexture::SetupTexture() {
} }
if (!(this->m_Flags & GLTFLAG_SYSTEM_BUFFER)) { if (!(this->m_Flags & GLTFLAG_SYSTEM_BUFFER)) {
BLIZZARD_ASSERT(this->m_RequestedNumMipmaps != 0); BC_ASSERT(this->m_RequestedNumMipmaps != 0);
this->m_NumMipmap = std::min(this->m_NumMipmap, this->m_RequestedNumMipmaps); this->m_NumMipmap = std::min(this->m_NumMipmap, this->m_RequestedNumMipmaps);
} }
@ -487,7 +487,7 @@ void GLTexture::SetupTexture() {
return; return;
} }
BLIZZARD_ASSERT(this->m_Data == nullptr); BC_ASSERT(this->m_Data == nullptr);
if (!this->IsRenderTarget()) { if (!this->IsRenderTarget()) {
this->m_Data = static_cast<char*>(Blizzard::Memory::Allocate(this->m_Size)); this->m_Data = static_cast<char*>(Blizzard::Memory::Allocate(this->m_Size));
@ -574,9 +574,9 @@ void GLTexture::SetupTexture() {
void GLTexture::Unbind(GLDevice* device, uint32_t stage) { void GLTexture::Unbind(GLDevice* device, uint32_t stage) {
auto& bindings = this->GetBindings(); auto& bindings = this->GetBindings();
BLIZZARD_ASSERT(device->GetID() < bindings.size()); BC_ASSERT(device->GetID() < bindings.size());
BLIZZARD_ASSERT(bindings[device->GetID()].device == device); BC_ASSERT(bindings[device->GetID()].device == device);
BLIZZARD_ASSERT(bindings[device->GetID()].boundStages[stage]); BC_ASSERT(bindings[device->GetID()].boundStages[stage]);
bindings[device->GetID()].boundStages[stage] = 0; bindings[device->GetID()].boundStages[stage] = 0;
} }
@ -628,7 +628,7 @@ GLTexture2D::GLTexture2D() : GLTexture() {
} }
void GLTexture2D::ReleaseObject() { void GLTexture2D::ReleaseObject() {
BLIZZARD_ASSERT(this->m_TextureType == GL_TEXTURE_2D); BC_ASSERT(this->m_TextureType == GL_TEXTURE_2D);
this->FreeTexture(); this->FreeTexture();
} }

View File

@ -15,7 +15,7 @@ uint32_t GLLTextureTypeToIndex(GLEnum textureType) {
} else { } else {
index = 5; index = 5;
BLIZZARD_ASSERT(false); BC_ASSERT(false);
} }
return index; return index;

View File

@ -107,7 +107,7 @@ void GLVertexArray::ApplyVertexFormat(GLDevice* device) {
this->m_GLStates.buffers[1] = indexBufferID; this->m_GLStates.buffers[1] = indexBufferID;
} }
BLIZZARD_ASSERT(this->GetProperties().m_VertexBufferFormat != nullptr); BC_ASSERT(this->GetProperties().m_VertexBufferFormat != nullptr);
auto& properties = this->GetProperties(); auto& properties = this->GetProperties();
bool attribEnable[16] = {}; bool attribEnable[16] = {};
@ -115,12 +115,12 @@ void GLVertexArray::ApplyVertexFormat(GLDevice* device) {
bool useVertexShader = device->GetShader(GLShader::eVertexShader) != nullptr; bool useVertexShader = device->GetShader(GLShader::eVertexShader) != nullptr;
for (int32_t index = 0; index < this->GetProperties().m_VertexBufferFormat->m_Size; index++) { for (int32_t index = 0; index < this->GetProperties().m_VertexBufferFormat->m_Size; index++) {
BLIZZARD_ASSERT(index < kMAX_VERTEX_ATTRIBS); BC_ASSERT(index < kMAX_VERTEX_ATTRIBS);
auto& attrib = this->GetProperties().m_VertexBufferFormat->m_Attribs[index]; auto& attrib = this->GetProperties().m_VertexBufferFormat->m_Attribs[index];
BLIZZARD_ASSERT(attrib.type != GLVT_INVALID); BC_ASSERT(attrib.type != GLVT_INVALID);
BLIZZARD_ASSERT(attrib.type < GLVT_NUM_VERTEX_TYPES); BC_ASSERT(attrib.type < GLVT_NUM_VERTEX_TYPES);
auto vertexBuffer = this->GetProperties().m_VertexBuffer[attrib.stream]; auto vertexBuffer = this->GetProperties().m_VertexBuffer[attrib.stream];

View File

@ -16,7 +16,7 @@ bool GLWindow::CanEnterFullscreenMode() {
void GLWindow::CreateView() { void GLWindow::CreateView() {
System_Autorelease::ScopedPool autorelease; System_Autorelease::ScopedPool autorelease;
BLIZZARD_ASSERT(this->m_View == nullptr); BC_ASSERT(this->m_View == nullptr);
GLLayerView* v1 = [this->m_ViewClass alloc]; GLLayerView* v1 = [this->m_ViewClass alloc];
NSView* v2 = [this->m_Window contentView]; NSView* v2 = [this->m_Window contentView];
@ -70,7 +70,7 @@ void GLWindow::Init(const CGRect& a2, GLWindowCallbacks* a3) {
this->SetCallbacks(a3); this->SetCallbacks(a3);
BLIZZARD_ASSERT(this->m_Window == nullptr); BC_ASSERT(this->m_Window == nullptr);
NSScreen* primaryScreen = [[NSScreen screens] objectAtIndex:0]; NSScreen* primaryScreen = [[NSScreen screens] objectAtIndex:0];
@ -102,7 +102,7 @@ void GLWindow::Init(const CGRect& a2, GLWindowCallbacks* a3) {
[window [window
setBackgroundColor: [NSColor blackColor]]; setBackgroundColor: [NSColor blackColor]];
BLIZZARD_ASSERT(this->m_Window != nullptr); BC_ASSERT(this->m_Window != nullptr);
// TODO // TODO
// return 1; // return 1;
@ -132,7 +132,7 @@ void GLWindow::SetCallbacks(GLWindowCallbacks* callbacks) {
} }
void GLWindow::SetOpenGLContext(GLContext* a2) { void GLWindow::SetOpenGLContext(GLContext* a2) {
BLIZZARD_ASSERT(this->m_View != nullptr); BC_ASSERT(this->m_View != nullptr);
System_Autorelease::ScopedPool autorelease; System_Autorelease::ScopedPool autorelease;

View File

@ -564,7 +564,7 @@ void CGxDeviceGLSDL::IRsSendToHw(EGxRenderState which) {
int32_t mode = static_cast<int32_t>(state->m_value); int32_t mode = static_cast<int32_t>(state->m_value);
// TODO // TODO
// BLIZZARD_ASSERT(mode <= GxCullState_CCW); // BC_ASSERT(mode <= GxCullState_CCW);
this->m_GLSDLDevice.SetCullMode(cullMode[mode]); this->m_GLSDLDevice.SetCullMode(cullMode[mode]);
@ -698,7 +698,7 @@ void CGxDeviceGLSDL::IShaderBindPixel(CGxShader* sh) {
this->IShaderCreatePixel(sh); this->IShaderCreatePixel(sh);
} }
BLIZZARD_ASSERT(sh->Valid()); BC_ASSERT(sh->Valid());
this->m_GLSDLDevice.SetShader(GLShader::ePixelShader, static_cast<GLShader*>(sh->apiSpecific)); this->m_GLSDLDevice.SetShader(GLShader::ePixelShader, static_cast<GLShader*>(sh->apiSpecific));
} }
@ -715,7 +715,7 @@ void CGxDeviceGLSDL::IShaderBindVertex(CGxShader* sh) {
this->IShaderCreateVertex(sh); this->IShaderCreateVertex(sh);
} }
BLIZZARD_ASSERT(sh->Valid()); BC_ASSERT(sh->Valid());
this->m_GLSDLDevice.SetShader(GLShader::eVertexShader, static_cast<GLShader*>(sh->apiSpecific)); this->m_GLSDLDevice.SetShader(GLShader::eVertexShader, static_cast<GLShader*>(sh->apiSpecific));
} }
@ -757,7 +757,7 @@ void CGxDeviceGLSDL::IShaderCreate(CGxShader* sh) {
} }
void CGxDeviceGLSDL::IShaderCreatePixel(CGxShader* ps) { void CGxDeviceGLSDL::IShaderCreatePixel(CGxShader* ps) {
BLIZZARD_ASSERT(!ps->loaded); BC_ASSERT(!ps->loaded);
ps->loaded = 1; ps->loaded = 1;
ps->valid = 0; ps->valid = 0;
@ -783,7 +783,7 @@ void CGxDeviceGLSDL::IShaderCreatePixel(CGxShader* ps) {
} }
void CGxDeviceGLSDL::IShaderCreateVertex(CGxShader* vs) { void CGxDeviceGLSDL::IShaderCreateVertex(CGxShader* vs) {
BLIZZARD_ASSERT(!vs->loaded); BC_ASSERT(!vs->loaded);
vs->loaded = 1; vs->loaded = 1;
vs->valid = 0; vs->valid = 0;
@ -1055,7 +1055,7 @@ void CGxDeviceGLSDL::ITexUpload(CGxTex* texId) {
texels texels
); );
BLIZZARD_ASSERT(texels != nullptr || texId->m_flags.m_renderTarget); BC_ASSERT(texels != nullptr || texId->m_flags.m_renderTarget);
if (!texId->m_flags.m_renderTarget) { if (!texId->m_flags.m_renderTarget) {
GLMipmap* mipmap = static_cast<GLTexture*>(texId->m_apiSpecificData)->GetMipmap(mipLevel - baseMip, CGxDeviceGLSDL::s_glCubeMapFaces[face]); GLMipmap* mipmap = static_cast<GLTexture*>(texId->m_apiSpecificData)->GetMipmap(mipLevel - baseMip, CGxDeviceGLSDL::s_glCubeMapFaces[face]);
@ -1070,8 +1070,8 @@ void CGxDeviceGLSDL::ITexUpload(CGxTex* texId) {
lockRect.maxY = std::min(lockRect.maxY, static_cast<int32_t>(height)); lockRect.maxY = std::min(lockRect.maxY, static_cast<int32_t>(height));
lockRect.maxX = std::min(lockRect.maxX, static_cast<int32_t>(width)); lockRect.maxX = std::min(lockRect.maxX, static_cast<int32_t>(width));
BLIZZARD_ASSERT(lockRect.minX >= 0 && lockRect.maxX <= static_cast<int32_t>(width)); BC_ASSERT(lockRect.minX >= 0 && lockRect.maxX <= static_cast<int32_t>(width));
BLIZZARD_ASSERT(lockRect.minY >= 0 && lockRect.maxY <= static_cast<int32_t>(height)); BC_ASSERT(lockRect.minY >= 0 && lockRect.maxY <= static_cast<int32_t>(height));
GLRect rect = { GLRect rect = {
lockRect.minX, lockRect.minX,
@ -1316,7 +1316,7 @@ int32_t CGxDeviceGLSDL::StereoEnabled() {
} }
void CGxDeviceGLSDL::TexDestroy(CGxTex* texId) { void CGxDeviceGLSDL::TexDestroy(CGxTex* texId) {
BLIZZARD_ASSERT(texId); BC_ASSERT(texId);
auto texture = static_cast<GLTexture*>(texId->m_apiSpecificData); auto texture = static_cast<GLTexture*>(texId->m_apiSpecificData);

View File

@ -54,10 +54,10 @@ GLBuffer::GLBuffer() : GLObject() {
} }
char* GLBuffer::Map(uint32_t offset, uint32_t size, eMapFlag flag) { char* GLBuffer::Map(uint32_t offset, uint32_t size, eMapFlag flag) {
BLIZZARD_ASSERT((offset + size) <= this->m_Size); BC_ASSERT((offset + size) <= this->m_Size);
BLIZZARD_ASSERT(this->m_Usage == GL_STATIC_DRAW || flag != GLMap_None); BC_ASSERT(this->m_Usage == GL_STATIC_DRAW || flag != GLMap_None);
BLIZZARD_ASSERT(this->m_MapFlag == GLMap_NotMapped); BC_ASSERT(this->m_MapFlag == GLMap_NotMapped);
BLIZZARD_ASSERT(flag >= GLMap_None && flag < GLMap_Count); BC_ASSERT(flag >= GLMap_None && flag < GLMap_Count);
this->m_MapOffset = offset; this->m_MapOffset = offset;
this->m_MapSize = offset + size == 0 ? this->m_Size : size; this->m_MapSize = offset + size == 0 ? this->m_Size : size;
@ -69,7 +69,7 @@ char* GLBuffer::Map(uint32_t offset, uint32_t size, eMapFlag flag) {
if (flag == GLMap_Unk2) { if (flag == GLMap_Unk2) {
if (this->m_Usage - GL_DYNAMIC_DRAW <= 1) { if (this->m_Usage - GL_DYNAMIC_DRAW <= 1) {
BLIZZARD_ASSERT(offset == 0); BC_ASSERT(offset == 0);
} }
glBufferData(this->m_Type, this->m_Size, nullptr, this->m_Usage); glBufferData(this->m_Type, this->m_Size, nullptr, this->m_Usage);
@ -78,7 +78,7 @@ char* GLBuffer::Map(uint32_t offset, uint32_t size, eMapFlag flag) {
void* data = glMapBuffer(this->m_Type, GLBuffer::s_FlagToAccess[flag]); void* data = glMapBuffer(this->m_Type, GLBuffer::s_FlagToAccess[flag]);
this->m_Data = reinterpret_cast<char*>(data); this->m_Data = reinterpret_cast<char*>(data);
BLIZZARD_ASSERT(this->m_Data != nullptr); BC_ASSERT(this->m_Data != nullptr);
} }
return this->m_Data + offset; return this->m_Data + offset;
@ -105,7 +105,7 @@ void GLBuffer::ReleaseObject() {
} }
void GLBuffer::Unmap(uint32_t size) { void GLBuffer::Unmap(uint32_t size) {
BLIZZARD_ASSERT((this->m_MapOffset + size) <= m_Size); BC_ASSERT((this->m_MapOffset + size) <= m_Size);
GLSDLDevice* device = GLSDLDevice::Get(); GLSDLDevice* device = GLSDLDevice::Get();
device->BindBuffer(this, GL_ZERO); device->BindBuffer(this, GL_ZERO);
@ -125,7 +125,7 @@ void GLBuffer::Unmap(uint32_t size) {
} }
GLboolean result = glUnmapBuffer(this->m_Type); GLboolean result = glUnmapBuffer(this->m_Type);
BLIZZARD_ASSERT(result); BC_ASSERT(result);
this->m_MapFlag = GLMap_NotMapped; this->m_MapFlag = GLMap_NotMapped;
} }

View File

@ -10,10 +10,10 @@ GLFramebuffer* GLFramebuffer::Create(bool a1) {
if (!a1) { if (!a1) {
// TODO // TODO
// BLIZZARD_ASSERT(framebuffer->m_FramebufferID >= PoolStats<GLFramebuffer>::NAME_POOL_FIRST_NAME); // BC_ASSERT(framebuffer->m_FramebufferID >= PoolStats<GLFramebuffer>::NAME_POOL_FIRST_NAME);
} }
BLIZZARD_ASSERT(framebuffer->m_NumAttach == 0); BC_ASSERT(framebuffer->m_NumAttach == 0);
framebuffer->m_Width = 0; framebuffer->m_Width = 0;
framebuffer->m_Height = 0; framebuffer->m_Height = 0;
@ -29,7 +29,7 @@ GLFramebuffer::GLFramebuffer(bool a1) : GLObject() {
} }
void GLFramebuffer::Attach(GLMipmap* image, GLenum a3, int32_t a4) { void GLFramebuffer::Attach(GLMipmap* image, GLenum a3, int32_t a4) {
BLIZZARD_ASSERT(this->m_Device == GLSDLDevice::Get()); BC_ASSERT(this->m_Device == GLSDLDevice::Get());
if (!image) { if (!image) {
this->Detach(a3); this->Detach(a3);
@ -37,7 +37,7 @@ void GLFramebuffer::Attach(GLMipmap* image, GLenum a3, int32_t a4) {
} }
if (a3 == GL_DEPTH_STENCIL) { if (a3 == GL_DEPTH_STENCIL) {
BLIZZARD_ASSERT(image->GetFormat() == GLTF_D24S8); BC_ASSERT(image->GetFormat() == GLTF_D24S8);
this->Attach(image, GL_DEPTH_ATTACHMENT, 0); this->Attach(image, GL_DEPTH_ATTACHMENT, 0);
this->Attach(image, GL_STENCIL_ATTACHMENT, 0); this->Attach(image, GL_STENCIL_ATTACHMENT, 0);
@ -57,7 +57,7 @@ void GLFramebuffer::Attach(GLMipmap* image, GLenum a3, int32_t a4) {
index = a3 - GL_COLOR_ATTACHMENT0; index = a3 - GL_COLOR_ATTACHMENT0;
} }
BLIZZARD_ASSERT(index < MAX_ATTACHMENT); BC_ASSERT(index < MAX_ATTACHMENT);
GLMipmap* oldImage = this->m_Attachments[index]; GLMipmap* oldImage = this->m_Attachments[index];
@ -77,7 +77,7 @@ void GLFramebuffer::Attach(GLMipmap* image, GLenum a3, int32_t a4) {
this->m_Device->Sub38460(0); this->m_Device->Sub38460(0);
} }
BLIZZARD_ASSERT((*image->m_AttachPoints)[m_FramebufferID].framebuffer == this); BC_ASSERT((*image->m_AttachPoints)[m_FramebufferID].framebuffer == this);
} }
void GLFramebuffer::Detach(GLenum a2) { void GLFramebuffer::Detach(GLenum a2) {
@ -96,7 +96,7 @@ void GLFramebuffer::Detach(GLenum a2) {
index = a2 - GL_COLOR_ATTACHMENT0; index = a2 - GL_COLOR_ATTACHMENT0;
} }
BLIZZARD_ASSERT(index < MAX_ATTACHMENT); BC_ASSERT(index < MAX_ATTACHMENT);
GLMipmap* oldImage = this->m_Attachments[index]; GLMipmap* oldImage = this->m_Attachments[index];
@ -129,7 +129,7 @@ GLMipmap* GLFramebuffer::GetAttachment(GLEnum a2) {
index = a2 - GL_COLOR_ATTACHMENT0; index = a2 - GL_COLOR_ATTACHMENT0;
} }
BLIZZARD_ASSERT(index < MAX_ATTACHMENT); BC_ASSERT(index < MAX_ATTACHMENT);
return this->m_Attachments[index]; return this->m_Attachments[index];
} }

View File

@ -18,7 +18,7 @@ void GLMipmap::Attach(GLFramebuffer* framebuffer, GLenum attachPoint, int32_t le
if (framebufferID >= attachPoints.size()) { if (framebufferID >= attachPoints.size()) {
attachPoints.resize(framebufferID + 1); attachPoints.resize(framebufferID + 1);
} else { } else {
BLIZZARD_ASSERT(attachPoints[framebufferID].framebuffer != framebuffer || attachPoints[framebufferID].point != attachPoint); BC_ASSERT(attachPoints[framebufferID].framebuffer != framebuffer || attachPoints[framebufferID].point != attachPoint);
auto& attach = attachPoints[framebufferID]; auto& attach = attachPoints[framebufferID];
@ -84,8 +84,8 @@ void GLMipmap::Detach(GLFramebuffer* framebuffer, GLenum attachPoint, bool a4) {
auto& attachPoints = *this->m_AttachPoints; auto& attachPoints = *this->m_AttachPoints;
BLIZZARD_ASSERT(attachPoints.size() >= framebufferID); BC_ASSERT(attachPoints.size() >= framebufferID);
BLIZZARD_ASSERT(attachPoints[framebufferID].framebuffer == framebuffer); BC_ASSERT(attachPoints[framebufferID].framebuffer == framebuffer);
if (!a4 && framebufferID) { if (!a4 && framebufferID) {
GLSDLDevice* v12 = GLSDLDevice::Get(); GLSDLDevice* v12 = GLSDLDevice::Get();
@ -104,17 +104,17 @@ void GLMipmap::Detach(GLFramebuffer* framebuffer, GLenum attachPoint, bool a4) {
GLAttachPoint* v9 = &attachPoints[framebufferID]; GLAttachPoint* v9 = &attachPoints[framebufferID];
if (v9->point == GL_DEPTH_STENCIL) { if (v9->point == GL_DEPTH_STENCIL) {
BLIZZARD_ASSERT(this->GetFormat() == GLTF_D24S8); BC_ASSERT(this->GetFormat() == GLTF_D24S8);
if (attachPoint == GL_DEPTH_ATTACHMENT) { if (attachPoint == GL_DEPTH_ATTACHMENT) {
v9->point = GL_STENCIL_ATTACHMENT; v9->point = GL_STENCIL_ATTACHMENT;
} else if (attachPoint == GL_STENCIL_ATTACHMENT) { } else if (attachPoint == GL_STENCIL_ATTACHMENT) {
v9->point = GL_DEPTH_ATTACHMENT; v9->point = GL_DEPTH_ATTACHMENT;
} else { } else {
BLIZZARD_ASSERT(false); BC_ASSERT(false);
} }
} else { } else {
BLIZZARD_ASSERT(attachPoints[framebufferID].point == attachPoint); BC_ASSERT(attachPoints[framebufferID].point == attachPoint);
v9->framebuffer = 0; v9->framebuffer = 0;
v9->point = 0; v9->point = 0;
@ -132,8 +132,8 @@ void GLMipmap::DetachAll() {
auto& attachPoints = *this->m_AttachPoints; auto& attachPoints = *this->m_AttachPoints;
for (int32_t i = 0; i < attachPoints.size(); i++) { for (int32_t i = 0; i < attachPoints.size(); i++) {
BLIZZARD_ASSERT(attachPoints[i].point != GL_ZERO); BC_ASSERT(attachPoints[i].point != GL_ZERO);
BLIZZARD_ASSERT(attachPoints[i].framebuffer->m_FramebufferID == i); BC_ASSERT(attachPoints[i].framebuffer->m_FramebufferID == i);
attachPoints[i].framebuffer->Detach(attachPoints[i].point); attachPoints[i].framebuffer->Detach(attachPoints[i].point);
} }
@ -170,11 +170,11 @@ uint16_t GLMipmap::GetWidth() {
} }
void* GLMipmap::Map(GLEnum mode, const GLBox* area) { void* GLMipmap::Map(GLEnum mode, const GLBox* area) {
BLIZZARD_ASSERT(!this->m_Texture->IsSystemBuffer()); BC_ASSERT(!this->m_Texture->IsSystemBuffer());
BLIZZARD_ASSERT(this->m_Data != nullptr); BC_ASSERT(this->m_Data != nullptr);
BLIZZARD_ASSERT(!this->m_Texture->IsRenderTarget()); BC_ASSERT(!this->m_Texture->IsRenderTarget());
BLIZZARD_ASSERT(mode != GL_ZERO); BC_ASSERT(mode != GL_ZERO);
BLIZZARD_ASSERT(this->m_MapParams == nullptr); BC_ASSERT(this->m_MapParams == nullptr);
if (mode != GL_READ_ONLY) { if (mode != GL_READ_ONLY) {
this->m_Texture->m_MappedMipmaps++; this->m_Texture->m_MappedMipmaps++;
@ -184,13 +184,13 @@ void* GLMipmap::Map(GLEnum mode, const GLBox* area) {
this->m_MapParams = mapParams; this->m_MapParams = mapParams;
if (area) { if (area) {
BLIZZARD_ASSERT(area->width > 0); BC_ASSERT(area->width > 0);
BLIZZARD_ASSERT(area->height > 0); BC_ASSERT(area->height > 0);
BLIZZARD_ASSERT(area->depth > 0); BC_ASSERT(area->depth > 0);
BLIZZARD_ASSERT(!this->GetFormatInfo().m_IsCompressed || ((area->top & 0x3) == 0 && (area->left & 0x3) == 0 && (area->width & 0x3) == 0 && (area->height & 0x3) == 0)); BC_ASSERT(!this->GetFormatInfo().m_IsCompressed || ((area->top & 0x3) == 0 && (area->left & 0x3) == 0 && (area->width & 0x3) == 0 && (area->height & 0x3) == 0));
BLIZZARD_ASSERT((area->height + area->top) <= this->m_Height); BC_ASSERT((area->height + area->top) <= this->m_Height);
BLIZZARD_ASSERT((area->depth + area->front) <= this->m_Depth); BC_ASSERT((area->depth + area->front) <= this->m_Depth);
BLIZZARD_ASSERT((area->width + area->left) <= this->m_Width); BC_ASSERT((area->width + area->left) <= this->m_Width);
mapParams->m_MapArea = { mapParams->m_MapArea = {
area->left, area->left,
@ -231,7 +231,7 @@ void* GLMipmap::Map(GLEnum mode, const GLBox* area) {
int32_t rowPitch = this->GetPitch(); int32_t rowPitch = this->GetPitch();
BLIZZARD_ASSERT(((mapParams->m_MapArea.top * rowPitch) + mapParams->m_MapArea.left * this->GetFormatInfo().m_BytePerPixel) < (this->GetFormatInfo().m_IsCompressed ? this->m_Size << 4 : this->m_Size)); BC_ASSERT(((mapParams->m_MapArea.top * rowPitch) + mapParams->m_MapArea.left * this->GetFormatInfo().m_BytePerPixel) < (this->GetFormatInfo().m_IsCompressed ? this->m_Size << 4 : this->m_Size));
int32_t v22 = rowPitch * this->m_Height; int32_t v22 = rowPitch * this->m_Height;
if (this->GetFormatInfo().m_IsCompressed) { if (this->GetFormatInfo().m_IsCompressed) {
@ -265,7 +265,7 @@ void* GLMipmap::Map(GLEnum mode, const GLRect* rect) {
} }
void GLMipmap::ReleaseObject() { void GLMipmap::ReleaseObject() {
BLIZZARD_ASSERT(this->m_MapParams == nullptr); BC_ASSERT(this->m_MapParams == nullptr);
this->RemoveDebugMipmap(); this->RemoveDebugMipmap();
this->DetachAll(); this->DetachAll();
@ -283,17 +283,17 @@ void GLMipmap::RemoveDebugMipmap() {
} }
void GLMipmap::ResetData(GLEnum target, int32_t level, unsigned char* data) { void GLMipmap::ResetData(GLEnum target, int32_t level, unsigned char* data) {
BLIZZARD_ASSERT(this->m_Target != GL_TEXTURE_3D || !this->GetFormatInfo().m_IsCompressed); BC_ASSERT(this->m_Target != GL_TEXTURE_3D || !this->GetFormatInfo().m_IsCompressed);
this->m_Target = target; this->m_Target = target;
this->m_Level = level; this->m_Level = level;
this->m_Data = data; this->m_Data = data;
BLIZZARD_ASSERT(this->GetFormat() != GLTF_INVALID); BC_ASSERT(this->GetFormat() != GLTF_INVALID);
BLIZZARD_ASSERT(this->GetFormat() < GLTF_NUM_TEXTURE_FORMATS); BC_ASSERT(this->GetFormat() < GLTF_NUM_TEXTURE_FORMATS);
if (!this->m_Texture->IsSystemBuffer() && this->m_Texture->IsRenderTarget()) { if (!this->m_Texture->IsSystemBuffer() && this->m_Texture->IsRenderTarget()) {
BLIZZARD_ASSERT(!this->GetFormatInfo().m_IsCompressed); BC_ASSERT(!this->GetFormatInfo().m_IsCompressed);
this->TexImage(nullptr); this->TexImage(nullptr);
this->m_Unk24 = 1; this->m_Unk24 = 1;
@ -306,7 +306,7 @@ void GLMipmap::ResetSize(uint32_t width, uint32_t height, uint32_t depth) {
this->m_Depth = depth ? depth : 1; this->m_Depth = depth ? depth : 1;
if (this->GetFormatInfo().m_IsCompressed) { if (this->GetFormatInfo().m_IsCompressed) {
BLIZZARD_ASSERT(this->m_Depth == 1); BC_ASSERT(this->m_Depth == 1);
this->m_Width = (this->m_Width + 3) & 0xFFFC; this->m_Width = (this->m_Width + 3) & 0xFFFC;
this->m_Height = (this->m_Height + 3) & 0xFFFC; this->m_Height = (this->m_Height + 3) & 0xFFFC;
@ -332,7 +332,7 @@ void GLMipmap::ResetSize(uint32_t width, uint32_t height, uint32_t depth) {
} }
void GLMipmap::TexImage(const void* pixels) { void GLMipmap::TexImage(const void* pixels) {
BLIZZARD_ASSERT((this->m_Texture->IsRenderTarget() || pixels != nullptr) && GLSDLDevice::Get()->GetVertexArrayStates().buffers[eGLBT_PIXEL_UNPACK] == 0); BC_ASSERT((this->m_Texture->IsRenderTarget() || pixels != nullptr) && GLSDLDevice::Get()->GetVertexArrayStates().buffers[eGLBT_PIXEL_UNPACK] == 0);
if (this->m_Target == GL_TEXTURE_3D) { if (this->m_Target == GL_TEXTURE_3D) {
glTexImage3D( glTexImage3D(
@ -374,7 +374,7 @@ void GLMipmap::TexImage(const void* pixels) {
} }
void GLMipmap::TexSubImage(const GLBox& a2, int32_t size, const void* pixels) { void GLMipmap::TexSubImage(const GLBox& a2, int32_t size, const void* pixels) {
BLIZZARD_ASSERT(!this->m_Texture->IsRenderTarget() && pixels != nullptr && GLSDLDevice::Get()->GetVertexArrayStates().buffers[eGLBT_PIXEL_UNPACK] == 0); BC_ASSERT(!this->m_Texture->IsRenderTarget() && pixels != nullptr && GLSDLDevice::Get()->GetVertexArrayStates().buffers[eGLBT_PIXEL_UNPACK] == 0);
if (this->m_Target == GL_TEXTURE_3D) { if (this->m_Target == GL_TEXTURE_3D) {
glPixelStorei(GL_UNPACK_ROW_LENGTH, this->m_Width); glPixelStorei(GL_UNPACK_ROW_LENGTH, this->m_Width);
@ -428,9 +428,9 @@ void GLMipmap::TexSubImage(const GLBox& a2, int32_t size, const void* pixels) {
} }
void GLMipmap::Unmap() { void GLMipmap::Unmap() {
BLIZZARD_ASSERT(!this->m_Texture->IsRenderTarget()); BC_ASSERT(!this->m_Texture->IsRenderTarget());
BLIZZARD_ASSERT(!this->m_Texture->IsSystemBuffer()); BC_ASSERT(!this->m_Texture->IsSystemBuffer());
BLIZZARD_ASSERT(this->m_MapParams != nullptr); BC_ASSERT(this->m_MapParams != nullptr);
if (this->m_MapParams->m_MapMode == GL_READ_ONLY) { if (this->m_MapParams->m_MapMode == GL_READ_ONLY) {
delete this->m_MapParams; delete this->m_MapParams;
@ -440,7 +440,7 @@ void GLMipmap::Unmap() {
GLSDLDevice* device = GLSDLDevice::Get(); GLSDLDevice* device = GLSDLDevice::Get();
BLIZZARD_ASSERT(this->m_Texture->m_MappedMipmaps > 0); BC_ASSERT(this->m_Texture->m_MappedMipmaps > 0);
this->Unmap(this->m_MapParams); this->Unmap(this->m_MapParams);
@ -448,7 +448,7 @@ void GLMipmap::Unmap() {
} }
void GLMipmap::Unmap(MapParams* mapParams) { void GLMipmap::Unmap(MapParams* mapParams) {
BLIZZARD_ASSERT(mapParams != nullptr); BC_ASSERT(mapParams != nullptr);
this->m_Texture->Bind(nullptr, 0); this->m_Texture->Bind(nullptr, 0);

View File

@ -5,7 +5,7 @@ void GLObject::AddRefTwin() {
} }
uint32_t GLObject::Release() { uint32_t GLObject::Release() {
BLIZZARD_ASSERT(this->m_RefCount > 0); BC_ASSERT(this->m_RefCount > 0);
this->m_RefCount--; this->m_RefCount--;

View File

@ -5,11 +5,11 @@
static bool s_GLEW_Initialized = false; static bool s_GLEW_Initialized = false;
void GLSDLContext::Create(GLSDLWindow* window) { void GLSDLContext::Create(GLSDLWindow* window) {
BLIZZARD_ASSERT(this->m_sdlGLContext == nullptr); BC_ASSERT(this->m_sdlGLContext == nullptr);
this->m_sdlGLContext = SDL_GL_CreateContext(window->m_sdlWindow); this->m_sdlGLContext = SDL_GL_CreateContext(window->m_sdlWindow);
BLIZZARD_ASSERT(this->m_sdlGLContext != nullptr); BC_ASSERT(this->m_sdlGLContext != nullptr);
if (s_GLEW_Initialized == false) { if (s_GLEW_Initialized == false) {
glewExperimental = true; glewExperimental = true;
@ -25,7 +25,7 @@ void GLSDLContext::Create(GLSDLWindow* window) {
} }
void GLSDLContext::Destroy() { void GLSDLContext::Destroy() {
BLIZZARD_ASSERT(this->m_sdlGLContext != nullptr); BC_ASSERT(this->m_sdlGLContext != nullptr);
SDL_GL_DeleteContext(this->m_sdlGLContext); SDL_GL_DeleteContext(this->m_sdlGLContext);
this->m_sdlGLContext = nullptr; this->m_sdlGLContext = nullptr;
@ -37,7 +37,7 @@ bool GLSDLContext::IsCurrentContext() {
void GLSDLContext::MakeCurrent(GLSDLWindow* window) { void GLSDLContext::MakeCurrent(GLSDLWindow* window) {
auto status = SDL_GL_MakeCurrent(window->m_sdlWindow, this->m_sdlGLContext); auto status = SDL_GL_MakeCurrent(window->m_sdlWindow, this->m_sdlGLContext);
BLIZZARD_ASSERT(status == 0); BC_ASSERT(status == 0);
} }
int32_t GLSDLContext::GetSampleCount() { int32_t GLSDLContext::GetSampleCount() {

View File

@ -156,7 +156,7 @@ void GLSDLDevice::SetOption(GLSDLDeviceOption option, bool enable) {
} }
default: { default: {
BLIZZARD_ASSERT(false); BC_ASSERT(false);
} }
} }
} }
@ -992,8 +992,8 @@ void GLSDLDevice::ApplyTransforms() {
} }
void GLSDLDevice::BindBuffer(GLBuffer* buffer, GLEnum target) { void GLSDLDevice::BindBuffer(GLBuffer* buffer, GLEnum target) {
BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); BC_ASSERT(this->m_Context.IsCurrentContext());
BLIZZARD_ASSERT(buffer != nullptr || target != GL_ZERO); BC_ASSERT(buffer != nullptr || target != GL_ZERO);
GLEnum bindTarget = target == GL_ZERO ? buffer->m_Type : target; GLEnum bindTarget = target == GL_ZERO ? buffer->m_Type : target;
GLuint bindName = buffer == nullptr ? 0 : buffer->m_BufferID; GLuint bindName = buffer == nullptr ? 0 : buffer->m_BufferID;
@ -1009,7 +1009,7 @@ void GLSDLDevice::BindBuffer(GLBuffer* buffer, GLEnum target) {
} else if (bindTarget == GL_PIXEL_UNPACK_BUFFER) { } else if (bindTarget == GL_PIXEL_UNPACK_BUFFER) {
bindIndex = 3; bindIndex = 3;
} else { } else {
BLIZZARD_ASSERT(false); BC_ASSERT(false);
} }
if (bindTarget == GL_ARRAY_BUFFER) { if (bindTarget == GL_ARRAY_BUFFER) {
@ -1031,7 +1031,7 @@ void GLSDLDevice::BindBuffer(GLBuffer* buffer, GLEnum target) {
} }
void GLSDLDevice::BindFramebuffer(GLFramebuffer* framebuffer) { void GLSDLDevice::BindFramebuffer(GLFramebuffer* framebuffer) {
BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); BC_ASSERT(this->m_Context.IsCurrentContext());
GLuint v3; GLuint v3;
@ -1054,8 +1054,8 @@ void GLSDLDevice::BindGLSLProgram(GLGLSLProgram* a2) {
} }
void GLSDLDevice::BindShader(GLShader* shader) { void GLSDLDevice::BindShader(GLShader* shader) {
BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); BC_ASSERT(this->m_Context.IsCurrentContext());
BLIZZARD_ASSERT(shader); BC_ASSERT(shader);
if (shader->var5 == GL_FRAGMENT_PROGRAM_ARB) { if (shader->var5 == GL_FRAGMENT_PROGRAM_ARB) {
if (this->m_States.binding.pixelProgram != shader->m_ShaderID) { if (this->m_States.binding.pixelProgram != shader->m_ShaderID) {
@ -1068,19 +1068,19 @@ void GLSDLDevice::BindShader(GLShader* shader) {
this->m_States.binding.vertexProgram = shader->m_ShaderID; this->m_States.binding.vertexProgram = shader->m_ShaderID;
} }
} else { } else {
BLIZZARD_ASSERT(false); BC_ASSERT(false);
} }
} }
void GLSDLDevice::BindTexture(GLEnum textureType, GLTexture* texture) { void GLSDLDevice::BindTexture(GLEnum textureType, GLTexture* texture) {
BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); BC_ASSERT(this->m_Context.IsCurrentContext());
BLIZZARD_ASSERT(texture == nullptr || textureType == texture->m_TextureType); BC_ASSERT(texture == nullptr || textureType == texture->m_TextureType);
uint32_t textureID = texture ? texture->m_TextureID : 0; uint32_t textureID = texture ? texture->m_TextureID : 0;
uint32_t index = GLSDLTextureTypeToIndex(textureType); uint32_t index = GLSDLTextureTypeToIndex(textureType);
BLIZZARD_ASSERT(this->m_States.binding.texture[index][this->m_States.binding.currentActiveTexture] != textureID); BC_ASSERT(this->m_States.binding.texture[index][this->m_States.binding.currentActiveTexture] != textureID);
BLIZZARD_ASSERT(this->m_BoundTextures[index][this->m_States.binding.currentActiveTexture] != texture); BC_ASSERT(this->m_BoundTextures[index][this->m_States.binding.currentActiveTexture] != texture);
GLTexture* boundTexture = this->m_BoundTextures[index][this->m_States.binding.currentActiveTexture]; GLTexture* boundTexture = this->m_BoundTextures[index][this->m_States.binding.currentActiveTexture];
if (boundTexture) { if (boundTexture) {
@ -1124,7 +1124,7 @@ void GLSDLDevice::BindTexture(GLEnum textureType, GLTexture* texture) {
} }
void GLSDLDevice::BindVertexArray(GLVertexArray* a2) { void GLSDLDevice::BindVertexArray(GLVertexArray* a2) {
BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); BC_ASSERT(this->m_Context.IsCurrentContext());
int32_t v4 = a2 ? a2->m_VertexArrayID : 0; int32_t v4 = a2 ? a2->m_VertexArrayID : 0;
@ -1136,8 +1136,8 @@ void GLSDLDevice::BindVertexArray(GLVertexArray* a2) {
} }
void GLSDLDevice::BlitFramebuffer(GLMipmap* src, const GLRect* srcRect, GLMipmap* dst, const GLRect* dstRect, GLEnum mask, GLEnum filter) { void GLSDLDevice::BlitFramebuffer(GLMipmap* src, const GLRect* srcRect, GLMipmap* dst, const GLRect* dstRect, GLEnum mask, GLEnum filter) {
BLIZZARD_ASSERT(mask == GL_COLOR_BUFFER_BIT); BC_ASSERT(mask == GL_COLOR_BUFFER_BIT);
BLIZZARD_ASSERT(src != nullptr); BC_ASSERT(src != nullptr);
GLRect fullSrcRect = { GLRect fullSrcRect = {
0, 0,
@ -1153,9 +1153,9 @@ void GLSDLDevice::BlitFramebuffer(GLMipmap* src, const GLRect* srcRect, GLMipmap
dst ? dst->GetHeight() : this->m_Window->GetHeight() dst ? dst->GetHeight() : this->m_Window->GetHeight()
}; };
BLIZZARD_ASSERT(filter == GL_NEAREST); BC_ASSERT(filter == GL_NEAREST);
// TODO // TODO
// BLIZZARD_ASSERT(srcRect == nullptr || *srcRect == fullSrcRect); // BC_ASSERT(srcRect == nullptr || *srcRect == fullSrcRect);
// TODO // TODO
// - non-shader code path // - non-shader code path
@ -1376,18 +1376,18 @@ void GLSDLDevice::BlitFramebuffer(GLMipmap* src, const GLRect* srcRect, GLMipmap
} }
void GLSDLDevice::CheckDepthTarget() { void GLSDLDevice::CheckDepthTarget() {
BLIZZARD_ASSERT(this->m_CurrentTargetColor[0] == nullptr || this->m_CurrentTargetColor[0]->GetTexture()->IsValid()); BC_ASSERT(this->m_CurrentTargetColor[0] == nullptr || this->m_CurrentTargetColor[0]->GetTexture()->IsValid());
BLIZZARD_ASSERT(this->m_CurrentTargetColor[1] == nullptr || this->m_CurrentTargetColor[1]->GetTexture()->IsValid()); BC_ASSERT(this->m_CurrentTargetColor[1] == nullptr || this->m_CurrentTargetColor[1]->GetTexture()->IsValid());
BLIZZARD_ASSERT(this->m_CurrentTargetColor[2] == nullptr || this->m_CurrentTargetColor[2]->GetTexture()->IsValid()); BC_ASSERT(this->m_CurrentTargetColor[2] == nullptr || this->m_CurrentTargetColor[2]->GetTexture()->IsValid());
BLIZZARD_ASSERT(this->m_CurrentTargetColor[3] == nullptr || this->m_CurrentTargetColor[3]->GetTexture()->IsValid()); BC_ASSERT(this->m_CurrentTargetColor[3] == nullptr || this->m_CurrentTargetColor[3]->GetTexture()->IsValid());
BLIZZARD_ASSERT(this->m_CurrentTargetDepth == nullptr || this->m_CurrentDepthBuffer != nullptr); BC_ASSERT(this->m_CurrentTargetDepth == nullptr || this->m_CurrentDepthBuffer != nullptr);
if (!this->m_CurrentDepthBuffer) { if (!this->m_CurrentDepthBuffer) {
return; return;
} }
BLIZZARD_ASSERT(this->m_CurrentDepthBuffer->GetTexture()->IsValid()); BC_ASSERT(this->m_CurrentDepthBuffer->GetTexture()->IsValid());
auto currentTargetColor = this->m_CurrentTargetColor[0]; auto currentTargetColor = this->m_CurrentTargetColor[0];
auto currentDepthBuffer = this->m_CurrentDepthBuffer; auto currentDepthBuffer = this->m_CurrentDepthBuffer;
@ -1539,8 +1539,8 @@ void GLSDLDevice::Clear(uint32_t clearMask, const GLColor4f& clearColor, double
} }
void GLSDLDevice::CopyTex(uint32_t a2, uint32_t a3, GLMipmap* dst, const GLRect* framebufferRect) { void GLSDLDevice::CopyTex(uint32_t a2, uint32_t a3, GLMipmap* dst, const GLRect* framebufferRect) {
BLIZZARD_ASSERT(framebufferRect->width == dst->GetWidth()); BC_ASSERT(framebufferRect->width == dst->GetWidth());
BLIZZARD_ASSERT(framebufferRect->height == dst->GetHeight()); BC_ASSERT(framebufferRect->height == dst->GetHeight());
dst->m_Texture->Bind(nullptr, false); dst->m_Texture->Bind(nullptr, false);
@ -1637,7 +1637,7 @@ const GLStates::VertexArrayObject& GLSDLDevice::GetVertexArrayStates() {
} }
void GLSDLDevice::GLSDLDraw(GLEnum mode, uint32_t start, uint32_t end, uint32_t a5, uint32_t a6, uint32_t count) { void GLSDLDevice::GLSDLDraw(GLEnum mode, uint32_t start, uint32_t end, uint32_t a5, uint32_t a6, uint32_t count) {
BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); BC_ASSERT(this->m_Context.IsCurrentContext());
this->CheckDepthTarget(); this->CheckDepthTarget();
@ -1699,7 +1699,7 @@ void GLSDLDevice::GLSDLDraw(GLEnum mode, uint32_t start, uint32_t end, uint32_t
} else if (format == GL_UNSIGNED_INT) { } else if (format == GL_UNSIGNED_INT) {
v18 = 2; v18 = 2;
} else { } else {
BLIZZARD_ASSERT(!"buffer uses unknown format"); BC_ASSERT(!"buffer uses unknown format");
} }
void* indices = GLBuffer::m_UsingVBO void* indices = GLBuffer::m_UsingVBO
@ -2015,7 +2015,7 @@ void GLSDLDevice::LoadDefaultStates() {
} }
void GLSDLDevice::ResetBackbuffer(uint32_t width, uint32_t height, GLTextureFormat colorFormat, GLTextureFormat depthFormat, uint32_t sampleCount) { void GLSDLDevice::ResetBackbuffer(uint32_t width, uint32_t height, GLTextureFormat colorFormat, GLTextureFormat depthFormat, uint32_t sampleCount) {
BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); BC_ASSERT(this->m_Context.IsCurrentContext());
// if ( // if (
// this->m_BackBufferColor // this->m_BackBufferColor
@ -2112,7 +2112,7 @@ void GLSDLDevice::ResetBackbuffer(uint32_t width, uint32_t height, GLTextureForm
this->SetDepthTestEnable(1); this->SetDepthTestEnable(1);
} }
BLIZZARD_ASSERT(this->m_CurrentTarget->IsValid()); BC_ASSERT(this->m_CurrentTarget->IsValid());
this->Clear(0x4500, GLColor4f::BLACK, 1.0, 0); this->Clear(0x4500, GLColor4f::BLACK, 1.0, 0);
} }
@ -2134,7 +2134,7 @@ void GLSDLDevice::Resize(uint32_t width, uint32_t height) {
} }
void GLSDLDevice::RestoreTextures() { void GLSDLDevice::RestoreTextures() {
BLIZZARD_ASSERT(this->m_Context.IsCurrentContext()); BC_ASSERT(this->m_Context.IsCurrentContext());
for (int32_t i = 0; i < 16; i++) { for (int32_t i = 0; i < 16; i++) {
GLTexture* texture = this->m_Textures[i]; GLTexture* texture = this->m_Textures[i];
@ -2181,7 +2181,7 @@ void GLSDLDevice::SetAlphaBlendEnable(bool enable) {
void GLSDLDevice::SetAlphaTest(GLEnum func, float ref) { void GLSDLDevice::SetAlphaTest(GLEnum func, float ref) {
if (this->m_States.fixedFunc.alphaTestFunc != func || this->m_States.fixedFunc.alphaTestRef != ref) { if (this->m_States.fixedFunc.alphaTestFunc != func || this->m_States.fixedFunc.alphaTestRef != ref) {
BLIZZARD_ASSERT(ref <= 1.0f); BC_ASSERT(ref <= 1.0f);
glAlphaFunc(func, ref); glAlphaFunc(func, ref);
this->m_States.fixedFunc.alphaTestFunc = func; this->m_States.fixedFunc.alphaTestFunc = func;
@ -2396,12 +2396,12 @@ void GLSDLDevice::SetFogParam(GLEnum param, float value) {
this->m_States.fixedFunc.fogDensity = value; this->m_States.fixedFunc.fogDensity = value;
} }
} else { } else {
BLIZZARD_ASSERT(false); BC_ASSERT(false);
} }
} }
void GLSDLDevice::SetIndexBuffer(GLBuffer* buffer) { void GLSDLDevice::SetIndexBuffer(GLBuffer* buffer) {
BLIZZARD_ASSERT(buffer == nullptr || buffer->m_IndexFormat != GL_ZERO); BC_ASSERT(buffer == nullptr || buffer->m_IndexFormat != GL_ZERO);
this->m_DefaultVertexArrayObject.m_Properties.m_IndexBuffer = buffer; this->m_DefaultVertexArrayObject.m_Properties.m_IndexBuffer = buffer;
} }
@ -2429,7 +2429,7 @@ void GLSDLDevice::SetModelView(GLEnum transform) {
} }
if (transform != GL_MODELVIEW) { if (transform != GL_MODELVIEW) {
BLIZZARD_ASSERT(false); BC_ASSERT(false);
} }
auto& world = this->m_States.fixedFunc.transforms.world; auto& world = this->m_States.fixedFunc.transforms.world;
@ -2450,7 +2450,7 @@ void GLSDLDevice::SetModelView(GLEnum transform) {
modelView.isDirty = true; modelView.isDirty = true;
} else { } else {
// TODO assign model * view to modelView // TODO assign model * view to modelView
BLIZZARD_ASSERT(!"Unimplemented"); BC_ASSERT(!"Unimplemented");
} }
if (this->m_States.fixedFunc.transforms.matrixMode != GL_MODELVIEW) { if (this->m_States.fixedFunc.transforms.matrixMode != GL_MODELVIEW) {
@ -2496,8 +2496,8 @@ void GLSDLDevice::SetShader(GLShader::ShaderType shaderType, GLShader* shader) {
// TODO // TODO
} }
BLIZZARD_ASSERT(shader->IsEnabled()); BC_ASSERT(shader->IsEnabled());
BLIZZARD_ASSERT(shader->GetShaderType() == shaderType); BC_ASSERT(shader->GetShaderType() == shaderType);
this->BindShader(shader); this->BindShader(shader);
} }
@ -2529,12 +2529,12 @@ void GLSDLDevice::SetShader(GLShader::ShaderType shaderType, GLShader* shader) {
this->m_PixelShader = shader; this->m_PixelShader = shader;
} else { } else {
BLIZZARD_ASSERT(!"Unknown shader type!"); BC_ASSERT(!"Unknown shader type!");
} }
} }
void GLSDLDevice::SetShaderConstants(GLShader::ShaderType shaderType, uint32_t index, const float* constants, uint32_t count) { void GLSDLDevice::SetShaderConstants(GLShader::ShaderType shaderType, uint32_t index, const float* constants, uint32_t count) {
BLIZZARD_ASSERT(count != 0); BC_ASSERT(count != 0);
GLShader* shader = nullptr; GLShader* shader = nullptr;
@ -2560,12 +2560,12 @@ void GLSDLDevice::SetShaderConstants(GLShader::ShaderType shaderType, uint32_t i
void GLSDLDevice::SetShaderConstantsInternal(GLShader::ShaderType shaderType, uint32_t index, const float* constants, uint32_t count) { void GLSDLDevice::SetShaderConstantsInternal(GLShader::ShaderType shaderType, uint32_t index, const float* constants, uint32_t count) {
if (shaderType == GLShader::eVertexShader) { if (shaderType == GLShader::eVertexShader) {
BLIZZARD_ASSERT((index + count) <= std::extent<decltype(this->m_States.shader.vertexShaderConst)>::value); BC_ASSERT((index + count) <= std::extent<decltype(this->m_States.shader.vertexShaderConst)>::value);
memcpy(&this->m_States.shader.vertexShaderConst[index], constants, (sizeof(float) * 4) * count); memcpy(&this->m_States.shader.vertexShaderConst[index], constants, (sizeof(float) * 4) * count);
BLIZZARD_ASSERT(index <= 0xFFFF); BC_ASSERT(index <= 0xFFFF);
BLIZZARD_ASSERT(count <= 0xFFFF); BC_ASSERT(count <= 0xFFFF);
uint16_t start = std::min(static_cast<uint16_t>(index), this->m_DirtyVertexShaderConsts.start); uint16_t start = std::min(static_cast<uint16_t>(index), this->m_DirtyVertexShaderConsts.start);
uint16_t end = std::max(static_cast<uint16_t>(index + count), this->m_DirtyVertexShaderConsts.end); uint16_t end = std::max(static_cast<uint16_t>(index + count), this->m_DirtyVertexShaderConsts.end);
@ -2573,12 +2573,12 @@ void GLSDLDevice::SetShaderConstantsInternal(GLShader::ShaderType shaderType, ui
this->m_DirtyVertexShaderConsts.start = start; this->m_DirtyVertexShaderConsts.start = start;
this->m_DirtyVertexShaderConsts.end = end; this->m_DirtyVertexShaderConsts.end = end;
} else if (shaderType == GLShader::ePixelShader) { } else if (shaderType == GLShader::ePixelShader) {
BLIZZARD_ASSERT((index + count) <= std::extent<decltype(this->m_States.shader.pixelShaderConst)>::value); BC_ASSERT((index + count) <= std::extent<decltype(this->m_States.shader.pixelShaderConst)>::value);
memcpy(&this->m_States.shader.pixelShaderConst[index], constants, (sizeof(float) * 4) * count); memcpy(&this->m_States.shader.pixelShaderConst[index], constants, (sizeof(float) * 4) * count);
BLIZZARD_ASSERT(index <= 0xFFFF); BC_ASSERT(index <= 0xFFFF);
BLIZZARD_ASSERT(count <= 0xFFFF); BC_ASSERT(count <= 0xFFFF);
uint16_t start = std::min(static_cast<uint16_t>(index), this->m_DirtyPixelShaderConsts.start); uint16_t start = std::min(static_cast<uint16_t>(index), this->m_DirtyPixelShaderConsts.start);
uint16_t end = std::max(static_cast<uint16_t>(index + count), this->m_DirtyPixelShaderConsts.end); uint16_t end = std::max(static_cast<uint16_t>(index + count), this->m_DirtyPixelShaderConsts.end);
@ -2587,16 +2587,16 @@ void GLSDLDevice::SetShaderConstantsInternal(GLShader::ShaderType shaderType, ui
this->m_DirtyPixelShaderConsts.end = end; this->m_DirtyPixelShaderConsts.end = end;
} else { } else {
// TODO // TODO
// BLIZZARD_ASSERT(false, "Unknown shader type %d!", shaderType); // BC_ASSERT(false, "Unknown shader type %d!", shaderType);
} }
} }
void GLSDLDevice::SetTexture(uint32_t stage, GLTexture* texture) { void GLSDLDevice::SetTexture(uint32_t stage, GLTexture* texture) {
if (stage > 15) { if (stage > 15) {
BLIZZARD_ASSERT(!"setting an unsupported texture stage to a non-NULL texture"); BC_ASSERT(!"setting an unsupported texture stage to a non-NULL texture");
} }
BLIZZARD_ASSERT(texture == nullptr || texture->IsValid()); BC_ASSERT(texture == nullptr || texture->IsValid());
uint32_t textureID = 0; uint32_t textureID = 0;
GLEnum textureType = GL_TEXTURE_2D; GLEnum textureType = GL_TEXTURE_2D;
@ -2637,7 +2637,7 @@ void GLSDLDevice::SetTransform(GLEnum transform, const float* a3) {
} else if (transform >= GL_TEXTURE0 && transform <= GL_TEXTURE7) { } else if (transform >= GL_TEXTURE0 && transform <= GL_TEXTURE7) {
t = &this->m_States.fixedFunc.transforms.texture[transform - GL_TEXTURE0]; t = &this->m_States.fixedFunc.transforms.texture[transform - GL_TEXTURE0];
} else { } else {
BLIZZARD_ASSERT(false); BC_ASSERT(false);
} }
if (*t != a3) { if (*t != a3) {
@ -2662,8 +2662,8 @@ void GLSDLDevice::SetUnpackClientStorage(bool enable) {
} }
void GLSDLDevice::SetVertexBuffer(uint32_t index, GLBuffer* buffer, uint32_t offset, uint32_t stride) { void GLSDLDevice::SetVertexBuffer(uint32_t index, GLBuffer* buffer, uint32_t offset, uint32_t stride) {
BLIZZARD_ASSERT(index < GL_MAX_STREAM); BC_ASSERT(index < GL_MAX_STREAM);
BLIZZARD_ASSERT(buffer == nullptr || buffer->m_IndexFormat == GL_ZERO); BC_ASSERT(buffer == nullptr || buffer->m_IndexFormat == GL_ZERO);
auto properties = &this->m_DefaultVertexArrayObject.m_Properties; auto properties = &this->m_DefaultVertexArrayObject.m_Properties;
properties->m_VertexBuffer[index] = buffer; properties->m_VertexBuffer[index] = buffer;
@ -2672,7 +2672,7 @@ void GLSDLDevice::SetVertexBuffer(uint32_t index, GLBuffer* buffer, uint32_t off
} }
void GLSDLDevice::SetVertexFormat(GLVertexFormat* format) { void GLSDLDevice::SetVertexFormat(GLVertexFormat* format) {
BLIZZARD_ASSERT(format->m_Size <= kMAX_VERTEX_ATTRIBS); BC_ASSERT(format->m_Size <= kMAX_VERTEX_ATTRIBS);
this->m_DefaultVertexArrayObject.m_Properties.m_VertexBufferFormat = format; this->m_DefaultVertexArrayObject.m_Properties.m_VertexBufferFormat = format;
} }

View File

@ -13,7 +13,7 @@
static bool s_GLSDL_Initialized = false; static bool s_GLSDL_Initialized = false;
void GLSDLWindow::Create(const char* title, const GLSDLWindowRect& rect, GLTextureFormat depthFormat, uint32_t sampleCount) { void GLSDLWindow::Create(const char* title, const GLSDLWindowRect& rect, GLTextureFormat depthFormat, uint32_t sampleCount) {
BLIZZARD_ASSERT(this->m_sdlWindow == nullptr); BC_ASSERT(this->m_sdlWindow == nullptr);
if (!s_GLSDL_Initialized) { if (!s_GLSDL_Initialized) {
// Initialize SDL video context // Initialize SDL video context
@ -48,7 +48,7 @@ void GLSDLWindow::Create(const char* title, const GLSDLWindowRect& rect, GLTextu
stencilSize = 8; stencilSize = 8;
break; break;
default: default:
BLIZZARD_ASSERT(false); BC_ASSERT(false);
break; break;
} }
@ -74,7 +74,7 @@ void GLSDLWindow::Create(const char* title, const GLSDLWindowRect& rect, GLTextu
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE
); );
BLIZZARD_ASSERT(this->m_sdlWindow != nullptr); BC_ASSERT(this->m_sdlWindow != nullptr);
SDL_StartTextInput(); SDL_StartTextInput();
} }
@ -126,7 +126,7 @@ void GLSDLWindow::Resize(const GLSDLWindowRect& rect) {
if (current.size.width != rect.size.width || current.size.height != rect.size.width) { if (current.size.width != rect.size.width || current.size.height != rect.size.width) {
SDL_SetWindowSize(this->m_sdlWindow, rect.size.width, rect.size.height); SDL_SetWindowSize(this->m_sdlWindow, rect.size.width, rect.size.height);
// BLIZZARD_ASSERT(status == 0); // BC_ASSERT(status == 0);
} }
} }

View File

@ -15,14 +15,14 @@ GLShader* GLShader::Create(ShaderType shaderType, bool hybrid, bool usingCG, con
const char* shaderCode = reinterpret_cast<const char*>(buf); const char* shaderCode = reinterpret_cast<const char*>(buf);
if (*reinterpret_cast<const int32_t*>(buf) == 'GSL1') { if (*reinterpret_cast<const int32_t*>(buf) == 'GSL1') {
BLIZZARD_ASSERT(!usingCG); BC_ASSERT(!usingCG);
const ShaderDataHeader header = *reinterpret_cast<const ShaderDataHeader*>(buf); const ShaderDataHeader header = *reinterpret_cast<const ShaderDataHeader*>(buf);
BLIZZARD_ASSERT(header.shaderType == shaderType); BC_ASSERT(header.shaderType == shaderType);
BLIZZARD_ASSERT(header.size == codeLen); BC_ASSERT(header.size == codeLen);
BLIZZARD_ASSERT(header.codePos >= sizeof(ShaderDataHeader)); BC_ASSERT(header.codePos >= sizeof(ShaderDataHeader));
BLIZZARD_ASSERT(header.codeSize > 0); BC_ASSERT(header.codeSize > 0);
shaderCode = &reinterpret_cast<const char*>(buf)[header.codePos]; shaderCode = &reinterpret_cast<const char*>(buf)[header.codePos];
} }
@ -85,7 +85,7 @@ int32_t GLShader::GetShaderType() {
} }
void GLShader::ImmediateCompile(GLShaderLogInfo* logInfo) { void GLShader::ImmediateCompile(GLShaderLogInfo* logInfo) {
BLIZZARD_ASSERT(!this->GetCode().empty()); BC_ASSERT(!this->GetCode().empty());
this->m_Device = GLSDLDevice::Get(); this->m_Device = GLSDLDevice::Get();
@ -105,7 +105,7 @@ void GLShader::ImmediateCompile(GLShaderLogInfo* logInfo) {
glProgramStringARB(this->var5, GL_PROGRAM_FORMAT_ASCII_ARB, arbLen, arbCode); glProgramStringARB(this->var5, GL_PROGRAM_FORMAT_ASCII_ARB, arbLen, arbCode);
BLIZZARD_ASSERT(this->CheckErrorsARB(logInfo)); BC_ASSERT(this->CheckErrorsARB(logInfo));
} else { } else {
// TODO // TODO
// - handle GLSL shaders // - handle GLSL shaders

View File

@ -18,14 +18,14 @@ void GLTexture::DestroyBindings(void* ptr) {
} }
void GLTexture::Bind(GLSDLDevice* device, bool force) { void GLTexture::Bind(GLSDLDevice* device, bool force) {
BLIZZARD_ASSERT(!this->IsSystemBuffer()); BC_ASSERT(!this->IsSystemBuffer());
BLIZZARD_ASSERT(this->m_Depth != 0); BC_ASSERT(this->m_Depth != 0);
if (!device) { if (!device) {
device = GLSDLDevice::Get(); device = GLSDLDevice::Get();
} }
BLIZZARD_ASSERT(device != nullptr); BC_ASSERT(device != nullptr);
auto& bindings = this->GetBindings(); auto& bindings = this->GetBindings();
uint32_t deviceID = device->GetID(); uint32_t deviceID = device->GetID();
@ -152,10 +152,10 @@ TextureFormatInfo& GLTexture::GetFormatInfo() {
} }
GLMipmap* GLTexture::GetMipmap(uint32_t level, GLEnum face) { GLMipmap* GLTexture::GetMipmap(uint32_t level, GLEnum face) {
BLIZZARD_ASSERT(face >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z); BC_ASSERT(face >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && face <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);
BLIZZARD_ASSERT(level < this->m_NumMipmap); BC_ASSERT(level < this->m_NumMipmap);
BLIZZARD_ASSERT(this->m_Mipmaps != nullptr); BC_ASSERT(this->m_Mipmaps != nullptr);
BLIZZARD_ASSERT(this->m_Mipmaps[face - GL_TEXTURE_CUBE_MAP_POSITIVE_X] != nullptr); BC_ASSERT(this->m_Mipmaps[face - GL_TEXTURE_CUBE_MAP_POSITIVE_X] != nullptr);
return &this->m_Mipmaps[face - GL_TEXTURE_CUBE_MAP_POSITIVE_X][level]; return &this->m_Mipmaps[face - GL_TEXTURE_CUBE_MAP_POSITIVE_X][level];
} }
@ -173,7 +173,7 @@ bool GLTexture::IsValid() {
} }
void* GLTexture::Map(uint32_t level, const GLRect* a3, uint32_t& a4, GLEnum a5) { void* GLTexture::Map(uint32_t level, const GLRect* a3, uint32_t& a4, GLEnum a5) {
BLIZZARD_ASSERT(this->m_TextureType != GL_TEXTURE_3D); BC_ASSERT(this->m_TextureType != GL_TEXTURE_3D);
auto mipmap = this->GetMipmap(level, GL_TEXTURE_CUBE_MAP_POSITIVE_X); auto mipmap = this->GetMipmap(level, GL_TEXTURE_CUBE_MAP_POSITIVE_X);
a4 = mipmap->GetPitch(); a4 = mipmap->GetPitch();
@ -209,7 +209,7 @@ void GLTexture::RecreateGLTexture() {
} }
void GLTexture::ResizeMipmaps() { void GLTexture::ResizeMipmaps() {
BLIZZARD_ASSERT(this->m_Mipmaps == nullptr); BC_ASSERT(this->m_Mipmaps == nullptr);
int32_t numFace = this->m_TextureType == GL_TEXTURE_CUBE_MAP ? 6 : 1; int32_t numFace = this->m_TextureType == GL_TEXTURE_CUBE_MAP ? 6 : 1;
@ -283,7 +283,7 @@ void GLTexture::SetBorderColor(const GLColor4f& color) {
} }
void GLTexture::SetCompareMode(GLEnum compareMode) { void GLTexture::SetCompareMode(GLEnum compareMode) {
BLIZZARD_ASSERT( BC_ASSERT(
this->GetFormatInfo().m_DataFormat == GL_DEPTH_COMPONENT this->GetFormatInfo().m_DataFormat == GL_DEPTH_COMPONENT
|| this->GetFormatInfo().m_DataFormat == GL_DEPTH_STENCIL_EXT || this->GetFormatInfo().m_DataFormat == GL_DEPTH_STENCIL_EXT
|| compareMode == GL_NONE || compareMode == GL_NONE
@ -335,16 +335,16 @@ void GLTexture::SetMinFilterMode(GLEnum mode) {
} }
void GLTexture::SetupTexture() { void GLTexture::SetupTexture() {
BLIZZARD_ASSERT(this->m_NumMipmap == 1 || (this->m_Flags & GLTFLAG_AUTOGEN_MIPMAP) == 0); BC_ASSERT(this->m_NumMipmap == 1 || (this->m_Flags & GLTFLAG_AUTOGEN_MIPMAP) == 0);
BLIZZARD_ASSERT(!this->IsRenderTarget() || this->m_NumMipmap == 1); BC_ASSERT(!this->IsRenderTarget() || this->m_NumMipmap == 1);
BLIZZARD_ASSERT(!this->IsRenderTarget() || (this->m_Flags & GLTFLAG_READ_ACCESS) == 0); BC_ASSERT(!this->IsRenderTarget() || (this->m_Flags & GLTFLAG_READ_ACCESS) == 0);
GLSDLDevice* device = GLSDLDevice::Get(); GLSDLDevice* device = GLSDLDevice::Get();
if (this->GetFormatInfo().m_IsCompressed) { if (this->GetFormatInfo().m_IsCompressed) {
int32_t smallestDim = std::min(this->m_Width, this->m_Height); int32_t smallestDim = std::min(this->m_Width, this->m_Height);
BLIZZARD_ASSERT(smallestDim >= 4); BC_ASSERT(smallestDim >= 4);
if (smallestDim == 4) { if (smallestDim == 4) {
this->m_NumMipmap = 1; this->m_NumMipmap = 1;
@ -422,7 +422,7 @@ void GLTexture::SetupTexture() {
} }
if (!(this->m_Flags & GLTFLAG_SYSTEM_BUFFER)) { if (!(this->m_Flags & GLTFLAG_SYSTEM_BUFFER)) {
BLIZZARD_ASSERT(this->m_RequestedNumMipmaps != 0); BC_ASSERT(this->m_RequestedNumMipmaps != 0);
this->m_NumMipmap = std::min(this->m_NumMipmap, this->m_RequestedNumMipmaps); this->m_NumMipmap = std::min(this->m_NumMipmap, this->m_RequestedNumMipmaps);
} }
@ -458,7 +458,7 @@ void GLTexture::SetupTexture() {
return; return;
} }
BLIZZARD_ASSERT(this->m_Data == nullptr); BC_ASSERT(this->m_Data == nullptr);
if (!this->IsRenderTarget()) { if (!this->IsRenderTarget()) {
this->m_Data = static_cast<char*>(Blizzard::Memory::Allocate(this->m_Size)); this->m_Data = static_cast<char*>(Blizzard::Memory::Allocate(this->m_Size));
@ -545,9 +545,9 @@ void GLTexture::SetupTexture() {
void GLTexture::Unbind(GLSDLDevice* device, uint32_t stage) { void GLTexture::Unbind(GLSDLDevice* device, uint32_t stage) {
auto& bindings = this->GetBindings(); auto& bindings = this->GetBindings();
BLIZZARD_ASSERT(device->GetID() < bindings.size()); BC_ASSERT(device->GetID() < bindings.size());
BLIZZARD_ASSERT(bindings[device->GetID()].device == device); BC_ASSERT(bindings[device->GetID()].device == device);
BLIZZARD_ASSERT(bindings[device->GetID()].boundStages[stage]); BC_ASSERT(bindings[device->GetID()].boundStages[stage]);
bindings[device->GetID()].boundStages[stage] = 0; bindings[device->GetID()].boundStages[stage] = 0;
} }
@ -599,7 +599,7 @@ GLTexture2D::GLTexture2D() : GLTexture() {
} }
void GLTexture2D::ReleaseObject() { void GLTexture2D::ReleaseObject() {
BLIZZARD_ASSERT(this->m_TextureType == GL_TEXTURE_2D); BC_ASSERT(this->m_TextureType == GL_TEXTURE_2D);
this->FreeTexture(); this->FreeTexture();
} }

View File

@ -15,7 +15,7 @@ uint32_t GLSDLTextureTypeToIndex(GLEnum textureType) {
} else { } else {
index = 5; index = 5;
BLIZZARD_ASSERT(false); BC_ASSERT(false);
} }
return index; return index;

View File

@ -107,7 +107,7 @@ void GLVertexArray::ApplyVertexFormat(GLSDLDevice* device) {
this->m_GLStates.buffers[1] = indexBufferID; this->m_GLStates.buffers[1] = indexBufferID;
} }
BLIZZARD_ASSERT(this->GetProperties().m_VertexBufferFormat != nullptr); BC_ASSERT(this->GetProperties().m_VertexBufferFormat != nullptr);
auto& properties = this->GetProperties(); auto& properties = this->GetProperties();
bool attribEnable[16] = {}; bool attribEnable[16] = {};
@ -115,12 +115,12 @@ void GLVertexArray::ApplyVertexFormat(GLSDLDevice* device) {
bool useVertexShader = device->GetShader(GLShader::eVertexShader) != nullptr; bool useVertexShader = device->GetShader(GLShader::eVertexShader) != nullptr;
for (int32_t index = 0; index < this->GetProperties().m_VertexBufferFormat->m_Size; index++) { for (int32_t index = 0; index < this->GetProperties().m_VertexBufferFormat->m_Size; index++) {
BLIZZARD_ASSERT(index < kMAX_VERTEX_ATTRIBS); BC_ASSERT(index < kMAX_VERTEX_ATTRIBS);
auto& attrib = this->GetProperties().m_VertexBufferFormat->m_Attribs[index]; auto& attrib = this->GetProperties().m_VertexBufferFormat->m_Attribs[index];
BLIZZARD_ASSERT(attrib.type != GLVT_INVALID); BC_ASSERT(attrib.type != GLVT_INVALID);
BLIZZARD_ASSERT(attrib.type < GLVT_NUM_VERTEX_TYPES); BC_ASSERT(attrib.type < GLVT_NUM_VERTEX_TYPES);
auto vertexBuffer = this->GetProperties().m_VertexBuffer[attrib.stream]; auto vertexBuffer = this->GetProperties().m_VertexBuffer[attrib.stream];

View File

@ -4,7 +4,7 @@
#include "util/Unimplemented.hpp" #include "util/Unimplemented.hpp"
#include <cstring> #include <cstring>
#include <storm/Error.hpp> #include <storm/Error.hpp>
#include <storm/Memory.hpp> #include <bc/Memory.hpp>
TSGrowableArray<uint8_t> CBLPFile::s_blpFileLoadBuffer; TSGrowableArray<uint8_t> CBLPFile::s_blpFileLoadBuffer;
@ -259,7 +259,7 @@ int32_t CBLPFile::Lock2(const char* fileName, PIXEL_FORMAT format, uint32_t mipL
switch (this->m_header.colorEncoding) { switch (this->m_header.colorEncoding) {
case COLOR_JPEG: case COLOR_JPEG:
STORM_PANIC("%s: JPEG decompression not enabled", fileName); SErrPrepareAppFatal(__FILE__, __LINE__); SErrDisplayAppFatal("%s: JPEG decompression not enabled", fileName);
return 0; return 0;
case COLOR_PAL: case COLOR_PAL:
@ -340,8 +340,9 @@ int32_t CBLPFile::LockChain2(const char* fileName, PIXEL_FORMAT format, MipBits*
} }
int32_t CBLPFile::Open(const char* filename, int32_t a3) { int32_t CBLPFile::Open(const char* filename, int32_t a3) {
STORM_ASSERT(filename); STORM_VALIDATE_BEGIN;
STORM_VALIDATE(filename, ERROR_INVALID_PARAMETER, 0); STORM_VALIDATE(filename);
STORM_VALIDATE_END;
this->m_inMemoryImage = nullptr; this->m_inMemoryImage = nullptr;

View File

@ -1,12 +1,15 @@
#include "gx/texture/CTgaFile.hpp" #include "gx/texture/CTgaFile.hpp"
#include <storm/Memory.hpp> #include <bc/Memory.hpp>
#include <storm/Error.hpp> #include <storm/Error.hpp>
#include <cstring> #include <cstring>
int32_t CTgaFile::Open(const char* filename, int32_t a3) { int32_t CTgaFile::Open(const char* filename, int32_t a3) {
STORM_VALIDATE_STRING(filename, ERROR_INVALID_PARAMETER, 0); STORM_VALIDATE_BEGIN;
STORM_VALIDATE(filename);
STORM_VALIDATE(*filename);
STORM_VALIDATE_END;
this->Close(); this->Close();
@ -40,9 +43,15 @@ int32_t CTgaFile::Open(const char* filename, int32_t a3) {
} }
// 3 pixels with alpha channel makes no sense // 3 pixels with alpha channel makes no sense
STORM_VALIDATE(!(this->m_header.bPixelDepth == 24 && this->m_header.desc.bAlphaChannelBits == 8), 0x8720012E, 0); if (this->m_header.bPixelDepth == 24 && this->m_header.desc.bAlphaChannelBits == 8) {
SErrSetLastError(0x8720012E);
return 0;
}
// 4 pixels with no alpha channel makes no sense // 4 pixels with no alpha channel makes no sense
STORM_VALIDATE(!(this->m_header.bPixelDepth == 32 && this->m_header.desc.bAlphaChannelBits == 0), 0x8720012F, 0); if (this->m_header.bPixelDepth == 32 && this->m_header.desc.bAlphaChannelBits == 0) {
SErrSetLastError(0x8720012F);
return 0;
}
return 1; return 1;
} }
@ -123,7 +132,10 @@ void CTgaFile::SetTopDown(int32_t set) {
return; return;
} }
STORM_VALIDATE(this->m_header.bImageType >= TGA_RLE_COLOR_MAPPED && this->m_header.bImageType <= TGA_RLE_BLACK_N_WHITE, 0xF7200083); if (!(this->m_header.bImageType >= TGA_RLE_COLOR_MAPPED && this->m_header.bImageType <= TGA_RLE_BLACK_N_WHITE)) {
SErrSetLastError(0xF7200083);
return;
}
auto newImage = static_cast<uint8_t*>(SMemAlloc(this->Bytes(), __FILE__, __LINE__, 0x0)); auto newImage = static_cast<uint8_t*>(SMemAlloc(this->Bytes(), __FILE__, __LINE__, 0x0));
@ -405,7 +417,10 @@ void CTgaFile::ConvertColorMapped(uint32_t flags) {
} }
int32_t CTgaFile::ReadColorMappedImage(uint32_t flags) { int32_t CTgaFile::ReadColorMappedImage(uint32_t flags) {
STORM_VALIDATE(this->m_header.bColorMapType, 0xF7200084, 0); if (!this->m_header.bColorMapType) {
SErrSetLastError(0xF7200084);
return 0;
}
int32_t status; int32_t status;
@ -421,8 +436,14 @@ int32_t CTgaFile::ReadColorMappedImage(uint32_t flags) {
} }
int32_t CTgaFile::LoadImageData(uint32_t flags) { int32_t CTgaFile::LoadImageData(uint32_t flags) {
STORM_VALIDATE(this->m_image == nullptr, ERROR_INVALID_PARAMETER, 1); if (this->m_image) {
STORM_VALIDATE(this->m_file, 0xF720007E, 1); SErrSetLastError(ERROR_INVALID_PARAMETER);
return 1;
}
if (!this->m_file) {
SErrSetLastError(0xF720007E);
return 1;
}
this->m_imageBytes = this->Bytes(); this->m_imageBytes = this->Bytes();

View File

@ -5,8 +5,7 @@
#include "util/Filesystem.hpp" #include "util/Filesystem.hpp"
#include "util/SFile.hpp" #include "util/SFile.hpp"
#include <cstring> #include <cstring>
#include <new> #include <bc/Memory.hpp>
#include <storm/Memory.hpp>
#include <storm/String.hpp> #include <storm/String.hpp>
#include <tempest/Box.hpp> #include <tempest/Box.hpp>
@ -36,8 +35,7 @@ CM2Shared* CM2Cache::CreateShared(const char* path, uint32_t flags) {
SFile* fileptr; SFile* fileptr;
if (SFile::OpenEx(nullptr, convertedPath, (flags >> 2) & 1, &fileptr)) { if (SFile::OpenEx(nullptr, convertedPath, (flags >> 2) & 1, &fileptr)) {
auto m = SMemAlloc(sizeof(CM2Shared), __FILE__, __LINE__, 0x0); auto shared = NEW(CM2Shared, this);
auto shared = new (m) CM2Shared(this);
if (shared->Load(fileptr, flags & 0x4, &v28)) { if (shared->Load(fileptr, flags & 0x4, &v28)) {
strcpy(shared->m_filePath, convertedPath); strcpy(shared->m_filePath, convertedPath);
@ -53,7 +51,7 @@ CM2Shared* CM2Cache::CreateShared(const char* path, uint32_t flags) {
} }
SFile::Close(fileptr); SFile::Close(fileptr);
delete shared; DEL(shared);
} }
return nullptr; return nullptr;

View File

@ -16,6 +16,7 @@ target_link_libraries(model
math math
util util
PUBLIC PUBLIC
bc
common common
storm storm
tempest tempest

View File

@ -4,9 +4,8 @@
#include "console/CVar.hpp" #include "console/CVar.hpp"
#include "util/Filesystem.hpp" #include "util/Filesystem.hpp"
#include <cstring> #include <cstring>
#include <new>
#include <common/ObjectAlloc.hpp> #include <common/ObjectAlloc.hpp>
#include <storm/Memory.hpp> #include <bc/Memory.hpp>
#include <storm/String.hpp> #include <storm/String.hpp>
static CVar* s_M2UseZFillVar; static CVar* s_M2UseZFillVar;
@ -116,8 +115,7 @@ int32_t M2ConvertModelFileName(const char* source, char* dest, uint32_t a3, uint
} }
CM2Scene* M2CreateScene() { CM2Scene* M2CreateScene() {
auto m = SMemAlloc(sizeof(CM2Scene), __FILE__, __LINE__, 0x0); return NEW(CM2Scene, &CM2Cache::s_cache);
return new (m) CM2Scene(&CM2Cache::s_cache);
} }
uint32_t M2GetCacheFlags() { uint32_t M2GetCacheFlags() {

View File

@ -34,6 +34,7 @@ target_link_libraries(net
client client
event event
PUBLIC PUBLIC
bc
common common
storm storm
) )

View File

@ -2,10 +2,10 @@
#include "net/connection/WowConnectionNet.hpp" #include "net/connection/WowConnectionNet.hpp"
#include "net/connection/WowConnectionResponse.hpp" #include "net/connection/WowConnectionResponse.hpp"
#include "util/HMAC.hpp" #include "util/HMAC.hpp"
#include <bc/Memory.hpp>
#include <common/DataStore.hpp> #include <common/DataStore.hpp>
#include <common/Time.hpp> #include <common/Time.hpp>
#include <storm/Error.hpp> #include <storm/Error.hpp>
#include <storm/Memory.hpp>
#include <storm/String.hpp> #include <storm/String.hpp>
#include <storm/Thread.hpp> #include <storm/Thread.hpp>
#include <algorithm> #include <algorithm>
@ -102,8 +102,7 @@ int32_t WowConnection::InitOsNet(bool (*fcn)(const NETADDR*), void (*threadinit)
numThreads = std::min(numThreads, 32); numThreads = std::min(numThreads, 32);
auto networkMem = SMemAlloc(sizeof(WowConnectionNet), __FILE__, __LINE__, 0x0); auto network = NEW(WowConnectionNet, numThreads, threadinit);
auto network = new (networkMem) WowConnectionNet(numThreads, threadinit);
WowConnection::s_network = network; WowConnection::s_network = network;
WowConnection::s_network->PlatformInit(useEngine); WowConnection::s_network->PlatformInit(useEngine);
@ -182,8 +181,7 @@ void WowConnection::CheckAccept() {
fcntl(sock, F_SETFL, O_NONBLOCK); fcntl(sock, F_SETFL, O_NONBLOCK);
#endif #endif
auto connMem = SMemAlloc(sizeof(WowConnection), __FILE__, __LINE__, 0x0); auto conn = NEW(WowConnection, sock, reinterpret_cast<sockaddr_in*>(&addr), this->m_response);
auto conn = new (connMem) WowConnection(sock, reinterpret_cast<sockaddr_in*>(&addr), this->m_response);
conn->AddRef(); conn->AddRef();
this->AddRef(); this->AddRef();

View File

@ -4,8 +4,7 @@
#include "net/grunt/Command.hpp" #include "net/grunt/Command.hpp"
#include "net/srp/SRP6_Random.hpp" #include "net/srp/SRP6_Random.hpp"
#include <cstring> #include <cstring>
#include <new> #include <bc/Memory.hpp>
#include <storm/Memory.hpp>
#include <storm/String.hpp> #include <storm/String.hpp>
Grunt::Command<Grunt::ClientLink> Grunt::s_clientCommands[] = { Grunt::Command<Grunt::ClientLink> Grunt::s_clientCommands[] = {
@ -381,8 +380,7 @@ void Grunt::ClientLink::Connect(const char* a2) {
this->SetState(1); this->SetState(1);
auto connectionMem = SMemAlloc(sizeof(WowConnection), __FILE__, __LINE__, 0x0); auto connection = NEW(WowConnection, this, nullptr);
auto connection = new (connectionMem) WowConnection(this, nullptr);
this->m_connection = connection; this->m_connection = connection;
this->m_connection->SetType(WOWC_TYPE_STREAM); this->m_connection->SetType(WOWC_TYPE_STREAM);

View File

@ -2,8 +2,7 @@
#include "net/grunt/ClientLink.hpp" #include "net/grunt/ClientLink.hpp"
#include "net/login/LoginResponse.hpp" #include "net/login/LoginResponse.hpp"
#include <cstring> #include <cstring>
#include <new> #include <bc/Memory.hpp>
#include <storm/Memory.hpp>
#include <storm/String.hpp> #include <storm/String.hpp>
GruntLogin::~GruntLogin() { GruntLogin::~GruntLogin() {
@ -75,7 +74,7 @@ void GruntLogin::GetLogonMethod() {
auto passwordLen = SStrLen(this->m_password); auto passwordLen = SStrLen(this->m_password);
memset(this->m_password, 0, passwordLen); memset(this->m_password, 0, passwordLen);
SMemFree(this->m_password, __FILE__, __LINE__, 0); FREE(this->m_password);
this->m_password = nullptr; this->m_password = nullptr;
} }
} }
@ -108,8 +107,8 @@ void GruntLogin::GetVersionProof(const uint8_t* versionChallenge) {
void GruntLogin::Init(LoginResponse* loginResponse) { void GruntLogin::Init(LoginResponse* loginResponse) {
this->m_loginResponse = loginResponse; this->m_loginResponse = loginResponse;
auto clientLinkMem = SMemAlloc(sizeof(Grunt::ClientLink), __FILE__, __LINE__, 0x0); auto clientLink = NEW(Grunt::ClientLink, *this);
auto clientLink = new (clientLinkMem) Grunt::ClientLink(*this);
this->m_clientLink = clientLink; this->m_clientLink = clientLink;
} }

View File

@ -1,8 +1,8 @@
#include "net/login/Login.hpp" #include "net/login/Login.hpp"
#include "net/login/LoginResponse.hpp" #include "net/login/LoginResponse.hpp"
#include <cstring> #include <cstring>
#include <bc/Memory.hpp>
#include <common/DataStore.hpp> #include <common/DataStore.hpp>
#include <storm/Memory.hpp>
#include <storm/String.hpp> #include <storm/String.hpp>
Login::~Login() { Login::~Login() {
@ -32,7 +32,7 @@ void Login::SetLogonCreds(const char* accountName, const char* password) {
if (this->m_password) { if (this->m_password) {
memset(this->m_password, 0, SStrLen(this->m_password)); memset(this->m_password, 0, SStrLen(this->m_password));
SMemFree(this->m_password, __FILE__, __LINE__, 0x0); FREE(this->m_password);
} }
this->m_password = SStrDupA(password, __FILE__, __LINE__); this->m_password = SStrDupA(password, __FILE__, __LINE__);

View File

@ -13,6 +13,9 @@ target_link_libraries(sound
PRIVATE PRIVATE
ui ui
util util
PUBLIC
bc
storm
) )
if(WHOA_BUILD_FMOD) if(WHOA_BUILD_FMOD)

View File

@ -1,7 +1,7 @@
#include "sound/SI2.hpp" #include "sound/SI2.hpp"
#include "ui/FrameScript.hpp" #include "ui/FrameScript.hpp"
#include "console/CVar.hpp" #include "console/CVar.hpp"
#include <storm/Memory.hpp> #include <bc/Memory.hpp>
#if defined(WHOA_BUILD_FMOD) #if defined(WHOA_BUILD_FMOD)

View File

@ -23,6 +23,7 @@ target_link_libraries(ui
net net
util util
PUBLIC PUBLIC
bc
common common
storm storm
tempest tempest

View File

@ -2,15 +2,14 @@
#include "gx/Draw.hpp" #include "gx/Draw.hpp"
#include "ui/CRenderBatch.hpp" #include "ui/CRenderBatch.hpp"
#include "ui/CSimpleModelFFXScript.hpp" #include "ui/CSimpleModelFFXScript.hpp"
#include <storm/Memory.hpp> #include <bc/Memory.hpp>
int32_t CSimpleModelFFX::s_metatable; int32_t CSimpleModelFFX::s_metatable;
CSimpleFrame* CSimpleModelFFX::Create(CSimpleFrame* parent) { CSimpleFrame* CSimpleModelFFX::Create(CSimpleFrame* parent) {
// TODO // TODO
// auto m = CDataAllocator::GetData(CSimpleModelFFX::s_simpleModelFFXHeap, 0, __FILE__, __LINE__); // auto m = CDataAllocator::GetData(CSimpleModelFFX::s_simpleModelFFXHeap, 0, __FILE__, __LINE__);
auto m = SMemAlloc(sizeof(CSimpleModelFFX), __FILE__, __LINE__, 0x0); return NEW(CSimpleModelFFX, parent);
return new (m) CSimpleModelFFX(parent);
} }
void CSimpleModelFFX::Render(void* arg) { void CSimpleModelFFX::Render(void* arg) {

View File

@ -1,9 +1,8 @@
#include "ui/LuaMemory.hpp" #include "ui/LuaMemory.hpp"
#include "ui/FrameScript.hpp" #include "ui/FrameScript.hpp"
#include <cstring> #include <cstring>
#include <new>
#include <common/MemPool.hpp> #include <common/MemPool.hpp>
#include <storm/Memory.hpp> #include <bc/Memory.hpp>
void* luaM_initPool() { void* luaM_initPool() {
void* m = SMemAlloc(sizeof(MemPool*) * 9, __FILE__, __LINE__, 0x0); void* m = SMemAlloc(sizeof(MemPool*) * 9, __FILE__, __LINE__, 0x0);

View File

@ -1,11 +1,11 @@
#include "util/SFile.hpp" #include "util/SFile.hpp"
#include <cstring> #include <cstring>
#include <limits> #include <limits>
#include <bc/Memory.hpp>
#include <StormLib.h> #include <StormLib.h>
#include <storm/Error.hpp> #include <storm/Error.hpp>
#include <storm/Memory.hpp>
#include <storm/String.hpp> #include <storm/String.hpp>
#include <bc/file/File.hpp> #include <bc/File.hpp>
#include "util/Filesystem.hpp" #include "util/Filesystem.hpp"
static char s_basepath[STORM_MAX_PATH] = { 0 }; static char s_basepath[STORM_MAX_PATH] = { 0 };
@ -25,7 +25,7 @@ int32_t SFile::Close(SFile* file) {
STORM_ASSERT(0); STORM_ASSERT(0);
} }
delete file; DEL(file);
return 1; return 1;
} }
@ -150,7 +150,9 @@ int32_t SFile::OpenEx(SArchive* archive, const char* filename, uint32_t flags, S
void* filehandle; void* filehandle;
HANDLE handle; HANDLE handle;
uint32_t openflags = BC_FILE_OPEN_MUST_EXIST | BC_FILE_OPEN_SHARE_READ | BC_FILE_OPEN_READ;
using Mode = Blizzard::File::Mode;
uint32_t openflags = Mode::mustexist | Mode::shareread | Mode::read;
Blizzard::File::StreamRecord* stream; Blizzard::File::StreamRecord* stream;
// Attempt to open plain file first // Attempt to open plain file first
@ -167,7 +169,7 @@ int32_t SFile::OpenEx(SArchive* archive, const char* filename, uint32_t flags, S
return 0; return 0;
} }
*file = new SFile; *file = NEW(SFile);
(*file)->m_handle = filehandle; (*file)->m_handle = filehandle;
(*file)->m_type = filetype; (*file)->m_type = filetype;
@ -212,7 +214,9 @@ int32_t SFile::Read(SFile* file, void* buffer, size_t bytestoread, size_t* bytes
switch (file->m_type) { switch (file->m_type) {
case SFILE_PLAIN: { case SFILE_PLAIN: {
auto stream = reinterpret_cast<Blizzard::File::StreamRecord*>(file->m_handle); auto stream = reinterpret_cast<Blizzard::File::StreamRecord*>(file->m_handle);
Blizzard::File::Read(stream, buffer, bytestoread, bytesread); auto count = static_cast<int32_t>(bytestoread);
Blizzard::File::Read(stream, buffer, &count);
*bytesread = static_cast<size_t>(count);
return 1; return 1;
} }
case SFILE_PAQ: { case SFILE_PAQ: {