Skip to content

Commit

Permalink
Support blend modes
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Jun 11, 2024
1 parent add78d9 commit 08f3a3c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Sources/globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ void globals_init(void) {
add_global_with_value(float_id, add_name("COMPARE_LESS_EQUAL"), 5);
add_global_with_value(float_id, add_name("COMPARE_GREATER"), 6);
add_global_with_value(float_id, add_name("COMPARE_GREATER_EQUAL"), 7);

add_global_with_value(float_id, add_name("BLEND_ONE"), 0);
add_global_with_value(float_id, add_name("BLEND_ZERO"), 1);
add_global_with_value(float_id, add_name("BLEND_SOURCE_ALPHA"), 2);
add_global_with_value(float_id, add_name("BLEND_DEST_ALPHA"), 3);
add_global_with_value(float_id, add_name("BLEND_INV_SOURCE_ALPHA"), 4);
add_global_with_value(float_id, add_name("BLEND_INV_DEST_ALPHA"), 5);
add_global_with_value(float_id, add_name("BLEND_SOURCE_COLOR"), 6);
add_global_with_value(float_id, add_name("BLEND_DEST_COLOR"), 7);
add_global_with_value(float_id, add_name("BLEND_INV_SOURCE_COLOR"), 8);
add_global_with_value(float_id, add_name("BLEND_INV_DEST_COLOR"), 9);
add_global_with_value(float_id, add_name("BLEND_CONSTANT"), 10);
add_global_with_value(float_id, add_name("BLEND_INV_CONSTANT"), 11);

add_global_with_value(float_id, add_name("BLENDOP_ADD"), 0);
add_global_with_value(float_id, add_name("BLENDOP_SUBTRACT"), 1);
add_global_with_value(float_id, add_name("BLENDOP_REVERSE_SUBTRACT"), 2);
add_global_with_value(float_id, add_name("BLENDOP_MIN"), 3);
add_global_with_value(float_id, add_name("BLENDOP_MAX"), 4);
}

global_id add_global(type_id type, name_id name) {
Expand Down
36 changes: 36 additions & 0 deletions Sources/integrations/kinc.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,42 @@ void kinc_export(char *directory, api_kind api) {
global g = find_global(t->members.m[j].value.identifier);
fprintf(output, "\t%s.depth_mode = %i;\n\n", get_name(t->name), (int)g.value);
}
else if (t->members.m[j].name == add_name("blend_source")) {
debug_context context = {0};
check(t->members.m[j].value.kind == TOKEN_IDENTIFIER, context, "blend_source expects an identifier");
global g = find_global(t->members.m[j].value.identifier);
fprintf(output, "\t%s.blend_source = %i;\n\n", get_name(t->name), (int)g.value);
}
else if (t->members.m[j].name == add_name("blend_destination")) {
debug_context context = {0};
check(t->members.m[j].value.kind == TOKEN_IDENTIFIER, context, "blend_destination expects an identifier");
global g = find_global(t->members.m[j].value.identifier);
fprintf(output, "\t%s.blend_destination = %i;\n\n", get_name(t->name), (int)g.value);
}
else if (t->members.m[j].name == add_name("blend_operation")) {
debug_context context = {0};
check(t->members.m[j].value.kind == TOKEN_IDENTIFIER, context, "blend_operation expects an identifier");
global g = find_global(t->members.m[j].value.identifier);
fprintf(output, "\t%s.blend_operation = %i;\n\n", get_name(t->name), (int)g.value);
}
else if (t->members.m[j].name == add_name("alpha_blend_source")) {
debug_context context = {0};
check(t->members.m[j].value.kind == TOKEN_IDENTIFIER, context, "alpha_blend_source expects an identifier");
global g = find_global(t->members.m[j].value.identifier);
fprintf(output, "\t%s.alpha_blend_source = %i;\n\n", get_name(t->name), (int)g.value);
}
else if (t->members.m[j].name == add_name("alpha_blend_destination")) {
debug_context context = {0};
check(t->members.m[j].value.kind == TOKEN_IDENTIFIER, context, "alpha_blend_destination expects an identifier");
global g = find_global(t->members.m[j].value.identifier);
fprintf(output, "\t%s.alpha_blend_destination = %i;\n\n", get_name(t->name), (int)g.value);
}
else if (t->members.m[j].name == add_name("alpha_blend_operation")) {
debug_context context = {0};
check(t->members.m[j].value.kind == TOKEN_IDENTIFIER, context, "alpha_blend_operation expects an identifier");
global g = find_global(t->members.m[j].value.identifier);
fprintf(output, "\t%s.alpha_blend_operation = %i;\n\n", get_name(t->name), (int)g.value);
}
else {
debug_context context = {0};
error(context, "Unsupported pipe member %s", get_name(t->members.m[j].name));
Expand Down

0 comments on commit 08f3a3c

Please sign in to comment.