Skip to content

Commit 00dc8e2

Browse files
committed
fix ios
1 parent 1365702 commit 00dc8e2

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/ruis/render/opengles/frame_buffer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ frame_buffer::frame_buffer( //
6868
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
6969
auto& tex = static_cast<texture_2d&>(*this->color);
7070

71-
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex.tex, 0);
71+
glFramebufferTexture2D(GL_FRAMEBUFFER,//
72+
GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex.tex, 0);
7273
assert_opengl_no_error();
7374
}
7475

@@ -77,7 +78,8 @@ frame_buffer::frame_buffer( //
7778
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-static-cast-downcast)
7879
auto& tex = static_cast<texture_depth&>(*this->depth);
7980

80-
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, tex.tex, 0);
81+
glFramebufferTexture2D(GL_FRAMEBUFFER,//
82+
GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, tex.tex, 0);
8183
assert_opengl_no_error();
8284
}
8385

src/ruis/render/opengles/texture_depth.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,16 @@ texture_depth::texture_depth(
4141
glTexImage2D( //
4242
GL_TEXTURE_2D,
4343
0, // 0th level, no mipmaps
44-
#if CFG_OS_NAME == CFG_OS_NAME_EMSCRIPTEN
44+
#if CFG_OS_NAME == CFG_OS_NAME_EMSCRIPTEN || CFG_OS_NAME == CFG_OS_NAME_IOS
4545
// According to https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_depth_texture
4646
// WebGL needs GL_DEPTH_COMPONENT as internal format.
4747
// Otherwise it doesn't work:
48-
// - framebuffer with such depth attachment fails test for being complete.And WebGL prints warning
48+
// - framebuffer with such depth attachment fails test for being complete. And WebGL prints warning.
4949
// - WebGL texImage2D() prints warning: "Invalid internalformat: 0x81a5"
50-
GL_DEPTH_COMPONENT, // internal format
50+
51+
// And iOS also needs this one instead of GL_DEPTH_COMPONENT16.
52+
53+
GL_DEPTH_COMPONENT, // internal format
5154
#else
5255
GL_DEPTH_COMPONENT16, // internal format
5356
#endif
@@ -68,4 +71,4 @@ texture_depth::texture_depth(
6871
assert_opengl_no_error();
6972
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
7073
assert_opengl_no_error();
71-
}
74+
}

0 commit comments

Comments
 (0)