Skip to content

feat: implement sprite renderer component - #38

Merged
MichalSzandar merged 4 commits into
mainfrom
feat/sprite-renderer
Oct 20, 2026
Merged

MichalSzandar merged 4 commits into
mainfrom
feat/sprite-renderer

Conversation

@MichalSzandar

@MichalSzandar MichalSzandar commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Sprite rendering

  • New SpriteRenderer component, registered for the proto's renderer entry. It draws img_path stretched over the object's Transform, rotated clockwise about its centre.
  • An empty img_path is allowed and draws nothing. An image path that can't be loaded fails the parse.
  • When there is an image, the Transform must be finite, within float range, and have a positive width and height.
  • If SDL fails to draw a sprite, the run stops before that frame is shown and before its marker is sent.

Image loading and upload

  • New Image and ImageLibrary classes. Each scene loads each image file once while parsing, and sprites showing the same file share it.
  • New onRenderTargetReady hook on components and the scene. The Renderer constructor calls it to upload images to the GPU before the first frame.
  • Loaded images stay in memory, so textures are rebuilt after SDL_RENDER_DEVICE_RESET. The new Renderer::pollEvents() handles this, and Runtime also uses it while waiting for the EEG stream.
  • Each texture keeps its SDL_Renderer alive.

Asset paths

  • Every component creator now receives a ComponentBuildContext. Relative paths resolve against the folder holding the .neuroz; absolute paths are used as they are.
  • Parser::parseStream(stream, assetRoot) takes the asset folder. The Blink and MarkerEmitter creators take the new parameter but don't use it.

Window

  • The default window is created hidden, and Runtime shows it only after the scene is uploaded. A failed upload never shows a window to the participant.

Build and CI

  • SDL2_image is a new dependency, added in CMake and in the CI packages.
  • runtime_core now links the whole static library (runtime_core_archive). Otherwise the linker drops the code that registers components (REGISTER_COMPONENT).

Proto

  • No net change: texture_path stays, and the runtime reads only img_path.

Tests

  • New test files:
    • sprite_renderer_test
    • image_library_test
    • sprite_scene_test
    • component_build_context_test
    • temp_dir_test
    • registration_tests, a separate executable that checks every component is linked in
  • New cases in RendererTest and runtime_test:
    • the render target reaching components
    • re-upload after a device reset
    • a failed draw sending no marker
    • the hidden window being shown
  • Shared test helpers in tests/utils/: SdlTestUtils.hpp (software renderer, reading pixels, writing a PNG) and TempDir.hpp. Both existing test suites now use them instead of their own copies.

Docs

  • README: component lifecycle and asset paths, the upload and window order, how registration works, and a Components status table with open questions.
  • CLAUDE.md: a step for adding new components to registration_tests.

@MichalSzandar MichalSzandar linked an issue Oct 12, 2026 that may be closed by this pull request
@MichalSzandar MichalSzandar self-assigned this Oct 12, 2026
@MichalSzandar
MichalSzandar requested a balanced review from Copilot October 13, 2026 09:41

Copilot AI left a comment

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Nowik11 Nowik11 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In my opinion there is no reason to change signature of proto file just to rename a field.

Comment thread protoFiles/neuronide.proto
Comment thread src/scene/components/SpriteRenderer.cpp Outdated

@Nowik11 Nowik11 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

except from that lgtm

Comment thread src/scene/components/SpriteRenderer.cpp

@Nowik11 Nowik11 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lgtm

Images are now decoded once per scene into an ImageLibrary owned by
Scene, however many sprites show the same file. The library uploads
every image when the render target is ready and keeps the decoded
pixels, so textures can be rebuilt after the GPU loses them.
@MichalSzandar
MichalSzandar merged commit 033961a into main Oct 20, 2026
2 checks passed
@MichalSzandar
MichalSzandar deleted the feat/sprite-renderer branch October 20, 2026 08:58
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.

Implement Sprite renderer update function

3 participants