PlayerResource ResourceCache::LoadPlayer( const PlayerType type, const std::string& name, const TiXmlHandle& hndl ) { const Size size = { static_cast<int>(mAppConfig.GetCellSize().Width * 1.55f), static_cast<int>(mAppConfig.GetCellSize().Height * 1.75f) }; const auto walk_len = 1000_ms; const auto spawn_len = 1000_ms; const auto death_len = 1000_ms; const auto player_hndl = hndl.FirstChild(name); PlayerResource player(type); player.SetFrames(PlayerAnimation::StandUp, walk_len, LoadTextures(player_hndl, "StandUp", size)); player.SetFrames(PlayerAnimation::StandDown, walk_len, LoadTextures(player_hndl, "StandDown", size)); player.SetFrames(PlayerAnimation::StandLeft, walk_len, LoadTextures(player_hndl, "StandLeft", size)); player.SetFrames(PlayerAnimation::StandRight, walk_len, LoadTextures(player_hndl, "StandRight", size)); player.SetFrames(PlayerAnimation::WalkUp, walk_len, LoadTextures(player_hndl, "WalkUp", size)); player.SetFrames(PlayerAnimation::WalkDown, walk_len, LoadTextures(player_hndl, "WalkDown", size)); player.SetFrames(PlayerAnimation::WalkLeft, walk_len, LoadTextures(player_hndl, "WalkLeft", size)); player.SetFrames(PlayerAnimation::WalkRight, walk_len, LoadTextures(player_hndl, "WalkRight", size)); player.SetFrames(PlayerAnimation::Spawn, spawn_len, LoadTextures(player_hndl, "Spawn", size)); player.SetFrames(PlayerAnimation::Destroy, death_len, LoadTextures(player_hndl, "Death", size)); return player; }
void ResourceCache::LoadWallResources(const TiXmlHandle& hndl) { const Size size = mAppConfig.GetCellSize(); WallResource indestructible(WallType::Indestructible, LoadTextures(hndl, "Indestructible", size)); WallResource destructible(WallType::Destructible, LoadTextures(hndl, "Destructible", size)); mWallRes.insert({ indestructible.GetType(), indestructible }); mWallRes.insert({ destructible.GetType(), destructible }); }
void ResourceCache::LoadArenaResources(const TiXmlHandle& hndl) { const Size size = mAppConfig.GetArenaSize(); ArenaResource arena_1(ArenaType::Arena_1, LoadTextures(hndl, "Arena_1", size)); ArenaResource arena_2(ArenaType::Arena_2, LoadTextures(hndl, "Arena_2", size)); ArenaResource arena_3(ArenaType::Arena_3, LoadTextures(hndl, "Arena_3", size)); mArenaRes.insert({ arena_1.GetType(), arena_1 }); mArenaRes.insert({ arena_2.GetType(), arena_2 }); mArenaRes.insert({ arena_3.GetType(), arena_3 }); }
void ResourceCache::LoadBombResources(const TiXmlHandle& hndl) { const Size size = mAppConfig.GetCellSize(); const auto len = mAppConfig.GetBombLifetime(); BombResource countdown(BombType::Countdown); countdown.SetFrames(len, LoadTextures(hndl, "Countdown", size)); BombResource remote(BombType::Remote); remote.SetFrames(len, LoadTextures(hndl, "Remote", size)); mBombRes.insert({ countdown.GetType(), countdown }); mBombRes.insert({ remote.GetType(), remote }); }
World::Impl::Impl( World * container, sf::RenderTarget & target, FontManager & fonts, SoundPlayer & sounds, bool isNetworked ) : pContainer( container ), mTarget( target ), mWorldView( target.getDefaultView() ), mTextures(), mFonts( fonts ), mSounds( sounds ), mSceneGraph(), mSceneLayers(), mWorldBounds( 0.f, 0.f, mWorldView.getSize().x, 5000.f ), mSpawnPosition( mWorldView.getSize().x / 2.f, mWorldBounds.height - mWorldView.getSize().y / 2.f ), mScrollSpeed( -50.f ), mScrollSpeedCompensation( 1.f ), mPlayerAircrafts(), mEnemySpawnPoints(), mActiveEnemies(), mNetworkedWorld( isNetworked ), mNetworkNode( nullptr ), mPhysics( b2Vec2( 0.f, 9.8f ) ) { mSceneTexture.create( mTarget.getSize().x, mTarget.getSize().y ); LoadTextures(); BuildScene(); mWorldView.setCenter( mSpawnPosition ); }
void FImGuiModuleManager::AddWidgetToViewport(UGameViewportClient* GameViewport) { checkf(GameViewport, TEXT("Null game viewport.")); checkf(FSlateApplication::IsInitialized(), TEXT("Slate should be initialized before we can add widget to game viewports.")); // Make sure that we have a context for this viewport's world and get its index. int32 ContextIndex; auto& Proxy = ContextManager.GetWorldContextProxy(*GameViewport->GetWorld(), ContextIndex); // Make sure that textures are loaded before the first Slate widget is created. LoadTextures(); // Create and initialize the widget. TSharedPtr<SImGuiWidget> SharedWidget; SAssignNew(SharedWidget, SImGuiWidget).ModuleManager(this).GameViewport(GameViewport).ContextIndex(ContextIndex); // We transfer widget ownerships to viewports but we keep weak references in case we need to manually detach active // widgets during module shutdown (important during hot-reloading). if (TWeakPtr<SImGuiWidget>* Slot = Widgets.FindByPredicate([](auto& Widget) { return !Widget.IsValid(); })) { *Slot = SharedWidget; } else { Widgets.Emplace(SharedWidget); } }
void CTerrainTextureManager::RecurseDirectory(const CTerrainPropertiesPtr& parentProps, const VfsPath& path) { //LOGMESSAGE("CTextureManager::RecurseDirectory(%s)", path.string8()); CTerrainPropertiesPtr props; // Load terrains.xml first, if it exists VfsPath pathname = path / "terrains.xml"; if (VfsFileExists(pathname)) props = GetPropertiesFromFile(parentProps, pathname); // No terrains.xml, or read failures -> use parent props (i.e. if (!props) { LOGMESSAGE("CTerrainTextureManager::RecurseDirectory(%s): no terrains.xml (or errors while loading) - using parent properties", path.string8()); props = parentProps; } // Recurse once for each subdirectory DirectoryNames subdirectoryNames; (void)g_VFS->GetDirectoryEntries(path, 0, &subdirectoryNames); for (size_t i=0;i<subdirectoryNames.size();i++) { VfsPath subdirectoryPath = path / subdirectoryNames[i] / ""; RecurseDirectory(props, subdirectoryPath); } LoadTextures(props, path); }
bool ModelClass::Initialize(ID3D11Device *device, char *modelFilename, WCHAR *textureFilename1, WCHAR * textureFilename2, WCHAR *textureFilename3) { bool result; //load model data result = LoadModel(modelFilename); if (!result) { return false; } //intialize the vertex and index buffer that hold the geometry for the triangle result = InitializeBuffers(device); if (!result) { return false; } //load the texture for this model result = LoadTextures(device, textureFilename1, textureFilename2, textureFilename3); if (!result) { return false; } return true; }
///<summary> /// CAnimatedInstanceModel:: Initialize ///</summary> ///<param name="AnimatedCoreModel"></param> void CAnimatedInstanceModel::Initialize(CAnimatedCoreModel *AnimatedCoreModel) { m_AnimatedCoreModel = AnimatedCoreModel; m_iNumAnimations = m_AnimatedCoreModel->GetNumAnimations(); m_CalModel = new CalModel(m_AnimatedCoreModel->GetCoreModel()); int meshId; for(meshId = 0; meshId < AnimatedCoreModel->GetCoreModel()->getCoreMeshCount(); meshId++) { m_CalModel->attachMesh(meshId); } LoadTextures(); BlendCycle(1, 0.0f); CEffectManager *l_EffectManager=CORE->GetEffectManager(); std::string &l_EffectTechniqueName=l_EffectManager->GetTechniqueEffectNameByVertexDefault(CAL3D_HW_VERTEX::GetVertexType()); const std::string &l_ModelName= m_AnimatedCoreModel->GetAnimatedCoreModelName(); if(l_ModelName=="bot") { m_EffectTechnique=l_EffectManager->GetEffectTechnique(m_AnimatedCoreModel->GetTechniqueName()); } else { m_EffectTechnique=l_EffectManager->GetEffectTechnique(l_EffectTechniqueName); } }
HRESULT Mesh::LoadMesh(WCHAR* directory, WCHAR* name, WCHAR* extension) { HRESULT hr; CleanUpMesh(); SetDirectory( directory ); SetName( name ); WCHAR meshfile[120]; WCHAR meshpathrel[120]; WCHAR meshpath[120]; Concat(meshfile, name, extension ); Concat(meshpathrel, directory, meshfile ); AppendToRootDir(meshpath, meshpathrel); hr = D3DXLoadMeshFromX( meshpath, D3DXMESH_MANAGED | D3DXMESH_32BIT, mDevice, NULL, &mMaterialBuffer, NULL, &mNumMaterials, &mMesh ); PD(hr, L"load mesh from file"); if(FAILED(hr)) return hr; mMaterials = (D3DXMATERIAL*)mMaterialBuffer->GetBufferPointer(); PD( AdjustMeshDecl(), L"adjust mesh delaration" ); PD( AttribSortMesh(), L"attribute sort mesh" ); PD( LoadTextures(), L"load textures" ); PD( CreateTopologyFromMesh(), L"create topology from mesh"); return D3D_OK; }
int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitWindowSize(1024, 768); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutCreateWindow("Arkanoid"); glutFullScreen(); glutDisplayFunc(Render); glutReshapeFunc(Resize); glutIdleFunc(Render); glutKeyboardFunc(Keys); glutSpecialFunc(PressKey); glutPassiveMotionFunc(PassiveMouseMove); glutMotionFunc(MouseMove); glutMouseFunc(MouseButton); ShowCursor(GL_FALSE); glEnable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); LoadTextures(); InitializeCubes(); projection.InitParts(0.001, 0, ROOM_HEIGHT, -ROOM_HALF_LENGTH); glutMainLoop(); return 0; }
bool ModelClass::Initialize(ID3D11Device* device, char* modelFilename, WCHAR* colorTextureFilename, WCHAR* normalTextureFilename) { bool result; // Load in the model data, result = LoadModel(modelFilename); if(!result) { return false; } // Initialize the vertex and index buffers. result = InitializeBuffers(device); if(!result) { return false; } // Load the textures for this model. result = LoadTextures(device, colorTextureFilename, normalTextureFilename); if(!result) { return false; } return true; }
// Public funcions BIT_UINT32 GUIManager::Load( ) { if( m_Loaded ) { bitTrace( "[GUIManager::Load] Already loaded\n" ); return BIT_ERROR; } if( m_pGraphicDevice == BIT_NULL ) { bitTrace( "[GUIManager::Load] Graphic device is NULL\n" ); return BIT_ERROR; } if( LoadVertexObject( ) != BIT_OK ) { bitTrace( "[GUIManager::Load] Can not load the vertex object\n" ); return BIT_ERROR; } if( LoadShaders( ) != BIT_OK ) { bitTrace( "[GUIManager::Load] Can not load the shaders\n" ); return BIT_ERROR; } if( LoadTextures( ) != BIT_OK ) { bitTrace( "[GUIManager::Load] Can not load the textures\n" ); return BIT_ERROR; } m_Loaded = BIT_TRUE; return BIT_OK; }
bool BumpModelClass::Initialize(ID3D10Device* device, char* modelFilename, WCHAR* textureFilename1, WCHAR* textureFilename2) { bool result; // Load in the model data. result = LoadModel(modelFilename); if(!result) { return false; } // Calculate the normal, tangent, and binormal vectors for the model. CalculateModelVectors(); // Initialize the vertex and index buffer that hold the geometry for the model. result = InitializeBuffers(device); if(!result) { return false; } // Load the textures for this model. result = LoadTextures(device, textureFilename1, textureFilename2); if(!result) { return false; } return true; }
/*!**************************************************************************** @Function InitView @Return bool true if no error occured @Description Code in InitView() will be called by PVRShell upon initialization or after a change in the rendering context. Used to initialize variables that are dependant on the rendering context (e.g. textures, vertex buffers, etc.) ******************************************************************************/ bool OGLES2ShadowMapping::InitView() { CPVRTString ErrorStr; if(!CPVRTgles2Ext::IsGLExtensionSupported("GL_OES_depth_texture")) { PVRShellSet(prefExitMessage, "Error: Unable to run this training course as it requires extension 'GL_OES_depth_texture'"); return false; } m_bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen); // Initialize VBO data if(!LoadVbos(&ErrorStr)) { PVRShellSet(prefExitMessage, ErrorStr.c_str()); return false; } // Load textures if (!LoadTextures(&ErrorStr)) { PVRShellSet(prefExitMessage, ErrorStr.c_str()); return false; } // Load and compile the shaders & link programs if (!LoadShaders(&ErrorStr)) { PVRShellSet(prefExitMessage, ErrorStr.c_str()); return false; } // Create a frame buffer with only the depth buffer attached glGenFramebuffers(1, &m_uiFrameBufferObject); glBindFramebuffer(GL_FRAMEBUFFER, m_uiFrameBufferObject); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_uiShadowMapTexture, 0); if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { PVRShellSet(prefExitMessage, "ERROR: Frame buffer not set up correctly\n"); return false; } glBindFramebuffer(GL_FRAMEBUFFER, 0); // Initialize Print3D if(m_Print3D.SetTextures(0,PVRShellGet(prefWidth),PVRShellGet(prefHeight),m_bRotate) != PVR_SUCCESS) { PVRShellSet(prefExitMessage, "ERROR: Cannot initialise Print3D\n"); return false; } // Use a nice bright blue as clear colour glClearColor(0.6f, 0.8f, 1.0f, 1.0f); return true; }
void myinit(void) { auxInitDisplayMode(AUX_DOUBLE|AUX_RGBA); auxInitPosition(100,100,800,600); auxInitWindow((LPCWSTR)"Solar System"); GLfloat light_ambient[]={0.3,0.5,0.3}; GLfloat light_diffuse[]={1.0,1.0,1.0}; GLfloat light_specular[]={0.8,0.8,0.0}; GLfloat light_position[]={0.0,0.0,0.0}; glLightfv(GL_LIGHT0,GL_AMBIENT,light_ambient); glLightfv(GL_LIGHT0,GL_DIFFUSE,light_diffuse); glLightfv(GL_LIGHT0,GL_SPECULAR,light_specular); glLightfv(GL_LIGHT0,GL_POSITION, light_position); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glClearColor(0, 0, 0, 0); glShadeModel(GL_SMOOTH); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_2D); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_CULL_FACE); LoadTextures(texture_id); for(int i = 0;i<8;i++){ year[i]=(rand()%360); day[i]=0; } }
/*!**************************************************************************** @Function InitView @Return bool true if no error occurred @Description Code in InitView() will be called by PVRShell upon initialization or after a change in the rendering context. Used to initialize variables that are dependent on the rendering context (e.g. textures, vertex buffers, etc.) ******************************************************************************/ bool OGLESPVRScopeRemote::InitView() { CPPLProcessingScoped PPLProcessingScoped(m_psSPSCommsData, __FUNCTION__, static_cast<unsigned int>(strlen(__FUNCTION__)), m_i32FrameCounter); CPVRTString ErrorStr; /* Initialize Print3D */ bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen); if(m_Print3D.SetTextures(0,PVRShellGet(prefWidth),PVRShellGet(prefHeight), bRotate) != PVR_SUCCESS) { PVRShellSet(prefExitMessage, "ERROR: Cannot initialise Print3D\n"); return false; } // Sets the clear color glClearColor(0.6f, 0.8f, 1.0f, 1.0f); // Enables texturing glEnable(GL_TEXTURE_2D); // Initialize VBO data if(!LoadVbos(&ErrorStr)) { PVRShellSet(prefExitMessage, ErrorStr.c_str()); return false; } /* Load textures */ if(!LoadTextures(&ErrorStr)) { PVRShellSet(prefExitMessage, ErrorStr.c_str()); return false; } /* Calculate the projection and view matrices */ m_mProjection = PVRTMat4::PerspectiveFovRH(PVRT_PIf/6, (float)PVRShellGet(prefWidth)/(float)PVRShellGet(prefHeight), CAM_NEAR, CAM_FAR, PVRTMat4::OGL, bRotate); m_mView = PVRTMat4::LookAtRH(PVRTVec3(0, 0, 75.0f), PVRTVec3(0, 0, 0), PVRTVec3(0, 1, 0)); // Enable the depth test glEnable(GL_DEPTH_TEST); // Enable culling glEnable(GL_CULL_FACE); // Initialise variables used for the animation m_fFrame = 0; m_iTimePrev = PVRShellGetTime(); return true; }
SObjModel::SObjModel(const std::string& fname) { LOGV("Opening obj model %s" ,fname.c_str()); CObjMeshParser parser; ObjCtx * ctx = parser.ParseFromFile(fname); if (!ctx) { LOGE("Unable open model"); return; } auto submesh_set = ctx->subMeshSet; long total_triangles = 0; for (auto it = submesh_set.begin(); it != submesh_set.end();++it) { MeshIndexer idx; auto res = idx.IndexNonIndexedMesh(*it); (*it)->vn.clear(); total_triangles += res->vn.size(); d_sm.push_back(res); } std::vector<std::string> mtlrefs = ctx->refMaterialFiles; CObjMeshParser::ReleaseContext(ctx); LOGV("Mesh information: Submesh count:%d, Total mesh triangles:%d", d_sm.size(), total_triangles ); LOGV("Load materials"); //std::string s = mtlrefs[0]; //printf("RefMaterial:%s\n",s.c_str()); if (!mtlrefs.empty()) { std::string json_fname = std::string(mtlrefs[0]+std::string(".json")); //if (CheckFileExists(json_fname)) { if (false) { /* Load */ std::ifstream ifs(json_fname); { cereal::JSONInputArchive arch(ifs); arch(d_materials); } } else { MTLParser mtl_p(mtlrefs[0]); d_materials = mtl_p.GetMaterials(); //OMG copy!! FIX ME mtl_p.SaveToJSON(json_fname); } } LoadTextures(); BindVAOs(); LOGV("Model configured"); IsReady = true; }
void ResourceCache::LoadExplosionResources(const TiXmlHandle& hndl) { const Size size = mAppConfig.GetCellSize(); const auto len = mAppConfig.GetExplosionLifetime(); ExplosionResource center(ExplosionType::Center); center.SetFrames(len, LoadTextures(hndl, "Center", size)); ExplosionResource horizontal(ExplosionType::Horizontal); horizontal.SetFrames(len, LoadTextures(hndl, "Horizontal", size)); ExplosionResource horizontal_leftend(ExplosionType::HorizontalLeftEnd); horizontal_leftend.SetFrames(len, LoadTextures(hndl, "HorizontalLeftEnd", size)); ExplosionResource horizontal_rightend(ExplosionType::HorizontalRightEnd); horizontal_rightend.SetFrames(len, LoadTextures(hndl, "HorizontalRightEnd", size)); ExplosionResource vertical(ExplosionType::Vertical); vertical.SetFrames(len, LoadTextures(hndl, "Vertical", size)); ExplosionResource vertical_upend(ExplosionType::VerticalUpEnd); vertical_upend.SetFrames(len, LoadTextures(hndl, "VerticalUpEnd", size)); ExplosionResource vertical_downend(ExplosionType::VerticalDownEnd); vertical_downend.SetFrames(len, LoadTextures(hndl, "VerticalDownEnd", size)); mExplosionRes.insert({ center.GetType(), center }); mExplosionRes.insert({ horizontal.GetType(), horizontal }); mExplosionRes.insert({ horizontal_leftend.GetType(), horizontal_leftend }); mExplosionRes.insert({ horizontal_rightend.GetType(), horizontal_rightend }); mExplosionRes.insert({ vertical.GetType(), vertical }); mExplosionRes.insert({ vertical_upend.GetType(), vertical_upend }); mExplosionRes.insert({ vertical_downend.GetType(), vertical_downend }); }
void Initsialaize() { LoadTextures(); glEnable(GL_TEXTURE_2D); glClearColor(0.0, 0.0, 0.0, 1.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-4.0, 4.0, -4.0, 4.0, -10.0, 10.0); glMatrixMode(GL_MODELVIEW); }
/*!**************************************************************************** @Function InitView @Return bool true if no error occured @Description Code in InitView() will be called by PVRShell upon initialization or after a change in the rendering context. Used to initialize variables that are dependant on the rendering context (e.g. textures, vertex buffers, etc.) ******************************************************************************/ bool OGLES3TextureStreaming::InitView() { CPVRTString ErrorStr; // Initialize VBO data if(!LoadVbos(&ErrorStr)) { PVRShellSet(prefExitMessage, ErrorStr.c_str()); return false; } // Load textures if(!LoadTextures(&ErrorStr)) { PVRShellSet(prefExitMessage, ErrorStr.c_str()); return false; } // Load and compile the shaders & link programs if(!LoadShaders(&ErrorStr)) { PVRShellSet(prefExitMessage, ErrorStr.c_str()); return false; } /* Initialize the textures used by Print3D. To properly display text, Print3D needs to know the viewport dimensions and whether the text should be rotated. We get the dimensions using the shell function PVRShellGet(prefWidth/prefHeight). We can also get the rotate parameter by checking prefIsRotated and prefFullScreen. */ bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen); if(m_Print3D.SetTextures(0, PVRShellGet(prefWidth), PVRShellGet(prefHeight), bRotate) != PVR_SUCCESS) { PVRShellSet(prefExitMessage, "ERROR: Cannot initialise Print3D\n"); return false; } //Set OpenGL ES render states needed for this demo // Enable backface culling and depth test glCullFace(GL_BACK); glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); // Sets the clear color glClearColor(0.6f, 0.8f, 1.0f, 1.0f); // Setup the AV capture if(!m_Camera.InitialiseSession(ePVRTHWCamera_Front)) return false; return true; }
//----------------------------------------------------------------------------------------------- void Initialize( HINSTANCE applicationInstanceHandle ) { CreateOpenGLWindow( applicationInstanceHandle ); OpenGLRenderer::Initalize(); InitializeTime(); LoadTextures(); LoadDeveloperConsole(); g_game.Initialize(); }
/*!**************************************************************************** @Function InitView @Return bool true if no error occured @Description Code in InitView() will be called by PVRShell upon initialization or after a change in the rendering context. Used to initialize variables that are dependant on the rendering context (e.g. textures, vertex buffers, etc.) ******************************************************************************/ bool OGLES2ChameleonMan::InitView() { CPVRTString ErrorStr; /* Initialize VBO data */ LoadVbos(); /* Load textures */ if (!LoadTextures(&ErrorStr)) { PVRShellSet(prefExitMessage, ErrorStr.c_str()); return false; } /* Load and compile the shaders & link programs */ if (!LoadShaders(&ErrorStr)) { PVRShellSet(prefExitMessage, ErrorStr.c_str()); return false; } /* Initialize Print3D */ // Is the screen rotated? bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen); if(m_Print3D.SetTextures(0,PVRShellGet(prefWidth),PVRShellGet(prefHeight), bRotate) != PVR_SUCCESS) { PVRShellSet(prefExitMessage, "ERROR: Cannot initialise Print3D\n"); return false; } /* Set OpenGL ES render states needed for this training course */ // Enable backface culling and depth test glCullFace(GL_BACK); glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); // Use black as our clear colour glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Initialise variables used for the animation m_iTimePrev = PVRShellGetTime(); return true; }
bool D3D10Model::Load(ID3D10Device* pdev, const TCHAR *name, const TCHAR *texture_path, ID3D10Effect *eff, BoneMatrixConstantType t) { if (!Model::Load(name, texture_path)) return false; LoadTextures(pdev); m_boneMatrixConstantType = t; //Load effect file m_ppMeshEffect = new ID3D10Effect*[m_numMeshs]; for (unsigned int i=0; i<m_numMeshs; i++) SetMeshEffect(i, eff); D3D10_BUFFER_DESC vbdesc; D3D10_SHADER_RESOURCE_VIEW_DESC SRVDesc; switch (m_animationType) { case SKINNING_ANIMATION: switch (m_boneMatrixConstantType) { case CONSTANT_BUFFER: //Create Constant buffer m_techConstantBuffer = eff->GetTechniqueByName( "techConstantBuffer" ); m_boneMatrixConstantBuffer = eff->GetVariableByName( "boneMatrixConstantBuffer" )->AsMatrix(); break; case BUFFER: //Create buffer m_techBuffer = eff->GetTechniqueByName( "techBuffer" ); m_boneMatrixBufferVar = eff->GetVariableByName( "boneMatrixBuffer" )->AsShaderResource(); ZeroMemory( &vbdesc, sizeof(vbdesc) ); vbdesc.ByteWidth = m_numBones*sizeof(float4x4); vbdesc.Usage = D3D10_USAGE_DYNAMIC; vbdesc.BindFlags = D3D10_BIND_SHADER_RESOURCE; vbdesc.CPUAccessFlags = D3D10_CPU_ACCESS_WRITE; vbdesc.MiscFlags = 0; pdev->CreateBuffer(&vbdesc, NULL, &m_boneMatrixBuffer); ZeroMemory( &SRVDesc, sizeof(SRVDesc) ); SRVDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; SRVDesc.ViewDimension = D3D10_SRV_DIMENSION_BUFFER; SRVDesc.Buffer.ElementOffset = 0; SRVDesc.Buffer.ElementWidth = m_numBones*4; pdev->CreateShaderResourceView(m_boneMatrixBuffer, &SRVDesc, &m_boneMatrixBufferRV); break; } break; case STATIC_GEOMETRY: m_techStatic = eff->GetTechniqueByName( "techStatic" ); break; } return true; }
void AELoadedResourcesTreeView::LoadResources() { LoadModels(); LoadMaterials(); LoadTextures(); // LoadMeshes(); // LoadModelInstances(); // LoadMeshInstances(); }
/*!**************************************************************************** @Function InitView @Return bool true if no error occured @Description Code in InitView() will be called by PVRShell upon initialization or after a change in the rendering context. Used to initialize variables that are dependant on the rendering context (e.g. textures, vertex buffers, etc.) ******************************************************************************/ bool OGLES3IntroducingPOD::InitView() { CPVRTString ErrorStr; /* Initialize VBO data */ if(!LoadVbos(&ErrorStr)) { PVRShellSet(prefExitMessage, ErrorStr.c_str()); return false; } /* Load textures */ if(!LoadTextures(&ErrorStr)) { PVRShellSet(prefExitMessage, ErrorStr.c_str()); return false; } /* Load and compile the shaders & link programs */ if(!LoadShaders(&ErrorStr)) { PVRShellSet(prefExitMessage, ErrorStr.c_str()); return false; } /* Initialize Print3D */ bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen); if(m_Print3D.SetTextures(0,PVRShellGet(prefWidth),PVRShellGet(prefHeight), bRotate) != PVR_SUCCESS) { PVRShellSet(prefExitMessage, "ERROR: Cannot initialise Print3D\n"); return false; } /* Set OpenGL ES render states needed for this training course */ // Enable backface culling and depth test glCullFace(GL_BACK); glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); // Use a nice bright blue as clear colour glClearColor(0.6f, 0.8f, 1.0f, 1.0f); return true; }
/*!**************************************************************************** @Function InitView @Return bool true if no error occurred @Description Code in InitView() will be called by PVRShell upon initialization or after a change in the rendering context. Used to initialize variables that are dependant on the rendering context (e.g. textures, vertex buffers, etc.) ******************************************************************************/ bool OGLES3EdgeDetection::InitView() { // Store width and height of the viewport. m_i32TexWidth = PVRShellGet(prefWidth); m_i32TexHeight = PVRShellGet(prefHeight); /* Get the current frame buffer object. As the program hasn't set it yet, this is the default buffer. On most platforms this just gives 0, but there are exceptions. */ glGetIntegerv(GL_FRAMEBUFFER_BINDING, &m_i32OriginalFramebuffer); // Create string for error codes. CPVRTString ErrorStr; // Checks to see if the screen is rotated or not. bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen); // Initialize VBO data if(!LoadVbos(&ErrorStr)) { PVRShellSet(prefExitMessage, ErrorStr.c_str()); return false; } // Initialise Print3D if(m_Print3D.SetTextures(0,m_i32TexWidth,m_i32TexHeight,bRotate) != PVR_SUCCESS) { PVRShellSet(prefExitMessage, "ERROR: Cannot initialise Print3D\n"); return false; } // Load external textures and create internal ones. if(!LoadTextures(&ErrorStr)) { PVRShellSet(prefExitMessage, ErrorStr.c_str()); return false; } // Load and compile the shaders & link programs if (!LoadShaders(&ErrorStr)) { PVRShellSet(prefExitMessage, ErrorStr.c_str()); return false; } // Creates and checks FBO creation if (!CreateFBO(&ErrorStr)) { PVRShellSet(prefExitMessage, ErrorStr.c_str()); return false; } SetupView(bRotate); return true; }
void CObject::LoadTextures (void) { int v; switch (info.renderType) { case RT_NONE: break; //doesn't render, like the CPlayerData case RT_POLYOBJ: if (rType.polyObjInfo.nTexOverride == -1) LoadModelTextures (rType.polyObjInfo.nModel); else LoadBitmap (gameData.pig.tex.bmIndex [0][rType.polyObjInfo.nTexOverride].index, 0); break; case RT_POWERUP: if (PowerupToDevice ()) LoadTextures (); else if ((info.nId >= MAX_POWERUP_TYPES_D2) && (rType.vClipInfo.nClipIndex >= gameData.eff.nClips [0])) rType.vClipInfo.nClipIndex = -MAX_ADDON_BITMAP_FILES - 1; break; case RT_MORPH: case RT_FIREBALL: case RT_THRUSTER: case RT_WEAPON_VCLIP: break; case RT_HOSTAGE: LoadVClipTextures (gameData.eff.vClips [0] + rType.vClipInfo.nClipIndex, 0); break; case RT_LASER: break; } switch (info.nType) { case OBJ_PLAYER: v = GetExplosionVClip (this, 0); if (v>= 0) LoadVClipTextures (gameData.eff.vClips [0] + v, 0); break; case OBJ_ROBOT: LoadRobotTextures (info.nId); break; case OBJ_REACTOR: LoadWeaponTextures (CONTROLCEN_WEAPON_NUM); if (gameData.models.nDeadModels [rType.polyObjInfo.nModel] != -1) LoadModelTextures (gameData.models.nDeadModels [rType.polyObjInfo.nModel]); break; } }
// e.g. filename should be "skybox" and filetype should be "bmp" // so "skybox_l.bmp", etc. will be loaded Skybox::Skybox (const char * const rFilename, const char * const rFiletype, TextureManager* rpTextureManager) : mpTextureManager (rpTextureManager), mTextureU (-1), mTextureD (-1), mTextureL (-1), mTextureR (-1), mTextureF (-1), mTextureB (-1) { mTopOfSkyColor = Color(); LoadTextures (rFilename, rFiletype); }
void OpenMDLmodel::LoadFromFile( CGcontext cgContex, const char* filename, float vertexScaleFactor ) { m_VertexScaleFactor = vertexScaleFactor; InitUberShader( cgContex ); // load a scene file bool newInstance = false; m_Scene = m_Importer.LoadScene(filename, &newInstance); // NOTE: newInstance will be true if the scene file was loaded for the first time. LoadTextures(); }