//---------------------------------------------------------------------------- void PerformanceAMDWindow::CreateScene() { struct Vertex { Vector3<float> position; Vector2<float> tcoord; }; VertexFormat vformat; vformat.Bind(VA_POSITION, DF_R32G32B32_FLOAT, 0); vformat.Bind(VA_TEXCOORD, DF_R32G32_FLOAT, 0); unsigned int const numTriangles = 1024; unsigned int const numVertices = 3 * numTriangles; std::shared_ptr<VertexBuffer> vbuffer(new VertexBuffer(vformat, numVertices)); // Randomly generate positions and texture coordinates. std::mt19937 mte; std::uniform_real_distribution<float> unirnd(0.0f, 1.0f); std::uniform_real_distribution<float> symrnd(-1.0f, 1.0f); Vertex* vertex = vbuffer->Get<Vertex>(); for (unsigned int i = 0; i < numVertices; ++i) { for (int j = 0; j < 3; ++j) { vertex[i].position[j] = symrnd(mte); } for (int j = 0; j < 2; ++j) { vertex[i].tcoord[j] = unirnd(mte); } } // The vertices are not indexed. Each consecutive triple is a triangle. std::shared_ptr<IndexBuffer> ibuffer(new IndexBuffer(IP_TRIMESH, numTriangles)); // Use a standard texture effect. std::shared_ptr<Texture2Effect> effect(new Texture2Effect( mProgramFactory, mBlurredTexture, SamplerState::MIN_L_MAG_L_MIP_P, SamplerState::CLAMP, SamplerState::CLAMP)); mPVWMatrix = effect->GetPVWMatrixConstant(); mTriangles.reset(new Visual(vbuffer, ibuffer, effect)); SubscribeCW(mTriangles, mPVWMatrix); EnableObjectMotion(); }
//---------------------------------------------------------------------------- PlaneMeshIntersectionWindow::PlaneMeshIntersectionWindow(Parameters& parameters) : Window(parameters), mTextColor(0.0f, 0.0f, 0.0f, 1.0f) { if (!SetEnvironment() || !CreateScene()) { parameters.created = false; return; } mCamera.SetFrustum(60.0f, GetAspectRatio(), 0.1f, 100.0f); Vector4<float> camPosition(0.0f, 0.0f, -2.5f, 1.0f); Vector4<float> camDVector(0.0f, 0.0f, 1.0f, 0.0f); Vector4<float> camUVector(0.0f, 1.0f, 0.0f, 0.0f); Vector4<float> camRVector = Cross(camDVector, camUVector); mCamera.SetFrame(camPosition, camDVector, camUVector, camRVector); mPSTarget.reset(new DrawTarget(2, DF_R32G32B32A32_FLOAT, mXSize, mYSize, true, false, DF_D24_UNORM_S8_UINT, false)); mPSColor = mPSTarget->GetRTTexture(0); mPSPlaneConstant = mPSTarget->GetRTTexture(1); mScreen.reset(new Texture2(DF_R32G32B32A32_FLOAT, mXSize, mYSize)); mScreen->SetUsage(Resource::SHADER_OUTPUT); mScreen->SetCopyType(Resource::COPY_STAGING_TO_CPU); mOverlay.reset(new OverlayEffect(mXSize, mYSize, mXSize, mYSize, SamplerState::MIN_P_MAG_P_MIP_P, SamplerState::CLAMP, SamplerState::CLAMP, true)); mOverlay->SetTexture(mScreen); mEngine->SetClearColor(Vector4<float>(1.0f, 1.0f, 1.0f, std::numeric_limits<float>::max())); mDrawIntersections->Set("color", mPSColor); mDrawIntersections->Set("planeConstant", mPSPlaneConstant); mDrawIntersections->Set("output", mScreen); EnableCameraMotion(0.01f, 0.001f, 2.0f, 2.0f); EnableObjectMotion(); }
//---------------------------------------------------------------------------- StructuredBuffersWindow::StructuredBuffersWindow(Parameters& parameters) : Window(parameters), mTextColor(0.0f, 0.0f, 0.0f, 1.0f) { if (!SetEnvironment() || !CreateScene()) { parameters.created = false; return; } mCamera.SetFrustum(60.0f, GetAspectRatio(), 0.1f, 100.0f); Vector4<float> camPosition(0.0f, 0.0f, 1.25f, 1.0f); Vector4<float> camDVector(0.0f, 0.0f, -1.0f, 0.0f); Vector4<float> camUVector(0.0f, 1.0f, 0.0f, 0.0f); Vector4<float> camRVector = Cross(camDVector, camUVector); mCamera.SetFrame(camPosition, camDVector, camUVector, camRVector); EnableCameraMotion(0.001f, 0.001f, 2.0f, 2.0f); EnableObjectMotion(); UpdateCW(); }