Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Void Testbed::Update()
- {
- Graphics::Manager* graphicsManager = Graphics::Manager::Singleton;
- Resource::Manager* resourceManager = Resource::Manager::Singleton;
- // These too (no pun intended)
- Graphics::Device::Context& deviceContext = graphicsManager->Context;
- Graphics::Window& window = graphicsManager->Window;
- // Bind the layout
- auto layout = resourceManager->GetLayout("Layout/FullTangent3D");
- layout->Bind();
- // Bind the shaders
- auto shader = resourceManager->GetShader("FullTangent3D.vso");
- shader->BindVS();
- shader = resourceManager->GetShader("ColorPS.pso");
- shader->BindPS();
- Float time = mTimer.Elapsed(Timer::Seconds);
- // Generate the transforms and constant buffer data
- Aligned Float4x4 world = To4x4(RotationZ(time)); //To4x4(RotationZ(fmod(ttime * 1.0f, 1.0f) * Pi * 2.0f));
- SSE::Float4x4 worldMatrix = SSE::Load(world); //Matrix::RotationZ((fmod(ttime * 1.0f, 1.0f) * Pi * 2.0f));
- //SSE::Float4x4 viewMatrix = SSE::LookAt(SSE::Load(-5.0f * cosf(time), -5.0f * sinf(time), 3.0f), SSE::Load(0.0f, 0.0f, 0.0f));
- SSE::Float4x4 viewMatrix = SSE::LookAt(SSE::Load(-3.0f, -3.0f, 3.0f), SSE::Load(0.0f, 0.0f, 0.0f));
- SSE::Float4x4 projectionMatrix = SSE::PerspectiveFovLH(pi / 4.0f, (Float)window.Width / window.Height, 0.01f, 1000.0f); //SSE::Load(window.ProjectionMatrix);
- // -- //
- Transforms buffer;
- buffer.WorldMatrix = SSE::Store(SSE::Transpose(worldMatrix));
- buffer.ViewProjectionMatrix = SSE::Store(SSE::MultiplyTranspose(viewMatrix, projectionMatrix));
- buffer.WorldViewProjectionMatrix = SSE::Store(SSE::MultiplyTranspose(SSE::Multiply(worldMatrix, viewMatrix), projectionMatrix));
- //buffer.WorldMatrix = Transpose(world);
- //buffer.ViewProjectionMatrix = Transpose(Multiply(view, projection));
- //buffer.WorldViewProjectionMatrix = Transpose(Multiply(Multiply(world, view), projection));
- mBuffer.Update(&buffer);
- // -- //
- Colors colors;
- colors.ColorPrimary = Float3(0.9f, 0.9f, 0.9f);
- colors.ColorSecondary = Float3(0.9f, 0.7f, 0.1f);
- colors.ColorOptional = Float3(0.9f, 0.1f, 0.1f);
- mColors.Update(&colors);
- // -- //
- PointLight light;
- light.Position = Float3(30.0f, 0.0f, 40.0f);
- light.Radius = 3.0f;
- light.Color = Float3(1.0f, 1.0f, 1.0f);
- light.Power = 100;
- mLight.Update(&light);
- // Bind the constant buffers
- Resource::Shader::SetBufferVS(mBuffer, 0);
- Resource::Shader::SetBufferPS(mColors, 0);
- Resource::Shader::SetBufferPS(mLight, 1);
- // Render the model
- // Get the model header
- auto lookupmodel = resourceManager->Resources.find(mModel.Handle);
- if(lookupmodel == resourceManager->Resources.end()) { Error("buh"); }
- // -- //
- auto model = (Model*)lookupmodel->second;
- // Get the mesh
- auto lookupmesh = resourceManager->Resources.find(model->Presets[mModel.Preset].Meshes[0].Handle); // lol
- if(lookupmesh == resourceManager->Resources.end()) { Error("buh"); }
- // -- //
- auto mesh = (Mesh*)lookupmesh->second;
- // Get the vertex and index buffers
- auto lookupvbuffer = resourceManager->Resources.find(mesh->VertexBufferID.Handle);
- auto lookupibuffer = resourceManager->Resources.find(mesh->IndexBufferID.Handle);
- if(lookupvbuffer == resourceManager->Resources.end()) { Error("buh"); }
- if(lookupibuffer == resourceManager->Resources.end()) { Error("buh"); }
- // -- //
- auto vbuffer = (Buffer*)lookupvbuffer->second;
- auto ibuffer = (Buffer*)lookupibuffer->second;
- // Bind the vbuffer and ibuffer
- // Set vertex buffer stride and offset.
- UInt stride = sizeof(Mesh::Vertex); // vbuffer->Size / vbuffer->Groups[0].Count;
- UInt offset = 0;
- // Set the vertex buffer to active in the input assembler so it can be rendered
- deviceContext->IASetVertexBuffers(0, 1, &vbuffer->Handle, &stride, &offset);
- // Set the index buffer to active in the input assembler so it can be rendered
- deviceContext->IASetIndexBuffer(ibuffer->Handle, DXGI_FORMAT_R16_UINT, 0);
- // Set the type of primitive that should be rendered from this vertex buffer, in this case, triangles
- deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
- // Render the mesh
- deviceContext->DrawIndexed(ibuffer->Groups[0].Count * 3, 0, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement