Move samplers bindings to shaders.

This commit is contained in:
Roz K 2022-12-31 13:36:48 +01:00
parent 2095e335ea
commit ae3333e22e
Signed by: roz
GPG Key ID: 51FBF4E483E1C822
3 changed files with 4 additions and 9 deletions

View File

@ -433,8 +433,7 @@ select_texture = _engine.rk_select_texture
select_texture.restype = None
select_texture.argtypes = (
ctypes.c_uint, # slot
ctypes.c_void_p, # texture
ctypes.c_void_p) # sampler
ctypes.c_void_p) # texture
draw_triangles = _engine.rk_draw_triangles
draw_triangles.restype = None

View File

@ -155,8 +155,7 @@ RK_EXPORT void rk_set_param_mat3(
RK_EXPORT void rk_select_texture(
rk_uint slot,
rk_texture_t texture,
rk_input_t sampler);
rk_texture_t texture);
RK_EXPORT void rk_draw_triangles(
rk_triangles_t triangles);

View File

@ -746,18 +746,15 @@ void rk_set_param_mat3(
void rk_select_texture(
rk_uint slot,
rk_texture_t _texture,
rk_input_t _sampler) {
rk_texture_t _texture) {
rk_texture const * const texture = reinterpret_cast<rk_texture const *>(_texture);
GLint const sampler = reinterpret_cast<intptr_t>(_sampler) - 1;
if (texture && sampler > -1) {
if (texture) {
glActiveTexture(GL_TEXTURE0 + slot);
if (texture->nlevels) {
glBindTexture(GL_TEXTURE_2D_ARRAY, texture->texture);
} else {
glBindTexture(GL_TEXTURE_2D, texture->texture);
}
glUniform1i(sampler, slot);
}
}