summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rendering.cc32
-rw-r--r--src/rendering.h2
2 files changed, 14 insertions, 20 deletions
diff --git a/src/rendering.cc b/src/rendering.cc
index 52d4eae..2c05c8e 100644
--- a/src/rendering.cc
+++ b/src/rendering.cc
@@ -6,51 +6,46 @@
bool wayc_image_init(texture_t* texture, image_type_e type,
image_format_e format, u32 width, u32 height) {
- bool success = false;
- glGenTextures(1, texture);
- wayc_defer_cond(glDeleteTextures(1, texture), success, true);
+ glCreateTextures(type, 1, texture);
+ if (*texture == 0) return false;
- glBindTexture(type, *texture);
switch (type) {
case IMAGE_TYPE_2D:
- glTexStorage2D(type, 1, format, width, height);
+ // TODO: add error checking
+ glTextureStorage2D(*texture, 1, format, width, height);
break;
default:
- return success;
+ break;
}
- glBindTexture(type, 0);
-
- success = true;
- return success;
+ return true;
}
bool wayc_image_upload(texture_t texture, ivec2 offset, u32 width, u32 height,
image_type_e type, image_format_e format,
image_data_type_e data_type, const u8* data) {
- glBindTexture(type, texture);
switch (type) {
case IMAGE_TYPE_2D:
- glTexSubImage2D(type, 0, offset[0], offset[1], width, height, format,
- data_type, data);
+ // TODO: add error checking
+ glTextureSubImage2D(texture, 0, offset[0], offset[1], width, height,
+ format, data_type, data);
break;
default:
- return false;
+ break;
}
return true;
}
-void wayc_image_use(texture_t texture, image_type_e type, u32 slot) {
- glActiveTexture(GL_TEXTURE0 + slot);
- glBindTexture(type, texture);
+void wayc_image_use(texture_t texture, u32 slot) {
+ glBindTextureUnit(slot, texture);
}
void wayc_image_deinit(texture_t* texture) { glDeleteTextures(1, texture); }
bool wayc_sampler_init(sampler_t* sampler, sample_filter_e filter,
sample_wrap_e wrap) {
- glGenSamplers(1, sampler);
+ glCreateSamplers(1, sampler);
if (*sampler == 0) return false;
glSamplerParameteri(*sampler, GL_TEXTURE_MIN_FILTER, filter);
@@ -62,7 +57,6 @@ bool wayc_sampler_init(sampler_t* sampler, sample_filter_e filter,
}
void wayc_sampler_use(sampler_t sampler, u32 slot) {
- glActiveTexture(GL_TEXTURE0 + slot);
glBindSampler(slot, sampler);
}
diff --git a/src/rendering.h b/src/rendering.h
index 7803040..5896697 100644
--- a/src/rendering.h
+++ b/src/rendering.h
@@ -32,7 +32,7 @@ bool wayc_image_upload(texture_t texture, ivec2 offset, u32 width, u32 height,
image_type_e type, image_format_e format,
image_data_type_e data_type, const u8* data);
-void wayc_image_use(texture_t texture, image_type_e type, u32 slot);
+void wayc_image_use(texture_t texture, u32 slot);
void wayc_image_deinit(texture_t* texture);
enum sample_filter_e {