bool MFVertex_CreateVertexBufferPlatformSpecific(MFVertexBuffer *pVertexBuffer, void *pVertexBufferMemory) { if(pVertexBuffer->bufferType == MFVBType_Dynamic || pVertexBufferMemory) { D3D11_BUFFER_DESC bd; MFZeroMemory(&bd, sizeof(bd)); bd.Usage = (pVertexBuffer->bufferType == MFVBType_Dynamic) ? D3D11_USAGE_DYNAMIC : D3D11_USAGE_IMMUTABLE; bd.ByteWidth = pVertexBuffer->pVertexDeclatation->pElementData[0].stride * pVertexBuffer->numVerts; bd.BindFlags = D3D11_BIND_VERTEX_BUFFER; bd.CPUAccessFlags = (pVertexBuffer->bufferType == MFVBType_Dynamic) ? D3D11_CPU_ACCESS_WRITE : 0; D3D11_SUBRESOURCE_DATA InitData; MFZeroMemory(&InitData, sizeof(InitData)); InitData.pSysMem = pVertexBufferMemory; ID3D11Buffer* pVB = NULL; HRESULT hr = g_pd3dDevice->CreateBuffer(&bd, pVertexBufferMemory ? &InitData : NULL, &pVB); if(FAILED(hr)) return false; pVertexBuffer->pPlatformData = pVB; } return true; }
bool MFVertex_CreateIndexBufferPlatformSpecific(MFIndexBuffer *pIndexBuffer, uint16 *pIndexBufferMemory) { if(pIndexBufferMemory) { D3D11_BUFFER_DESC bd; MFZeroMemory(&bd, sizeof(bd)); bd.Usage = D3D11_USAGE_IMMUTABLE; bd.ByteWidth = sizeof(WORD) * pIndexBuffer->numIndices; bd.BindFlags = D3D11_BIND_INDEX_BUFFER; D3D11_SUBRESOURCE_DATA initData; MFZeroMemory(&initData, sizeof(initData)); initData.pSysMem = pIndexBufferMemory; ID3D11Buffer *pIB = NULL; HRESULT hr = g_pd3dDevice->CreateBuffer(&bd, &initData, &pIB); if (FAILED(hr)) return false; pIndexBuffer->pPlatformData = pIB; } return true; }
MF_API void MFVertex_UnlockIndexBuffer(MFIndexBuffer *pIndexBuffer) { MFDebug_Assert(pIndexBuffer, "NULL index buffer"); MFDebug_Assert(pIndexBuffer->bLocked, "Index buffer not locked!"); ID3D11Buffer *pIB = (ID3D11Buffer*)pIndexBuffer->pPlatformData; if(pIB) pIB->Release(); D3D11_BUFFER_DESC bd; MFZeroMemory(&bd, sizeof(bd)); bd.Usage = D3D11_USAGE_IMMUTABLE; bd.ByteWidth = sizeof(WORD) * pIndexBuffer->numIndices; bd.BindFlags = D3D11_BIND_INDEX_BUFFER; D3D11_SUBRESOURCE_DATA initData; MFZeroMemory(&initData, sizeof(initData)); initData.pSysMem = pIndexBuffer->pLocked; HRESULT hr = g_pd3dDevice->CreateBuffer(&bd, &initData, &pIB); MFDebug_Assert(SUCCEEDED(hr), "Couldn't create index buffer!"); if (FAILED(hr)) return; pIndexBuffer->pPlatformData = pIB; MFHeap_Free(pIndexBuffer->pLocked); pIndexBuffer->pLocked = NULL; pIndexBuffer->bLocked = false; }
void MFDisplay_InitModulePlatformSpecific() { MFZeroMemory(gXKeys, sizeof(gXKeys)); MFZeroMemory(&gXMouse, sizeof(gXMouse)); gXMouse.x = -1; // gNumDisplayDevices = 0; // gpDisplayAdaptors = (MFDisplayAdaptorDesc*)MFHeap_Alloc(sizeof(MFDisplayAdaptorDesc)*0); xdisplay = XOpenDisplay(NULL); if(!xdisplay) { MFDebug_Error("Unable to open display"); return; } screen = DefaultScreen(xdisplay); rootWindow = RootWindow(xdisplay, screen); wm_delete_window = XInternAtom(xdisplay, "WM_DELETE_WINDOW", false); // build our internal list of available video modes /* GetModes(&modes, false);//!gDisplay.windowed); while(!FindMode(modes, width, height)) { if(!gDisplay.windowed) { // no fullscreen mode, try windowed mode instead MFDebug_Warn(1, "No suitable modes for fullscreen mode, trying windowed mode"); gDisplay.windowed = true; FreeModes(); GetModes(&modes, false); } else { // default is some sort of custom mode that doesn't appear in the windowed mode list // HACK: we'll add it to the end.. modes[numModes].width = width; modes[numModes].height = height; currentMode = numModes; ++numModes; break; } } */ DebugMenu_AddItem("Resolution", "Display Options", &resSelect, ChangeResCallback); DebugMenu_AddItem("Apply", "Display Options", &applyDisplayMode, ApplyDisplayModeCallback); }
// Functions MFInitStatus MFInput_InitModule(int moduleId, bool bPerformInitialisation) { MFZeroMemory(gGamepadStates, sizeof(gGamepadStates[0])*MFInput_MaxInputID); MFZeroMemory(gKeyStates, sizeof(gKeyStates[0])*MFInput_MaxInputID); MFZeroMemory(gMouseStates, sizeof(gMouseStates[0])*MFInput_MaxInputID); MFZeroMemory(gAccelerometerStates, sizeof(gAccelerometerStates[0])*MFInput_MaxInputID); MFZeroMemory(gTouchPanelStates, sizeof(gTouchPanelStates[0])*MFInput_MaxInputID); MFInput_InitModulePlatformSpecific(); MFInput_Update(); return MFIS_Succeeded; }
// Functions MFInitStatus MFInput_InitModule() { MFZeroMemory(gGamepadStates, sizeof(gGamepadStates[0])*MFInput_MaxInputID); MFZeroMemory(gKeyStates, sizeof(gKeyStates[0])*MFInput_MaxInputID); MFZeroMemory(gMouseStates, sizeof(gMouseStates[0])*MFInput_MaxInputID); MFZeroMemory(gAccelerometerStates, sizeof(gAccelerometerStates[0])*MFInput_MaxInputID); MFZeroMemory(gTouchPanelStates, sizeof(gTouchPanelStates[0])*MFInput_MaxInputID); MFInput_InitModulePlatformSpecific(); MFInput_Update(); return MFAIC_Succeeded; }
void *MFObjectPool::AllocAndZero() { void *pNew = Alloc(); if(pNew) MFZeroMemory(pNew, objectSize); return pNew; }
MF_API void* MFHeap_AllocAndZeroInternal(size_t bytes, MFHeap *pHeap) { void *pMem = MFHeap_AllocInternal(bytes, pHeap); if(pMem) MFZeroMemory(pMem, bytes); return pMem; }
void MFInput_GetGamepadStateInternal(int id, MFGamepadState *pGamepadState) { MFCALLSTACK; MFZeroMemory(pGamepadState, sizeof(MFGamepadState)); pGamepadState->values[Button_PP_Cross] = (padData.Buttons & PSP_CTRL_CROSS) ? 1.0f : 0.0f; pGamepadState->values[Button_PP_Circle] = (padData.Buttons & PSP_CTRL_CIRCLE) ? 1.0f : 0.0f; pGamepadState->values[Button_PP_Box] = (padData.Buttons & PSP_CTRL_SQUARE) ? 1.0f : 0.0f; pGamepadState->values[Button_PP_Triangle] = (padData.Buttons & PSP_CTRL_TRIANGLE) ? 1.0f : 0.0f; pGamepadState->values[Button_PP_L] = (padData.Buttons & PSP_CTRL_LTRIGGER) ? 1.0f : 0.0f; pGamepadState->values[Button_PP_R] = (padData.Buttons & PSP_CTRL_RTRIGGER) ? 1.0f : 0.0f; pGamepadState->values[Button_PP_Start] = (padData.Buttons & PSP_CTRL_START) ? 1.0f : 0.0f; pGamepadState->values[Button_PP_Select] = (padData.Buttons & PSP_CTRL_SELECT) ? 1.0f : 0.0f; pGamepadState->values[Button_DUp] = (padData.Buttons & PSP_CTRL_UP) ? 1.0f : 0.0f; pGamepadState->values[Button_DDown] = (padData.Buttons & PSP_CTRL_DOWN) ? 1.0f : 0.0f; pGamepadState->values[Button_DLeft] = (padData.Buttons & PSP_CTRL_LEFT) ? 1.0f : 0.0f; pGamepadState->values[Button_DRight] = (padData.Buttons & PSP_CTRL_RIGHT) ? 1.0f : 0.0f; pGamepadState->values[Axis_LX] = (float)padData.Lx/127.5f - 1.0f; pGamepadState->values[Axis_LY] = -((float)padData.Ly/127.5f - 1.0f); pGamepadState->values[Axis_RX] = 0.0f; pGamepadState->values[Axis_RY] = 0.0f; }
MF_API void MFDisplay_GetDefaults(MFDisplaySettings *pDisplaySettings) { MFZeroMemory(pDisplaySettings, sizeof(*pDisplaySettings)); pDisplaySettings->displayAdaptor = 0; pDisplaySettings->monitor = 0; pDisplaySettings->mode = MFDM_Progressive; pDisplaySettings->aspect = MFDA_Default; pDisplaySettings->cable = MFDC_Unknown; pDisplaySettings->bVSync = true; pDisplaySettings->numBuffers = 2; pDisplaySettings->flags = 0;//MFDF_CanResizeWindow; pDisplaySettings->pWindow = NULL; pDisplaySettings->backBufferFormat = ImgFmt_SelectDefault; pDisplaySettings->depthStencilFormat = ImgFmt_SelectDepth; #if defined(MF_RETAIL) // TODO: should use the native or desktop res? pDisplaySettings->bFullscreen = true; pDisplaySettings->width = (int)gInitParams.display.displayRect.width; pDisplaySettings->height = (int)gInitParams.display.displayRect.height; pDisplaySettings->refreshRate = 0; #else pDisplaySettings->bFullscreen = false; pDisplaySettings->width = (int)gInitParams.display.displayRect.width; pDisplaySettings->height = (int)gInitParams.display.displayRect.height; pDisplaySettings->refreshRate = 0; #endif }
MF_API MFVertexBuffer *MFVertex_CreateVertexBuffer(const MFVertexDeclaration *pVertexFormat, int numVerts, MFVertexBufferType type, void *pVertexBufferMemory, const char *pName) { int nameLen = pName ? MFString_Length(pName) + 1 : 0; MFVertexBuffer *pVB; if(type == MFVBType_Scratch) pVB = (MFVertexBuffer*)MFRenderer_AllocateScratchMemory(sizeof(MFVertexBuffer) + nameLen); else pVB = (MFVertexBuffer*)MFHeap_Alloc(sizeof(MFVertexBuffer) + nameLen); MFZeroMemory(pVB, sizeof(MFVertexBuffer)); if(pName) pName = MFString_Copy((char*)&pVB[1], pName); pVB->pVertexDeclatation = pVertexFormat; pVB->bufferType = type; pVB->numVerts = numVerts; if(!MFVertex_CreateVertexBufferPlatformSpecific(pVB, pVertexBufferMemory)) { if(type != MFVBType_Scratch) MFHeap_Free(pVB); return NULL; } if(type == MFVBType_Scratch) { // add to a scratch list that will be cleaned up later... pVB->pNextScratchBuffer = gpScratchBufferList; gpScratchBufferList = pVB; } else MFResource_AddResource(pVB, MFRT_VertexBuffer, (uint32)(MFUtil_HashPointer(pVB) & 0xFFFFFFFF), pName); return pVB; }
void Game_Init(void *pUserData) { // create the renderer with a single layer that clears before rendering MFRenderLayerDescription layers[] = { "Scene" }; pRenderer = MFRenderer_Create(layers, 1, NULL, NULL); MFRenderer_SetCurrent(pRenderer); pDefaultStates = MFStateBlock_CreateDefault(); MFRenderer_SetGlobalStateBlock(pRenderer, pDefaultStates); MFRenderLayer *pLayer = MFRenderer_GetLayer(pRenderer, 0); MFRenderLayer_SetClear(pLayer, MFRCF_All, MakeVector(0.f, 0.f, 0.2f, 1.f)); MFRenderLayerSet layerSet; MFZeroMemory(&layerSet, sizeof(layerSet)); layerSet.pSolidLayer = pLayer; MFRenderer_SetRenderLayerSet(pRenderer, &layerSet); // init HKUserInterface HKUserInterface::Init(); pUI = new HKUserInterface(); HKUserInterface::SetActiveUI(pUI); // load a test UI HKWidget *pTestLayout = HKWidget_CreateFromXML("ui-test.xml"); MFDebug_Assert(pTestLayout != NULL, "Couldn't load UI!"); pUI->AddTopLevelWidget(pTestLayout, true); }
MF_API void MFMidi_SendPacket(MFDevice *pDevice, const uint8 *pBytes, size_t len) { MFMidiPC_MidiOutputDevice *pMidi = (MFMidiPC_MidiOutputDevice*)pDevice->pInternal; // TODO: get hdr from pool... MIDIHDR hdr; MFZeroMemory(&hdr, sizeof(hdr)); hdr.lpData = (LPSTR)pBytes; hdr.dwBufferLength = (DWORD)len; hdr.dwBytesRecorded = (DWORD)len; hdr.dwUser = (DWORD_PTR)pDevice; MMRESULT r = midiOutPrepareHeader(pMidi->hMidiOut, &hdr, sizeof(hdr)); if (r != MMSYSERR_NOERROR) { wchar_t errorBuffer[256]; midiOutGetErrorText(r, errorBuffer, sizeof(errorBuffer)); MFDebug_Warn(1, MFStr("Failed to send MIDI message: %s", MFString_WCharAsUTF8(errorBuffer))); return; } r = midiOutLongMsg(pMidi->hMidiOut, &hdr, sizeof(hdr)); if (r != MMSYSERR_NOERROR) { wchar_t errorBuffer[256]; midiOutGetErrorText(r, errorBuffer, sizeof(errorBuffer)); MFDebug_Warn(1, MFStr("Failed to send MIDI message: %s", MFString_WCharAsUTF8(errorBuffer))); } }
MFInitStatus MFFileSystem_InitModule(int moduleId, bool bPerformInitialisation) { gModuleId = moduleId; if(!bPerformInitialisation) return MFIS_Succeeded; ALLOC_MODULE_DATA(MFFileSystemState); pModuleData->hNativeFileSystem = -1; pModuleData->hMemoryFileSystem = -1; pModuleData->hCachedFileSystem = -1; pModuleData->hZipFileSystem = -1; pModuleData->hHTTPFileSystem = -1; pModuleData->hFTPFileSystem = -1; pModuleData->gOpenFiles.Init(sizeof(MFFile), gDefaults.filesys.maxOpenFiles, gDefaults.filesys.maxOpenFiles); pModuleData->gFileSystems.Init("File Systems", gDefaults.filesys.maxFileSystems); pModuleData->ppFileSystemList = (MFFileSystem**)MFHeap_Alloc(sizeof(MFFileSystem*) * gDefaults.filesys.maxFileSystems); MFZeroMemory(pModuleData->ppFileSystemList, sizeof(MFFileSystem*) * gDefaults.filesys.maxFileSystems); pModuleData->gFinds.Init("File System Find Instances", gDefaults.filesys.maxFinds); return MFIS_Succeeded; }
MFInitStatus MFView_InitModule() { // allocate view stack gpViewStack = (MFView*)MFHeap_Alloc(sizeof(MFView) * gDefaults.view.maxViewsOnStack); // set default ortho rect MFView::defaultOrthoRect.x = gDefaults.view.orthoMinX; MFView::defaultOrthoRect.y = gDefaults.view.orthoMinY; MFView::defaultOrthoRect.width = gDefaults.view.orthoMaxX; MFView::defaultOrthoRect.height = gDefaults.view.orthoMaxY; // initialise default view MFZeroMemory(&MFView::defaultView, sizeof(MFView)); pCurrentView = &MFView::defaultView; pCurrentView->cameraMatrix = MFMatrix::identity; pCurrentView->view = MFMatrix::identity; pCurrentView->viewProj = MFMatrix::identity; MFView_SetOrtho(&MFView::defaultOrthoRect); MFView_ConfigureProjection(MFDEGREES(gDefaults.view.defaultFOV), gDefaults.view.defaultNearPlane, gDefaults.view.defaultFarPlane); MFView_SetAspectRatio(gDefaults.view.defaultAspect); MFView_SetProjection(); pCurrentView = gpViewStack; MFView_SetDefault(); return MFIS_Succeeded; }
HKUserInterface::HKUserInterface() { MFZeroMemory(pFocusList, sizeof(pFocusList)); MFZeroMemory(pHoverList, sizeof(pHoverList)); pRoot = CreateWidget<HKWidgetLayoutFrame>(); MFRect rect; // MFView_GetOrthoRect(&rect); MFDisplay_GetDisplayRect(&rect); pRoot->SetPosition(MakeVector(rect.x, rect.y)); pRoot->SetSize(MakeVector(rect.width, rect.height)); pInputManager = new HKInputManager(); pInputManager->OnInputEvent += fastdelegate::MakeDelegate(this, &HKUserInterface::OnInputEvent); }
MFInitStatus MFResource_InitModule(int moduleId, bool bPerformInitialisation) { MFZeroMemory(gResourceCounts, sizeof(gResourceCounts)); gResourceTable.Init(1024, 1024, 1024); return MFIS_Succeeded; }
void MFInput_InitModulePlatformSpecific() { MFCALLSTACK; MFZeroMemory(gKeyState, 256); sceCtrlSetSamplingCycle(0); sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG); }
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrev, LPSTR lpCmdLine, int nCmdShow) { MFInitParams initParams; MFZeroMemory(&initParams, sizeof(MFInitParams)); initParams.hInstance = hInstance; initParams.pCommandLine = lpCmdLine; return GameMain(&initParams); }
int main(int argc, const char *argv[]) { MFInitParams initParams; MFZeroMemory(&initParams, sizeof(MFInitParams)); initParams.argc = argc; initParams.argv = argv; return GameMain(&initParams); }
void *MFObjectPoolGroup::AllocAndZero(size_t bytes, size_t *pAllocated) { size_t size = 0; void *pNew = Alloc(bytes, &size); if(pNew) MFZeroMemory(pNew, size); if(pAllocated) *pAllocated = size; return pNew; }
void MFInput_GetKeyStateInternal(int id, MFKeyState *pKeyState) { MFDebug_Assert(id == 0, "Only one keyboard supported currently."); MFZeroMemory(pKeyState, sizeof(MFKeyState)); #if MF_DISPLAY == MF_DRIVER_X11 for(int a=0; a<Key_Max; a++) pKeyState->keys[a] = gXKeys[MFKeyToXK[a]]; #endif }
int main(int argc, const char *argv[]) { MFInitParams initParams; MFZeroMemory(&initParams, sizeof(MFInitParams)); initParams.argc = argc; initParams.argv = argv; int r = GameMain(&initParams); sceKernelExitGame(); return r; }
static void AllocateAllocTable() { numFree = poolSize = 1024; gpItemPool = (MFHeap_AllocItem*)MFHeap_SystemMalloc(sizeof(MFHeap_AllocItem)*poolSize + sizeof(MFHeap_AllocItem*)*poolSize); gppFreeList = (MFHeap_AllocItem**)&gpItemPool[poolSize]; for(size_t i = 0; i<poolSize; ++i) gppFreeList[i] = &gpItemPool[i]; MFZeroMemory(gpAllocTable, sizeof(gpAllocTable)); }
void MFInput_GetAccelerometerStateInternal(int id, MFAccelerometerState *pAccelerometerState) { MFZeroMemory(pAccelerometerState, sizeof(MFAccelerometerState)); if(id == 0) { pAccelerometerState->values[Acc_XAxis] = gAcceleration[0]; pAccelerometerState->values[Acc_YAxis] = gAcceleration[1]; pAccelerometerState->values[Acc_ZAxis] = gAcceleration[2]; pAccelerometerState->values[Acc_Acceleration] = MakeVector(gAcceleration[0], gAcceleration[1], gAcceleration[2]).Magnitude3(); } }
MF_API void MFVertex_UnlockVertexBuffer(MFVertexBuffer *pVertexBuffer) { MFDebug_Assert(pVertexBuffer, "Null vertex buffer"); ID3D11Buffer *pVB = (ID3D11Buffer*)pVertexBuffer->pPlatformData; if(pVertexBuffer->bufferType == MFVBType_Dynamic) { g_pImmediateContext->Unmap(pVB, 0); } else { if(pVB) pVB->Release(); D3D11_BUFFER_DESC bd; MFZeroMemory(&bd, sizeof(bd)); bd.Usage = D3D11_USAGE_IMMUTABLE; bd.ByteWidth = pVertexBuffer->pVertexDeclatation->pElementData[0].stride * pVertexBuffer->numVerts; bd.BindFlags = D3D11_BIND_VERTEX_BUFFER; D3D11_SUBRESOURCE_DATA initData; MFZeroMemory(&initData, sizeof(initData)); initData.pSysMem = pVertexBuffer->pLocked; HRESULT hr = g_pd3dDevice->CreateBuffer(&bd, &initData, &pVB); MFDebug_Assert(SUCCEEDED(hr), "Couldn't create vertex buffer!"); if(FAILED(hr)) { pVertexBuffer->pPlatformData = NULL; return; } pVertexBuffer->pPlatformData = pVB; MFHeap_Free(pVertexBuffer->pLocked); } pVertexBuffer->pLocked = NULL; pVertexBuffer->bLocked = false; }
uint16* GetStringCopy(const uint16* pString, int len) { int l = len < 0 ? MFWString_Length(pString) : len; uint16 *pStr = (uint16*)malloc(sizeof(uint16) * (l + 1)); MFZeroMemory(pStr, sizeof(uint16) * (l+1)); if(*pString == '\"' && pString[l-1] == '\"') { ++pString; l -= 2; } uint16 *pS = pStr; while(l) { if(*pString == '\\') { bool bInc = true; if(pString[1] == 'n') *pS = '\n'; else if(pString[1] == 'r') *pS = '\r'; else if(pString[1] == 't') *pS = '\t'; else if(pString[1] == '\\') *pS = '\\'; else { *pS = '\\'; bInc = false; } if(bInc) { --l; ++pString; } } else { *pS = *pString; } ++pS; ++pString; --l; } return pStr; }
const char *ParseNormals(const char *pText, F3DSubObject &sub, const MFMatrix &mat, int numFaces, int *pMatFaces) { SkipToken(pText, "{"); // get num positions int numNormals = GetInt(pText, &pText); sub.normals.resize(numNormals); // read positions for(int a=0; a<numNormals; a++) { sub.normals[a].x = GetFloat(pText, &pText); sub.normals[a].y = GetFloat(pText, &pText); sub.normals[a].z = GetFloat(pText, &pText); sub.normals[a] = ApplyMatrix3(sub.normals[a], mat); sub.normals[a].Normalise3(); if(a < numNormals-1) SkipToken(pText, ","); } SkipToken(pText, ";"); // get num faces int numNormalFaces = GetInt(pText, &pText); MFDebug_Assert(numNormalFaces == numFaces, "Number of normal faces does not match the number of faces in the mesh."); // read faces int face[16], numVerts[16]; MFZeroMemory(numVerts, sizeof(numVerts)); for(int a=0; a<numNormalFaces; a++) { int matSub = pMatFaces ? pMatFaces[a] : 0; int numPoints = GetInt(pText, &pText); GetIntArray(pText, face, numPoints, &pText); for(int b=0; b<numPoints; b++) sub.matSubobjects[matSub].vertices[numVerts[matSub]+b].normal = face[b]; numVerts[matSub] += numPoints; if(a < numNormalFaces-1) SkipToken(pText, ","); } SkipToken(pText, ";"); SkipToken(pText, "}"); return pText; }
MFInitStatus MFHeap_InitModule() { MFCALLSTACK; MFDebug_Assert(MFThread_GetMutexSizePlatformSpecific() <= sizeof(gMutexBuffer), "Mutex buffer too small!"); MFThread_InitMutexPlatformSpecific((MFMutex)gMutexBuffer, "MFHeap alloc mutex"); gAllocMutex = (MFMutex)gMutexBuffer; // any heap tracking allocations should be made in the debug space MFHeap *pOld = MFHeap_SetActiveHeap(MFHeap_GetDebugHeap()); #if defined(_USE_TRACKING_HASH_TABLE) // set up the memory tracking hash table // note: this is slightly complicated due to the chicken and egg nature // of making the first allocation for the pool its self ;) static const int numAllocHeaders = 1024; // uint32 bytes = (sizeof(MFHeap_AllocItem) + sizeof(void**)) * numAllocHeaders; // void *pPoolMemory = MFHeap_Alloc(bytes); // gAllocHeaderPool.Init(sizeof(MFHeap_AllocItem), numAllocHeaders, 1024, pPoolMemory, bytes); gAllocHeaderPool.Init(sizeof(MFHeap_AllocItem), numAllocHeaders, 1024); MFZeroMemory(gpAllocTable, sizeof(gpAllocTable)); // artificially add an entry for the pool its self... MFHeap_AllocItem *pHeader = (MFHeap_AllocItem*)gAllocHeaderPool.Alloc(); pHeader->header.pHeap = &gExternalHeap; pHeader->header.size = bytes; pHeader->header.pFile = __FILE__; pHeader->header.line = (uint16)__LINE__; pHeader->header.alignment = 4; pHeader->pMemory = pPoolMemory; pHeader->pNext = NULL; gpAllocTable[MFUtil_HashPointer(pPoolMemory) % MFHeap_AllocTableLength] = pHeader; #endif #if defined(_USE_ALLOC_TRACKER) gAllocList.Init(sizeof(void*), 1024, 1024); gPoolInitialised = true; #endif // restore the active heap MFHeap_SetActiveHeap(pOld); // init the heap MFHeap_InitModulePlatformSpecific(); return MFAIC_Succeeded; }
void Game_Init() { // create the renderer with a single layer that clears before rendering MFRenderLayerDescription layers[] = { { "Scene" } }; pRenderer = MFRenderer_Create(layers, 1, NULL, NULL); MFRenderer_SetCurrent(pRenderer); MFRenderLayer *pLayer = MFRenderer_GetLayer(pRenderer, 0); MFRenderLayer_SetClear(pLayer, MFRCF_All, MakeVector(0.f, 0.f, 0.2f, 1.f)); MFRenderLayerSet layerSet; MFZeroMemory(&layerSet, sizeof(layerSet)); layerSet.pSolidLayer = pLayer; MFRenderer_SetRenderLayerSet(pRenderer, &layerSet); Scan("data:"); }