本文整理汇总了C++中CGUIImage::AllocResources方法的典型用法代码示例。如果您正苦于以下问题:C++ CGUIImage::AllocResources方法的具体用法?C++ CGUIImage::AllocResources怎么用?C++ CGUIImage::AllocResources使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGUIImage
的用法示例。
在下文中一共展示了CGUIImage::AllocResources方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Show
void CSplash::Show()
{
g_graphicsContext.Lock();
g_graphicsContext.Clear();
g_graphicsContext.Flip();
#ifndef _WIN32
g_graphicsContext.Clear();
g_graphicsContext.Flip();
g_graphicsContext.Clear();
g_graphicsContext.Flip();
#endif
float w = g_graphicsContext.GetWidth();
float h = g_graphicsContext.GetHeight();
if(g_graphicsContext.GetRenderLowresGraphics())
{
RESOLUTION res = g_graphicsContext.GetGraphicsResolution();
w = g_settings.m_ResInfo[res].iWidth;
h = g_settings.m_ResInfo[res].iHeight;
}
CGUIImage* image = new CGUIImage(0, 0, 0, 0, w, h, m_ImageName);
image->SetAspectRatio(CAspectRatio::AR_KEEP);
image->AllocResources();
//render splash image
g_Windowing.BeginRender();
image->Render();
image->FreeResources();
delete image;
//show it on screen
g_Windowing.EndRender();
g_graphicsContext.Flip();
g_graphicsContext.Unlock();
}
示例2: Process
void CSplash::Process()
{
D3DGAMMARAMP newRamp;
D3DGAMMARAMP oldRamp;
g_graphicsContext.Lock();
g_graphicsContext.Get3DDevice()->Clear(0, NULL, D3DCLEAR_TARGET, 0, 0, 0);
g_graphicsContext.SetCameraPosition(CPoint(0, 0));
float w = g_graphicsContext.GetWidth();
float h = g_graphicsContext.GetHeight();
CGUIImage* image = new CGUIImage(0, 0, 0, 0, w, h, m_ImageName);
CGUIImage* image2 = new CGUIImage(0, 0, 0, 0, w, h, m_ImageName2);
image->SetAspectRatio(CAspectRatio::AR_STRETCH);
image2->SetAspectRatio(CAspectRatio::AR_STRETCH);
image->AllocResources();
image2->AllocResources();
// Store the old gamma ramp
g_graphicsContext.Get3DDevice()->GetGammaRamp(&oldRamp);
float fade = 0.5f;
for (int i = 0; i < 256; i++)
{
newRamp.red[i] = (int)((float)oldRamp.red[i] * fade);
newRamp.green[i] = (int)((float)oldRamp.red[i] * fade);
newRamp.blue[i] = (int)((float)oldRamp.red[i] * fade);
}
g_graphicsContext.Get3DDevice()->SetGammaRamp(GAMMA_RAMP_FLAG, &newRamp);
//render splash image
#ifndef HAS_XBOX_D3D
g_graphicsContext.Get3DDevice()->BeginScene();
#endif
image->Render();
image2->Render();
image->FreeResources();
image2->FreeResources();
delete image;
delete image2;
//show it on screen
#ifdef HAS_XBOX_D3D
g_graphicsContext.Get3DDevice()->BlockUntilVerticalBlank();
#else
g_graphicsContext.Get3DDevice()->EndScene();
#endif
g_graphicsContext.Get3DDevice()->Present( NULL, NULL, NULL, NULL );
g_graphicsContext.Unlock();
//fade in and wait untill the thread is stopped
while (!m_bStop)
{
if (fade <= 1.f)
{
for (int i = 0; i < 256; i++)
{
newRamp.red[i] = (int)((float)oldRamp.red[i] * fade);
newRamp.green[i] = (int)((float)oldRamp.green[i] * fade);
newRamp.blue[i] = (int)((float)oldRamp.blue[i] * fade);
}
g_graphicsContext.Lock();
Sleep(3);
g_graphicsContext.Get3DDevice()->SetGammaRamp(GAMMA_RAMP_FLAG, &newRamp);
g_graphicsContext.Unlock();
fade += 0.01f;
}
else
{
Sleep(10);
}
}
g_graphicsContext.Lock();
// fade out
for (float fadeout = fade - 0.01f; fadeout >= 0.f; fadeout -= 0.01f)
{
for (int i = 0; i < 256; i++)
{
newRamp.red[i] = (int)((float)oldRamp.red[i] * fadeout);
newRamp.green[i] = (int)((float)oldRamp.green[i] * fadeout);
newRamp.blue[i] = (int)((float)oldRamp.blue[i] * fadeout);
}
Sleep(3);
g_graphicsContext.Get3DDevice()->SetGammaRamp(GAMMA_RAMP_FLAG, &newRamp);
}
//restore original gamma ramp
g_graphicsContext.Get3DDevice()->Clear(0, NULL, D3DCLEAR_TARGET, 0, 0, 0);
g_graphicsContext.Get3DDevice()->SetGammaRamp(0, &oldRamp);
g_graphicsContext.Get3DDevice()->Present( NULL, NULL, NULL, NULL );
g_graphicsContext.Unlock();
}