MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / CreateScene

Method CreateScene

GTE/Samples/Graphics/WireMesh/WireMeshWindow3.cpp:72–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72bool WireMeshWindow3::CreateScene()
73{
74 std::string vsPath = mEnvironment.GetPath(mEngine->GetShaderName("WireMesh.vs"));
75 std::string psPath = mEnvironment.GetPath(mEngine->GetShaderName("WireMesh.ps"));
76 std::string gsPath = mEnvironment.GetPath(mEngine->GetShaderName("WireMesh.gs"));
77 auto program = mProgramFactory->CreateFromFiles(vsPath, psPath, gsPath);
78 if (!program)
79 {
80 return false;
81 }
82
83 auto parameters = std::make_shared<ConstantBuffer>(3 * sizeof(Vector4<float>), false);
84 auto* data = parameters->Get<Vector4<float>>();
85 data[0] = { 0.0f, 0.0f, 1.0f, 1.0f }; // mesh color
86 data[1] = { 0.0f, 0.0f, 0.0f, 1.0f }; // edge color
87 data[2] = { static_cast<float>(mXSize), static_cast<float>(mYSize), 0.0f, 0.0f };
88 program->GetVertexShader()->Set("WireParameters", parameters);
89 program->GetPixelShader()->Set("WireParameters", parameters);
90 program->GetGeometryShader()->Set("WireParameters", parameters);
91
92 auto cbuffer = std::make_shared<ConstantBuffer>(sizeof(Matrix4x4<float>), true);
93 program->GetVertexShader()->Set("PVWMatrix", cbuffer);
94
95 auto effect = std::make_shared<VisualEffect>(program);
96
97 VertexFormat vformat;
98 vformat.Bind(VASemantic::POSITION, DF_R32G32B32_FLOAT, 0);
99 MeshFactory mf;
100 mf.SetVertexFormat(vformat);
101 mMesh = mf.CreateSphere(16, 16, 1.0f);
102 mMesh->SetEffect(effect);
103
104 mPVWMatrices.Subscribe(mMesh->worldTransform, cbuffer);
105
106 mTrackBall.Attach(mMesh);
107 mTrackBall.Update();
108 return true;
109}
110
111

Callers

nothing calls this directly

Calls 11

GetPathMethod · 0.80
CreateFromFilesMethod · 0.80
SetVertexFormatMethod · 0.80
SetEffectMethod · 0.80
SubscribeMethod · 0.80
AttachMethod · 0.80
GetShaderNameMethod · 0.45
SetMethod · 0.45
BindMethod · 0.45
CreateSphereMethod · 0.45
UpdateMethod · 0.45

Tested by

no test coverage detected