Konstansbufferek benn
This commit is contained in:
		
							parent
							
								
									989583c029
								
							
						
					
					
						commit
						c836535da6
					
				
							
								
								
									
										21
									
								
								DXWindow.cpp
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								DXWindow.cpp
									
									
									
									
									
								
							@ -1,6 +1,8 @@
 | 
				
			|||||||
#include "DXWindow.h"
 | 
					#include "DXWindow.h"
 | 
				
			||||||
#include "IDrawable.h"
 | 
					#include "IDrawable.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using namespace DirectX;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace eg3d {
 | 
					namespace eg3d {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	DXWindow::DXWindow() : Window(true)
 | 
						DXWindow::DXWindow() : Window(true)
 | 
				
			||||||
@ -286,6 +288,7 @@ namespace eg3d {
 | 
				
			|||||||
		mCommandList->OMSetRenderTargets(1, &getCurrentBackBufferRTVHandle(), true, &getDSVHandle());
 | 
							mCommandList->OMSetRenderTargets(1, &getCurrentBackBufferRTVHandle(), true, &getDSVHandle());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// TODO konstansbuffer bekötése
 | 
							// TODO konstansbuffer bekötése
 | 
				
			||||||
 | 
							mCommandList->SetGraphicsRootConstantBufferView(0, cbResource->GetGPUVirtualAddress());
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		////////// OBJEKTUMOK KIRAJZOLÁSA
 | 
							////////// OBJEKTUMOK KIRAJZOLÁSA
 | 
				
			||||||
		//drawObject();
 | 
							//drawObject();
 | 
				
			||||||
@ -295,8 +298,6 @@ namespace eg3d {
 | 
				
			|||||||
			drawables[i]->draw(mCommandList);
 | 
								drawables[i]->draw(mCommandList);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// TODO drawables kirajzolása
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		//////////
 | 
							//////////
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		mCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(getCurrentBackBuffer(), D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT));
 | 
							mCommandList->ResourceBarrier(1, &CD3DX12_RESOURCE_BARRIER::Transition(getCurrentBackBuffer(), D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT));
 | 
				
			||||||
@ -410,19 +411,29 @@ namespace eg3d {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	void DXWindow::createConstantBuffers()
 | 
						void DXWindow::createConstantBuffers()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		// konstansbuffer létrehozása
 | 
							cbResource = createBuffer_UH(mDevice, calc256AlignedSize(sizeof(constantBuffer)));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void DXWindow::updateConstantBuffers()
 | 
						void DXWindow::updateConstantBuffers()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		// TODO konstansbuffer feltöltése
 | 
							// transzformáció frissítése
 | 
				
			||||||
 | 
							//DirectX::XMStoreFloat4x4(&constantBuffer.transformMatrix, DirectX::XMMatrixScaling(2.0, 1.0, 1.0));
 | 
				
			||||||
 | 
							DirectX::XMStoreFloat4x4(&constantBuffer.transformMatrix, DirectX::XMMatrixRotationZ(XM_PI));
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							bufferMapCopy(cbResource, static_cast<void *>(&constantBuffer), sizeof(constantBuffer));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void DXWindow::createRootSignature()
 | 
						void DXWindow::createRootSignature()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		// TODO root paraméterek megadása
 | 
							// TODO root paraméterek megadása
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		CD3DX12_ROOT_SIGNATURE_DESC rsD(0, nullptr, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT);
 | 
							// root paraméterek létrehozása
 | 
				
			||||||
 | 
							CD3DX12_ROOT_PARAMETER slotParams[1];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// konstansbuffer-TÍPUS beállítása
 | 
				
			||||||
 | 
							slotParams[0].InitAsConstantBufferView(0);
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							CD3DX12_ROOT_SIGNATURE_DESC rsD(1, &slotParams[0], 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ComPtr<ID3DBlob> serializedRS = nullptr, errorBlob = nullptr;
 | 
							ComPtr<ID3DBlob> serializedRS = nullptr, errorBlob = nullptr;
 | 
				
			||||||
		if (FAILED(D3D12SerializeRootSignature(&rsD, D3D_ROOT_SIGNATURE_VERSION_1, serializedRS.GetAddressOf(), errorBlob.GetAddressOf())))
 | 
							if (FAILED(D3D12SerializeRootSignature(&rsD, D3D_ROOT_SIGNATURE_VERSION_1, serializedRS.GetAddressOf(), errorBlob.GetAddressOf())))
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										10
									
								
								DXWindow.h
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								DXWindow.h
									
									
									
									
									
								
							@ -14,6 +14,8 @@
 | 
				
			|||||||
#include "comdef.h"
 | 
					#include "comdef.h"
 | 
				
			||||||
#include "IDrawable.h"
 | 
					#include "IDrawable.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <DirectXMath.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Vertex struktúrája
 | 
					// Vertex struktúrája
 | 
				
			||||||
struct Vertex
 | 
					struct Vertex
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -21,7 +23,11 @@ struct Vertex
 | 
				
			|||||||
	float r, g, b;
 | 
						float r, g, b;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO konstansbuffer típus
 | 
					// konstansbuffer struktúrája
 | 
				
			||||||
 | 
					struct ConstantBuffer
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						DirectX::XMFLOAT4X4 transformMatrix;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace eg3d {
 | 
					namespace eg3d {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -83,6 +89,8 @@ namespace eg3d {
 | 
				
			|||||||
		ComPtr<ID3DBlob> vertexShader, pixelShader; // vertex- és pixel-shader program
 | 
							ComPtr<ID3DBlob> vertexShader, pixelShader; // vertex- és pixel-shader program
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // TODO konstansbuffer példány és DX-objektum
 | 
					        // TODO konstansbuffer példány és DX-objektum
 | 
				
			||||||
 | 
							ComPtr<ID3D12Resource> cbResource; // konstansbuffer DX-objektuma
 | 
				
			||||||
 | 
							ConstantBuffer constantBuffer; // konstansbuffer
 | 
				
			||||||
		// TODO TRANSZFORMÁCIÓS TULAJDONSÁGOK
 | 
							// TODO TRANSZFORMÁCIÓS TULAJDONSÁGOK
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		void initDrawObjects(); // kirajzolandó objektumok inicializálása
 | 
							void initDrawObjects(); // kirajzolandó objektumok inicializálása
 | 
				
			||||||
 | 
				
			|||||||
@ -10,11 +10,16 @@ struct VSOutput // vertex shader kimeneti strukt
 | 
				
			|||||||
    float3 color : COLOR;
 | 
					    float3 color : COLOR;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cbuffer CBuf : register(b0)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    float4x4 transformMatrix;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
VSOutput vs_main(VSInput input)
 | 
					VSOutput vs_main(VSInput input)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    VSOutput output; // vertex shader kimenete
 | 
					    VSOutput output; // vertex shader kimenete
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    output.position_H = float4(input.position_D, 1.0);
 | 
					    output.position_H = mul(transformMatrix, float4(input.position_D, 1.0));
 | 
				
			||||||
    output.color = input.color;
 | 
					    output.color = input.color;
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    return output;
 | 
					    return output;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user