Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
idontknow
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 |
rsDesc.FillMode = D3D11_FILL_SOLID; rsDesc.CullMode = D3D11_CULL_NONE; rsDesc.FrontCounterClockwise = FALSE; rsDesc.DepthBias = 0; rsDesc.DepthBiasClamp = 0.0f; rsDesc.SlopeScaledDepthBias = 0.0f; rsDesc.DepthClipEnable = FALSE; rsDesc.ScissorEnable = FALSE; rsDesc.MultisampleEnable = FALSE; rsDesc.AntialiasedLineEnable = FALSE; |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
void renderer::render_triangle(const vec2f& a, const vec2f& ta, const vec2f& b, const vec2f& tb, const vec2f& c, const vec2f& tc) { vertex_p vertizes[] = {vertex_p(a, ta), vertex_p(b, tb), vertex_p(c, tc)}; memcpy(m_VertexBufferPointer, vertizes, sizeof(vertex_p) * 3); m_VertexBufferPointer += 3; unsigned long indizes[] = {m_NumRendered, m_NumRendered + 1, m_NumRendered + 2}; memcpy(m_IndexBufferPointer, indizes, sizeof(unsigned long) * 3); // Hier ist/war ein Bug -> der IndexBufferPointer muss um 3 inkrementiert werden, komischerweise ändert das nichts am Output.. m_NumRendered++; } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
void renderer::render() { unsigned int stride = sizeof(vertex_p; unsigned int offset = 0; ID3D11Buffer* vertex_buffers[] = {m_VertexBuffer}; context->VSSetShader(m_VertexShader, nullptr, 0U); context->PSSetShader(m_PixelShader, nullptr, 0U); // Set the vertex buffer to active in the input assembler so it can be rendered. context->IASetVertexBuffers(0, 1, vertex_buffers, &stride, &offset); // Set the index buffer to active in the input assembler so it can be rendered. context->IASetIndexBuffer(m_IndexBuffer, DXGI_FORMAT_R32_UINT, 0); // Set the type of primitive that should be rendered from this vertex buffer, in this case triangles. context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); context->IASetInputLayout(m_InputLayout); context->Draw(m_NumRendered * 3, 0); } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
//std::vector<vec2f> m_Points; // In der Liste sind diese Punkte: vec2f a(0.0f, 0.0f), b(10.0f, 0.0f), c(10.0f, 10.0f), d(0.0f, 10.0f); (nacheinander eingefügt) void Polygon::render(renderer& renderObj) { //m_Points.push_back(m_Points[0]); for(unsigned int i = 2; i < m_Points.size(); i++) { vec2f a(m_Points[i]), b(m_Points[i - 1]), c(m_Points[i - 2]); vec2f tex(0.0f, 1.0f); renderObj.render_triangle(a, tex, b, tex, c, tex); } //m_Points.erase(m_Points.begin() + m_Points.size() - 1); } |
HLSL-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
Texture2D shaderTexture; SamplerState SampleType; // Pixel shader input structure struct PS_INPUT { float4 Position : SV_Position; float2 Texture : TEXCOORD0; }; // Pixel shader output structure struct PS_OUTPUT { float4 Color : SV_Target0; }; PS_OUTPUT main( in PS_INPUT In ) { PS_OUTPUT Out; Out.Color = shaderTexture.Sample(SampleType, In.Texture); return Out; } |
HLSL-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
// Vertex shader input structure struct VS_INPUT { float3 Position : POSITION; float2 Texture : TEXCOORD0; }; // Vertex shader output structure struct VS_OUTPUT { float4 Position : SV_Position; float2 Texture : TEXCOORD0; }; VS_OUTPUT main( in VS_INPUT In ) { VS_OUTPUT Out; Out.Position = float4(In.Position.xy, 0.1f, 1.0f); Out.Texture = In.Texture; return Out; } |
Dieser Beitrag wurde bereits 6 mal editiert, zuletzt von »idontknow« (03.02.2013, 19:34)
idontknow
unregistriert
Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von »idontknow« (03.02.2013, 20:24)
idontknow
unregistriert
Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »idontknow« (03.02.2013, 21:20)
Werbeanzeige