void FnResourcesCallbackCreate(const string& sPathname, void* pvCallbackData) { static bool b = true; if ( b ) { b = false; SDL_SysWMinfo wmi = { 0 }; SDL_GetWMInfo(&wmi); SetWindowPos(wmi.window, HWND_TOP, NULL, NULL, NULL, NULL, SWP_NOMOVE|SWP_NOREPOSITION |SWP_NOSIZE); GetRender()->BeginProjection(eProjectionOrtho); { // GetUi()->FindWindow("splash")->FindChild("frame")->FindChild("frame")->FindChild("image")->ResizeBy(CVec2i(GetRandom(-2, 2), GetRandom(-2,2))); GetGlue()->HandleScript("[ui.splash.frame.frame.loading set text:'loading %s']", sPathname.c_str()); GetUi()->Render(); } GetRender()->EndProjection(eProjectionOrtho); GetRender()->Swap(); GetRender()->Update(); b = true; } }
void CD3DDummy::ShowBoundingFrame(int Operator) { switch(Operator) { case DBFO_HIDE: { if(m_pBoundingFrame) m_pBoundingFrame->SetVisible(false); } break; case DBFO_SHOW: { if(m_pBoundingFrame) m_pBoundingFrame->SetVisible(true); else { if(GetRender()==NULL) return; m_pBoundingFrame=new CD3DBoundingFrame(); m_pBoundingFrame->SetRender(GetRender()); m_pBoundingFrame->CreateFromBBox(m_BoundingBox); m_pBoundingFrame->SetParent(this); GetRender()->AddObject(m_pBoundingFrame); } } break; case DBFO_RELEASE: SAFE_RELEASE(m_pBoundingFrame); break; } }
void Base::DrawTreeNode( Controls::Base* ctrl, bool bOpen, bool bSelected, int iLabelHeight, int iLabelWidth, int iHalfWay, int iLastBranch, bool bIsRoot ) { GetRender()->SetDrawColor( Colors.Tree.Lines ); if ( !bIsRoot ) { GetRender()->DrawFilledRect( gwen::Rect( 8, iHalfWay, 16 - 9, 1 ) ); } if ( !bOpen ) { return; } GetRender()->DrawFilledRect( gwen::Rect( 14 + 7, iLabelHeight + 1, 1, iLastBranch + iHalfWay - iLabelHeight ) ); }
void MenuSelectLevel::UpdateLevel( IGameContext & context, float dt ) { bool updatePicture = false; if ( m_state != STATE_STAY ) { m_timer -= dt * 1000; if ( m_timer <= 0 ) { if ( m_state == STATE_FADE_OUT ) { updatePicture = true; m_state = STATE_FADE_IN; m_timer = FADE_TIME; } else m_state = STATE_STAY; } } else updatePicture = true; if ( updatePicture && !m_wantLevelObject.empty() ) { const char *pictureFile = context.GetObjectPictureForMenu( m_wantLevelObject.c_str() ); m_levelObjectImage = GetRender().LoadImage( pictureFile ); m_wantLevelObject = ""; } }
void GameScene::RemoveSprite(SpriteFactory::TSpriteNode* sprite) { MapScene* myRender = reinterpret_cast<MapScene*>(GetRender()); if (myRender) myRender->RemoveSprite(sprite->m_sprite); }
void CD3DGUIWndRect::TopTo(IUIBaseRect** pRects,UINT RectCount,IUIBaseRect* pBeforeRect) { CEasyArray<CD3DObject *> ObjectList(64,64); for(UINT i=0;i<RectCount;i++) { ObjectList.Add(dynamic_cast<CD3DObject *>(pRects[i])); } ((CD3DUIRender *)GetRender())->MoveToTop(ObjectList.GetBuffer(),RectCount,dynamic_cast<CD3DObject *>(pBeforeRect)); }
void XvMCOSD::CompositeOSD(VideoFrame* frame, VideoFrame* osdframe) { if (!osd_subpict_alloc) return; X11L; XvMCCompositeSubpicture(XJ_disp, &osd_subpict, osd_xv_image, 0, 0, XJ_width, XJ_height, 0, 0); // delay sync until after getnextfreeframe... XvMCFlushSubpicture(XJ_disp, &osd_subpict); X11U; if (osd_subpict_mode == BLEND_SUBPICTURE && osdframe) { xvmc_render_state_t *render = GetRender(frame); xvmc_render_state_t *osdren = GetRender(osdframe); X11S(XvMCSyncSubpicture(XJ_disp, &osd_subpict)); VideoOutputXv::SyncSurface(frame); X11L; XvMCBlendSubpicture2(XJ_disp, render->p_surface, osdren->p_surface, &osd_subpict, 0, 0, XJ_width, XJ_height, 0, 0, XJ_width, XJ_height); XvMCFlushSurface(XJ_disp, osdren->p_surface); X11U; } else if (osd_subpict_mode == BACKEND_SUBPICTURE) { X11L; XvMCSyncSubpicture(XJ_disp, &osd_subpict); XvMCBlendSubpicture(XJ_disp, GetRender(frame)->p_surface, &osd_subpict, 0, 0, XJ_width, XJ_height, 0, 0, XJ_width, XJ_height); XvMCFlushSurface(XJ_disp, GetRender(frame)->p_surface); X11U; } }
void GameScene::Update(const float elapsed) { //BaseScene::Update(elapsed); // Update of graphic scene. MapScene* myRender = reinterpret_cast<MapScene*>(GetRender()); if (myRender) { myRender->Update(elapsed); Camera& camera = myRender->GetCamera(); GetSource()->SetPosition( static_cast<float>(camera.GetX()), static_cast<float>(camera.GetY()), 0); } // Camera update. Camera& myCamera = GetRender()->GetCamera(); myCamera.SetPosition(myCamera.GetX() + MOVE_CAMERA, myCamera.GetY()); // Update of logic entities. for (unsigned int i = 0; i < m_entities.Size(); i++) m_entities[i]->Update(elapsed); }
bool GameScene::AddSprite(SpriteFactory::TSpriteNode* sprite) { bool isValid = false; MapScene* myRender = reinterpret_cast<MapScene*>(GetRender()); if (myRender) { myRender->AddSprite(sprite->m_sprite, sprite->m_layer); isValid = true; } return isValid; }
void CAppBase::Release() { if ( 0 != --m_cRef ) return; GetInput()->Release(); GetClasses()->Release(); GetUi()->Release(); GetRender()->Release(); GetVideo()->Release(); GetResources()->Release(); GetGlue()->RemoveGlued(this); GetGlue()->Release(); }
void teTexture::Init(ETextureType setTextureType, u32 setFlags, image::teImage * image, ERenderBufferType renderBufferType, const teVector2duh & renderBufferSize) { textureType = setTextureType; flags = setFlags; GetRender()->GetDevice()->CreateTexture(image->levels[0].width, image->levels[0].height, image->levelsCount, 0, GetTextureInternalFormat((image::EImagePixelFormat)image->pixelFormat), D3DPOOL_MANAGED, &texture, 0); for(u8 i = 0; i < image->levelsCount; ++i) { D3DLOCKED_RECT rect; texture->LockRect(i, &rect, NULL, 0); memcpy(rect.pBits, image->GetPixels(0), image->levels[i].bytes); texture->UnlockRect(i); } }
void CAppBase::Update() { GetTime()->Update(); GetInput()->Update(); GetResources()->Update(); // GetNetwork()->Update(); GetObjects()->Update(); GetUi()->Update(); GetRender()->Update(); // if ( !s_pAcre ) // { // s_pAcre = IAcre::Create("terrain/0_0.acre"); // } }
void Map::Render(std::string Index, int PosX, int PosY) { SDL_Rect src; src.h = 1024; src.w = 1024; src.x = 0; src.y = 0; SDL_Rect dest; dest.h = 1024; dest.w = 1020; dest.x = PosX; dest.y = PosY; SDL_RenderCopy(GetRender(), LoadTexture::Instance()->GetTexture(Index), &src, &dest); }
void CMap::Draw(float fElapsedTime) { IRender* render = GetRender(); if (! render) return; // clear back to red, then do not need draw red grid // render->FillRectList(&m_vecRect[0], m_vecRect.size(), 0xffff0000); render->FillRectList(&m_vecBlock[0], m_vecBlock.size(), 0xff000000); render->FillRect(m_rect, 0xffffff00); render->DrawLineList(&m_vecBackLine[0], m_vecBackLine.size(), 0xff000000); if (! m_findPath.empty()) { render->DrawLineStrip(&m_findPath[0], m_findPath.size(), 0xffffffff); } }
bool CustomDeserialize( const TiXmlElement *pElement ) { const TiXmlElement *pPhrase = 0; while( pPhrase = pPhrase ? pPhrase->NextSiblingElement( "Phrase" ) : pElement->FirstChildElement( "Phrase" ) ) { std::string image, text; if ( pPhrase->QueryValueAttribute( "Image", &image ) != TIXML_SUCCESS ) continue; if ( pPhrase->QueryValueAttribute( "Text", &text ) != TIXML_SUCCESS ) continue; ImageHandle imgHandle = GetRender().LoadImage( image.c_str() ); TextHandle txtHandle = GetTextManager().LoadResource( text.c_str() ); m_levelDirector.m_briefing.push_back( STalkEntry( imgHandle, txtHandle ) ); } return true; }
void CAppBase::Acquire() { if ( 1 != ++m_cRef ) return; GetGlue()->Acquire(); GetGlue()->AddGlued(this); GetResources()->Acquire(); GetVideo()->Acquire(); GetVideo()->SetWidth(800); GetVideo()->SetHeight(600); GetVideo()->ApplySettings(); GetRender()->Acquire(); GetUi()->Acquire(); GetClasses()->Acquire(); GetInput()->Acquire(); // OLD STUFF CGuid Guid; Guid.Create(); NETWORKINITSTRUCT nis; nis.Guid = Guid; // if ( !GetNetwork()->Init(nis) ) // { // return -1; // } OBJECTSINITSTRUCT ois; ois.bServer = true; if ( !GetObjects()->Init(ois) ) { return; } }
static void RenderFacesTube(void* pvData) { ITube* pTube = (ITube*)pvData; ((CRender*)GetRender())->RenderFacesTube(pTube); }
bool GameScene::Init() { bool isValid = BaseScene::Init(); if (isValid) { rapidjson::Document* myDoc = GetDoc(); // Load map. m_map = NEW(Map, ((*myDoc)["map"].GetString())); MapScene* myRender = 0; if (m_map) { SetRender(NEW(MapScene, (m_map))); myRender = reinterpret_cast<MapScene*>(GetRender()); } // MapScene* myRender = reinterpret_cast<MapScene*>(GetRender()); if (myRender) { const char* dirImage = (*myDoc)["background"].GetString(); SpriteFactory::TSpriteNode* myImage = SpriteFactory::Instance().CreateImageNode(dirImage); myRender->SetBackgroundImage(myImage->m_image); myRender->GetCamera().SetBounds(0, 0, myRender->GetMap()->GetWidth(), myRender->GetMap()->GetHeight()); double cameraX = (*myDoc)["camera"]["x"].GetDouble(); double cameraY = (*myDoc)["camera"]["y"].GetDouble(); myRender->GetCamera().SetPosition(cameraX, cameraY); // Load entities types. const rapidjson::Value& myInfo = (*myDoc)["typesEntities"]; unsigned int numInfo = myInfo.Size(); for (unsigned int i = 0; i < numInfo; i++) EntityFactory::Instance().LoadInfo(myInfo[i]); // Load entities. const rapidjson::Value& entities = (*myDoc)["entities"]; unsigned int numEntities = entities.Size(); isValid = true; for (unsigned int i = 0; i < numEntities && isValid; i++) { BaseEntity* myEntity = EntityFactory::Instance().CreateEntity(entities[i]); if (myEntity) { myEntity->AddToScene(this); if (myEntity->GetSprite()) { Sprite* mySprite = myEntity->GetSprite()->m_sprite; mySprite->SetMap(m_map); mySprite->SetCollisionPixelData(NEW(CollisionPixelData, ("./data/sprites/dwarf_col.png"))); mySprite->SetCollision(Sprite::COLLISION_PIXEL); } m_entities.Add(myEntity); isValid = m_entities.Last()->Init(); } else isValid = false; } } } return isValid; }
void CAppBase::Render() { // SDL_SysWMinfo wmi = { 0 }; // SDL_GetWMInfo(&wmi); // SetWindowPos(wmi.window, HWND_TOPMOST, NULL, NULL, NULL, NULL, SWP_NOREPOSITION |SWP_NOSIZE); CCamera Camera; Camera.SetViewportDims(CVec2i(GetVideo()->GetWidth(), GetVideo()->GetHeight())); GetRender()->SetCamera(&Camera); CVec3f vDirection; vDirection.Point(g_fAzimuth, g_fElevation); Camera.SetDirection(-vDirection); CVec3f vPosition(0,0,0); vDirection *= g_fZoom; Camera.SetPosition(vPosition+vDirection+CVec3f(160,0,160)); // Camera.SetFOV(60.0f); // Camera.SetAspectRatio(4.0f/3.0f); static ITube* s_pTube = NULL; if ( !s_pTube ) { s_pTube = ITube::Create(); s_pTube->SetShader("shaders/tube.shader"); CVec3f vPoint(0,0,0); for ( int i = 0 ; i < 100 ; ++i ) { s_pTube->AddControlPoint(CVec3f(160+20.0f*sin(float(i)/10.0f), i, (160+20.0f*cos(float(i)/10.0f)))); } } GetRender()->BeginProjection(eProjectionPerspective); { GetRender()->BeginRenderPass(eRenderPassAccum); { GetScene()->Render3d(); GetRender()->RenderTube(s_pTube); } GetRender()->EndRenderPass(eRenderPassAccum); GetRender()->BeginRenderPass(eRenderPassNormal); { GetScene()->Render3d(); GetRender()->RenderTube(s_pTube); static bool once = true; static CVec3f vSrc; static CVec3f vDest; // if ( once ) { vSrc = GetRender()->Unproject(NULL, g_vMousePos, 10.0f); vDest = GetRender()->Unproject(NULL, g_vMousePos, 10000.0f); once=false; } CVec3f vDir = vDest-vSrc; vDir.Normalize(); IObject* pObject = NULL; if ( pObject = GetScene()->PickObject(vSrc, vDir) ) { Debug("Picked %s", pObject->GetClass()->GetClassDef()->GetName().c_str()); } CPlane3f plane(CVec3f(0,1,0), 0.0f); if ( plane.IntersectRay(CRay3f(vSrc, vDir), &g_vCursor3d) ) { // Debug("x,y,z = %f,%f,%f", g_vCursor3d.x, g_vCursor3d.y, g_vCursor3d.z); } else { // Debug("..."); } // GetRender()->RenderLine(CVec3f(160,0,160), vDest, CRGBA(255,255,0,255)); // GetRender()->RenderLine(CVec3f(0,0,0), vDest, CRGBA(0,255,0,255)); // GetRender()->RenderModelSkinned(&s_ModelSkinned); } GetRender()->EndRenderPass(eRenderPassNormal); } GetRender()->EndProjection(eProjectionPerspective); GetRender()->BeginProjection(eProjectionOrtho); { GetUi()->Render(); } GetRender()->EndProjection(eProjectionOrtho); GetRender()->SetCamera(NULL); GetRender()->Swap(); }
void CD3DWOWM2RibbonEmitter::PrepareRender(CD3DDevice * pDevice,CD3DSubMesh * pSubMesh,CD3DSubMeshMaterial * pMaterial,CEasyArray<CD3DLight *>& LightList,CD3DCamera * pCamera) { if(pSubMesh&&pMaterial) { if(pMaterial->GetFX()) { //设置灯光 if(LightList.GetCount()) { D3DLIGHT9 Light; char szParamName[32]; pMaterial->GetFX()->SetInt("LightCount",LightList.GetCount()); for(UINT i=0;i<LightList.GetCount();i++) { LightList[i]->GetCurLight(Light); sprintf_s(szParamName,32,"LightType[%d]",i); pMaterial->GetFX()->SetInt(szParamName,Light.Type); sprintf_s(szParamName,32,"LightPos[%d]",i); pMaterial->GetFX()->SetVector(szParamName,CD3DVector3(Light.Position)); sprintf_s(szParamName,32,"LightDir[%d]",i); pMaterial->GetFX()->SetVector(szParamName,CD3DVector3(Light.Direction)); sprintf_s(szParamName,32,"LightAmbient[%d]",i); pMaterial->GetFX()->SetColor(szParamName,Light.Ambient); sprintf_s(szParamName,32,"LightDiffuse[%d]",i); pMaterial->GetFX()->SetColor(szParamName,Light.Diffuse); sprintf_s(szParamName,32,"LightSpecular[%d]",i); pMaterial->GetFX()->SetColor(szParamName,Light.Specular); sprintf_s(szParamName,32,"LightRange[%d]",i); pMaterial->GetFX()->SetFloat(szParamName,Light.Range); sprintf_s(szParamName,32,"LightAtn0[%d]",i); pMaterial->GetFX()->SetFloat(szParamName,Light.Attenuation0); sprintf_s(szParamName,32,"LightAtn1[%d]",i); pMaterial->GetFX()->SetFloat(szParamName,Light.Attenuation1); sprintf_s(szParamName,32,"LightAtn2[%d]",i); pMaterial->GetFX()->SetFloat(szParamName,Light.Attenuation2); //sprintf_s(szParamName,32,"LightFalloff[%d]",i); //pMaterial->GetFX()->SetFloat(szParamName,Light.Falloff); //sprintf_s(szParamName,32,"LightTheta[%d]",i); //pMaterial->GetFX()->SetFloat(szParamName,Light.Theta); //sprintf_s(szParamName,32,"LightPhi[%d]",i); //pMaterial->GetFX()->SetFloat(szParamName,Light.Phi); } } //设置雾 pMaterial->GetFX()->SetColor("FogColor",GetRender()->GetFogColor()); pMaterial->GetFX()->SetFloat("FogNear",GetRender()->GetFogNear()); pMaterial->GetFX()->SetFloat("FogFar",GetRender()->GetFogFar()); //设置材质 D3DMATERIAL9 * pD3DMaterial; if(pSubMesh->IsSelected()) pD3DMaterial=&SELECTED_SUBMESH_MATERIAL; else pD3DMaterial=&(pMaterial->GetMaterial()); pMaterial->GetFX()->SetColor("MaterialAmbient",pD3DMaterial->Ambient); pMaterial->GetFX()->SetColor("MaterialDiffuse",pD3DMaterial->Diffuse); pMaterial->GetFX()->SetColor("MaterialSpecular",pD3DMaterial->Specular); pMaterial->GetFX()->SetColor("MaterialEmissive",pD3DMaterial->Emissive); pMaterial->GetFX()->SetFloat("MaterialPower",pD3DMaterial->Power); //设置纹理 pMaterial->GetFX()->SetTexture("TexLay0",pMaterial->GetTexture(0)); //设置视投影矩阵 pMaterial->GetFX()->SetMatrix("ViewMatrix",pCamera->GetViewMat()); pMaterial->GetFX()->SetMatrix("ProjMatrix",pCamera->GetProjectMat()); } } else { } }
void CD3DGUIWndRect::TopTo(IUIBaseRect* pBeforeRect) { ((CD3DUIRender *)GetRender())->MoveToTop(this,dynamic_cast<CD3DObject *>(pBeforeRect)); }
void CD3DWOWM2BillBoardParticleEmitter::PrepareRender(CD3DDevice * pDevice,CD3DSubMesh * pSubMesh,CD3DSubMeshMaterial * pMaterial,CEasyArray<CD3DLight *>& LightList,CD3DCamera * pCamera) { if(pSubMesh&&pMaterial) { if(pMaterial->GetFX()) { //设置灯光 if(LightList.GetCount()) { D3DLIGHT9 Light; char szParamName[32]; pMaterial->GetFX()->SetInt("LightCount",LightList.GetCount()); for(UINT i=0;i<LightList.GetCount();i++) { LightList[i]->GetCurLight(Light); sprintf_s(szParamName,32,"LightType[%d]",i); pMaterial->GetFX()->SetInt(szParamName,Light.Type); sprintf_s(szParamName,32,"LightPos[%d]",i); pMaterial->GetFX()->SetVector(szParamName,CD3DVector3(Light.Position)); sprintf_s(szParamName,32,"LightDir[%d]",i); pMaterial->GetFX()->SetVector(szParamName,CD3DVector3(Light.Direction)); sprintf_s(szParamName,32,"LightAmbient[%d]",i); pMaterial->GetFX()->SetColor(szParamName,Light.Ambient); sprintf_s(szParamName,32,"LightDiffuse[%d]",i); pMaterial->GetFX()->SetColor(szParamName,Light.Diffuse); sprintf_s(szParamName,32,"LightSpecular[%d]",i); pMaterial->GetFX()->SetColor(szParamName,Light.Specular); sprintf_s(szParamName,32,"LightRange[%d]",i); pMaterial->GetFX()->SetFloat(szParamName,Light.Range); sprintf_s(szParamName,32,"LightAtn0[%d]",i); pMaterial->GetFX()->SetFloat(szParamName,Light.Attenuation0); sprintf_s(szParamName,32,"LightAtn1[%d]",i); pMaterial->GetFX()->SetFloat(szParamName,Light.Attenuation1); sprintf_s(szParamName,32,"LightAtn2[%d]",i); pMaterial->GetFX()->SetFloat(szParamName,Light.Attenuation2); //sprintf_s(szParamName,32,"LightFalloff[%d]",i); //pMaterial->GetFX()->SetFloat(szParamName,Light.Falloff); //sprintf_s(szParamName,32,"LightTheta[%d]",i); //pMaterial->GetFX()->SetFloat(szParamName,Light.Theta); //sprintf_s(szParamName,32,"LightPhi[%d]",i); //pMaterial->GetFX()->SetFloat(szParamName,Light.Phi); } } //设置雾 pMaterial->GetFX()->SetColor("FogColor",GetRender()->GetFogColor()); pMaterial->GetFX()->SetFloat("FogNear",GetRender()->GetFogNear()); pMaterial->GetFX()->SetFloat("FogFar",GetRender()->GetFogFar()); //设置材质 D3DMATERIAL9 * pD3DMaterial; if(pSubMesh->IsSelected()) pD3DMaterial=&SELECTED_SUBMESH_MATERIAL; else pD3DMaterial=&(pMaterial->GetMaterial()); pMaterial->GetFX()->SetColor("MaterialAmbient",pD3DMaterial->Ambient); pMaterial->GetFX()->SetColor("MaterialDiffuse",pD3DMaterial->Diffuse); pMaterial->GetFX()->SetColor("MaterialSpecular",pD3DMaterial->Specular); pMaterial->GetFX()->SetColor("MaterialEmissive",pD3DMaterial->Emissive); pMaterial->GetFX()->SetFloat("MaterialPower",pD3DMaterial->Power); //设置纹理 pMaterial->GetFX()->SetTexture("TexLay0",pMaterial->GetTexture(0)); if(m_NoTrail) { pMaterial->GetFX()->SetMatrix("WorldMatrix",GetWorldMatrix()); pMaterial->GetFX()->SetMatrix("WorldRotation",GetWorldMatrix().GetRotation()); pMaterial->GetFX()->SetVector("WorldScale",GetWorldMatrix().GetScale()); pMaterial->GetFX()->SetVector("WorldTranslation",GetWorldMatrix().GetTranslation()); } else { CD3DMatrix Mat; CD3DVector3 Vec; Mat.SetIdentity(); pMaterial->GetFX()->SetMatrix("WorldMatrix",Mat); pMaterial->GetFX()->SetMatrix("WorldRotation",Mat); Vec=1.0f; pMaterial->GetFX()->SetVector("WorldScale",Vec); Vec=0.0f; pMaterial->GetFX()->SetVector("WorldTranslation",Vec); } //设置视投影矩阵 pMaterial->GetFX()->SetMatrix("ViewMatrix",pCamera->GetViewMat()); pMaterial->GetFX()->SetMatrix("ProjMatrix",pCamera->GetProjectMat()); pMaterial->GetFX()->SetBool("TransformGravity",m_EnbaleGravityTransform); pMaterial->GetFX()->SetInt("TextureTileRotation",m_TextureTileRotation); } } else { } }
void GameStateWinGame::NextStage() { // Free resources used by old stage switch( m_stage ) { case STAGE_INVALID: m_stage = STAGE_SPACE; break; case STAGE_SPACE: GetRender().DestroyImage( m_space ); m_space = ImageHandle(); m_stage = STAGE_EARTH; m_fadeOut = false; break; case STAGE_EARTH: GetRender().DestroyImage( m_ship ); GetRender().DestroyImage( m_island ); m_ship = ImageHandle(); m_island = ImageHandle(); m_fadeOut = false; m_stage = STAGE_TEXT; break; case STAGE_TEXT: m_stage = STAGE_LAST; break; } // Set up new stage switch( m_stage ) { case STAGE_SPACE: m_y = 0; m_yShip = -300; m_timer = 15.0f; break; case STAGE_EARTH: m_yShip = -200; m_timer = 10.0f; m_fadeIn = true; m_fadeTimer = 2.0f; m_fadeMax = 2.0f; m_fadeColor = Color(0,0,0,0); break; case STAGE_TEXT: m_timer = 10.0f; m_fadeIn = true; m_fadeTimer = 2.0f; m_fadeMax = 2.0f; m_fadeColor = Color(255,255,255,255); break; case STAGE_LAST: GetRender().DestroyImage( m_island ); GetRender().DestroyImage( m_ship ); GetRender().DestroyImage( m_question ); GetRender().DestroyImage( m_space ); m_island = ImageHandle(); m_ship = ImageHandle(); m_question = ImageHandle(); m_space = ImageHandle(); default: ; } }
int main(int argc, char **argv) #endif { #ifdef USE_BREAKPAD google_breakpad::ExceptionHandler *pHandler = new google_breakpad::ExceptionHandler( L"dumps\\", DmpFilter, DmpCallback, 0, google_breakpad::ExceptionHandler::HANDLER_ALL, MiniDumpNormal, L"", 0 ); #endif srand( time( 0 ) ); ISystem & sys = GetSystem(); if ( !sys.Init( "Return of Dr. Destructo", "game.log" ) ) return -1; #ifdef ALLEGRO_ANDROID al_android_set_apk_file_interface(); #endif sys.SetConfigName( "dd.cfg" ); sys.LoadConfig(); ++g_options_version; ISound & sound = GetSound(); sound.Init(); const int masterVolume = sys.HasConfigValue( "DD_Sound", "Master" ) ? sys.GetConfigValue_Int( "DD_Sound", "Master" ) : 100; const int soundVolume = sys.HasConfigValue( "DD_Sound", "Sound" ) ? sys.GetConfigValue_Int( "DD_Sound", "Sound" ) : 100; const int musicVolume = sys.HasConfigValue( "DD_Sound", "Music" ) ? sys.GetConfigValue_Int( "DD_Sound", "Music" ) : 100; sound.SetMasterVolume( masterVolume / 100.0f ); sound.SetVolumeByType( ISample::TYPE_SOUND, soundVolume / 100.0f ); sound.SetVolumeByType( ISample::TYPE_MUSIC, musicVolume / 100.0f ); int cfgW = sys.GetConfigValue_Int( "DD_Graphics", "Width" ); int cfgH = sys.GetConfigValue_Int( "DD_Graphics", "Height" ); int cfgB = sys.GetConfigValue_Int( "DD_Graphics", "Depth" ); int scaling = sys.GetConfigValue_Int( "DD_Graphics", "Scaling" ); if ( scaling == 0 ) scaling = SCALING_KEEP_ASPECT; bool fullscreen = sys.GetConfigValue_Int( "DD_Graphics", "Fullscreen" ); bool vsync = sys.HasConfigValue( "DD_Graphics", "VSync" ) ? sys.GetConfigValue_Int( "DD_Graphics", "VSync" ) : false; if ( cfgW <= 0 ) cfgW = 1280; if ( cfgH <= 0 ) cfgH = 960; if ( cfgB <= 0 ) cfgB = 32; //cfgW = 320; //cfgH = 200; IRender & render = GetRender(); int renderType = sys.GetConfigValue_Int( "DD_Graphics", "RenderMode" ); ERenderType realType = renderType == 0 ? RENDERTYPE_DIRECT3D : RENDERTYPE_OPENGL; if ( !render.Init( realType, cfgW, cfgH, cfgB, fullscreen, vsync, "Data/Fonts/111-catatan-perjalanan.otf" ) ) return -1; render.SetGlobalScaling( (EScalingMode)scaling, SCREEN_W, SCREEN_H ); IInput & input = GetInput(); if ( !input.Init( true, true, true, true ) ) return -1; sys.SetWindowTitle( "Return of Dr. Destructo v1.0" ); Game game; game.Run(); render.Clear(); return 0; }
void teTexture::Bind(u32 layer) const { GetRender()->GetDevice()->SetTexture(layer, texture); }
/* void RenderLine(const CVec3f& vSrc, const CVec3f& vDest, const CRGBA& rgbaColor) { glDisable(GL_TEXTURE_2D); glBegin(GL_LINES); // glColor4f(float(rgbaColor.r)/255.0f, float(rgbaColor.g)/255.0f, float(rgbaColor.b)/255.0f, float(rgbaColor.a)/255.0f); glVertex3fv(vSrc.m_xyz); glVertex3fv(vDest.m_xyz); glEnd(); glEnable(GL_TEXTURE_2D); } */ static void RenderFacesText(void* pvData) { ((CRender*)GetRender())->RenderFacesText((IText*)pvData); }
static void RenderFacesImage(void* pvData) { IImage* pImage = (IImage*)pvData; ((CRender*)GetRender())->RenderFacesImage(pImage); }
void DepthTexture::Generate() { int nWidth=0; int nHeight=0; if(GetSizeType() == TEX_TYPE_DEVICE) { nWidth = GetRender()->GetDeviceWidth(); nHeight = GetRender()->GetDeviceHeight(); } else { nWidth = GetWidth(); nHeight = GetHeight(); } uint32 id = GetID(); if (GetID()) { glDeleteTextures(1, &id); } glGenTextures(1, &id); SetID(id); // make active and bind glBindTexture(GL_TEXTURE_2D, id); // turn off filtering and wrap models //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); GLenum internalFormat = GL_DEPTH_COMPONENT; GLenum textureFormat = GL_DEPTH_COMPONENT; // egl EGL_DEPTH_SIZE 24 use GL_UNSIGNED_INT, 16 use GL_UNSIGNED_SHORT //GLenum type = GL_UNSIGNED_INT; GLenum type = GL_FLOAT; switch(GetFormat()) { case TEX_FORMAT_DEPTH_DEFAULT: { internalFormat = GL_DEPTH_COMPONENT; textureFormat = GL_DEPTH_COMPONENT; type = GL_FLOAT; } break; default: break; } // android test //type = GL_UNSIGNED_SHORT; glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, nWidth, nHeight, 0, textureFormat, type, NULL); glBindTexture(GL_TEXTURE_2D, 0); }
void ColorTexture::Generate() { int nWidth=0; int nHeight=0; if(GetSizeType() == TEX_TYPE_DEVICE) { nWidth = GetRender()->GetDeviceWidth(); nHeight = GetRender()->GetDeviceHeight(); } else { nWidth = GetWidth(); nHeight = GetHeight(); } uint32 id = GetID(); if (GetID()) { glDeleteTextures(1, &id); } glGenTextures(1, &id); SetID(id); // make active and bind glBindTexture(GL_TEXTURE_2D, id); // turn off filtering and wrap models glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // changed on android //GLenum internalFormat = GL_RGB; //GLenum textureFormat = GL_RGB; //GLenum type = GL_UNSIGNED_SHORT_5_6_5; GLenum internalFormat = GL_RGBA; GLenum textureFormat = GL_RGBA; GLenum type = GL_UNSIGNED_BYTE; switch (GetFormat()) { case TEX_FORMAT_rgb_alpha: { internalFormat = GL_RGBA; textureFormat = GL_RGBA; type = GL_UNSIGNED_BYTE; } break; case TEX_FORMAT_rgb: { internalFormat = GL_RGB; textureFormat = GL_RGB; type = GL_UNSIGNED_BYTE; } break; default: break; } glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, nWidth, nHeight, 0, textureFormat, type, NULL); glBindTexture(GL_TEXTURE_2D, 0); }
static void RenderFacesModelSkinned(void* pvData) { ModelSkinnedMesh* pmsm = (ModelSkinnedMesh*)pvData; ((CRender*)GetRender())->RenderFacesModelSkinned(pmsm->pModelSkinned, pmsm->nMeshId); }