diff --git a/Backends/Graphics4/OpenGL/Sources/kinc/backend/graphics4/OpenGL.c.h b/Backends/Graphics4/OpenGL/Sources/kinc/backend/graphics4/OpenGL.c.h index 2ae4873eb..66abe9fce 100644 --- a/Backends/Graphics4/OpenGL/Sources/kinc/backend/graphics4/OpenGL.c.h +++ b/Backends/Graphics4/OpenGL/Sources/kinc/backend/graphics4/OpenGL.c.h @@ -789,12 +789,21 @@ void kinc_g4_set_index_buffer(kinc_g4_index_buffer_t *indexBuffer) { kinc_internal_g4_index_buffer_set(indexBuffer); } -void Kinc_G4_Internal_TextureSet(kinc_g4_texture_t *texture, kinc_g4_texture_unit_t unit); void Kinc_G4_Internal_TextureImageSet(kinc_g4_texture_t *texture, kinc_g4_texture_unit_t unit); +#ifdef KINC_KONG +void Kinc_G4_Internal_TextureSet(kinc_g4_texture_t *texture, uint32_t unit); + +void kinc_g4_set_texture(uint32_t unit, kinc_g4_texture_t *texture) { + Kinc_G4_Internal_TextureSet(texture, unit); +} +#else +void Kinc_G4_Internal_TextureSet(kinc_g4_texture_t *texture, kinc_g4_texture_unit_t unit); + void kinc_g4_set_texture(kinc_g4_texture_unit_t unit, kinc_g4_texture_t *texture) { Kinc_G4_Internal_TextureSet(texture, unit); } +#endif void kinc_g4_set_image_texture(kinc_g4_texture_unit_t unit, kinc_g4_texture_t *texture) { Kinc_G4_Internal_TextureImageSet(texture, unit); @@ -865,6 +874,15 @@ static void setTextureAddressingInternal(GLenum target, kinc_g4_texture_unit_t u glCheckErrors(); } +#ifdef KINC_KONG +int Kinc_G4_Internal_TextureAddressingU(uint32_t unit) { + return texModesU[unit]; +} + +int Kinc_G4_Internal_TextureAddressingV(uint32_t unit) { + return texModesV[unit]; +} +#else int Kinc_G4_Internal_TextureAddressingU(kinc_g4_texture_unit_t unit) { return texModesU[unit.stages[KINC_G4_SHADER_TYPE_FRAGMENT]]; } @@ -872,6 +890,7 @@ int Kinc_G4_Internal_TextureAddressingU(kinc_g4_texture_unit_t unit) { int Kinc_G4_Internal_TextureAddressingV(kinc_g4_texture_unit_t unit) { return texModesV[unit.stages[KINC_G4_SHADER_TYPE_FRAGMENT]]; } +#endif void kinc_g4_set_texture_addressing(kinc_g4_texture_unit_t unit, kinc_g4_texture_direction_t dir, kinc_g4_texture_addressing_t addressing) { setTextureAddressingInternal(GL_TEXTURE_2D, unit, dir, addressing); diff --git a/Backends/Graphics4/OpenGL/Sources/kinc/backend/graphics4/OpenGL.h b/Backends/Graphics4/OpenGL/Sources/kinc/backend/graphics4/OpenGL.h index 029ccae57..9d88cf735 100644 --- a/Backends/Graphics4/OpenGL/Sources/kinc/backend/graphics4/OpenGL.h +++ b/Backends/Graphics4/OpenGL/Sources/kinc/backend/graphics4/OpenGL.h @@ -8,8 +8,13 @@ extern "C" { #endif +#ifdef KINC_KONG +int Kinc_G4_Internal_TextureAddressingU(uint32_t unit); +int Kinc_G4_Internal_TextureAddressingV(uint32_t unit); +#else int Kinc_G4_Internal_TextureAddressingU(kinc_g4_texture_unit_t unit); int Kinc_G4_Internal_TextureAddressingV(kinc_g4_texture_unit_t unit); +#endif int Kinc_G4_Internal_StencilFunc(kinc_g4_compare_mode_t mode); #ifdef __cplusplus diff --git a/Backends/Graphics4/OpenGL/Sources/kinc/backend/graphics4/rendertarget.c.h b/Backends/Graphics4/OpenGL/Sources/kinc/backend/graphics4/rendertarget.c.h index 918e39fc2..faa29e039 100644 --- a/Backends/Graphics4/OpenGL/Sources/kinc/backend/graphics4/rendertarget.c.h +++ b/Backends/Graphics4/OpenGL/Sources/kinc/backend/graphics4/rendertarget.c.h @@ -358,12 +358,22 @@ void kinc_g4_render_target_destroy(kinc_g4_render_target_t *renderTarget) { GLuint framebuffers[] = {renderTarget->impl._framebuffer}; glDeleteFramebuffers(1, framebuffers); } + +#ifdef KINC_KONG +void kinc_g4_render_target_use_color_as_texture(kinc_g4_render_target_t *renderTarget, uint32_t unit) { + glActiveTexture(GL_TEXTURE0 + unit); + glCheckErrors(); + glBindTexture(renderTarget->isCubeMap ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D, renderTarget->impl._texture); + glCheckErrors(); +} +#else void kinc_g4_render_target_use_color_as_texture(kinc_g4_render_target_t *renderTarget, kinc_g4_texture_unit_t unit) { glActiveTexture(GL_TEXTURE0 + unit.stages[KINC_G4_SHADER_TYPE_FRAGMENT]); glCheckErrors(); glBindTexture(renderTarget->isCubeMap ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D, renderTarget->impl._texture); glCheckErrors(); } +#endif void kinc_g4_render_target_use_depth_as_texture(kinc_g4_render_target_t *renderTarget, kinc_g4_texture_unit_t unit) { glActiveTexture(GL_TEXTURE0 + unit.stages[KINC_G4_SHADER_TYPE_FRAGMENT]); diff --git a/Backends/Graphics4/OpenGL/Sources/kinc/backend/graphics4/texture.c.h b/Backends/Graphics4/OpenGL/Sources/kinc/backend/graphics4/texture.c.h index d9d4747de..d46eab9c7 100644 --- a/Backends/Graphics4/OpenGL/Sources/kinc/backend/graphics4/texture.c.h +++ b/Backends/Graphics4/OpenGL/Sources/kinc/backend/graphics4/texture.c.h @@ -502,6 +502,28 @@ void kinc_g4_texture_destroy(kinc_g4_texture_t *texture) { glFlush(); } +#ifdef KINC_KONG +void Kinc_G4_Internal_TextureSet(kinc_g4_texture_t *texture, uint32_t unit) { + GLenum target = texture->tex_depth > 1 ? GL_TEXTURE_3D : GL_TEXTURE_2D; + glActiveTexture(GL_TEXTURE0 + unit); + glCheckErrors(); +#ifdef KORE_ANDROID + if (texture->impl.external_oes) { + glBindTexture(GL_TEXTURE_EXTERNAL_OES, texture->impl.texture); + glCheckErrors(); + } + else { + glBindTexture(target, texture->impl.texture); + glCheckErrors(); + } +#else + glBindTexture(target, texture->impl.texture); + glCheckErrors(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, Kinc_G4_Internal_TextureAddressingU(unit)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, Kinc_G4_Internal_TextureAddressingV(unit)); +#endif +} +#else void Kinc_G4_Internal_TextureSet(kinc_g4_texture_t *texture, kinc_g4_texture_unit_t unit) { GLenum target = texture->tex_depth > 1 ? GL_TEXTURE_3D : GL_TEXTURE_2D; glActiveTexture(GL_TEXTURE0 + unit.stages[KINC_G4_SHADER_TYPE_FRAGMENT]); @@ -522,6 +544,7 @@ void Kinc_G4_Internal_TextureSet(kinc_g4_texture_t *texture, kinc_g4_texture_uni glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, Kinc_G4_Internal_TextureAddressingV(unit)); #endif } +#endif void Kinc_G4_Internal_TextureImageSet(kinc_g4_texture_t *texture, kinc_g4_texture_unit_t unit) { #if defined(KORE_WINDOWS) || (defined(KORE_LINUX) && defined(GL_VERSION_4_4))