|
R-Type
Distributed multiplayer game engine in C++
|
Graphical rendering system using Raylib. More...
#include <Rendering.hpp>

Public Member Functions | |
| Rendering (EventBus &eventBus) | |
| Constructor with EventBus reference. | |
| ~Rendering () | |
| Destructor. | |
| bool | Initialize (uint32_t width, uint32_t height, const std::string &title) |
| Initialize the rendering system and create window. | |
| void | Shutdown () |
| Stop the rendering system and destroy window. | |
| void | ClearWindow () |
| Clears the window before rendering its content. | |
| void | Render () |
| Perform rendering of current frame. | |
| bool | IsWindowOpen () const |
| Check if window is open. | |
| void | StartGame () |
| Switch immediately to the game scene. | |
| bool | LoadTexture (const std::string &textureName, const std::string &path) |
| Load a texture from file. | |
| void | DrawSprite (const std::string &textureId, float xPosition, float yPosition, float rotation=0.0, float scale=1.0) |
| Draw a sprite on screen. | |
| void | DrawText (const std::string &text, float xPosition, float yPosition, uint32_t size=24) |
| Draw text on screen. | |
| uint32_t | GetWidth () const |
| Get window width. | |
| uint32_t | GetHeight () const |
| Get window height. | |
| bool | WindowShouldClose () const |
| void | UpdateEntity (uint32_t id, RType::Messages::Shared::EntityType type, float x, float y, int health, const std::string ¤tAnimation, int srcX, int srcY, int srcW, int srcH) |
| Update or create an entity for rendering with animation. | |
| void | RemoveEntity (uint32_t id) |
| Remove an entity from rendering. | |
| void | SetMyEntityId (uint32_t id) |
| Set the local player's entity ID. | |
| void | ClearAllEntities () |
| Clear all entities from the rendering cache. | |
| void | SetBackground (const std::string &mainBackground, const std::string ¶llaxBackground, float scrollSpeed, float parallaxSpeedFactor) |
| Set up background layers for parallax scrolling. | |
| void | ClearBackground () |
| Clear background configuration. | |
| void | UpdateBackground (float deltaTime) |
| Update background scroll positions. | |
| void | ShowGameOver (const std::string &reason) |
| Display the game over screen. | |
| bool | IsKeyDown (int key) const |
| Check if a key is currently being held down. | |
| bool | IsGamepadAvailable (int gamepad) const |
| Check if a gamepad is available/connected. | |
| bool | IsGamepadButtonDown (int gamepad, int button) const |
| Check if a gamepad button is currently held down. | |
| void | UpdateInterpolation (float deltaTime) |
| Update interpolation for all entities. | |
| void | UpdatePingTimer (float deltaTime) |
| Update ping display timer (called every frame) | |
| void | MoveEntityLocally (uint32_t entityId, float deltaX, float deltaY) |
| Move an entity locally (client-side prediction) | |
| void | UpdateRoomList (const std::vector< RoomData > &rooms) |
| Update room list from server data. | |
| void | UpdateWaitingRoom (const std::vector< Game::PlayerInfo > &players, const std::string &roomName, bool isHost, bool isSpectator=false) |
| Update waiting room with player list. | |
| void | AddChatMessage (uint32_t playerId, const std::string &playerName, const std::string &message, uint64_t timestamp) |
| Add a chat message to the chat widget. | |
| void | SetOnChatMessageSent (std::function< void(const std::string &)> callback) |
| Set callback for when a chat message is sent. | |
| void | UpdateChatVisibility () |
| Update chat widget visibility based on current scene. | |
| void | SetClientSidePredictionEnabled (bool enabled) |
| Enable or disable client-side prediction for local player. | |
| void | SetReconciliationThreshold (float threshold) |
| Set the reconciliation threshold for client-side prediction. | |
| float | GetReconciliationThreshold () const |
| Get the current reconciliation threshold. | |
| void | SetLocalPlayerMoving (bool moving) |
| Set whether the local player is currently moving. | |
| void | SetPing (uint32_t pingMs) |
| Set the current ping value for display. | |
| void | SetShowPing (bool enabled) |
| Enable/disable ping display. | |
| bool | GetShowPing () const |
| Get ping display state. | |
| void | SetShowFps (bool enabled) |
| Enable/disable FPS display. | |
| bool | GetShowFps () const |
| Get FPS display state. | |
| void | SetPlayerName (const std::string &name) |
| Update the displayed player name (e.g., after authentication) | |
Private Types | |
| enum class | Scene { MENU , IN_GAME , GAME_OVER } |
Private Member Functions | |
| void | InitializeMenus () |
| Initialize UI factory, menus and all related callbacks. | |
| void | ApplyInitialMenuSettings () |
| Apply runtime settings affecting rendering (target FPS, HUD visibility...). | |
| void | InitializeConfirmQuitMenu () |
| void | InitializeSettingsMenu () |
| void | InitializeAccessibilityMenu () |
| void | InitializeKeyBindingsMenu () |
| void | InitializeMainMenu () |
| void | InitializeLoginMenu () |
| void | InitializeServerListMenu () |
| void | InitializeAddServerMenu () |
| void | InitializeRoomListMenu () |
| void | InitializeCreateRoomMenu () |
| void | InitializeWaitingRoomMenu () |
| void | InitializeDefeatMenu () |
| void | InitializeVictoryMenu () |
| void | InitializeConnectionMenu () |
| void | InitializeChatWidget () |
| void | SubscribeToConnectionEvents () |
| void | LoadAccessibilitySettings () |
| void | SaveAccessibilitySettings () |
| void | UpdateFpsCounter () |
| Update FPS counter based on delta time. | |
| void | HandleEscapeKeyInput () |
| Handle ESC key input to toggle settings overlay in-game. | |
| void | UpdateUI () |
| Update all UI elements based on current scene. | |
| void | RenderGameScene () |
| Render the game scene (entities). | |
| void | RenderUI () |
| Render all UI menus based on current scene and overlay state. | |
| void | RenderHUD () |
| Render HUD elements (ping, FPS). | |
Static Private Attributes | |
| static constexpr float | PING_UPDATE_INTERVAL = 1.0f |
Graphical rendering system using Raylib.
Rendering handles the display of all visual game elements:
Architecture:
Definition at line 62 of file Rendering.hpp.
|
strongprivate |
| Enumerator | |
|---|---|
| MENU | |
| IN_GAME | |
| GAME_OVER | |
Definition at line 469 of file Rendering.hpp.
|
explicit |
Constructor with EventBus reference.
| eventBus | Event bus for inter-component communication |
Definition at line 15 of file Rendering.cpp.
References _entityRenderer, and _graphics.
| Rendering::~Rendering | ( | ) |
Destructor.
Frees Raylib wrapper resources (textures, window, etc.)
Definition at line 21 of file Rendering.cpp.
References Shutdown().

