| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 |
Tags
- CTF
- linear regression
- animation
- widget
- 언리얼 엔진
- ability task
- UI
- gas
- MAC
- 게임 개발
- 언리얼엔진
- listen server
- rpc
- C++
- 유니티
- local prediction
- Replication
- unity
- os
- Aegis
- 게임개발
- Unreal Engine
- gameplay tag
- Multiplay
- photon fusion2
- gameplay ability system
- 보안
- stride
- gameplay effect
- attribute
Archives
- Today
- Total
Replicated
삼각형 띄우기 본문

void Game::Init(HWND hand)
{
_hwnd = hand;
_width = GWinSizeX;
_height = GWinSizeY;
CreateDeviceAndSwapChain();
CreateRenterTargetView();
SetViewPort();
CreateGeometry();
CreateVS();
CreateInputLayout();
CreatePS();
}
CreateGeometry : 정점 데이터 -> GPU 버퍼
CreateVS : 버텍스 쉐이더 로드
CreateInputLayout..
D3D11_BUFFER_DESC desc;
ZeroMemory(&desc, sizeof(desc));
desc.Usage = D3D11_USAGE_IMMUTABLE; // GPU Read Only
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
desc.ByteWidth = static_cast<uint32>( sizeof(Vertex) * _vertices.size() );
D3D11_SUBRESOURCE_DATA data;
ZeroMemory(&data, sizeof(data));
data.pSysMem = &_vertices[0];
_device->CreateBuffer(&desc, &data, _vertexBuffer.GetAddressOf());
Usage : IMMUTABLE은 한 번 만들고 안바꿈 -> GPU 리드 온리
pSysMem은 초기 데이터의 출처
void Game::CreateInputLayout()
{
D3D11_INPUT_ELEMENT_DESC layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
};
const int32 count = sizeof(layout) / sizeof(D3D11_INPUT_ELEMENT_DESC);
_device->CreateInputLayout(layout, count, _vsBlob->GetBufferPointer(), _vsBlob->GetBufferSize(), _inputLayout.GetAddressOf());
}
결국 그래봐야 바이트 덩어리라 레이아웃 맞춰줘야 함
void Game::CreateVS()
{
LoadShaderFromFile(L"Default.hlsl", "VS", "vs_5_0", _vsBlob);
HRESULT hr = _device->CreateVertexShader(_vsBlob->GetBufferPointer(), _vsBlob->GetBufferSize(), nullptr, _vertexShader.GetAddressOf());
CHECK(hr);
}
void Game::CreatePS()
{
LoadShaderFromFile(L"Default.hlsl", "PS", "ps_5_0", _psBlob);
HRESULT hr = _device->CreatePixelShader(_psBlob->GetBufferPointer(), _psBlob->GetBufferSize(), nullptr, _pixelShader.GetAddressOf());
CHECK(hr);
}
void Game::LoadShaderFromFile(const wstring& path, const string& name, const string& version, ComPtr<ID3DBlob>& blob)
{
const uint32 compileFlag = D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION;
HRESULT hr = ::D3DCompileFromFile(
path.c_str(),
nullptr,
D3D_COMPILE_STANDARD_FILE_INCLUDE,
name.c_str(),
version.c_str(),
compileFlag,
0,
blob.GetAddressOf(),
nullptr
);
CHECK(hr);
}
ID2DBlob은 그냥 바이트 덩어리고 여기에 쉐이더 바이트 코드가 담김
'DirectX 11' 카테고리의 다른 글
| Constant Buffer (0) | 2026.08.01 |
|---|---|
| 텍스처, UV (0) | 2026.08.01 |
| 장치 초기화 (0) | 2026.08.01 |
| Windows API로 진입점 만들기 (0) | 2025.04.07 |
| 그래픽스 개요 (0) | 2025.04.06 |