switch front faces to be CCW instead of CW

This commit is contained in:
Sven Balzer 2025-09-25 06:01:16 +02:00
parent ec34b2df61
commit 8633cff3cb
3 changed files with 23 additions and 23 deletions

View File

@ -113,9 +113,9 @@ struct Vertex {
static Vertex vertices[] = {
{{ -0.5f, 0.5f }},
{{ 0.5f, 0.5f }},
{{ 0.5f, -0.5f }},
{{ -0.5f, -0.5f }},
{{ 0.5f, -0.5f }},
{{ 0.5f, 0.5f }},
};
static Uint16 indices[] = {
@ -127,27 +127,27 @@ static Uint16 indices[] = {
static Vertex grid_vertices[] = {
// LEFT
{{ -0.5f, 0.5f }},
{{ -0.5f + grid_line_size, 0.5f }},
{{ -0.5f + grid_line_size, -0.5f + grid_line_size }},
{{ -0.5f, -0.5f + grid_line_size }},
{{ -0.5f + grid_line_size, -0.5f + grid_line_size }},
{{ -0.5f + grid_line_size, 0.5f }},
// TOP
{{ -0.5f + grid_line_size, 0.5f }},
{{ 0.5f, 0.5f }},
{{ 0.5f, 0.5f - grid_line_size }},
{{ -0.5f + grid_line_size, 0.5f - grid_line_size }},
{{ 0.5f, 0.5f - grid_line_size }},
{{ 0.5f, 0.5f }},
// RIGHT
{{ 0.5f - grid_line_size, 0.5f - grid_line_size }},
{{ 0.5f, 0.5f - grid_line_size }},
{{ 0.5f, -0.5f }},
{{ 0.5f - grid_line_size, -0.5f }},
{{ 0.5f, -0.5f }},
{{ 0.5f, 0.5f - grid_line_size }},
// BOTTOM
{{ -0.5f, -0.5f + grid_line_size }},
{{ 0.5f - grid_line_size, -0.5f + grid_line_size }},
{{ 0.5f - grid_line_size, -0.5f }},
{{ -0.5f, -0.5f }},
{{ 0.5f - grid_line_size, -0.5f }},
{{ 0.5f - grid_line_size, -0.5f + grid_line_size }},
};
static Uint16 grid_indices[] = {
@ -805,7 +805,7 @@ static bool recreate_graphics_pipelines() {
.primitive = {
.topology = WGPUPrimitiveTopology_TriangleList,
.stripIndexFormat = WGPUIndexFormat_Undefined,
.frontFace = WGPUFrontFace_CW,
.frontFace = WGPUFrontFace_CCW,
.cullMode = WGPUCullMode_Back,
.unclippedDepth = false,
},
@ -958,7 +958,7 @@ static bool recreate_graphics_pipelines() {
.primitive = {
.topology = WGPUPrimitiveTopology_TriangleList,
.stripIndexFormat = WGPUIndexFormat_Undefined,
.frontFace = WGPUFrontFace_CW,
.frontFace = WGPUFrontFace_CCW,
.cullMode = WGPUCullMode_Back,
.unclippedDepth = false,
},
@ -1051,7 +1051,7 @@ static bool recreate_graphics_pipelines() {
.primitive = {
.topology = WGPUPrimitiveTopology_TriangleList,
.stripIndexFormat = WGPUIndexFormat_Undefined,
.frontFace = WGPUFrontFace_CW,
.frontFace = WGPUFrontFace_CCW,
.cullMode = WGPUCullMode_Back,
.unclippedDepth = false,
},

View File

@ -29,9 +29,9 @@ struct FragmentShaderOutput {
switch (input.vertex_index) {
case 0: { output.uv = input.uv0uv1.xy; }
case 1: { output.uv = input.uv0uv1.zw; }
case 1: { output.uv = input.uv2uv3.zw; }
case 2: { output.uv = input.uv2uv3.xy; }
case 3: { output.uv = input.uv2uv3.zw; }
case 3: { output.uv = input.uv0uv1.zw; }
default: {}
}

View File

@ -51,9 +51,9 @@ struct Per_Frame_Data {
case 0: {
switch (input.vertex_index) {
case 0: { output.uv = uv_min_max.xy; }
case 1: { output.uv = uv_min_max.zy; }
case 1: { output.uv = uv_min_max.xw; }
case 2: { output.uv = uv_min_max.zw; }
case 3: { output.uv = uv_min_max.xw; }
case 3: { output.uv = uv_min_max.zy; }
default: {}
}
}
@ -61,9 +61,9 @@ struct Per_Frame_Data {
case 1: {
switch (input.vertex_index) {
case 0: { output.uv = uv_min_max.zy; }
case 1: { output.uv = uv_min_max.zw; }
case 1: { output.uv = uv_min_max.xy; }
case 2: { output.uv = uv_min_max.xw; }
case 3: { output.uv = uv_min_max.xy; }
case 3: { output.uv = uv_min_max.zw; }
default: {}
}
}
@ -71,9 +71,9 @@ struct Per_Frame_Data {
case 2: {
switch (input.vertex_index) {
case 0: { output.uv = uv_min_max.zw; }
case 1: { output.uv = uv_min_max.xw; }
case 1: { output.uv = uv_min_max.zy; }
case 2: { output.uv = uv_min_max.xy; }
case 3: { output.uv = uv_min_max.zy; }
case 3: { output.uv = uv_min_max.xw; }
default: {}
}
}
@ -81,9 +81,9 @@ struct Per_Frame_Data {
case 3: {
switch (input.vertex_index) {
case 0: { output.uv = uv_min_max.xw; }
case 1: { output.uv = uv_min_max.xy; }
case 1: { output.uv = uv_min_max.zw; }
case 2: { output.uv = uv_min_max.zy; }
case 3: { output.uv = uv_min_max.zw; }
case 3: { output.uv = uv_min_max.xy; }
default: {}
}
}