| void Rendering::AddChatMessage | ( | uint32_t | playerId, |
| const std::string & | playerName, | ||
| const std::string & | message, | ||
| uint64_t | timestamp | ||
| ) |
Add a chat message to the chat widget.
| playerId | ID of the player who sent the message |
| playerName | Name of the player |
| message | The message text |
| timestamp | Message timestamp |
Definition at line 1344 of file Rendering.cpp.
References _chatWidget.
|
private |
Apply runtime settings affecting rendering (target FPS, HUD visibility...).
Definition at line 89 of file Rendering.cpp.
References _graphics, _settingsMenu, _showFps, _showPing, and Graphics::RaylibGraphics::SetTargetFPS().
Referenced by Initialize().

| void Rendering::ClearAllEntities | ( | ) |
Clear all entities from the rendering cache.
Useful for scene transitions or disconnection.
Definition at line 1207 of file Rendering.cpp.
References _entityRenderer.
| void Rendering::ClearBackground | ( | ) |
Clear background configuration.
Called when leaving the game scene to stop background rendering.
Definition at line 1220 of file Rendering.cpp.
References _entityRenderer.
| void Rendering::ClearWindow | ( | ) |
Clears the window before rendering its content.
Definition at line 715 of file Rendering.cpp.
References _graphics, _initialized, and Graphics::RaylibGraphics::ClearWindow().

| void Rendering::DrawSprite | ( | const std::string & | textureId, |
| float | xPosition, | ||
| float | yPosition, | ||
| float | rotation = 0.0, |
||
| float | scale = 1.0 |
||
| ) |
Draw a sprite on screen.
Adds a sprite to the render queue for current frame.
| textureId | Texture identifier (loaded with loadTexture) |
| x | X position on screen (0 = left) |
| y | Y position on screen (0 = top) |
| rotation | Rotation in degrees (0-360) |
| scale | Scale (1.0 = original size, 2.0 = double) |
Definition at line 1158 of file Rendering.cpp.
References _graphics, and Graphics::RaylibGraphics::DrawTextureEx().

| void Rendering::DrawText | ( | const std::string & | text, |
| float | xPosition, | ||
| float | yPosition, | ||
| uint32_t | size = 24 |
||
| ) |
Draw text on screen.
Displays text with default font.
| text | Text to display (UTF-8 supported) |
| x | X position (origin at top-left of text) |
| y | Y position (origin at top-left of text) |
| size | Font size in pixels (default: 24) |
Definition at line 1163 of file Rendering.cpp.
References _graphics, and Graphics::RaylibGraphics::DrawText().

| uint32_t Rendering::GetHeight | ( | ) | const |
Get window height.
Definition at line 1172 of file Rendering.cpp.
References _height.
| float Rendering::GetReconciliationThreshold | ( | ) | const |
Get the current reconciliation threshold.
Delegates to EntityRenderer.
Definition at line 1278 of file Rendering.cpp.
References _entityRenderer.
| bool Rendering::GetShowFps | ( | ) | const |
| bool Rendering::GetShowPing | ( | ) | const |
| uint32_t Rendering::GetWidth | ( | ) | const |
Get window width.
Definition at line 1168 of file Rendering.cpp.
References _width.
|
private |
Handle ESC key input to toggle settings overlay in-game.
Definition at line 856 of file Rendering.cpp.
References _graphics, _scene, _settingsMenu, _settingsOverlay, Input::KeyBindings::getInstance(), IN_GAME, Graphics::RaylibGraphics::IsKeyPressed(), Game::SettingsMenu::OVERLAY, and Input::PAUSE_MENU.
Referenced by Render().

| bool Rendering::Initialize | ( | uint32_t | width, |
| uint32_t | height, | ||
| const std::string & | title | ||
| ) |
Initialize the rendering system and create window.
Creates a window through Raylib wrapper with specified parameters. Loads basic resources (fonts, shaders).
| width | Window width in pixels |
| height | Window height in pixels |
| title | Window title |
Definition at line 25 of file Rendering.cpp.
References _entityRenderer, _fps, _fpsAccumulator, _fpsFrameCount, _graphics, _height, _initialized, _quitRequested, _showFps, _showPing, _width, ApplyInitialMenuSettings(), InitializeMenus(), Graphics::RaylibGraphics::InitWindow(), LOG_INFO, and LOG_WARNING.

