本文整理汇总了C++中Style::SetParameter方法的典型用法代码示例。如果您正苦于以下问题:C++ Style::SetParameter方法的具体用法?C++ Style::SetParameter怎么用?C++ Style::SetParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Style
的用法示例。
在下文中一共展示了Style::SetParameter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WinMain
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR cmd, int nCmd)
{
u32 r = Log2(48);
Window* window = Window::Create("BFAATW!", 480, 320, false);
if ( ! window ) return 42;
Renderer* renderer = Renderer::Create(window);
if ( ! renderer ) { delete window; return 42; }
ResourceManager* resources = new ResourceManager(renderer);
Style* style = resources->LoadStyle("basic.style");
renderer->SetStyle(style);
Mesh* plane = CreatePlane(resources, "ground");
Texture* ground = resources->LoadTexture("hill_mound_b.dds");
Matrix planeWorld(Matrix::Identity);
Matrix tmp;
MatrixScaling(tmp, Vector(10.0f, 1.0f, 10.0f));
MatrixMultiply(planeWorld, tmp);
MatrixTranslation(tmp, Vector(0.0f, -3.0f, 0.0f));
MatrixMultiply(planeWorld, tmp);
Mesh* cube = CreateCube(resources, "cube");
Texture* diffuse = resources->LoadTexture("Catwalk_03_Diffuse_512.dds");
Matrix cubeWorld(Matrix::Identity);
Matrix view, projection;
Camera::Perspective(MATH_PI_3, 480.0f/320.0f, 0.1f, 100.0f, projection);
RenderTarget* shadowMap = resources->CreateRenderTarget("shadowmap", 1024, 1024, RT_SHADOWMAP);
Vector lightPosition(3.0f, 5.0f, 2.0f);
Matrix lightView, lightProjection;
Camera::Orthographic(-3.0f, 3.0f, -3.0f, 3.0f, 0.1f, 100.0f, lightProjection);
Camera::LookAt(lightPosition, Vector::Zero, Vector::UnitY, lightView);
Timer timer(60);
timer.Start();
Texture* depth = shadowMap->GetTexture(0);
style->SetParameter("shadow", &depth);
style->SetParameter("lightPosition", &lightPosition);
while ( window->Update() && ! window->IsKeyDown(KEY_ESCAPE) )
{
while ( timer.Update() )
{
if ( window->IsMouseButtonDown(MOUSE_RIGHT) )
{
// Set camera position
u32 wx, wy;
window->GetSize(wx, wy);
s32 mx, my;
window->GetMousePosition(mx, my);
Vector eye;
float theta = -float(my) / float(wy) * MATH_2_PI;
float rho = float(mx) / float(wx) * MATH_2_PI * 2.0f;
theta = Clamp(theta, -4.5f, -2.0f);
eye.x = 5.0f * cosf(theta) * cosf(rho);
eye.y = 5.0f * sinf(theta);
eye.z = 5.0f * cosf(theta) * sinf(rho);
Camera::LookAt(eye, Vector::Zero, Vector::UnitY, view);
}
MatrixRotation(tmp, Vector::UnitY, MATH_PI / 120.0f);
MatrixMultiply(planeWorld, tmp);
//cubeWorld = Matrix::Identity * Matrix::Scaling(Vector::One * (cosf(timer.GetTime() * 13.0f)+1.2f));
}
{ // render to shadow map
renderer->SetRenderTarget(shadowMap);
renderer->SetViewport(0, 0, 1024, 1024);
renderer->Clear();
int b = false;
style->SetParameter("processShadow", &b);
Matrix viewProjection = lightView;
MatrixMultiply(viewProjection, lightProjection);
style->SetParameter("viewProjection", &viewProjection);
style->SetParameter("diffuse", (const Texture**) &diffuse);
style->SetParameter("world", &cubeWorld);
renderer->Render(cube);
style->SetParameter("diffuse", (const Texture**) &ground);
style->SetParameter("world", &planeWorld);
renderer->Render(plane);
}
{ // render to screen
renderer->SetRenderTarget(0);
renderer->SetViewport(0, 0, 480, 320);
renderer->Clear();
int b = true;
style->SetParameter("processShadow", &b);
//.........这里部分代码省略.........