Skip to content

Commit

Permalink
c: moves global static handle out of getter, initializes handle by de…
Browse files Browse the repository at this point in the history
…fault
  • Loading branch information
Dav1dde committed Oct 21, 2022
1 parent e0b64d9 commit 24ddbba
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
3 changes: 2 additions & 1 deletion glad/generator/c/templates/base_template.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ extern "C" {

{% block variables %}
{% if options.mx_global %}
Glad{{ feature_set.name|api }}Context* {{ global_context }};
{% call template_utils.zero_initialized() %}Glad{{ feature_set.name|api }}Context {{ global_context }}_static{% endcall %}
Glad{{ feature_set.name|api }}Context* {{ global_context }} = &{{ global_context }}_static;
{% endif %}
{% endblock %}

Expand Down
3 changes: 0 additions & 3 deletions glad/generator/c/templates/gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,6 @@ int gladLoad{{ api|api }}(GLADloadfunc load) {

{% if options.mx_global %}
Glad{{ feature_set.name|api }}Context* gladGet{{ feature_set.name|api }}Context() {
static Glad{{ feature_set.name|api }}Context default_context;
if (!{{ global_context }})
{{ global_context }} = &default_context;
return {{ global_context }};
}

Expand Down
3 changes: 0 additions & 3 deletions glad/generator/c/templates/vk.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,6 @@ int gladLoad{{ api|api }}(VkPhysicalDevice physical_device, GLADloadfunc load) {

{% if options.mx_global %}
Glad{{ feature_set.name|api }}Context* gladGet{{ feature_set.name|api }}Context() {
static Glad{{ feature_set.name|api }}Context default_context;
if (!{{ global_context }})
{{ global_context }} = &default_context;
return {{ global_context }};
}

Expand Down

0 comments on commit 24ddbba

Please sign in to comment.