|
private |
Definition at line 207 of file Rendering.cpp.
References _accessibilityMenu, _graphics, _keyBindingsMenu, _keyBindingsOverlay, _settingsMenu, _uiFactory, Graphics::DEUTERANOPIA, Game::AccessibilityMenu::DEUTERANOPIA, Game::AccessibilityMenu::FULLSCREEN, LOG_INFO, Graphics::MONOCHROMACY, Game::AccessibilityMenu::MONOCHROMACY, Graphics::NONE, Game::KeyBindingsMenu::OVERLAY, Graphics::PROTANOPIA, Game::AccessibilityMenu::PROTANOPIA, SaveAccessibilitySettings(), Graphics::RaylibGraphics::SetColorblindFilter(), Graphics::TRITANOPIA, and Game::AccessibilityMenu::TRITANOPIA.
Referenced by InitializeMenus().

|
private |
Definition at line 427 of file Rendering.cpp.
References _addServerMenu, _graphics, _serverListMenu, _soundEffectManager, _uiFactory, LOG_ERROR, and LOG_INFO.
Referenced by InitializeMenus().
|
private |
Definition at line 1326 of file Rendering.cpp.
References _chatWidget, _graphics, _height, _uiFactory, _width, LOG_ERROR, and LOG_INFO.
Referenced by InitializeMenus().
|
private |
Definition at line 104 of file Rendering.cpp.
References _confirmQuitMenu, _confirmQuitOverlay, _mainMenu, _quitRequested, _scene, _soundEffectManager, _uiFactory, and MENU.
Referenced by InitializeMenus().
|
private |
Definition at line 462 of file Rendering.cpp.
References _connectionMenu, _eventBus, _graphics, _mainMenu, _soundEffectManager, _uiFactory, JOIN_GAME, EventBus::publish(), and StartGame().
Referenced by InitializeMenus().

|
private |
Definition at line 567 of file Rendering.cpp.
References _createRoomMenu, _eventBus, _graphics, _roomListMenu, _soundEffectManager, _uiFactory, _waitingRoomMenu, CREATE_ROOM, LOG_INFO, and EventBus::publish().
Referenced by InitializeMenus().

|
private |
Definition at line 491 of file Rendering.cpp.
References _defeatMenu, _eventBus, _mainMenu, _scene, _soundEffectManager, _uiFactory, LEAVE_ROOM, MENU, and EventBus::publish().
Referenced by InitializeMenus().

|
private |
Definition at line 273 of file Rendering.cpp.
References _accessibilityMenu, _graphics, _keyBindingsMenu, _keyBindingsOverlay, _uiFactory, Input::KeyBindings::getInstance(), LOG_INFO, Game::KeyBindingsMenu::OVERLAY, and Input::KeyBindings::SaveToFile().
Referenced by InitializeMenus().

|
private |
Definition at line 362 of file Rendering.cpp.
References _graphics, _loginMenu, _loginOverlay, _mainMenu, _soundEffectManager, and _uiFactory.
Referenced by InitializeMenus().
|
private |
Definition at line 298 of file Rendering.cpp.
References _eventBus, _height, _loginMenu, _loginOverlay, _mainMenu, _quitRequested, _roomListMenu, _serverListMenu, _settingsMenu, _settingsOverlay, _soundEffectManager, _uiFactory, _waitingRoomMenu, _width, AUTO_MATCHMAKING, Game::SettingsMenu::FULLSCREEN, LOG_INFO, EventBus::publish(), and REQUEST_ROOM_LIST.
Referenced by InitializeMenus().

|
private |
Initialize UI factory, menus and all related callbacks.
Keeps Rendering::Initialize() small and focused.
Definition at line 56 of file Rendering.cpp.
References _graphics, _soundEffectManager, _uiFactory, Input::KeyBindings::getInstance(), InitializeAccessibilityMenu(), InitializeAddServerMenu(), InitializeChatWidget(), InitializeConfirmQuitMenu(), InitializeConnectionMenu(), InitializeCreateRoomMenu(), InitializeDefeatMenu(), InitializeKeyBindingsMenu(), InitializeLoginMenu(), InitializeMainMenu(), InitializeRoomListMenu(), InitializeServerListMenu(), InitializeSettingsMenu(), InitializeVictoryMenu(), InitializeWaitingRoomMenu(), LoadAccessibilitySettings(), Input::KeyBindings::LoadFromFile(), LOG_WARNING, and SubscribeToConnectionEvents().
Referenced by Initialize().

|
private |
Definition at line 531 of file Rendering.cpp.
References _createRoomMenu, _eventBus, _graphics, _mainMenu, _roomListMenu, _selectedRoomId, _soundEffectManager, _uiFactory, _waitingRoomMenu, JOIN_GAME, LOG_INFO, and EventBus::publish().
Referenced by InitializeMenus().

|
private |
Definition at line 378 of file Rendering.cpp.
References _addServerMenu, _connectingServerName, _eventBus, _graphics, _isConnecting, _quitRequested, _selectedServerIp, _selectedServerPort, _serverListMenu, _soundEffectManager, _uiFactory, LOG_INFO, EventBus::publish(), and SERVER_CONNECT.
Referenced by InitializeMenus().

