Skip to content

Android fixes#150

Open
boludoz wants to merge 14 commits into
aap:masterfrom
boludoz:LOG-GL
Open

Android fixes#150
boludoz wants to merge 14 commits into
aap:masterfrom
boludoz:LOG-GL

Conversation

@boludoz

@boludoz boludoz commented Dec 11, 2025

Copy link
Copy Markdown

@boludoz

boludoz commented Dec 11, 2025

Copy link
Copy Markdown
Author

Inspired by @klaymen1n

@boludoz boludoz changed the title Android fix Android fixes Dec 11, 2025
Comment thread src/gl/gl3device.cpp Outdated
Comment thread src/gl/glad/khrplatform.h Outdated
#elif defined (__SYMBIAN32__)
# define KHRONOS_APICALL IMPORT_C
#elif defined(__ANDROID__)
#elif defined(__ANDROID__) || defined(ANDROID)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think only using __ANDROID__ is enough.
__ANDROID_ is an intrinsic defined by the compiler. ANDROID is added by the Android build CMake toolchain.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This isn't addressed yet.

Comment thread src/image.cpp Outdated
Comment on lines +305 to +306
uint64 alphas = 0;
memcpy(&alphas, src+j+2, sizeof(alphas));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This needs extra documentation.
Or at least it's not SDL2/3-related.
aap should comment on this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

arm bus

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, I see. Is this alignment-related?
If so, you can unconditionally do the memcpy. The undefined sanitizer will also complain about this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We can replace this with a for loop and let the compiler do the rest ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nah, the compiler should do that with -O2.

Comment thread src/gl/gl3device.cpp Outdated
Comment thread src/gl/gl3raster.cpp
natras->backingStore->levels[level].size);
}
}else{
} else if(level == 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Needs a look by aap.

@boludoz boludoz Dec 11, 2025

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This fixes a bug that causes some textures to appear black. Maybe related to #128

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

image image

@boludoz

boludoz commented Dec 12, 2025

Copy link
Copy Markdown
Author

Only a few minor adjustments are needed.

Comment thread src/gl/gl3device.cpp
Comment thread src/gl/gl3device.cpp Outdated
@boludoz

boludoz commented Dec 15, 2025

Copy link
Copy Markdown
Author

I've tried to simulate computer resolution on devices without resolution support, and it's incredibly difficult. I can't get past the first cutscene.

@boludoz

boludoz commented Dec 19, 2025

Copy link
Copy Markdown
Author

Although there are no bugs: In ARM, some types tend to behave differently; some bitwise types may be broken, and that may be what causes some breakages in the format conversion.

Copilot AI review requested due to automatic review settings May 22, 2026 15:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR improves texture handling and device initialization across GL3/GLES backends while adding OpenGL capability logging.

Changes:

  • Fix undefined behavior in DXT decompression and correct DXT block flipping pointer usage.
  • Add OpenGL info logging and adjust SDL2/SDL3 video mode/window creation logic.
  • Update raster upload/mipmap generation behavior and tighten video-mode index validation.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
src/image.cpp Avoid unaligned/aliasing reads in DXT5 alpha decode; fix pointer usage in DXT1 flipping loop.
src/gl/gl3raster.cpp Changes texture upload path and mipmap generation behavior during raster unlock.
src/gl/gl3device.cpp Adds GL info logging, GLES-specific beginUpdate state changes, and SDL/GLFW mode handling updates.
src/CMakeLists.txt Avoids redundant SDL3 find_package when SDL3 target already exists.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/gl/gl3raster.cpp
Comment on lines +552 to 560
} else if(level == 0) {
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, level, natras->internalFormat,
raster->width, raster->height,
0, natras->format, natras->type, raster->pixels);
}
if(level == 0 && natras->autogenMipmap)
// if(level == 0 && natras->autogenMipmap)
glGenerateMipmap(GL_TEXTURE_2D);
bindTexture(prev);
Comment thread src/gl/gl3device.cpp
Comment on lines +37 to +42
#if defined(LIBRW_SDL2) || defined(LIBRW_SDL3)
const char *version = (const char *)glGetString(GL_VERSION);
const char *vendor = (const char *)glGetString(GL_VENDOR);
const char *renderer = (const char *)glGetString(GL_RENDERER);
const char *extensions = (const char *)glGetString(GL_EXTENSIONS);
const char *shadingLang = (const char *)glGetString(GL_SHADING_LANGUAGE_VERSION);
Comment thread src/gl/gl3device.cpp
Comment on lines +61 to +67
#if defined(LIBRW_GL_LOG_INFO)
const char *basePath = SDL_GetBasePath();

if(basePath) {
char logPath[512];
snprintf(logPath, sizeof(logPath), "%sGL_info.txt", basePath);
FILE *log = fopen(logPath, "w");
Comment thread src/gl/gl3device.cpp
if(gl3Caps.gles) {
// glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
glDisable(GL_STENCIL_TEST);
Comment thread src/gl/gl3device.cpp
Comment on lines 2337 to 2340
case DEVICEGETVIDEOMODEINFO:
if (n <= 0)
return 0;
rwmode = (VideoMode*)arg;
rwmode->width = glGlobals.modes[n].mode.w;
rwmode->height = glGlobals.modes[n].mode.h;
Comment thread src/gl/gl3device.cpp

case DEVICESETVIDEOMODE:
if(n >= glGlobals.numModes)
if (n <= 0 || n >= glGlobals.numModes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants