Skip to content

Commit

Permalink
- set default msaa sample count to 8
Browse files Browse the repository at this point in the history
- change baked ghostscript tiger commands in perf test to use srgb
- update smiley sketch
  • Loading branch information
martinfouilleul committed Apr 26, 2024
1 parent 82b9006 commit 4bb32b5
Show file tree
Hide file tree
Showing 5 changed files with 329 additions and 324 deletions.
2 changes: 1 addition & 1 deletion sketches/smiley/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ mkdir -p $BINDIR
clang -g $FLAGS $LIBS $INCLUDES -o $BINDIR/example_smiley main.c

cp $LIBDIR/liborca.dylib $BINDIR/
cp $LIBDIR/mtl_renderer.metallib $BINDIR/
cp $LIBDIR/libwebgpu.dylib $BINDIR/

install_name_tool -add_rpath "@executable_path" $BINDIR/example_smiley
37 changes: 21 additions & 16 deletions sketches/smiley/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,26 @@ int main()

oc_rect contentRect = oc_window_get_content_rect(window);

//NOTE: create surface
oc_surface surface = oc_surface_create_for_window(window, OC_CANVAS);
//NOTE: create renderer, surface, and context

oc_canvas_renderer renderer = oc_canvas_renderer_create();
if(oc_canvas_renderer_is_nil(renderer))
{
oc_log_error("Error: couldn't create renderer\n");
return (-1);
}

oc_surface surface = oc_canvas_surface_create_for_window(renderer, window);
if(oc_surface_is_nil(surface))
{
oc_log_error("Error: couldn't create surface\n");
return (-1);
}
oc_surface_swap_interval(surface, 0);

oc_canvas canvas = oc_canvas_create();

if(oc_canvas_is_nil(canvas))
oc_canvas_context context = oc_canvas_context_create();
if(oc_canvas_context_is_nil(context))
{
printf("Error: couldn't create canvas\n");
oc_log_error("Error: couldn't create canvas\n");
return (-1);
}

Expand Down Expand Up @@ -109,19 +115,19 @@ int main()
{
f32 factor = (event->key.mods & OC_KEYMOD_SHIFT) ? 10 : 1;

if(event->key.code == OC_KEY_LEFT)
if(event->key.keyCode == OC_KEY_LEFT)
{
x -= 0.3 * factor;
}
else if(event->key.code == OC_KEY_RIGHT)
else if(event->key.keyCode == OC_KEY_RIGHT)
{
x += 0.3 * factor;
}
else if(event->key.code == OC_KEY_UP)
else if(event->key.keyCode == OC_KEY_UP)
{
y -= 0.3 * factor;
}
else if(event->key.code == OC_KEY_DOWN)
else if(event->key.keyCode == OC_KEY_DOWN)
{
y += 0.3 * factor;
}
Expand Down Expand Up @@ -199,17 +205,16 @@ int main()
frameTime,
1. / frameTime);

oc_surface_select(surface);
oc_render(canvas);
oc_surface_present(surface);
oc_canvas_render(renderer, context, surface);
oc_canvas_present(renderer, surface);

oc_scratch_end(scratch);
frameTime = oc_clock_time(OC_CLOCK_MONOTONIC) - startTime;
}

oc_font_destroy(font);
oc_canvas_destroy(canvas);
oc_canvas_context_destroy(context);
oc_surface_destroy(surface);
oc_canvas_renderer_destroy(renderer);
oc_window_destroy(window);

oc_terminate();
Expand Down
1 change: 1 addition & 0 deletions src/graphics/graphics_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,7 @@ oc_canvas_context oc_canvas_context_create()
context->clipStackSize = 0;
context->primitiveCount = 0;
context->clearColor = (oc_color){ 0, 0, 0, 0 };
context->msaaSampleCount = 8;

context->attributes = (oc_attributes){ 0 };
context->attributes.hasGradient = false;
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/wgsl_shaders/segment_setup.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ fn cubic_emit(curve : cubic_info, p : array<vec2f, 4>, s0 : f32, s1 : f32, sp :
var v2 : vec2f;
var K : mat3x3f;

//TODO: haul that up in caller
//TODO: haul that up in caller, we don't need to compute K for all monotonic segments
let sqrNorm0 : f32 = dot(p[1] - p[0], p[1] - p[0]);
let sqrNorm1 : f32 = dot(p[2] - p[3], p[2] - p[3]);

Expand Down
Loading

0 comments on commit 4bb32b5

Please sign in to comment.