|
private |
Definition at line 128 of file Rendering.cpp.
References _accessibilityMenu, _chatWidget, _entityRenderer, _eventBus, _graphics, _mainMenu, _scene, _settingsMenu, _settingsOverlay, _soundEffectManager, _uiFactory, Game::SettingsMenu::FULLSCREEN, LEAVE_ROOM, LOG_INFO, MENU, EventBus::publish(), SetShowFps(), SetShowPing(), Graphics::RaylibGraphics::SetTargetFPS(), and UPDATE_AUTO_MATCHMAKING_PREF.
Referenced by InitializeMenus().

|
private |
Definition at line 511 of file Rendering.cpp.
References _eventBus, _mainMenu, _scene, _soundEffectManager, _uiFactory, _victoryMenu, LEAVE_ROOM, MENU, and EventBus::publish().
Referenced by InitializeMenus().

|
private |
Definition at line 600 of file Rendering.cpp.
References _eventBus, _graphics, _roomListMenu, _soundEffectManager, _uiFactory, _waitingRoomMenu, LEAVE_ROOM, LOG_INFO, EventBus::publish(), and START_GAME_REQUEST.
Referenced by InitializeMenus().

| bool Rendering::IsGamepadAvailable | ( | int | gamepad | ) | const |
Check if a gamepad is available/connected.
| gamepad | Gamepad index (0-3) |
Definition at line 1236 of file Rendering.cpp.
References _graphics, and Graphics::RaylibGraphics::IsGamepadAvailable().

| bool Rendering::IsGamepadButtonDown | ( | int | gamepad, |
| int | button | ||
| ) | const |
Check if a gamepad button is currently held down.
| gamepad | Gamepad index (0-3) |
| button | Button code (GAMEPAD_BUTTON_* constants) |
Definition at line 1240 of file Rendering.cpp.
References _graphics, and Graphics::RaylibGraphics::IsGamepadButtonDown().

| bool Rendering::IsKeyDown | ( | int | key | ) | const |
Check if a key is currently being held down.
| key | Raylib key code |
Definition at line 1232 of file Rendering.cpp.
References _graphics, and Graphics::RaylibGraphics::IsKeyDown().

| bool Rendering::IsWindowOpen | ( | ) | const |
Check if window is open.
Definition at line 1146 of file Rendering.cpp.
References _graphics, _initialized, and Graphics::RaylibGraphics::IsWindowOpen().

|
private |
Definition at line 1373 of file Rendering.cpp.
References _accessibilityMenu, _graphics, Settings::AccessibilitySettings::colorblindFilter, Graphics::DEUTERANOPIA, Game::AccessibilityMenu::DEUTERANOPIA, Settings::DEUTERANOPIA, Settings::LoadSettings(), LOG_INFO, Graphics::MONOCHROMACY, Game::AccessibilityMenu::MONOCHROMACY, Settings::MONOCHROMACY, Graphics::NONE, Game::AccessibilityMenu::NONE, Graphics::PROTANOPIA, Game::AccessibilityMenu::PROTANOPIA, Settings::PROTANOPIA, Graphics::RaylibGraphics::SetColorblindFilter(), Settings::SETTINGS_FILE_PATH, Graphics::TRITANOPIA, Game::AccessibilityMenu::TRITANOPIA, and Settings::TRITANOPIA.
Referenced by InitializeMenus().

| bool Rendering::LoadTexture | ( | const std::string & | textureName, |
| const std::string & | path | ||
| ) |
Load a texture from file.
Loads a texture into memory and associates it with an identifier. Texture is cached for reuse.
| id | Unique identifier for this texture (e.g., "player_ship") |
| path | Path to image file (PNG, JPG, BMP) |
Definition at line 1153 of file Rendering.cpp.
References _graphics, and Graphics::RaylibGraphics::LoadTexture().

| void Rendering::MoveEntityLocally | ( | uint32_t | entityId, |
| float | deltaX, | ||
| float | deltaY | ||
| ) |
Move an entity locally (client-side prediction)
| entityId | Entity ID to move |
| deltaX | Movement in X direction (pixels) |
| deltaY | Movement in Y direction (pixels) |
Used for local player prediction: moves the entity immediately without waiting for server confirmation.
Provides instant (0ms) input response for the local player.
Definition at line 1260 of file Rendering.cpp.
References _entityRenderer.
| void Rendering::RemoveEntity | ( | uint32_t | id | ) |
Remove an entity from rendering.
| id | Entity unique identifier |
Delegates to EntityRenderer. Call when entity is destroyed.
Definition at line 1195 of file Rendering.cpp.
References _entityRenderer.
| void Rendering::Render | ( | ) |
Perform rendering of current frame.
Clears buffer, draws all queued elements, and displays. Must be called once per frame.
Definition at line 808 of file Rendering.cpp.
References _graphics, _initialized, _quitRequested, Graphics::RaylibGraphics::BeginColorblindCapture(), Graphics::RaylibGraphics::ClearWindow(), Graphics::RaylibGraphics::DisplayWindow(), Graphics::RaylibGraphics::EndColorblindCapture(), HandleEscapeKeyInput(), RenderGameScene(), RenderHUD(), RenderUI(), Graphics::RaylibGraphics::StartDrawing(), UpdateFpsCounter(), UpdateUI(), and Graphics::RaylibGraphics::WindowShouldClose().

|
private |
Render the game scene (entities).
Definition at line 1004 of file Rendering.cpp.
References _entityRenderer, _graphics, _scene, Graphics::RaylibGraphics::GetDeltaTime(), and IN_GAME.
Referenced by Render().

