Skip to content

Commit 4811a4a

Browse files
committed
Fix #2470 wasm CommandBufferGL::readPixels not work
1 parent bd5d431 commit 4811a4a

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

core/platform/PlatformMacros.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md).
8383

8484
/** @def AX_ENABLE_CACHE_TEXTURE_DATA
8585
* Enable it if you want to cache the texture data.
86-
* Not enabling for Emscripten any more -- doesn't seem necessary and don't want
8786
* to be different from other platforms unless there's a good reason.
8887
*
8988
* @since v0.99.5

core/renderer/backend/opengl/CommandBufferGL.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040

4141
NS_AX_BACKEND_BEGIN
4242

43+
#if AX_GLES_PROFILE != 200 && AX_TARGET_PLATFORM != AX_PLATFORM_WASM
44+
# define AX_HAVE_MAP_BUFFER_RANGE 1
45+
#else
46+
# define AX_HAVE_MAP_BUFFER_RANGE 0
47+
#endif
48+
4349
namespace
4450
{
4551
void applyTexture(TextureBackend* texture, int slot, int index)
@@ -469,7 +475,7 @@ void CommandBufferGL::readPixels(RenderTarget* rt,
469475
glPixelStorei(GL_PACK_ALIGNMENT, 1);
470476

471477
auto bufferSize = bytesPerRow * height;
472-
#if AX_GLES_PROFILE != 200
478+
#if AX_HAVE_MAP_BUFFER_RANGE
473479
GLuint pbo;
474480
glGenBuffers(1, &pbo);
475481
__gl->bindBuffer(BufferType::PIXEL_PACK_BUFFER, pbo);
@@ -507,14 +513,14 @@ void CommandBufferGL::readPixels(RenderTarget* rt,
507513
// for cache for restore on EGL context resume, don't need flip
508514
pbd._width = width;
509515
pbd._height = height;
510-
#if AX_GLES_PROFILE != 200
516+
#if AX_HAVE_MAP_BUFFER_RANGE
511517
pbd._data.copy(buffer_ptr, static_cast<ssize_t>(bufferSize));
512518
#else
513519
static_cast<axstd::byte_buffer&>(pbd._data).swap(buffer);
514520
#endif
515521
}
516522
}
517-
#if AX_GLES_PROFILE != 200
523+
#if AX_HAVE_MAP_BUFFER_RANGE
518524
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
519525
__gl->bindBuffer(BufferType::PIXEL_PACK_BUFFER, 0);
520526
glDeleteBuffers(1, &pbo);

0 commit comments

Comments
 (0)