added buffer for tiles and player, added +=, -= to math_graphics.h
git-svn-id: svn://ammerhai.com/home/mike/pokemon_repo@4 24008968-59e6-ed4c-a10b-0b2c954b24ab
This commit is contained in:
parent
685fdf3fa9
commit
7a8abc6af9
@ -1,6 +1,5 @@
|
|||||||
struct PixelShaderInput {
|
struct PixelShaderInput {
|
||||||
float4 pos : SV_POSITION;
|
float4 pos : SV_POSITION;
|
||||||
float4 color : COLOR;
|
|
||||||
float4 uvst : COORDINATES;
|
float4 uvst : COORDINATES;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -6,13 +6,11 @@ struct VertexShaderInput {
|
|||||||
|
|
||||||
// Per Instance
|
// Per Instance
|
||||||
float4 pos_size : INSTANCE_POSITION_SIZE;
|
float4 pos_size : INSTANCE_POSITION_SIZE;
|
||||||
float4 left_color : LEFT_COLOR;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VertexShaderOutput {
|
struct VertexShaderOutput {
|
||||||
float4 pos : SV_POSITION;
|
float4 pos : SV_POSITION;
|
||||||
float4 color : COLOR;
|
|
||||||
float4 uvst : COORDINATES;
|
float4 uvst : COORDINATES;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -48,7 +46,6 @@ VertexShaderOutput main(VertexShaderInput input) {
|
|||||||
//output.pos.xy = mul(pos, input.pos.xyz).xy;
|
//output.pos.xy = mul(pos, input.pos.xyz).xy;
|
||||||
output.pos.zw = float2(0, 1);
|
output.pos.zw = float2(0, 1);
|
||||||
|
|
||||||
output.color = input.left_color;
|
|
||||||
output.uvst = input.uvst;
|
output.uvst = input.uvst;
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
|||||||
BIN
assets/std_person.tga
Normal file
BIN
assets/std_person.tga
Normal file
Binary file not shown.
BIN
assets/std_tile.tga
Normal file
BIN
assets/std_tile.tga
Normal file
Binary file not shown.
BIN
bin/pokemon.exe
BIN
bin/pokemon.exe
Binary file not shown.
BIN
bin/pokemon.pdb
BIN
bin/pokemon.pdb
Binary file not shown.
175
src/main.cpp
175
src/main.cpp
@ -27,6 +27,10 @@ typedef int16_t int16;
|
|||||||
typedef int32_t int32;
|
typedef int32_t int32;
|
||||||
typedef int64_t int64;
|
typedef int64_t int64;
|
||||||
|
|
||||||
|
//
|
||||||
|
HRESULT hresult;
|
||||||
|
ID3D11SamplerState* sampler_state;
|
||||||
|
|
||||||
IDXGISwapChain* swap_chain;
|
IDXGISwapChain* swap_chain;
|
||||||
ID3D11Device* device;
|
ID3D11Device* device;
|
||||||
ID3D11DeviceContext* devicecontext;
|
ID3D11DeviceContext* devicecontext;
|
||||||
@ -37,7 +41,8 @@ ID3D11RenderTargetView* render_target_view;
|
|||||||
ID3D11InputLayout* input_layout;
|
ID3D11InputLayout* input_layout;
|
||||||
ID3D11Buffer* vertex_buffer;
|
ID3D11Buffer* vertex_buffer;
|
||||||
ID3D11Buffer* index_buffer;
|
ID3D11Buffer* index_buffer;
|
||||||
ID3D11Buffer* instance_buffer;
|
ID3D11Buffer* tiles_instance_buffer;
|
||||||
|
ID3D11Buffer* player_instance_buffer;
|
||||||
|
|
||||||
ID3DBlob* vertex_shader_code;
|
ID3DBlob* vertex_shader_code;
|
||||||
ID3D11VertexShader* vertex_shader;
|
ID3D11VertexShader* vertex_shader;
|
||||||
@ -46,9 +51,10 @@ ID3DBlob* pixel_shader_code;
|
|||||||
ID3D11PixelShader* pixel_shader;
|
ID3D11PixelShader* pixel_shader;
|
||||||
|
|
||||||
bool Running = true;
|
bool Running = true;
|
||||||
|
//
|
||||||
|
|
||||||
BMP_Texture tex1 = load_tga_file("../assets/strawberry_paintnet.tga");
|
#define view_width 16
|
||||||
//strawberry_paintnet.tga kommt aus paintNet... ich will kein GIMP :O
|
#define view_height 12
|
||||||
|
|
||||||
struct Vertex {
|
struct Vertex {
|
||||||
V4 pos;
|
V4 pos;
|
||||||
@ -69,18 +75,17 @@ uint16 indices[] = {
|
|||||||
|
|
||||||
struct Instance {
|
struct Instance {
|
||||||
V4 pos_size;
|
V4 pos_size;
|
||||||
V4 left_color;
|
|
||||||
V4 right_color;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Instance instances[1] = {
|
Instance tiles_instances[view_width * view_height] = {
|
||||||
{{0.1, 0.1, 0.2, 0.2}, {0, 1, 1, 1}, {1, 0, 1, 1}},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Instance player_instance = { {0.5f, 0.5f, 1.0f / view_width, 1.0f / view_height } };
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool LoadShaders() {
|
bool LoadShaders() {
|
||||||
|
|
||||||
ID3DBlob* error_msgs = 0;
|
ID3DBlob* error_msgs = 0;
|
||||||
@ -90,27 +95,27 @@ bool LoadShaders() {
|
|||||||
log("CompileFromFile has failed");
|
log("CompileFromFile has failed");
|
||||||
if (error_msgs)
|
if (error_msgs)
|
||||||
log_error("%.*s", error_msgs->GetBufferSize(), error_msgs->GetBufferPointer());
|
log_error("%.*s", error_msgs->GetBufferSize(), error_msgs->GetBufferPointer());
|
||||||
return false;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device->CreateVertexShader(vertex_shader_code->GetBufferPointer(), vertex_shader_code->GetBufferSize(), 0, &vertex_shader)) {
|
if (device->CreateVertexShader(vertex_shader_code->GetBufferPointer(), vertex_shader_code->GetBufferSize(), 0, &vertex_shader)) {
|
||||||
log_error("CreateVertexShader has failed");
|
log_error("CreateVertexShader has failed");
|
||||||
return false;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error_code = D3DCompileFromFile(L"../Assets/Shader/basic_pixel_shader.hlsl", 0, 0, "main", "ps_5_0", D3DCOMPILE_DEBUG | D3DCOMPILE_WARNINGS_ARE_ERRORS | D3DCOMPILE_OPTIMIZATION_LEVEL0, 0, &pixel_shader_code, &error_msgs)) {
|
if (error_code = D3DCompileFromFile(L"../Assets/Shader/basic_pixel_shader.hlsl", 0, 0, "main", "ps_5_0", D3DCOMPILE_DEBUG | D3DCOMPILE_WARNINGS_ARE_ERRORS | D3DCOMPILE_OPTIMIZATION_LEVEL0, 0, &pixel_shader_code, &error_msgs)) {
|
||||||
log("CompileFromFile has failed");
|
log("CompileFromFile has failed");
|
||||||
if (error_msgs)
|
if (error_msgs)
|
||||||
log_error("%.*s", error_msgs->GetBufferSize(), error_msgs->GetBufferPointer());
|
log_error("%.*s", error_msgs->GetBufferSize(), error_msgs->GetBufferPointer());
|
||||||
return false;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device->CreatePixelShader(pixel_shader_code->GetBufferPointer(), pixel_shader_code->GetBufferSize(), 0, &pixel_shader)) {
|
if (device->CreatePixelShader(pixel_shader_code->GetBufferPointer(), pixel_shader_code->GetBufferSize(), 0, &pixel_shader)) {
|
||||||
log_error("CreatePixelShader has failed");
|
log_error("CreatePixelShader has failed");
|
||||||
return false;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT WindowMsgs(HWND Window, UINT Message, WPARAM wParam, LPARAM lParam) {
|
LRESULT WindowMsgs(HWND Window, UINT Message, WPARAM wParam, LPARAM lParam) {
|
||||||
@ -272,7 +277,7 @@ bool init_directx11(HWND Window) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!LoadShaders()) {
|
if (LoadShaders()) {
|
||||||
log_error("LoadShaders has failed");
|
log_error("LoadShaders has failed");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -282,8 +287,6 @@ bool init_directx11(HWND Window) {
|
|||||||
{ "VERTEX_POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
{ "VERTEX_POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
{ "COORDINATES", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
{ "COORDINATES", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 16, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
{ "INSTANCE_POSITION_SIZE", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
|
{ "INSTANCE_POSITION_SIZE", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
|
||||||
{ "LEFT_COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 16, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
|
|
||||||
{ "RIGHT_COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 32, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (device->CreateInputLayout(input_element_desc, sizeof(input_element_desc) / sizeof(*input_element_desc), vertex_shader_code->GetBufferPointer(), vertex_shader_code->GetBufferSize(), &input_layout)) {
|
if (device->CreateInputLayout(input_element_desc, sizeof(input_element_desc) / sizeof(*input_element_desc), vertex_shader_code->GetBufferPointer(), vertex_shader_code->GetBufferSize(), &input_layout)) {
|
||||||
@ -309,25 +312,8 @@ bool init_directx11(HWND Window) {
|
|||||||
|
|
||||||
vertex_buffer = CreateBuffer("vertex_buffer", sizeof(vertices), vertices, D3D11_BIND_VERTEX_BUFFER);
|
vertex_buffer = CreateBuffer("vertex_buffer", sizeof(vertices), vertices, D3D11_BIND_VERTEX_BUFFER);
|
||||||
index_buffer = CreateBuffer("index_buffer", sizeof(indices), indices, D3D11_BIND_INDEX_BUFFER);
|
index_buffer = CreateBuffer("index_buffer", sizeof(indices), indices, D3D11_BIND_INDEX_BUFFER);
|
||||||
instance_buffer = CreateBuffer("instance_buffer", sizeof(instances), instances, D3D11_BIND_VERTEX_BUFFER, D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE);
|
tiles_instance_buffer = CreateBuffer("tiles_instance_buffer", sizeof(tiles_instances), tiles_instances, D3D11_BIND_VERTEX_BUFFER, D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE);
|
||||||
|
player_instance_buffer = CreateBuffer("player_instance_buffer", sizeof(player_instance), &player_instance, D3D11_BIND_VERTEX_BUFFER, D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
HRESULT hresult;
|
|
||||||
|
|
||||||
CoInitializeEx(0, COINIT_MULTITHREADED);
|
|
||||||
|
|
||||||
auto Window = (HWND)create_window(WindowMsgs);
|
|
||||||
if (!Window) {
|
|
||||||
|
|
||||||
printf("CreateWindow failed!\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (init_directx11(Window))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
D3D11_SAMPLER_DESC sampler_desc = {
|
D3D11_SAMPLER_DESC sampler_desc = {
|
||||||
.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT,
|
.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT,
|
||||||
@ -342,16 +328,44 @@ int main() {
|
|||||||
.MaxLOD = 0,
|
.MaxLOD = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
ID3D11SamplerState* sampler_state;
|
|
||||||
|
|
||||||
if ((hresult = device->CreateSamplerState(&sampler_desc, &sampler_state)) != S_OK) {
|
if ((hresult = device->CreateSamplerState(&sampler_desc, &sampler_state)) != S_OK) {
|
||||||
log_error("CreateSamplerState has failed. %ld", hresult);
|
log_error("CreateSamplerState has failed. %ld", hresult);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
D3D11_BLEND_DESC blend_desc = {
|
||||||
|
.AlphaToCoverageEnable = FALSE,
|
||||||
|
.IndependentBlendEnable = FALSE,
|
||||||
|
.RenderTarget = {
|
||||||
|
{
|
||||||
|
.BlendEnable = TRUE,
|
||||||
|
.SrcBlend = D3D11_BLEND_SRC_ALPHA,
|
||||||
|
.DestBlend = D3D11_BLEND_INV_SRC_ALPHA,
|
||||||
|
.BlendOp = D3D11_BLEND_OP_ADD,
|
||||||
|
.SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA,
|
||||||
|
.DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA,
|
||||||
|
.BlendOpAlpha = D3D11_BLEND_OP_ADD,
|
||||||
|
.RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
ID3D11BlendState *blend_state;
|
||||||
|
if ((hresult = device->CreateBlendState(&blend_desc, &blend_state) != S_OK)) {
|
||||||
|
log_error("CreateBlendState has failed. %ld", hresult);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
devicecontext->OMSetBlendState(blend_state, 0, 0xffffffff);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ID3D11ShaderResourceView* create_shader_texture(char* bmp_texture_path) {
|
||||||
|
BMP_Texture bmp_texture = load_tga_file(bmp_texture_path);
|
||||||
|
|
||||||
D3D11_TEXTURE2D_DESC texture_desc = {
|
D3D11_TEXTURE2D_DESC texture_desc = {
|
||||||
.Width = (UINT)tex1.bmp_width,
|
.Width = (UINT)bmp_texture.bmp_width,
|
||||||
.Height = (UINT)tex1.bmp_height,
|
.Height = (UINT)bmp_texture.bmp_height,
|
||||||
.MipLevels = 1,
|
.MipLevels = 1,
|
||||||
.ArraySize = 1,
|
.ArraySize = 1,
|
||||||
.Format = DXGI_FORMAT_B8G8R8A8_UNORM,
|
.Format = DXGI_FORMAT_B8G8R8A8_UNORM,
|
||||||
@ -363,21 +377,58 @@ int main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
D3D11_SUBRESOURCE_DATA initial_data = {
|
D3D11_SUBRESOURCE_DATA initial_data = {
|
||||||
.pSysMem = tex1.pixel,
|
.pSysMem = bmp_texture.pixel,
|
||||||
.SysMemPitch = (UINT)tex1.bmp_width * 4,
|
.SysMemPitch = (UINT)bmp_texture.bmp_width * 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
ID3D11Texture2D* texture;
|
ID3D11Texture2D* texture;
|
||||||
|
|
||||||
if ((hresult = device->CreateTexture2D(&texture_desc, &initial_data, &texture)) != S_OK) {
|
if ((hresult = device->CreateTexture2D(&texture_desc, &initial_data, &texture)) != S_OK) {
|
||||||
log_error("CreateTexture2D has failed. %ld", hresult);
|
log_error("CreateTexture2D has failed. %ld", hresult);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
DX11SetDebugName(texture, { strlen(bmp_texture_path), bmp_texture_path });
|
||||||
|
|
||||||
|
ID3D11ShaderResourceView* resource_view;
|
||||||
|
if ((hresult = device->CreateShaderResourceView(texture, 0, &resource_view)) != S_OK) {
|
||||||
|
log_error("CreateShaderResourceView failed. %ld", hresult);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
DX11SetDebugName(resource_view, {strlen(bmp_texture_path), bmp_texture_path});
|
||||||
|
|
||||||
|
free(bmp_texture.pixel);
|
||||||
|
return resource_view;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
CoInitializeEx(0, COINIT_MULTITHREADED);
|
||||||
|
|
||||||
|
auto Window = (HWND)create_window(WindowMsgs);
|
||||||
|
if (!Window) {
|
||||||
|
|
||||||
|
printf("CreateWindow failed!\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D11ShaderResourceView* resource_view;
|
for (int y = 0; y < view_height; y++) {
|
||||||
|
for (int x = 0; x < view_width; x++) {
|
||||||
|
tiles_instances[x + y * view_width].pos_size.zw = { 1.0f / view_width, 1.0f / view_height };
|
||||||
|
tiles_instances[x + y * view_width].pos_size.xy = { (float)x / view_width, (float)y / (float)view_height };
|
||||||
|
tiles_instances[x + y * view_width].pos_size.xy += tiles_instances[x + y * view_width].pos_size.zw * 0.5f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((hresult = device->CreateShaderResourceView(texture, 0, &resource_view)) != S_OK) {
|
if (init_directx11(Window))
|
||||||
log_error("CreateShaderResourceView failed. %ld", hresult);
|
return 1;
|
||||||
|
|
||||||
|
ID3D11ShaderResourceView* tile_texture = 0;
|
||||||
|
if (!(tile_texture = create_shader_texture("../assets/std_tile.tga"))) {
|
||||||
|
log_error("CreateShaderTexture has failed.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ID3D11ShaderResourceView* player_texture = 0;
|
||||||
|
if (!(player_texture = create_shader_texture("../assets/strawberry_paintnet.tga"))) {
|
||||||
|
log_error("CreateShaderTexture has failed.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,19 +446,9 @@ int main() {
|
|||||||
V4 clear_color = { 0, 0, 0, 1 };
|
V4 clear_color = { 0, 0, 0, 1 };
|
||||||
devicecontext->ClearRenderTargetView(render_target_view, clear_color.E);
|
devicecontext->ClearRenderTargetView(render_target_view, clear_color.E);
|
||||||
|
|
||||||
//Quad rendern
|
|
||||||
D3D11_MAPPED_SUBRESOURCE mapped_subresource;
|
|
||||||
devicecontext->Map(instance_buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_subresource);
|
|
||||||
memcpy(mapped_subresource.pData, instances, sizeof(instances));
|
|
||||||
devicecontext->Unmap(instance_buffer, 0);
|
|
||||||
|
|
||||||
devicecontext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
devicecontext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||||
devicecontext->IASetInputLayout(input_layout);
|
devicecontext->IASetInputLayout(input_layout);
|
||||||
|
|
||||||
ID3D11Buffer* input_buffers[] = {
|
|
||||||
vertex_buffer,
|
|
||||||
instance_buffer,
|
|
||||||
};
|
|
||||||
|
|
||||||
UINT input_strides[] = {
|
UINT input_strides[] = {
|
||||||
sizeof(Vertex),
|
sizeof(Vertex),
|
||||||
@ -419,7 +460,13 @@ int main() {
|
|||||||
0,
|
0,
|
||||||
};
|
};
|
||||||
|
|
||||||
devicecontext->IASetVertexBuffers(0, sizeof(input_buffers) / sizeof(*input_buffers), input_buffers, input_strides, input_offsets);
|
//leeres Feld
|
||||||
|
ID3D11Buffer* tiles_input_buffers[] = {
|
||||||
|
vertex_buffer,
|
||||||
|
tiles_instance_buffer,
|
||||||
|
};
|
||||||
|
|
||||||
|
devicecontext->IASetVertexBuffers(0, sizeof(tiles_input_buffers) / sizeof(*tiles_input_buffers), tiles_input_buffers, input_strides, input_offsets);
|
||||||
devicecontext->IASetIndexBuffer(index_buffer, DXGI_FORMAT_R16_UINT, 0);
|
devicecontext->IASetIndexBuffer(index_buffer, DXGI_FORMAT_R16_UINT, 0);
|
||||||
|
|
||||||
devicecontext->IASetInputLayout(input_layout);
|
devicecontext->IASetInputLayout(input_layout);
|
||||||
@ -427,12 +474,22 @@ int main() {
|
|||||||
devicecontext->PSSetShader(pixel_shader, 0, 0);
|
devicecontext->PSSetShader(pixel_shader, 0, 0);
|
||||||
|
|
||||||
devicecontext->PSSetSamplers(0, 1, &sampler_state);
|
devicecontext->PSSetSamplers(0, 1, &sampler_state);
|
||||||
devicecontext->PSSetShaderResources(0, 1, &resource_view);
|
|
||||||
|
|
||||||
|
devicecontext->PSSetShaderResources(0, 1, &tile_texture);
|
||||||
|
devicecontext->DrawIndexedInstanced(6, view_width * view_height, 0, 0, 0);
|
||||||
|
|
||||||
|
|
||||||
|
//Spieler Feld
|
||||||
|
ID3D11Buffer* player_input_buffers[] = {
|
||||||
|
vertex_buffer,
|
||||||
|
player_instance_buffer,
|
||||||
|
};
|
||||||
|
|
||||||
|
devicecontext->IASetVertexBuffers(0, sizeof(player_input_buffers) / sizeof(*player_input_buffers), player_input_buffers, input_strides, input_offsets);
|
||||||
|
|
||||||
|
devicecontext->PSSetShaderResources(0, 1, &player_texture);
|
||||||
devicecontext->DrawIndexedInstanced(6, 1, 0, 0, 0);
|
devicecontext->DrawIndexedInstanced(6, 1, 0, 0, 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
swap_chain->Present(0, 0);
|
swap_chain->Present(0, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -111,6 +111,11 @@ inline V2 operator +(V2 a, V2 b) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Vektor Addition
|
||||||
|
inline V2 operator +=(V2& a, V2 b) {
|
||||||
|
return a = a + b;
|
||||||
|
}
|
||||||
|
|
||||||
//Subtraktion 2er 2-dim Vektoren
|
//Subtraktion 2er 2-dim Vektoren
|
||||||
inline V2 operator -(V2 a, V2 b) {
|
inline V2 operator -(V2 a, V2 b) {
|
||||||
return {
|
return {
|
||||||
@ -119,6 +124,11 @@ inline V2 operator -(V2 a, V2 b) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Vektor Subtraktion
|
||||||
|
inline V2 operator -=(V2& a, V2 b) {
|
||||||
|
return a = a - b;
|
||||||
|
}
|
||||||
|
|
||||||
//Skalarmultiplikation -> erst Skalar, dann Vektor
|
//Skalarmultiplikation -> erst Skalar, dann Vektor
|
||||||
inline V2 operator *(float a, V2 b) {
|
inline V2 operator *(float a, V2 b) {
|
||||||
return {
|
return {
|
||||||
@ -153,6 +163,7 @@ inline V2 operator /(V2 a, float b) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//Skalarprodukt
|
//Skalarprodukt
|
||||||
inline float dot(V2 a, V2 b) {
|
inline float dot(V2 a, V2 b) {
|
||||||
return a.x * b.x + a.y * b.y;
|
return a.x * b.x + a.y * b.y;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user