|
private |
Render HUD elements (ping, FPS).
Definition at line 1110 of file Rendering.cpp.
References _displayedPing, _fps, _graphics, _showFps, _showPing, Graphics::RaylibGraphics::DrawRectFilled(), Graphics::RaylibGraphics::DrawText(), UI::TextUtils::EstimateTextWidth(), and Graphics::RaylibGraphics::GetWindowWidth().
Referenced by Render().

|
private |
Render all UI menus based on current scene and overlay state.
Definition at line 1012 of file Rendering.cpp.
References _accessibilityMenu, _addServerMenu, _chatWidget, _confirmQuitMenu, _confirmQuitOverlay, _connectionMenu, _createRoomMenu, _defeatMenu, _gameOverReason, _graphics, _height, _keyBindingsMenu, _loginMenu, _mainMenu, _roomListMenu, _scene, _serverListMenu, _settingsMenu, _settingsOverlay, _victoryMenu, _waitingRoomMenu, _width, Graphics::RaylibGraphics::DrawRectFilled(), Graphics::RaylibGraphics::DrawText(), GAME_OVER, and MENU.
Referenced by Render().

|
private |
Definition at line 1428 of file Rendering.cpp.
References _accessibilityMenu, Settings::AccessibilitySettings::colorblindFilter, Game::AccessibilityMenu::DEUTERANOPIA, Settings::DEUTERANOPIA, LOG_ERROR, LOG_INFO, Game::AccessibilityMenu::MONOCHROMACY, Settings::MONOCHROMACY, Settings::NONE, Game::AccessibilityMenu::PROTANOPIA, Settings::PROTANOPIA, Settings::SaveSettings(), Settings::AccessibilitySettings::SetDefaults(), Settings::SETTINGS_FILE_PATH, Game::AccessibilityMenu::TRITANOPIA, and Settings::TRITANOPIA.
Referenced by InitializeAccessibilityMenu().

| void Rendering::SetBackground | ( | const std::string & | mainBackground, |
| const std::string & | parallaxBackground, | ||
| float | scrollSpeed, | ||
| float | parallaxSpeedFactor | ||
| ) |
Set up background layers for parallax scrolling.
| mainBackground | Path to the main background texture |
| parallaxBackground | Path to the parallax layer texture (rendered on top, scrolls slower) |
| scrollSpeed | Base scroll speed in pixels/second |
| parallaxSpeedFactor | Speed factor for parallax layer (0.5 = half speed) |
Called when starting a game with map configuration.
Definition at line 1213 of file Rendering.cpp.
References _entityRenderer.
| void Rendering::SetClientSidePredictionEnabled | ( | bool | enabled | ) |
Enable or disable client-side prediction for local player.
| enabled | true to enable prediction (instant movement), false for interpolation |
Delegates to EntityRenderer. Should be called when toggling prediction mode.
Definition at line 1266 of file Rendering.cpp.
References _entityRenderer.
| void Rendering::SetLocalPlayerMoving | ( | bool | moving | ) |
Set whether the local player is currently moving.
| moving | true if player is actively moving, false if stopped |
This affects reconciliation behavior to prevent rollback when stopping. Delegates to EntityRenderer.
Definition at line 1285 of file Rendering.cpp.
References _entityRenderer.
| void Rendering::SetMyEntityId | ( | uint32_t | id | ) |
Set the local player's entity ID.
| id | Entity ID representing the local player |
Allows visual differentiation of the player's own entity.
Definition at line 1201 of file Rendering.cpp.
References _entityRenderer.
| void Rendering::SetOnChatMessageSent | ( | std::function< void(const std::string &)> | callback | ) |
Set callback for when a chat message is sent.
| callback | Function to call when user sends a message |
Definition at line 1351 of file Rendering.cpp.
References _chatWidget.
| void Rendering::SetPing | ( | uint32_t | pingMs | ) |
Set the current ping value for display.
| pingMs | Ping in milliseconds |
Updates the ping value displayed in the top-right corner. Color changes based on quality:
Definition at line 1291 of file Rendering.cpp.
References _currentPing.
| void Rendering::SetPlayerName | ( | const std::string & | name | ) |
Update the displayed player name (e.g., after authentication)
| name | The player's username |
Definition at line 740 of file Rendering.cpp.
References _mainMenu, and LOG_INFO.
Referenced by SubscribeToConnectionEvents().
| void Rendering::SetReconciliationThreshold | ( | float | threshold | ) |
Set the reconciliation threshold for client-side prediction.
| threshold | Distance in pixels before server correction is applied |
Controls when the client prediction is corrected by the server's authoritative position. Smaller values = more frequent corrections (tighter sync, more visual jitter) Larger values = fewer corrections (looser sync, smoother visuals)
Recommended ranges based on network latency:
Delegates to EntityRenderer.
Definition at line 1272 of file Rendering.cpp.
References _entityRenderer.
| void Rendering::SetShowFps | ( | bool | enabled | ) |
Enable/disable FPS display.
Definition at line 732 of file Rendering.cpp.
References _showFps.
Referenced by InitializeSettingsMenu().
| void Rendering::SetShowPing | ( | bool | enabled | ) |
Enable/disable ping display.
Definition at line 724 of file Rendering.cpp.
References _showPing.
Referenced by InitializeSettingsMenu().
| void Rendering::ShowGameOver | ( | const std::string & | reason | ) |
Display the game over screen.
| reason | Reason for game over (e.g., "Defeat", "Victory") |
Shows the appropriate game over menu based on the reason:
Definition at line 780 of file Rendering.cpp.
References _defeatMenu, _gameOverReason, _scene, _settingsMenu, _settingsOverlay, _victoryMenu, and GAME_OVER.
| void Rendering::Shutdown | ( | ) |
Stop the rendering system and destroy window.
Frees all allocated graphical resources. Closes the window properly.
Definition at line 707 of file Rendering.cpp.
References _graphics, _initialized, and Graphics::RaylibGraphics::CloseWindow().
Referenced by ~Rendering().

