Skip to content

OpenGL ES Fix #270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/opengl.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static void OpenGLRenderer_EndDraw() {
}

int viewport_x = (drawable_width - viewport_width) >> 1;
int viewport_y = (viewport_height - viewport_height) >> 1;
int viewport_y = (drawable_height - viewport_height) >> 1;

glBindTexture(GL_TEXTURE_2D, g_texture.gl_texture);
if (g_draw_width == g_texture.width && g_draw_height == g_texture.height) {
Expand All @@ -222,7 +222,7 @@ static void OpenGLRenderer_EndDraw() {
if (!g_opengl_es)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, g_draw_width, g_draw_height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, g_screen_buffer);
else
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, g_draw_width, g_draw_height, 0, GL_BGRA, GL_UNSIGNED_BYTE, g_screen_buffer);
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA, g_draw_width, g_draw_height, 0, GL_BGRA, GL_UNSIGNED_BYTE, g_screen_buffer);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GL_BGRA doesn't appear to be a valid value for this parameter?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was getting a GL_INVALID_VALUE (0x501) error until I changed the internal format to match the format. Having them both as GL_RGBA also worked, but I got a black screen with GL_RGBA as the internal format and GL_BGRA as the format. I found the solution on this page: https://stackoverflow.com/questions/50717395/how-to-load-a-bgra-image-texture-in-gles2

It may be an issue specific to android, but it fixed the errors on both an x86-64 android emulator and physical android device with an Adreno 630 GPU.

}

glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
Expand Down