Skip to content

Bunch of improvements - #6

Open
siddharthroy12 wants to merge 6 commits into
tmpstpdwn:mainfrom
siddharthroy12:cmake-raylib-submodule
Open

Bunch of improvements#6
siddharthroy12 wants to merge 6 commits into
tmpstpdwn:mainfrom
siddharthroy12:cmake-raylib-submodule

Conversation

@siddharthroy12

Copy link
Copy Markdown
  1. Uses cmake instead of make
  2. Uses raylib submodule instead of storing binary in the repo.
  3. Can compile to Mac, Linux and Windows.
  4. Fixed rendering issue on Mac.
  5. Added support for web.
  6. Added CI/CD pipeline to build the project for web, mac, linux, and windows.

siddharthroy12 and others added 6 commits July 22, 2026 22:39
Replace the vendored raylib static libraries and headers with a git
submodule (external/raylib, pinned to tag 6.0), and build the project
with CMake instead of the hand-written Makefile.

- Add CMakeLists.txt that builds raylib from the submodule and links it
  into cTetris; preserves the release/debug flags and the Windows
  resource/icon + -mwindows handling from the old Makefile.
- Add cmake/toolchain-mingw64.cmake for cross-compiling Windows builds.
- Add run.sh to configure, build, and launch in one step.
- Remove lib/, lib_win/, and the vendored raylib.h/raymath.h/rlgl.h.
- Update README build instructions for CMake + submodule, .clangd for
  the new header path, and add .gitignore for build dirs.

Also make the game window resizable and lay the UI out against the true
drawable size, which fixes the UI being clipped on HiDPI (Retina)
displays:

- Set FLAG_WINDOW_RESIZABLE and recompute the whole layout (reloading
  fonts at the new sizes) whenever the window is resized, preserving
  game and score state.
- Issue a one-shot startup resize a few frames in so the framebuffer
  resize event fires and the GL viewport gets corrected, so the layout
  fills the window correctly on first launch.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Build for the browser with `emcmake cmake -B build-web && cmake --build
build-web`, producing cTetris.html/.js/.wasm. raylib is compiled for
PLATFORM_WEB automatically under emcmake.

- CMakeLists.txt: on Emscripten, output an .html page via a custom shell,
  enable ALLOW_MEMORY_GROWTH, use gnu C mode (raylib's miniaudio needs
  EM_ASM), and drop the `-s` strip flag (a settings prefix under emcc).
- main.c: drive the loop with emscripten_set_main_loop() on the web
  (the browser owns the loop) and persist the high score whenever it
  improves, since the web loop never returns to save at exit.
- score.c: store the high score in localStorage on the web instead of
  the (non-persistent) virtual filesystem.
- renderer.c: skip SetTargetFPS() and WindowShouldClose() on the web;
  both call emscripten_sleep(), which would require ASYNCIFY. The browser
  drives the frame rate via requestAnimationFrame instead.
- web/shell.html: minimal self-contained page hosting the canvas.
- README: web build/run instructions and prerequisites.

Verified in-browser: renders correctly and takes keyboard input.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- desktop-linux: native build on ubuntu-latest (installs the raylib
  X11/OpenGL deps), uploads build/cTetris as an artifact.
- web: WebAssembly build via emscripten (setup-emsdk), uploads the
  cTetris.html/.js/.wasm bundle.
- deploy-pages: publishes the web build to GitHub Pages on the default
  branch.

The raylib submodule is fetched via actions/checkout submodules:
recursive.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- desktop-macos: native build on macos-latest, uploads cTetris.
- desktop-windows: cross-compiled from Linux with mingw-w64 using the
  cmake/toolchain-mingw64.cmake toolchain file, uploads cTetris.exe.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
raylib's CMakeLists enables the C++ language, so CMake was falling back
to the host's /usr/bin/c++ for the CXX compiler test and failing when it
hit mingw's Windows link flags. Point CMAKE_CXX_COMPILER at
x86_64-w64-mingw32-g++ in the toolchain file, and install
g++-mingw-w64-x86-64 in the CI job.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@tmpstpdwn tmpstpdwn left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can you provide an image or a video verifying the fix?
Preferably one that captures the entire desktop along with the cTetris window.

@siddharthroy12

Copy link
Copy Markdown
Author
2026-07-23.18-43-38.mov

@tmpstpdwn

tmpstpdwn commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Thanks for the PR. I don't intend to change the build system or merge most of the proposed changes.
My main interest is the macOS scaling/HiDPI fix. If that issue can be isolated along with necessary changes to the Makefile and Readme then I'd be happy to review it.
Also, it looks like the PR branch was created from an older commit rather than the current main, so there are some unrelated differences mixed into the PR.

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.

2 participants