| void Rendering::StartGame | ( | ) |
Switch immediately to the game scene.
Forces the rendering system to enter the game mode:
Useful when the game state is already active (e.g. after login flow).
Definition at line 747 of file Rendering.cpp.
References _addServerMenu, _connectionMenu, _createRoomMenu, _entityRenderer, _graphics, _initialized, _mainMenu, _roomListMenu, _scene, _serverListMenu, _settingsMenu, _settingsOverlay, _waitingRoomMenu, IN_GAME, and LOG_INFO.
Referenced by InitializeConnectionMenu().
|
private |
Definition at line 626 of file Rendering.cpp.
References _eventBus, _isConnecting, _loginMenu, _mainMenu, _scene, _serverListMenu, _settingsMenu, APPLY_AUTO_MATCHMAKING_PREF, AUTH_SUCCESS, CONNECTION_FAILED, CONNECTION_SUCCESS, LOG_ERROR, LOG_INFO, LOGIN_FAILED, MENU, EventBus::publish(), REGISTER_FAILED, REGISTER_SUCCESS, REQUEST_ROOM_LIST, ROOM_LIST_RECEIVED, SetPlayerName(), and EventBus::subscribe().
Referenced by InitializeMenus().

| void Rendering::UpdateBackground | ( | float | deltaTime | ) |
Update background scroll positions.
| deltaTime | Time elapsed since last frame (in seconds) |
Should be called every frame during gameplay.
Definition at line 1226 of file Rendering.cpp.
References _entityRenderer.
| void Rendering::UpdateChatVisibility | ( | ) |
Update chat widget visibility based on current scene.
Definition at line 1357 of file Rendering.cpp.
References _chatWidget, _scene, _settingsMenu, _waitingRoomMenu, and IN_GAME.
Referenced by UpdateUI().
| void Rendering::UpdateEntity | ( | uint32_t | id, |
| RType::Messages::Shared::EntityType | type, | ||
| float | x, | ||
| float | y, | ||
| int | health, | ||
| const std::string & | currentAnimation, | ||
| int | srcX, | ||
| int | srcY, | ||
| int | srcW, | ||
| int | srcH | ||
| ) |
Update or create an entity for rendering with animation.
| id | Entity unique identifier |
| type | Entity type (Player, Enemy, Bullet) |
| x | World position X |
| y | World position Y |
| health | Current health (-1 if not applicable) |
| currentAnimation | Current animation clip name |
| srcX | Sprite source X on spritesheet |
| srcY | Sprite source Y on spritesheet |
| srcW | Sprite width |
| srcH | Sprite height |
Delegates to EntityRenderer. Call when receiving GameState updates.
Definition at line 1187 of file Rendering.cpp.
References _entityRenderer.
|
private |
Update FPS counter based on delta time.
Definition at line 845 of file Rendering.cpp.
References _fps, _fpsAccumulator, _fpsFrameCount, _graphics, and Graphics::RaylibGraphics::GetDeltaTime().
Referenced by Render().

| void Rendering::UpdateInterpolation | ( | float | deltaTime | ) |
Update interpolation for all entities.
| deltaTime | Time elapsed since last frame (in seconds) |
Should be called every frame before Render() to smoothly interpolate entity positions between network updates.
Delegates to EntityRenderer.
Definition at line 1244 of file Rendering.cpp.
References _entityRenderer.
| void Rendering::UpdatePingTimer | ( | float | deltaTime | ) |
Update ping display timer (called every frame)
| deltaTime | Time elapsed since last frame (in seconds) |
Updates the displayed ping value once per second to avoid flickering and optimize performance. Should be called from GameLoop's update().
Definition at line 1250 of file Rendering.cpp.
References _currentPing, _displayedPing, _pingUpdateTimer, and PING_UPDATE_INTERVAL.
| void Rendering::UpdateRoomList | ( | const std::vector< RoomData > & | rooms | ) |
Update room list from server data.
| rooms | Vector of room information |
Definition at line 1295 of file Rendering.cpp.
References _roomListMenu, and LOG_INFO.
|
private |
Update all UI elements based on current scene.
Definition at line 885 of file Rendering.cpp.
References _accessibilityMenu, _addServerMenu, _chatWidget, _confirmQuitMenu, _connectionMenu, _createRoomMenu, _defeatMenu, _eventBus, _keyBindingsMenu, _loginMenu, _mainMenu, _roomListMenu, _scene, _serverListMenu, _settingsMenu, _settingsOverlay, _victoryMenu, _waitingRoomMenu, GAME_OVER, LOG_INFO, LOGIN_ACCOUNT, MENU, EventBus::publish(), REGISTER_ACCOUNT, and UpdateChatVisibility().
Referenced by Render().

