Skip to content

Commit

Permalink
wgpu samples: start fixing triangle sample
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Aug 2, 2023
1 parent 82fc0ad commit 5599ddc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions wgpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ fips_begin_app(clear-wgpu windowed)
fips_deps(wgpu_entry)
fips_end_app()

#fips_begin_app(triangle-wgpu windowed)
# fips_files(triangle-wgpu.c)
# sokol_shader(triangle-wgpu.glsl wgpu)
# fips_deps(wgpu_entry)
#fips_end_app()
#
fips_begin_app(triangle-wgpu windowed)
fips_files(triangle-wgpu.c)
sokol_shader(triangle-wgpu.glsl wgsl)
fips_deps(wgpu_entry)
fips_end_app()

#fips_begin_app(quad-wgpu windowed)
# fips_files(quad-wgpu.c)
# sokol_shader(quad-wgpu.glsl wgpu)
Expand Down
10 changes: 5 additions & 5 deletions wgpu/triangle-wgpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// triangle-wgpu.c
// Vertex buffer, simple shader, pipeline state object.
//------------------------------------------------------------------------------
#include "wgpu_entry.h"
#define SOKOL_IMPL
#define SOKOL_WGPU
#include "sokol_gfx.h"
#include "sokol_log.h"
#include "wgpu_entry.h"
#include "triangle-wgpu.glsl.h"

static struct {
Expand All @@ -15,7 +15,7 @@ static struct {
sg_pass_action pass_action;
} state = {
.pass_action = {
.colors[0] = { .action = SG_ACTION_CLEAR, .value = { 0.0f, 0.0f, 0.0f, 1.0f } }
.colors[0] = { .load_action = SG_LOADACTION_CLEAR, .clear_value = { 0.0f, 0.0f, 0.0f, 1.0f } }
}
};

Expand All @@ -25,7 +25,7 @@ static void init(void) {
.logger.func = slog_func,
});

/* a vertex buffer with 3 vertices */
// a vertex buffer with 3 vertices
float vertices[] = {
// positions // colors
0.0f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 1.0f,
Expand All @@ -36,10 +36,10 @@ static void init(void) {
.data = SG_RANGE(vertices)
});

/* create a shader from precompiled SPIRV bytecode */
// FIXME: use WGSL directly here, not sokol-shdc
sg_shader shd = sg_make_shader(triangle_shader_desc(sg_query_backend()));

/* create a pipeline object (default render states are fine for triangle) */
// create a pipeline object (default render states are fine for triangle)
state.pip = sg_make_pipeline(&(sg_pipeline_desc){
.shader = shd,
.layout = {
Expand Down

0 comments on commit 5599ddc

Please sign in to comment.