[DirectX11] 006~007 사각형 띄우기
목차
Vertex Buffer 세팅
디바이스 구조 기초

두르기 순서
왼손 좌표계의 경우 시계 방향으로 감긴다. 반면에 오른손 좌표계의 경우 반시계 방향으로 감긴다.
DX9 - 왼손 좌표계
Unreal, Unity - 왼손 좌표계
DX10, 11, 12, GL - 오른손 좌표계이지만 기존의 컨벤션을 유지하기 위해 왼손 좌표계 방식으로 코팅을 한다.

사각형 출력하기
07_Rect.fx
더보기
struct VertexInput { float4 Position : Position; }; struct VertexOutput { float4 Position : SV_Position; }; VertexOutput VS(VertexInput input) { VertexOutput output; output.Position = input.Position; return output; } float4 PS_R(VertexOutput input) : SV_Target { return float4(1, 0, 0, 1); } RasterizerState FillMode_Wireframe { FillMode = Wireframe; }; technique11 T0 { pass P0 { SetVertexShader(CompileShader(vs_5_0, VS())); SetPixelShader(CompileShader(ps_5_0, PS_R())); } pass P1 { SetRasterizerState(FillMode_Wireframe); SetVertexShader(CompileShader(vs_5_0, VS())); SetPixelShader(CompileShader(ps_5_0, PS_R())); } }
RectDemo.h
더보기
#pragma once #include "Systems/IExecute.h" class RectDemo : public IExecute { public: virtual void Initialize() override; virtual void Ready() override {} virtual void Destroy() override; virtual void Update() override; virtual void PreRender() override {} virtual void Render() override; virtual void PostRender() override {} virtual void ResizeScreen() override {} private: Shader* shader; Vertex vertices[6]; ID3D11Buffer* vertexBuffer; };
RectDemo.cpp
더보기
#include "stdafx.h" #include "RectDemo.h" void RectDemo::Initialize() { shader = new Shader(L"07_Rect.fx"); vertices[0].Position = Vector3(+0.0f, +0.0f, 0.0f); vertices[1].Position = Vector3(+0.0f, +0.5f, 0.0f); vertices[2].Position = Vector3(+0.5f, +0.0f, 0.0f); vertices[3].Position = Vector3(+0.5f, +0.0f, 0.0f); vertices[4].Position = Vector3(+0.0f, +0.5f, 0.0f); vertices[5].Position = Vector3(+0.5f, +0.5f, 0.0f); D3D11_BUFFER_DESC desc; ZeroMemory(&desc, sizeof(D3D11_BUFFER_DESC)); desc.ByteWidth = sizeof(Vertex) * 6; desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; D3D11_SUBRESOURCE_DATA subResource = { 0 }; subResource.pSysMem = vertices; Check(D3D::GetDevice()->CreateBuffer(&desc, &subResource, &vertexBuffer)); } void RectDemo::Destroy() { SafeDelete(shader); SafeRelease(vertexBuffer); } void RectDemo::Update() { } void RectDemo::Render() { UINT stride = sizeof(Vertex); UINT offset = 0; D3D::GetDC()->IASetVertexBuffers(0, 1, &vertexBuffer, &stride, &offset); D3D::GetDC()->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); shader->Draw(0, 1, 6); }
실행화면

'⭐ DirectX > DirectX11 3D' 카테고리의 다른 글
[DirectX11] 011 Index (0) | 2023.01.10 |
---|---|
[DirectX11] 010 World (0) | 2023.01.09 |
[DirectX11] 009 World Matrix (0) | 2023.01.08 |
[DirectX11] 008 User Interface (1) | 2023.01.07 |
[DirectX11] 001~005 DirectX11 기초, NDC 좌표계 (0) | 2023.01.04 |
댓글
이 글 공유하기
다른 글
-
[DirectX11] 010 World
[DirectX11] 010 World
2023.01.09목차 World World에 3개의 사각형 출력 후 크기 조절하기 및 위치 이동하기 World.fx 코드 10_World.fx 더보기 matrix World; matrix View; matrix Projection; uint Index; struct VertexInput { float4 Position : Position; }; struct VertexOutput { float4 Position : SV_Position; }; VertexOutput VS(VertexInput input) { VertexOutput output; output.Position = mul(input.Position, World); output.Position = mul(output.Position, View); output…. -
[DirectX11] 009 World Matrix
[DirectX11] 009 World Matrix
2023.01.08목차 World Matrix View Projection 행렬 4x4 행렬Identity1 0 0 00 1 0 00 0 1 00 0 0 1 World.fx 코드 08_World.fx더보기matrix World;matrix View;matrix Projection;struct VertexInput{ float4 Position : Position;};struct VertexOutput{ float4 Position : SV_Position;};float4 VS(VertexInput input) : SV_Position{ // float4의 위치(=input.Position)에 W V P를 곱하여 output.Position 반환 VertexOutput outpu… -
[DirectX11] 008 User Interface
[DirectX11] 008 User Interface
2023.01.07목차 User Interface 파이프라인 Vertex -> IA -> VS -> RS -> PS -> Pixel IA (Input Assembler)스테이지를 이용해 렌더링 데이터 세팅VS(Vertex Shader)W, V, P. 정점의 위치 변환. NDC 공간의 사용.RS(Rasterization Shader)정점을 픽셀로 바꿔준다. 픽셀로 채워주는 과정PS(Pixel Shader)한점 한점을 어떻게 처리할 것인가? 픽셀 하나하나를 처리하는 과정. 색을 결정하는 과정에 쓰인다. User Interface UserInterfaceDemo.h더보기#pragma once#include "Systems/IExecute.h"class UserInterfaceDemo : public IExe… -
[DirectX11] 001~005 DirectX11 기초, NDC 좌표계
[DirectX11] 001~005 DirectX11 기초, NDC 좌표계
2023.01.04목차 DirectX11 기초 파이프라인 Vertex(정점) -> IA -> VS -> RS -> PS -> Pixel IA(Input Assembler)스테이지를 이용해 렌더링 데이터 세팅VS(Vertex Shader)정점의 위치 변환. NDC 공간의 사용.RS(Rasterization Shader)정점을 픽셀로 바꿔준다. 픽셀로 채워주는 과정PS(Pixel Shader)한점 한점을 어떻게 처리할 것인가? 픽셀 하나하나를 처리하는 과정. 색을 결정하는 과정에 쓰인다. NDC(Nomalized Device Coordinates) 좌표계 NDC(Nomalized Device Coordinates) 좌표계란?3D 물체가 Projection(=투영 변환)을 거쳐 2D 공간에 변환되면서 가지게되는…
댓글을 사용할 수 없습니다.