void OGLESTexture3D::CreateHWResource(ElementInitData const * init_data) { uint32_t texel_size = NumFormatBytes(format_); GLint glinternalFormat; GLenum glformat; GLenum gltype; OGLESMapping::MappingFormat(glinternalFormat, glformat, gltype, format_); glBindTexture(target_type_, texture_); for (uint32_t level = 0; level < num_mip_maps_; ++ level) { uint32_t const w = this->Width(level); uint32_t const h = this->Height(level); uint32_t const d = this->Depth(level); if (IsCompressedFormat(format_)) { uint32_t const block_size = NumFormatBytes(format_) * 4; GLsizei const image_size = ((w + 3) / 4) * ((h + 3) / 4) * d * block_size; void* ptr; if (nullptr == init_data) { tex_data_[level].resize(image_size, 0); ptr = nullptr; } else { tex_data_[level].resize(image_size); std::memcpy(&tex_data_[level][0], init_data[level].data, image_size); ptr = &tex_data_[level][0]; } if (glloader_GLES_VERSION_3_0()) { glCompressedTexImage3D(target_type_, level, glinternalFormat, w, h, d, 0, image_size, ptr); } else { glCompressedTexImage3DOES(target_type_, level, glinternalFormat, w, h, d, 0, image_size, ptr); } } else { GLsizei const image_size = w * h * d * texel_size; void* ptr; if (nullptr == init_data) { tex_data_[level].resize(image_size, 0); ptr = nullptr; } else { tex_data_[level].resize(image_size); std::memcpy(&tex_data_[level][0], init_data[level].data, image_size); ptr = &tex_data_[level][0]; } if (glloader_GLES_VERSION_3_0()) { glTexImage3D(target_type_, level, glinternalFormat, w, h, d, 0, glformat, gltype, ptr); } else { glTexImage3DOES(target_type_, level, glinternalFormat, w, h, d, 0, glformat, gltype, ptr); } } } hw_res_ready_ = true; }
JNIEXPORT void JNICALL Java_org_lwjgl_opengles_OESTexture3D_nglCompressedTexImage3DOES(JNIEnv *__env, jclass clazz, jint target, jint level, jint internalformat, jint width, jint height, jint depth, jint border, jint imageSize, jlong dataAddress) { glCompressedTexImage3DOESPROC glCompressedTexImage3DOES = (glCompressedTexImage3DOESPROC)tlsGetFunction(782); intptr_t data = (intptr_t)dataAddress; UNUSED_PARAM(clazz) glCompressedTexImage3DOES(target, level, internalformat, width, height, depth, border, imageSize, data); }