| void Rendering::UpdateWaitingRoom | ( | const std::vector< Game::PlayerInfo > & | players, |
| const std::string & | roomName, | ||
| bool | isHost, | ||
| bool | isSpectator = false |
||
| ) |
Update waiting room with player list.
| players | Vector of players in the room |
| roomName | Name of the room |
| isHost | Whether local player is the host |
| isSpectator | Whether local player is a spectator |
Definition at line 1310 of file Rendering.cpp.
References _waitingRoomMenu, and LOG_INFO.
| bool Rendering::WindowShouldClose | ( | ) | const |
Definition at line 1176 of file Rendering.cpp.
References _graphics, _initialized, and Graphics::RaylibGraphics::WindowShouldClose().

|
private |
Definition at line 494 of file Rendering.hpp.
Referenced by InitializeAccessibilityMenu(), InitializeKeyBindingsMenu(), InitializeSettingsMenu(), LoadAccessibilitySettings(), RenderUI(), SaveAccessibilitySettings(), and UpdateUI().
|
private |
Definition at line 488 of file Rendering.hpp.
Referenced by InitializeAddServerMenu(), InitializeServerListMenu(), RenderUI(), StartGame(), and UpdateUI().
|
private |
Definition at line 519 of file Rendering.hpp.
Referenced by AddChatMessage(), InitializeChatWidget(), InitializeSettingsMenu(), RenderUI(), SetOnChatMessageSent(), UpdateChatVisibility(), and UpdateUI().
|
private |
Definition at line 496 of file Rendering.hpp.
Referenced by InitializeConfirmQuitMenu(), RenderUI(), and UpdateUI().
|
private |
Definition at line 502 of file Rendering.hpp.
Referenced by InitializeConfirmQuitMenu(), and RenderUI().
|
private |
Definition at line 510 of file Rendering.hpp.
Referenced by InitializeServerListMenu().
|
private |
Definition at line 492 of file Rendering.hpp.
Referenced by InitializeConnectionMenu(), RenderUI(), StartGame(), and UpdateUI().
|
private |
Definition at line 490 of file Rendering.hpp.
Referenced by InitializeCreateRoomMenu(), InitializeRoomListMenu(), RenderUI(), StartGame(), and UpdateUI().
|
private |
Definition at line 522 of file Rendering.hpp.
Referenced by SetPing(), and UpdatePingTimer().
|
private |
Definition at line 498 of file Rendering.hpp.
Referenced by InitializeDefeatMenu(), RenderUI(), ShowGameOver(), and UpdateUI().
|
private |
Definition at line 523 of file Rendering.hpp.
Referenced by RenderHUD(), and UpdatePingTimer().
|
private |
Definition at line 516 of file Rendering.hpp.
Referenced by ClearAllEntities(), ClearBackground(), GetReconciliationThreshold(), Initialize(), InitializeSettingsMenu(), MoveEntityLocally(), RemoveEntity(), RenderGameScene(), Rendering(), SetBackground(), SetClientSidePredictionEnabled(), SetLocalPlayerMoving(), SetMyEntityId(), SetReconciliationThreshold(), StartGame(), UpdateBackground(), UpdateEntity(), and UpdateInterpolation().
|
private |
Definition at line 474 of file Rendering.hpp.
Referenced by InitializeConnectionMenu(), InitializeCreateRoomMenu(), InitializeDefeatMenu(), InitializeMainMenu(), InitializeRoomListMenu(), InitializeServerListMenu(), InitializeSettingsMenu(), InitializeVictoryMenu(), InitializeWaitingRoomMenu(), SubscribeToConnectionEvents(), and UpdateUI().
|
private |
Definition at line 531 of file Rendering.hpp.
Referenced by Initialize(), RenderHUD(), and UpdateFpsCounter().
|
private |
Definition at line 532 of file Rendering.hpp.
Referenced by Initialize(), and UpdateFpsCounter().
|
private |
Definition at line 533 of file Rendering.hpp.
Referenced by Initialize(), and UpdateFpsCounter().
|
private |
Definition at line 472 of file Rendering.hpp.
Referenced by RenderUI(), and ShowGameOver().
|
private |
Definition at line 479 of file Rendering.hpp.
Referenced by ApplyInitialMenuSettings(), ClearWindow(), DrawSprite(), DrawText(), HandleEscapeKeyInput(), Initialize(), InitializeAccessibilityMenu(), InitializeAddServerMenu(), InitializeChatWidget(), InitializeConnectionMenu(), InitializeCreateRoomMenu(), InitializeKeyBindingsMenu(), InitializeLoginMenu(), InitializeMenus(), InitializeRoomListMenu(), InitializeServerListMenu(), InitializeSettingsMenu(), InitializeWaitingRoomMenu(), IsGamepadAvailable(), IsGamepadButtonDown(), IsKeyDown(), IsWindowOpen(), LoadAccessibilitySettings(), LoadTexture(), Render(), RenderGameScene(), RenderHUD(), Rendering(), RenderUI(), Shutdown(), StartGame(), UpdateFpsCounter(), and WindowShouldClose().
|
private |
Definition at line 478 of file Rendering.hpp.
Referenced by GetHeight(), Initialize(), InitializeChatWidget(), InitializeMainMenu(), and RenderUI().
|
private |
Definition at line 475 of file Rendering.hpp.
Referenced by ClearWindow(), Initialize(), IsWindowOpen(), Render(), Shutdown(), StartGame(), and WindowShouldClose().
|
private |
Definition at line 509 of file Rendering.hpp.
Referenced by InitializeServerListMenu(), and SubscribeToConnectionEvents().
|
private |
Definition at line 495 of file Rendering.hpp.
Referenced by InitializeAccessibilityMenu(), InitializeKeyBindingsMenu(), RenderUI(), and UpdateUI().
|
private |
Definition at line 504 of file Rendering.hpp.
Referenced by InitializeAccessibilityMenu(), and InitializeKeyBindingsMenu().
|
private |
Definition at line 497 of file Rendering.hpp.
Referenced by InitializeLoginMenu(), InitializeMainMenu(), RenderUI(), SubscribeToConnectionEvents(), and UpdateUI().
|
private |
Definition at line 503 of file Rendering.hpp.
Referenced by InitializeLoginMenu(), and InitializeMainMenu().
|
private |
Definition at line 486 of file Rendering.hpp.
Referenced by InitializeConfirmQuitMenu(), InitializeConnectionMenu(), InitializeDefeatMenu(), InitializeLoginMenu(), InitializeMainMenu(), InitializeRoomListMenu(), InitializeSettingsMenu(), InitializeVictoryMenu(), RenderUI(), SetPlayerName(), StartGame(), SubscribeToConnectionEvents(), and UpdateUI().
|
private |
Definition at line 524 of file Rendering.hpp.
Referenced by UpdatePingTimer().
|
private |
Definition at line 476 of file Rendering.hpp.
Referenced by Initialize(), InitializeConfirmQuitMenu(), InitializeMainMenu(), InitializeServerListMenu(), and Render().
|
private |
Definition at line 489 of file Rendering.hpp.
Referenced by InitializeCreateRoomMenu(), InitializeMainMenu(), InitializeRoomListMenu(), InitializeWaitingRoomMenu(), RenderUI(), StartGame(), UpdateRoomList(), and UpdateUI().
|
private |
Definition at line 471 of file Rendering.hpp.
Referenced by HandleEscapeKeyInput(), InitializeConfirmQuitMenu(), InitializeDefeatMenu(), InitializeSettingsMenu(), InitializeVictoryMenu(), RenderGameScene(), RenderUI(), ShowGameOver(), StartGame(), SubscribeToConnectionEvents(), UpdateChatVisibility(), and UpdateUI().
|
private |
Definition at line 513 of file Rendering.hpp.
Referenced by InitializeRoomListMenu().
|
private |
Definition at line 507 of file Rendering.hpp.
Referenced by InitializeServerListMenu().
|
private |
Definition at line 508 of file Rendering.hpp.
Referenced by InitializeServerListMenu().
|
private |
Definition at line 487 of file Rendering.hpp.
Referenced by InitializeAddServerMenu(), InitializeMainMenu(), InitializeServerListMenu(), RenderUI(), StartGame(), SubscribeToConnectionEvents(), and UpdateUI().
|
private |
Definition at line 493 of file Rendering.hpp.
Referenced by ApplyInitialMenuSettings(), HandleEscapeKeyInput(), InitializeAccessibilityMenu(), InitializeMainMenu(), InitializeSettingsMenu(), RenderUI(), ShowGameOver(), StartGame(), SubscribeToConnectionEvents(), UpdateChatVisibility(), and UpdateUI().
|
private |
Definition at line 501 of file Rendering.hpp.
Referenced by HandleEscapeKeyInput(), InitializeMainMenu(), InitializeSettingsMenu(), RenderUI(), ShowGameOver(), StartGame(), and UpdateUI().
|
private |
Definition at line 528 of file Rendering.hpp.
Referenced by ApplyInitialMenuSettings(), GetShowFps(), Initialize(), RenderHUD(), and SetShowFps().
|
private |
Definition at line 527 of file Rendering.hpp.
Referenced by ApplyInitialMenuSettings(), GetShowPing(), Initialize(), RenderHUD(), and SetShowPing().
|
private |
Definition at line 482 of file Rendering.hpp.
Referenced by InitializeAddServerMenu(), InitializeConfirmQuitMenu(), InitializeConnectionMenu(), InitializeCreateRoomMenu(), InitializeDefeatMenu(), InitializeLoginMenu(), InitializeMainMenu(), InitializeMenus(), InitializeRoomListMenu(), InitializeServerListMenu(), InitializeSettingsMenu(), InitializeVictoryMenu(), and InitializeWaitingRoomMenu().
|
private |
Definition at line 485 of file Rendering.hpp.
Referenced by InitializeAccessibilityMenu(), InitializeAddServerMenu(), InitializeChatWidget(), InitializeConfirmQuitMenu(), InitializeConnectionMenu(), InitializeCreateRoomMenu(), InitializeDefeatMenu(), InitializeKeyBindingsMenu(), InitializeLoginMenu(), InitializeMainMenu(), InitializeMenus(), InitializeRoomListMenu(), InitializeServerListMenu(), InitializeSettingsMenu(), InitializeVictoryMenu(), and InitializeWaitingRoomMenu().
|
private |
Definition at line 499 of file Rendering.hpp.
Referenced by InitializeVictoryMenu(), RenderUI(), ShowGameOver(), and UpdateUI().
|
private |
Definition at line 491 of file Rendering.hpp.
Referenced by InitializeCreateRoomMenu(), InitializeMainMenu(), InitializeRoomListMenu(), InitializeWaitingRoomMenu(), RenderUI(), StartGame(), UpdateChatVisibility(), UpdateUI(), and UpdateWaitingRoom().
|
private |
Definition at line 477 of file Rendering.hpp.
Referenced by GetWidth(), Initialize(), InitializeChatWidget(), InitializeMainMenu(), and RenderUI().
|
staticconstexprprivate |
Definition at line 525 of file Rendering.hpp.
Referenced by UpdatePingTimer().