cWidgetCheckBox::cWidgetCheckBox(cGuiSet *apSet, cGuiSkin *apSkin) : iWidget(eWidgetType_CheckBox,apSet, apSkin) { mbChecked = false; mbPressed = false; LoadGraphics(); }
/** ** Load resources(sprites and sound) from files ** ** @param filename Name of file which carry name of file - images or sound ** @note ** Class function = 0. ** Times perfomes = once. */ global void LoadResource(char *filename) { int type_resource=0;/*GRAPHICAL , SOUND*/ ResourceObj object= {}; /*box for object*/ Texture_Obj texture_obj= {}; /*box for texture*/ char str[150]=""; Open_file(filename,&(resources.file)); while (!getstr(resources.file.pfile,str)) { /*read one string*/ /*places here for auto clean*/ char file_res[50]="";/*Name of file resources*/ if(sscanf(str,"%d:%d:%d:%d:%d:%d:%s", &object.id_resource, &type_resource, &texture_obj.texcord.x, &texture_obj.texcord.y, &object.sprite.width, &object.sprite.height, file_res)!=0) { if(type_resource==GRAPHICAL) { if(*file_res) { /*not use share image*/ LoadGraphics(file_res,video.video_render,&texture_obj);/*load image*/ object.share=OFF;/*self loaded*/ } else { object.share=ON;/*share file*/ } } object.sprite.texture_obj=texture_obj; CreateResourceCell(&object); } } }
int main(){ Init(); LoadGraphics(); Loop(); ShutDown(); return 0; }
OGLTexture Graphics_Manager::GetOGLTextureByID(TexID ID) { GraphicsID graphicsID = GetGraphicsEntryByID(ID); if (graphicsID == BAD_ID) { //logWrite("ERROR: Texture ID %d failed lookup",ID); return 0; } if (!graphicsEntries[graphicsID]->TextureAtlas->dataLoaded) { logWrite("!!!! TRYING TO RENDER ATLAS WITHOUT DATA !!!!"); LoadGraphics(graphicsID); return 0; } else { return graphicsEntries[graphicsID]->TextureAtlas->TextureOGLID; } }
void C_Rat::Initialize(float2 _position, float2 _thickness) { IsAttackMode = false; C_Character::Initialize(_position, _thickness); Parameter.HP = MaxHP = 100; Parameter.ATK = 25; Parameter.DEF = 0; if (DeadGraphic == -1) { LoadGraphics(); } NowAnimeNumber = 0; }
//================================================ //コンティニュー画面 //================================================ void DrawContinue() { g_Score = 0; g_gamecounter = 0; model.Initialize(); camera.Initialize(); player.Initialize(); menu.Initialize(); //pause.Initialize(); //tuto_menu.Initialize(); window.Initialize(); for(int i = 0;i < ENEMY_NUM;i++) { enemy[i].Initialize(); } boss.Initialize(); /*初期座標等セット*/ player.SetPosition(200, 400); //-------------------------------- //テクスチャ読み込み //-------------------------------- LoadGraphics(); //-------------------------------- //音読み込み //-------------------------------- //LoadSounds(); //-------------------------------- //カメラ生成 //-------------------------------- camera.Create(); g_GameMode = SCENE_MAIN; }
void PaletteWindow::ThreadStart() { LoadGraphics(); // 24 depth bits, 8 stencil bits, 8x AA, major version 4. sf::ContextSettings contextSettings = sf::ContextSettings(24, 8, 8, 4, 0); sf::Uint32 style = sf::Style::Titlebar; sf::RenderWindow window(sf::VideoMode(size, size * 3), "Palette", style, contextSettings); window.setFramerateLimit(60); // Start the main loop isAlive = true; while (isAlive) { HandleEvents(window); Render(window); // Display what we rendered. window.display(); } }
cWidgetTextBox::cWidgetTextBox(cGuiSet *apSet, cGuiSkin *apSkin) : iWidget(eWidgetType_TextBox,apSet, apSkin) { LoadGraphics(); mlMarkerCharPos = -1; mlSelectedTextEnd = -1; mlFirstVisibleChar =0; mlVisibleCharSize =0; mfTextMaxSize =0; mfMaxTextSizeNeg =0; mlMaxCharacters = -1; mlVisibleCharSize =0; mbPressed = false; mbCanEdit = true; mpPointerGfx = mpSkin->GetGfx(eGuiSkinGfx_PointerText); }
void iWidget::Init() { OnInit(); LoadGraphics(); }
void HSWDisplay::RenderInternal(ovrEyeType eye, const ovrTexture* eyeTexture) { if(RenderEnabled && eyeTexture) { // We need to render to the eyeTexture with the texture viewport. // Setup rendering to the texture. ovrGLTexture* eyeTextureGL = const_cast<ovrGLTexture*>(reinterpret_cast<const ovrGLTexture*>(eyeTexture)); OVR_ASSERT(eyeTextureGL->Texture.Header.API == ovrRenderAPI_OpenGL); // We init a temporary Context, Bind our own context, then Bind the temporary context below before exiting. // It's more exensive to have a temp context copy made here instead of having it as a saved member variable, // but we can't have a saved member variable because the app might delete the saved member behind our back // or associate it with another thread, which would cause our bind of it before exiting to be a bad operation. Context currentGLContext; // To do: Change this to use the AutoContext class that was recently created. currentGLContext.InitFromCurrent(); if(GLContext.GetIncarnation() == 0) // If not yet initialized... GLContext.CreateShared(currentGLContext); GLContext.Bind(); #if defined(OVR_OS_MAC) // To consider: merge the following into the Bind function. GLContext.SetSurface(currentGLContext); #endif // Load the graphics if not loaded already. if (!pTexture) LoadGraphics(); // Calculate ortho projection. GetOrthoProjection(RenderState, OrthoProjection); // Set the rendering to be to the eye texture. glBindFramebuffer(GL_FRAMEBUFFER, FrameBuffer); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, eyeTextureGL->OGL.TexId, 0); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0); // We aren't using depth, as we currently want this to overwrite everything. GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); OVR_ASSERT(status == GL_FRAMEBUFFER_COMPLETE); OVR_UNUSED(status); // Set up the viewport const GLint x = (GLint)eyeTextureGL->Texture.Header.RenderViewport.Pos.x; const GLint y = (GLint)eyeTextureGL->Texture.Header.RenderViewport.Pos.y; // Note that GL uses bottom-up coordinates. const GLsizei w = (GLsizei)eyeTextureGL->Texture.Header.RenderViewport.Size.w; const GLsizei h = (GLsizei)eyeTextureGL->Texture.Header.RenderViewport.Size.h; glViewport(x, y, w, h); // Set fixed-function render states. //glDepthRange(0.0, 1.0); // This is the default glDepthMask(GL_FALSE); glDisable(GL_DEPTH_TEST); glFrontFace(GL_CW); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Enable the buffer and shaders we use. ShaderFill fill(pShaderSet); if (pTexture) fill.SetTexture(0, pTexture); // Set shader uniforms. const float scale = HSWDISPLAY_SCALE * ((RenderState.OurHMDInfo.HmdType == HmdType_DK1) ? 0.70f : 1.f); pShaderSet->SetUniform2f("Scale", scale, scale / 2.f); // X and Y scale. Y is a fixed proportion to X in order to give a certain aspect ratio. pShaderSet->SetUniform2f("PositionOffset", OrthoProjection[eye].GetTranslation().x, 0.0f); // Set vertex attributes if (GLVersionInfo.SupportsVAO) { OVR_ASSERT(VAO != 0); glBindVertexArray(VAO); } if(!VAOInitialized) // This executes for the case that VAO isn't supported. { glBindBuffer(GL_ARRAY_BUFFER, pVB->GLBuffer); // This must be called before glVertexAttribPointer is called below. const GLuint shaderProgram = pShaderSet->Prog; GLint attributeLocationArray[3]; attributeLocationArray[0] = glGetAttribLocation(shaderProgram, "Position"); glVertexAttribPointer(attributeLocationArray[0], sizeof(Vector3f)/sizeof(float), GL_FLOAT, false, sizeof(HASWVertex), reinterpret_cast<char*>(offsetof(HASWVertex, Pos))); attributeLocationArray[1] = glGetAttribLocation(shaderProgram, "Color"); glVertexAttribPointer(attributeLocationArray[1], sizeof(Color)/sizeof(uint8_t), GL_UNSIGNED_BYTE, true, sizeof(HASWVertex), reinterpret_cast<char*>(offsetof(HASWVertex, C))); // True because we want it to convert [0,255] to [0,1] for us. attributeLocationArray[2] = glGetAttribLocation(shaderProgram, "TexCoord"); glVertexAttribPointer(attributeLocationArray[2], sizeof(float[2])/sizeof(float), GL_FLOAT, false, sizeof(HASWVertex), reinterpret_cast<char*>(offsetof(HASWVertex, U))); for (size_t i = 0; i < OVR_ARRAY_COUNT(attributeLocationArray); i++) glEnableVertexAttribArray((GLuint)i); } fill.Set(Prim_TriangleStrip); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); if (GLVersionInfo.SupportsVAO) { VAOInitialized = true; glBindVertexArray(0); } currentGLContext.Bind(); } }
bool C4Def::Load(C4Group &hGroup, StdMeshSkeletonLoader &loader, DWORD dwLoadWhat, const char *szLanguage, C4SoundSystem *pSoundSystem, C4DefGraphicsPtrBackup *gfx_backup ) { bool AddFileMonitoring = false; if (Game.pFileMonitor && !SEqual(hGroup.GetFullName().getData(),Filename) && !hGroup.IsPacked()) AddFileMonitoring = true; // Store filename SCopy(hGroup.GetFullName().getData(),Filename); // Verbose log filename if (Config.Graphics.VerboseObjectLoading>=3) Log(hGroup.GetFullName().getData()); if (AddFileMonitoring) Game.pFileMonitor->AddDirectory(Filename); // Pre-read all images and shader stuff because they ar eaccessed in unpredictable order during loading hGroup.PreCacheEntries(C4CFN_ShaderFiles); hGroup.PreCacheEntries(C4CFN_ImageFiles); LoadMeshMaterials(hGroup, gfx_backup); bool fSuccess = LoadParticleDef(hGroup); // Read DefCore if (fSuccess) fSuccess = LoadDefCore(hGroup); // Skip def: don't even read sounds! if (fSuccess && Game.C4S.Definitions.SkipDefs.GetIDCount(id, 1)) return false; // Read sounds, even if not a valid def (for pure ocd sound folders) if (dwLoadWhat & C4D_Load_Sounds) LoadSounds(hGroup, pSoundSystem); // cancel if not a valid definition if (!fSuccess) return false; // Read and parse SolidMask bitmap if (!LoadSolidMask(hGroup)) return false; // Read surface bitmap, meshes, skeletons if ((dwLoadWhat & C4D_Load_Bitmap) && !LoadGraphics(hGroup, loader)) return false; // Read string table C4Language::LoadComponentHost(&StringTable, hGroup, C4CFN_ScriptStringTbl, szLanguage); // Register ID with script engine ::ScriptEngine.RegisterGlobalConstant(id.ToString(), C4VPropList(this)); ParentKeyName = ::Strings.RegString(id.ToString()); // Read script if (dwLoadWhat & C4D_Load_Script) LoadScript(hGroup, szLanguage); // Read clonknames if (dwLoadWhat & C4D_Load_ClonkNames) LoadClonkNames(hGroup, pClonkNames, szLanguage); // Read clonkranks if (dwLoadWhat & C4D_Load_RankNames) LoadRankNames(hGroup, szLanguage); // Read rankfaces if (dwLoadWhat & C4D_Load_RankFaces) LoadRankFaces(hGroup); // Temporary flag if (dwLoadWhat & C4D_Load_Temporary) Temporary=true; return true; }
void HSWDisplay::RenderInternal(ovrEyeType eye, const ovrTexture* eyeTexture) { if(RenderEnabled && eyeTexture) { // Note: The D3D9 implementation below is entirely fixed-function and isn't yet using shaders. // For the time being this is sufficient, but future designs will likely necessitate moving // to a system that uses programmable shaders. // We need to render to the eyeTexture with the texture viewport. // Setup rendering to the texture. ovrD3D9Texture* eyeTextureD3D9 = const_cast<ovrD3D9Texture*>(reinterpret_cast<const ovrD3D9Texture*>(eyeTexture)); OVR_ASSERT(eyeTextureD3D9->Texture.Header.API == ovrRenderAPI_D3D9); // Save previous state. // To do: Merge this saved state with that done by DistortionRenderer::GraphicsState::Save(), and put them in a shared location. DWORD fvfSaved; RenderParams.Device->GetFVF(&fvfSaved); Ptr<IDirect3DVertexBuffer9> pVBDSaved; UINT vbOffsetSaved; UINT vbStrideSaved; RenderParams.Device->GetStreamSource(0, &pVBDSaved.GetRawRef(), &vbOffsetSaved, &vbStrideSaved); Ptr<IDirect3DBaseTexture9> pTexture0Saved; RenderParams.Device->GetTexture(0, &pTexture0Saved.GetRawRef()); Ptr<IDirect3DBaseTexture9> pTexture1Saved; RenderParams.Device->GetTexture(1, &pTexture1Saved.GetRawRef()); D3DMATRIX worldMatrixSaved, viewMatrixSaved, projectionMatrixSaved, texture0MatrixSaved; RenderParams.Device->GetTransform(D3DTS_WORLD, &worldMatrixSaved); RenderParams.Device->GetTransform(D3DTS_VIEW, &viewMatrixSaved); RenderParams.Device->GetTransform(D3DTS_PROJECTION, &projectionMatrixSaved); RenderParams.Device->GetTransform(D3DTS_TEXTURE0, &texture0MatrixSaved); Ptr<IDirect3DVertexShader9> pVertexShaderSaved; RenderParams.Device->GetVertexShader(&pVertexShaderSaved.GetRawRef()); Ptr<IDirect3DPixelShader9> pPixelShaderSaved; RenderParams.Device->GetPixelShader(&pPixelShaderSaved.GetRawRef()); D3DVIEWPORT9 viewportSaved; RenderParams.Device->GetViewport(&viewportSaved); Ptr<IDirect3DSurface9> pRenderTargetSaved; RenderParams.Device->GetRenderTarget(0, &pRenderTargetSaved.GetRawRef()); // Load the graphics if not loaded already. if(!pTexture) LoadGraphics(); // Calculate ortho projection. GetOrthoProjection(RenderState, OrthoProjection); HRESULT hResult = RenderParams.Device->BeginScene(); if(FAILED(hResult)) { HSWDISPLAY_LOG(("[HSWDisplay D3D9] BeginScene failed. %d (%x)", hResult, hResult)); } Ptr<IDirect3DSurface9> pDestSurface; hResult = eyeTextureD3D9->D3D9.pTexture->GetSurfaceLevel(0, &pDestSurface.GetRawRef()); if(FAILED(hResult)) { HSWDISPLAY_LOG(("[HSWDisplay D3D9] GetSurfaceLevel failed. %d (%x)", hResult, hResult)); } hResult = RenderParams.Device->SetRenderTarget(0, pDestSurface); if(FAILED(hResult)) { HSWDISPLAY_LOG(("[HSWDisplay D3D9] SetRenderTarget failed. %d (%x)", hResult, hResult)); } D3DVIEWPORT9 D3DViewport; D3DViewport.X = eyeTextureD3D9->Texture.Header.RenderViewport.Pos.x; D3DViewport.Y = eyeTextureD3D9->Texture.Header.RenderViewport.Pos.y; D3DViewport.Width = eyeTextureD3D9->Texture.Header.RenderViewport.Size.w; D3DViewport.Height = eyeTextureD3D9->Texture.Header.RenderViewport.Size.h; D3DViewport.MinZ = 0; D3DViewport.MaxZ = 1; hResult = RenderParams.Device->SetViewport(&D3DViewport); if(FAILED(hResult)) { HSWDISPLAY_LOG(("[HSWDisplay D3D9] SetViewport failed. %d (%x)", hResult, hResult)); } hResult = RenderParams.Device->SetTexture(0, pTexture); if(FAILED(hResult)) { HSWDISPLAY_LOG(("[HSWDisplay D3D9] SetTexture failed. %d (%x)", hResult, hResult)); } RenderParams.Device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); RenderParams.Device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); RenderParams.Device->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); RenderParams.Device->SetVertexShader(NULL); RenderParams.Device->SetPixelShader(NULL); hResult = RenderParams.Device->SetStreamSource(0, pVB, 0, sizeof(HASWVertex)); if(FAILED(hResult)) { HSWDISPLAY_LOG(("[HSWDisplay D3D9] SetStreamSource failed. %d (%x)", hResult, hResult)); } RenderParams.Device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP); RenderParams.Device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP); RenderParams.Device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); RenderParams.Device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); RenderParams.Device->SetRenderState(D3DRS_LIGHTING, FALSE); RenderParams.Device->SetRenderState(D3DRS_ZENABLE, FALSE); RenderParams.Device->SetRenderState(D3DRS_ZWRITEENABLE, FALSE); RenderParams.Device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); RenderParams.Device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); RenderParams.Device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); const float scale = HSWDISPLAY_SCALE * ((RenderState.OurHMDInfo.HmdType == HmdType_DK1) ? 0.70f : 1.f); Matrix4f identityMatrix = Matrix4f::Identity(); Vector3f translation = OrthoProjection[eye].GetTranslation(); Matrix4f orthoStereoMatrix( scale, 0, 0, 0, 0, scale / 2, 0, 0, 0, 0, HSWDISPLAY_DISTANCE, 0, translation.x, translation.y, translation.z, 1 ); RenderParams.Device->SetTransform(D3DTS_WORLD, reinterpret_cast<const D3DMATRIX*>(&identityMatrix)); RenderParams.Device->SetTransform(D3DTS_VIEW, reinterpret_cast<const D3DMATRIX*>(&identityMatrix)); RenderParams.Device->SetTransform(D3DTS_PROJECTION, reinterpret_cast<const D3DMATRIX*>(&orthoStereoMatrix)); RenderParams.Device->SetTransform(D3DTS_TEXTURE0, reinterpret_cast<const D3DMATRIX*>(&identityMatrix)); hResult = RenderParams.Device->SetFVF(HASWVertexD3D9Format); if(FAILED(hResult)) { HSWDISPLAY_LOG(("[HSWDisplay D3D9] SetFVF failed. %d (%x)", hResult, hResult)); } hResult = RenderParams.Device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); if(FAILED(hResult)) { HSWDISPLAY_LOG(("[HSWDisplay D3D9] DrawPrimitive failed. %d (%x)", hResult, hResult)); } hResult = RenderParams.Device->EndScene(); if(FAILED(hResult)) { HSWDISPLAY_LOG(("[HSWDisplay D3D9] EndScene failed. %d (%x)", hResult, hResult)); } // Restore previous state. RenderParams.Device->SetRenderTarget(0, pRenderTargetSaved); RenderParams.Device->SetViewport(&viewportSaved); RenderParams.Device->SetPixelShader(pPixelShaderSaved); RenderParams.Device->SetVertexShader(pVertexShaderSaved); RenderParams.Device->SetTransform(D3DTS_TEXTURE0, &texture0MatrixSaved); RenderParams.Device->SetTransform(D3DTS_PROJECTION, &projectionMatrixSaved); RenderParams.Device->SetTransform(D3DTS_VIEW, &viewMatrixSaved); RenderParams.Device->SetTransform(D3DTS_WORLD, &worldMatrixSaved); RenderParams.Device->SetTexture(0, pTexture0Saved); RenderParams.Device->SetTexture(1, pTexture1Saved); RenderParams.Device->SetStreamSource(0, pVBDSaved, vbOffsetSaved, vbStrideSaved); RenderParams.Device->SetFVF(fvfSaved); } }
//================================================ //初期化 //================================================ void Initialize(void) { g_Score = 0; g_gamecounter = 0; model.Initialize(); camera.Initialize(); tcamera.Initialize(); player.Initialize(); menu.Initialize(); //pause.Initialize(); //tuto_menu.Initialize(); window.Initialize(); for(int i = 0;i < ENEMY_NUM;i++) { enemy[i].Initialize(); } boss.Initialize(); /*初期座標等セット*/ player.SetPosition(200, 400); //-------------------------------- //音読み込み //-------------------------------- //-------------------------------- //テクスチャ読み込み //-------------------------------- LoadGraphics(); //-------------------------------- //カメラ生成 //-------------------------------- camera.Create(); tcamera.Create(); //-------------------------------- //ライトの設定 //-------------------------------- SetLight(); //-------------------------------- //モデル生成 //-------------------------------- model.LoadData("field\\field_5_3.x", COLORKEY_DISABLE); //-------------------------------- //フォント生成 //-------------------------------- window.CreateFontSprite(); window.CreateFont(); score.CreateFont(); menu.CreateFontSprite(); //pause.CreateFontSprite(); //tuto_menu.CreateFontSprite(); //mode.CreateFontSprite(); menu.CreateFont(); //-------------------------------- //プリミティブ生成 //-------------------------------- lPrim = LunaPrimitive::Create(512, PRIM_VERTEX_UV0, false); /*モデルデータ変形*/ //model.Translation(); g_GameMode = SCENE_TITLE; }