Skip to content

macOS: allocate chunk VBOs, ASCII date string, focus dialog field - #4

Merged
j92580498-max merged 1 commit into
mainfrom
devin/1778785038-mavericks-r4-vbo-chunks
May 14, 2026
Merged

macOS: allocate chunk VBOs, ASCII date string, focus dialog field#4
j92580498-max merged 1 commit into
mainfrom
devin/1778785038-mavericks-r4-vbo-chunks

Conversation

@j92580498-max

Copy link
Copy Markdown
Owner

Fixes the SIGSEGV at Chunk::rebuild() + 672 on real Mavericks hardware (see issue #2 follow-up).

Root cause

LevelRenderers VBO allocation was gated on OPENGL_ES, but Chunk::rebuild() uses VBOs whenever USE_VBO is defined (which gles.h does for both iOS GLES 1.1 AND macOS desktop GL 2.1). The macOS path therefore created chunks with vboBuffers = &chunkBuffers[id] where chunkBuffers was an uninitialised GLuint* member of LevelRenderer. The moment any chunk had geometry to flush, Tesselator::end(true, vboBuffers[l]) dereferenced the garbage pointer and crashed inside Chunk::rebuild(). The previous r3 defensive check was only inside the inner tile loop -- the new crash was in the post-loop t.end() call which reads vboBuffers[l].

Changes

  1. LevelRenderer.cpp -- switch all 4 #ifdef OPENGL_ES guards to #ifdef USE_VBO (constructor, destructor, sky draw, onGraphicsReset). The iOS build behaviour is unchanged because OPENGL_ES => USE_VBO in gles.h. macOS now actually allocates the chunk VBO array.
  2. AppPlatform_macOS.mm -- getDateString -- pin en_US_POSIX locale and yyyy-MM-dd HH:mm format. The engines Font.cpp is a 256-slot bitmap indexed by raw byte value, so the previous medium-style localized date produced Cyrillic on a Russian-locale system which Font rendered as garbage (the "strange symbol" on the world-list screen).
  3. AppPlatform_macOS.mm -- showDialog -- push first-responder into the world-name field once the NSAlert sheet is laid out so users do not have to click the field before typing.

Verification

Cross-built with OSXCross + MacOSX10.9.sdk. Binary is Mach-O 64-bit x86_64, LC_VERSION_MIN_MACOSX = 10.9.

…log field

The world-creation crash on real Mavericks hardware was actually two
distinct bugs stacked on top of each other:

1. LevelRenderer's VBO allocation was gated on OPENGL_ES, but Chunk
   uses VBOs whenever USE_VBO is defined (set in gles.h for iOS GLES 1.1
   AND macOS desktop GL 2.1). On the macOS path chunkBuffers was never
   allocated, so chunk->vboBuffers held uninitialised heap; the moment
   any chunk had geometry to flush, Tesselator::end(true, vboBuffers[l])
   dereferenced garbage and the renderer crashed inside Chunk::rebuild().
   Switch all four guards in LevelRenderer.cpp from OPENGL_ES to USE_VBO
   so the buffer allocation, the sky VBO upload, and the destructor
   match what the renderer actually does.

2. getDateString used the system locale (NSDateFormatterMediumStyle).
   On a Russian-locale Mavericks install that produces Cyrillic; the
   engine's Font.cpp is a 256-slot bitmap indexed by raw byte value,
   so non-ASCII rendered as tile glyphs (the 'strange symbol' the user
   reported on the world-list screen). Pin en_US_POSIX + a fixed
   yyyy-MM-dd HH:mm format so the date is always ASCII.

Also push first-responder into the world-name text field once the
NSAlert sheet is laid out so users don't have to mouse-click the field
before typing -- 'world naming doesn't work' on Mavericks turned out to
be that the focus ring isn't visible until the field is active.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@j92580498-max
j92580498-max merged commit baa7155 into main May 14, 2026
2 checks passed
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.

1 participant