/** * OpenGL ES does not support glGetTexLevelParameteriv, but it is possible to * probe whether a texture has a given size by crafting a dummy glTexSubImage() * call. */ static bool probeTextureLevelSizeOES(GLenum target, GLint level, const GLint size[3]) { while (glGetError() != GL_NO_ERROR) ; GLenum internalFormat = GL_RGBA; GLenum type = GL_UNSIGNED_BYTE; GLint dummy = 0; switch (target) { case GL_TEXTURE_2D: case GL_TEXTURE_CUBE_MAP: case GL_TEXTURE_CUBE_MAP_POSITIVE_X: case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: glTexSubImage2D(target, level, size[0], size[1], 0, 0, internalFormat, type, &dummy); break; case GL_TEXTURE_3D_OES: glTexSubImage3DOES(target, level, size[0], size[1], size[2], 0, 0, 0, internalFormat, type, &dummy); default: assert(0); return false; } GLenum error = glGetError(); if (0) { std::cerr << "(" << size[0] << ", " << size[1] << ", " << size[2] << ") = " << enumToString(error) << "\n"; } if (error == GL_NO_ERROR) { return true; } while (glGetError() != GL_NO_ERROR) ; return false; }
void OGLESTexture3D::Unmap3D(uint32_t array_index, uint32_t level) { BOOST_ASSERT(0 == array_index); KFL_UNUSED(array_index); switch (last_tma_) { case TMA_Read_Only: break; case TMA_Write_Only: case TMA_Read_Write: { GLint gl_internalFormat; GLenum gl_format; GLenum gl_type; OGLESMapping::MappingFormat(gl_internalFormat, gl_format, gl_type, format_); uint32_t const w = this->Width(level); uint32_t const h = this->Height(level); uint32_t const d = this->Depth(level); OGLESRenderEngine& re = *checked_cast<OGLESRenderEngine*>(&Context::Instance().RenderFactoryInstance().RenderEngineInstance()); re.BindTexture(0, target_type_, texture_); if (IsCompressedFormat(format_)) { uint32_t const block_size = NumFormatBytes(format_) * 4; GLsizei const image_size = ((w + 3) / 4) * ((h + 3) / 4) * d * block_size; if (glloader_GLES_VERSION_3_0()) { glCompressedTexSubImage3D(target_type_, level, 0, 0, 0, w, h, d, gl_format, image_size, &tex_data_[level][0]); } else { glCompressedTexSubImage3DOES(target_type_, level, 0, 0, 0, w, h, d, gl_format, image_size, &tex_data_[level][0]); } } else { if (glloader_GLES_VERSION_3_0()) { glTexSubImage3D(target_type_, level, 0, 0, 0, w, h, d, gl_format, gl_type, &tex_data_[level][0]); } else { glTexSubImage3DOES(target_type_, level, 0, 0, 0, w, h, d, gl_format, gl_type, &tex_data_[level][0]); } } } break; default: BOOST_ASSERT(false); break; } }
JNIEXPORT void JNICALL Java_org_lwjgl_opengles_OESTexture3D_nglTexSubImage3DOES__IIIIIIIIIIJ(JNIEnv *__env, jclass clazz, jint target, jint level, jint xoffset, jint yoffset, jint zoffset, jint width, jint height, jint depth, jint format, jint type, jlong pixelsAddress) { glTexSubImage3DOESPROC glTexSubImage3DOES = (glTexSubImage3DOESPROC)tlsGetFunction(780); intptr_t pixels = (intptr_t)pixelsAddress; UNUSED_PARAM(clazz) glTexSubImage3DOES(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); }