From c53038448d63de03801e4fa42acc6383e71e1a79 Mon Sep 17 00:00:00 2001 From: halx99 Date: Thu, 10 Jun 2021 14:17:47 +0800 Subject: [PATCH] Fix android compile error [ci build] --- cocos/renderer/backend/opengl/DeviceInfoGL.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cocos/renderer/backend/opengl/DeviceInfoGL.cpp b/cocos/renderer/backend/opengl/DeviceInfoGL.cpp index 8ff36c5dee..19fe5998a4 100644 --- a/cocos/renderer/backend/opengl/DeviceInfoGL.cpp +++ b/cocos/renderer/backend/opengl/DeviceInfoGL.cpp @@ -70,7 +70,20 @@ static bool checkReallySupportsASTC() { if (!error) { // read pixel RGB: should be: 255, 128, 0 uint8_t pixels[TEXTURE_DIM * TEXTURE_DIM * 4] = {0}; + +#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); +#else + GLuint fbo = 0; + glGenFramebuffers(1, &fbo); + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texID, 0); + + glReadPixels(0, 0, TEXTURE_DIM, TEXTURE_DIM, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + + glBindFramebuffer(GL_FRAMEBUFFER, 0); + glDeleteFramebuffers(1, &fbo); +#endif error = glGetError(); if (error || pixels[0] != 255 || pixels[1] != 128) { error = GL_INVALID_VALUE;