// // FUNCTION: InitInstance(HINSTANCE, int) // // PURPOSE: Saves instance handle and creates main window // // COMMENTS: // // In this function, we save the instance handle in a global variable and // create and display the main program window. // BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { HWND hWnd; hInst = hInstance; // Store instance handle in our global variable #if defined(ZOOM) && defined(SECOND_SCREEN) hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, 1920 + 0, 0, 1920, 1000, NULL, NULL, hInstance, NULL); #elif defined(ZOOM) && !defined(SECOND_SCREEN) hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, 0, 0, 1920, 1000, NULL, NULL, hInstance, NULL); #elif !defined(ZOOM) && defined(SECOND_SCREEN) hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, 1920 + 296, 266, 1296, 538, NULL, NULL, hInstance, NULL); #else hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, 296, 266, 1296, 538, NULL, NULL, hInstance, NULL); #endif if (!hWnd) { return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); // Run the Pi tests Tests tests; tests.RunAllTests(); // while(1); LoadFontResource(&gFontErasDemi18, "Eras Demi ITC.bin"); LoadImageResource(&gWaterTempImage, "..\\..\\bitmaps\\Water.bmp"); LoadImageResource(&gFuelImage, "..\\..\\bitmaps\\Fuel.bmp"); LoadImageResource(&gCarTopView, "..\\..\\bitmaps\\CamaroGrey.bmp"); LoadImageResource(&gLeftArrowImage, "..\\..\\bitmaps\\LeftArrow.bmp"); LoadImageResource(&gRightArrowImage, "..\\..\\bitmaps\\RightArrow.bmp"); Rect rect(0, 0, 1280, 480); gCluster.Init(rect); gFontDB.CreateFontDatabase("Eras Demi ITC", 18); return TRUE; }
BOOL CEnBitmap::LoadImage(UINT uIDRes, LPCTSTR szResourceType, HMODULE hInst, COLORREF crBack) { ASSERT(m_hObject == NULL); // only attach once, detach on destroy if (m_hObject != NULL) return FALSE; return Attach(LoadImageResource(uIDRes, szResourceType, hInst, crBack)); }
void ResourceManager::SignalResourceRetrieved(ResourceType type, uint32_t id) { // reset state to not loaded, to be able to perform generic loading process m_resources[RSTYPE_IMAGE][id]->loadState = RLS_NOT_LOADED; // store flag to not verify checksum again during current gameplay sResourceStreamManager->SetResourceChecksumVerified(type, id); switch (type) { case RSTYPE_IMAGE: LoadImageResource((ImageResource*)m_resources[RSTYPE_IMAGE][id]); sDrawing->SetUIRedrawFlag(); sDrawing->SetCanvasRedrawFlag(); break; default: break; } }
ImageResource* ResourceManager::GetOrCreateImageResource(uint32_t id, bool isInternal) { ImageResource* imgres; // if resource does not exist, create it if ((!isInternal && m_resources[RSTYPE_IMAGE].find(id) == m_resources[RSTYPE_IMAGE].end()) || (isInternal && m_internalResources[RSTYPE_IMAGE].find(id) == m_internalResources[RSTYPE_IMAGE].end())) { imgres = new ImageResource(id); imgres->renderedTexture = nullptr; imgres->metadata = nullptr; imgres->isInternal = isInternal; if (!isInternal) { m_resources[RSTYPE_IMAGE][id] = imgres; m_resources[RSTYPE_IMAGE][id]->loadState = RLS_NOT_LOADED; m_resources[RSTYPE_IMAGE][id]->metaLoadState = RLS_NOT_LOADED; } else { m_internalResources[RSTYPE_IMAGE][id] = imgres; m_internalResources[RSTYPE_IMAGE][id]->loadState = RLS_NOT_LOADED; m_internalResources[RSTYPE_IMAGE][id]->metaLoadState = RLS_NOT_LOADED; } } else { if (!isInternal) imgres = (ImageResource*)m_resources[RSTYPE_IMAGE][id]; else imgres = (ImageResource*)m_internalResources[RSTYPE_IMAGE][id]; } // if metadata not loaded, load it if (imgres->metaLoadState == RLS_NOT_LOADED) LoadImageResourceMeta(imgres); // if contents not loaded, load it if (imgres->loadState == RLS_NOT_LOADED) LoadImageResource(imgres); return imgres; }