Game* Game_Create( Keyboard* const keyboard, Mouse* const mouse) { Mat4 tmpProjectionMatrix; OBJFile* objFile = OBJFile_Load( "assets/models/cubeModel.obj"); MTLFile* mtlFile = MTLFile_Load( "assets/models/cubeModel.mtl"); Game* game = malloc( sizeof(Game)); memset( game, 0, sizeof(Game)); Keyboard_Initialize( keyboard); Mouse_Initialize( mouse); game->Keyboard = keyboard; game->Mouse = mouse; // load content game->DiffuseTexture = Texture_Load("assets/textures/checkerboard.png"); game->CubeModel = Mesh_CreateFromOBJGroup( objFile->Objects, objFile->Objects->Groups); // unload temp data OBJFile_Unload(objFile); MTLFile_Unload(mtlFile); // setup camera Mat4_LoadPerspective( &tmpProjectionMatrix, 70.0f, (float)SCREEN_WIDTH / (float)SCREEN_HEIGHT, 0.1f, 100.0f); game->Camera = Camera_Create( &tmpProjectionMatrix); return game; }
static Skins_ApplyVariant(ModelContainer_t *pContainer, SkinSet_t::iterator itEthnic, ShadersForMaterial_t::iterator itMaterialShaders, string strMaterialName, int iVariant) { if (itMaterialShaders != (*itEthnic).second.end()) { LPCSTR psShaderName = (*itMaterialShaders).second[iVariant].c_str(); // shader name to load from skinset pContainer->MaterialShaders[strMaterialName] = psShaderName; LPCSTR psLocalTexturePath = R_FindShader( psShaderName ); // shader->texture name if (psLocalTexturePath && strlen(psLocalTexturePath)) { TextureHandle_t hTexture = TextureHandle_ForName( psLocalTexturePath ); if (hTexture == -1) { hTexture = Texture_Load(psLocalTexturePath); } GLuint uiBind = Texture_GetGLBind( hTexture ); pContainer->MaterialBinds[strMaterialName] = uiBind; } } }
void ClientGame::LoadResources() { struct TextureLoad { Texture* texture; const char* fileName; }; TextureLoad load[] = { { &m_agentTexture, "assets/agent.png" }, { &m_agentHackingTexture, "assets/agent_hacking.png" }, { &m_agentIntelTexture, "assets/agent_intel.png" }, { &m_agentStakeoutTexture, "assets/agent_stakeout.png" }, { &m_intelTexture, "assets/intel.png" }, { &m_buildingTowerTexture, "assets/building_tower.png" }, { &m_buildingBankTexture, "assets/building_bank.png" }, { &m_buildingHouseTexture, "assets/building_safehouse.png" }, { &m_buildingRaidedHouseTexture, "assets/raided_safehouse.png" }, { &m_buildingPoliceTexture, "assets/building_police.png" }, { &m_buttonTexture[ButtonId_Infiltrate], "assets/action_infiltrate.png" }, { &m_buttonTexture[ButtonId_Capture], "assets/action_capture.png" }, { &m_buttonTexture[ButtonId_Stakeout], "assets/action_stakeout.png" }, { &m_buttonTexture[ButtonId_Hack], "assets/action_hack.png" }, { &m_buttonTexture[ButtonId_Intel], "assets/action_drop.png" }, { &m_buttonShadowTexture, "assets/button_shadow.png" }, { &m_playerPortraitTexture, "assets/player_portrait.png" }, { &m_playerEliminatedTexture, "assets/player_eliminated.png" }, { &m_playerBankHackedTexture, "assets/player_bank_hacked.png" }, { &m_playerCellHackedTexture, "assets/player_cell_hacked.png" }, { &m_playerPoliceHackedTexture, "assets/player_police_hacked.png" }, { &m_titleBackgroundTexture, "assets/title_background.png" }, { &m_titleTextTexture, "assets/title_text.png" }, { &m_uiTexture, "assets/ui.png" }, }; int numTextures = sizeof(load) / sizeof(TextureLoad); for (int i = 0; i < numTextures; ++i) { Texture_Load(*load[i].texture, load[i].fileName); } Font_Load(m_font, "assets/font.csv"); m_soundAction = BASS_SampleLoad(false, "assets/sound_action.wav", 0, 0, 3, BASS_SAMPLE_OVER_POS); m_soundDeath = BASS_SampleLoad(false, "assets/sound_death.wav", 0, 0, 3, BASS_SAMPLE_OVER_POS); m_soundDrop = BASS_SampleLoad(false, "assets/sound_drop.wav", 0, 0, 3, BASS_SAMPLE_OVER_POS); m_soundHack = BASS_SampleLoad(false, "assets/sound_hack.wav", 0, 0, 3, BASS_SAMPLE_OVER_POS); m_soundPickup = BASS_SampleLoad(false, "assets/sound_pickup.wav", 0, 0, 3, BASS_SAMPLE_OVER_POS); m_soundTrain = BASS_SampleLoad(false, "assets/sound_train.wav", 0, 0, 3, BASS_SAMPLE_OVER_POS); m_notificationLog.LoadResources(); }
GLuint demo5_loadTexture(const char *filepath) { GLuint texID; /* load texture */ texture_t *tex = NULL; path_t texPath; filesystem_t fs; FileSystem_Init(&fs); Path_Init(texPath, fs.resPath); Path_AppendPath(texPath, filepath); tex = TextureLoader_LoadFromFile(texPath); Texture_Load(tex); Texture_SetWrapMode(tex, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE); texID = tex->texID; Texture_Free(tex); return texID; }
bool Skins_Validate( ModelContainer_t *pContainer, int iSkinNumber ) { bool bReturn = true; bool bPREV_bReportImageLoadErrors = g_bReportImageLoadErrors; g_bReportImageLoadErrors = false; bool bCheckMissingMaterials = true;//GetYesNo("Check for materials referenced by model but missing in skinfile(s)?\n\n( Note: This can give false alarms for skins which don't use (eg) \"scarf\" )"); // first, build up a list of all model materials... // StringSet_t MaterialsPresentInModel; for (int iSurface = 0; iSurface < pContainer->iNumSurfaces; iSurface++) { bool bOnOff = GLMModel_SurfaceIsON(pContainer->hModel, iSurface); if (bOnOff) { LPCSTR psMaterial = GLMModel_GetSurfaceShaderName( pContainer->hModel, iSurface); MaterialsPresentInModel.insert(MaterialsPresentInModel.end(),psMaterial); } } // build up a list of shaders used... // StringSet_t UniqueSkinShaders; SkinFileMaterialsMissing_t SkinFileMaterialsMissing; int iThisSkinIndex = 0; for (SkinSets_t::iterator itSkins = pContainer->SkinSets.begin(); itSkins != pContainer->SkinSets.end(); ++itSkins, iThisSkinIndex++) { if (iSkinNumber == iThisSkinIndex || iSkinNumber == -1) { SkinSet_Validate_BuildList(UniqueSkinShaders, itSkins, MaterialsPresentInModel, SkinFileMaterialsMissing); } } // now process the unique list we've just built... // CWaitCursor wait; string strFoundList; string strNotFoundList; int iUniqueIndex = 0; for (StringSet_t::iterator it = UniqueSkinShaders.begin(); it != UniqueSkinShaders.end(); ++it, iUniqueIndex++) { string strShader(*it); StatusMessage(va("Processing shader %d/%d: \"%s\"\n",iUniqueIndex,UniqueSkinShaders.size(),strShader.c_str())); OutputDebugString(va("Unique: \"%s\"... ",strShader.c_str())); int iTextureHandle = Texture_Load(strShader.c_str(), true); // bInhibitStatus GLuint uiGLBind = Texture_GetGLBind( iTextureHandle ); if (uiGLBind == 0) { OutputDebugString("NOT FOUND\n"); strNotFoundList += strShader; strNotFoundList += "\n"; } else { OutputDebugString("found\n"); strFoundList += strShader; strFoundList += "\n"; } } StatusMessage(NULL); // see if we were missing any model materials in these skins... // CString strModelMaterialsMissing; if (SkinFileMaterialsMissing.size()) { for (SkinFileMaterialsMissing_t::iterator itSkinFileMaterialsMissing = SkinFileMaterialsMissing.begin(); itSkinFileMaterialsMissing != SkinFileMaterialsMissing.end(); ++itSkinFileMaterialsMissing) { string strSkinFileName((*itSkinFileMaterialsMissing).first); if (iSkinNumber == -1) { strModelMaterialsMissing += va("\nSkin \"%s\":\n",strSkinFileName.c_str()); } for (EthnicMaterials_t::iterator itSkinFile = (*itSkinFileMaterialsMissing).second.begin(); itSkinFile != (*itSkinFileMaterialsMissing).second.end(); ++itSkinFile) { string strEthnicFileName((*itSkinFile).first); strModelMaterialsMissing += va("Ethnic \"%s\": ",strEthnicFileName.c_str()); StringVector_t& MaterialStrings = (*itSkinFile).second; for (int iMaterial = 0; iMaterial != MaterialStrings.size(); ++iMaterial) { string strMaterial(MaterialStrings[iMaterial]); strModelMaterialsMissing += va("%s\"%s\"",(iMaterial==0)?"":", ",strMaterial.c_str()); } strModelMaterialsMissing += "\n"; } } } if (!strModelMaterialsMissing.IsEmpty()) { if (iSkinNumber == -1) { strModelMaterialsMissing.Insert(0, "One or more skin files are missing some material definitions referenced by this model's currently-active surfaces.\nList follows...\n\n"); } else { strModelMaterialsMissing.Insert(0, "This skin file is missing one or more material definitions referenced by this model's currently-active surfaces.\nList follows...\n\n"); } } if (!strModelMaterialsMissing.IsEmpty()) { if (bCheckMissingMaterials) { WarningBox(va("Summary Part 1: Missing materials\n\n%s",(LPCSTR)strModelMaterialsMissing)); } } // Now output results... // If too many lines to fit on screen (which is now happening), send 'em to notepad instead... // // ( tacky way of counting lines...) CString strTackyCount(strNotFoundList.c_str()); strTackyCount += strFoundList.c_str(); int iLines = strTackyCount.Replace('\n','?'); // :-) #define MAX_BOX_LINES_HERE 50 if (strNotFoundList.empty()) { if (iLines > MAX_BOX_LINES_HERE) { if (GetYesNo(va("All shaders found... :-)\n\nList has > %d entries, send to Notepad?",MAX_BOX_LINES_HERE))) { SendStringToNotepad(va("All shaders found... :-)\n\nList follows:\n\n%s",strFoundList.c_str()),"found_shaders.txt"); } } else { InfoBox(va("All shaders found... :-)\n\nList follows:\n\n%s",strFoundList.c_str())); } } else { if (iLines > MAX_BOX_LINES_HERE) { if (GetYesNo(va("Some missing shader, some found, but list is > %d entries, send to Notepad?",MAX_BOX_LINES_HERE))) { SendStringToNotepad(va("Missing shaders:\n\n%s\n\nFound shaders:\n\n%s",strNotFoundList.c_str(),strFoundList.c_str()),"found_shaders.txt"); } } else { WarningBox(va("Missing shaders:\n\n%s\n\nFound shaders:\n\n%s",strNotFoundList.c_str(),strFoundList.c_str())); } bReturn = false; } g_bReportImageLoadErrors = bPREV_bReportImageLoadErrors; return bReturn; }
//Testing void HGE_CALL HGE_Impl::Gfx_Test() { _GfxInit(); //265 x 199 HTEXTURE mouse = Texture_Load("resources/tile4.bmp"); }