R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
IGraphics.hpp
Go to the documentation of this file.
1/*
2** EPITECH PROJECT, 2025
3** r-type
4** File description:
5** IGraphics
6*/
7
8#pragma once
9
10namespace Graphics {
11
16 NONE = 0,
17 PROTANOPIA = 1,
18 DEUTERANOPIA = 2,
19 TRITANOPIA = 3,
20 MONOCHROMACY = 4
21 };
22
32 class IGraphics {
33 public:
37 virtual ~IGraphics() = default;
38
39 // ========== Window Management ==========
40
47 virtual void InitWindow(int width, int height, const char *title) = 0;
48
52 virtual void ClearWindow() = 0;
53
57 virtual void StartDrawing() = 0;
58
62 virtual void DisplayWindow() = 0;
63
68 virtual bool IsWindowOpen() const = 0;
69
73 virtual void CloseWindow() = 0;
74
79 [[nodiscard]] virtual int GetWindowWidth() const = 0;
80
85 [[nodiscard]] virtual int GetWindowHeight() const = 0;
86
87 // ========== Window Configuration ==========
88
93 virtual void SetWindowTitle(const char *title) = 0;
94
100 virtual void SetWindowSize(int width, int height) = 0;
101
105 virtual void ToggleFullScreen() = 0;
106
111 virtual void SetTargetFPS(int fps) = 0;
112
117 virtual void SetClearColor(unsigned int color) = 0;
118
123 virtual void TakeScreenshot(const char *filepath) = 0;
124
125 // ========== Time and Profiling ==========
126
131 virtual float GetTime() const = 0;
132
137 virtual float GetDeltaTime() const = 0;
138
139 // ========== Drawing Primitives ==========
140
149 virtual void DrawRect(int x, int y, int width, int height, unsigned int color) = 0;
150
159 virtual void DrawRectFilled(int x, int y, int width, int height, unsigned int color) = 0;
160
168 virtual void DrawCircle(int x, int y, int radius, unsigned int color) = 0;
169
177 virtual void DrawCircleFilled(int x, int y, int radius, unsigned int color) = 0;
178
179 // ========== Font and Text Rendering ==========
180
187 virtual int LoadFont(const char *filepath, int size) = 0;
188
193 virtual void UnloadFont(int fontHandle) = 0;
194
204 virtual void DrawText(int fontHandle, const char *text, int x, int y, int fontSize,
205 unsigned int color) = 0;
206
213 virtual int GetFontHeight(int fontHandle, int fontSize) = 0;
214
215 // ========== Texture and Image Management ==========
216
222 virtual int LoadTexture(const char *textureName, const char *filepath) = 0;
223
232 virtual int CreateTextureFromMemory(const char *textureName, const void *pixels, int width,
233 int height, int format) = 0;
234
240 virtual void UpdateTexture(const char *textureName, const void *pixels) = 0;
241
246 virtual void UnloadTexture(const char *textureName) = 0;
247
255 virtual void DrawTexture(const char *textureName, int x, int y, unsigned int tint) = 0;
256
270 virtual void DrawTextureEx(const char *textureName, int srcX, int srcY, int srcW, int srcH,
271 float destX, float destY, float rotation, float scale,
272 unsigned int tint) = 0;
273
281 virtual bool GetTextureSize(const char *textureName, int &width, int &height) const = 0;
282
296 virtual void DrawTexturePro(const char *textureName, int srcX, int srcY, int srcW, int srcH,
297 float destX, float destY, float destW, float destH,
298 unsigned int tint) = 0;
299
300 // ========== Input Handling ==========
301
307 virtual bool IsKeyPressed(int key) const = 0;
308
314 virtual bool IsKeyDown(int key) const = 0;
315
321 virtual bool IsKeyReleased(int key) const = 0;
322
323 // ========== Gamepad/Controller Input ==========
324
330 virtual bool IsGamepadAvailable(int gamepad) const = 0;
331
338 virtual bool IsGamepadButtonPressed(int gamepad, int button) const = 0;
339
346 virtual bool IsGamepadButtonDown(int gamepad, int button) const = 0;
347
354 virtual float GetGamepadAxisMovement(int gamepad, int axis) const = 0;
355
361 virtual bool IsMouseButtonPressed(int button) const = 0;
362
368 virtual bool IsMouseButtonDown(int button) const = 0;
369
375 virtual void GetMousePosition(float &x, float &y) const = 0;
376
381 virtual bool WindowShouldClose() const = 0;
382
387 virtual int GetMouseX() const = 0;
388
393 virtual int GetMouseY() const = 0;
394
399 virtual int GetCharPressed() const = 0;
400
405 virtual int GetScreenWidth() const = 0;
406
411 virtual int GetScreenHeight() const = 0;
412
421 virtual void DrawRectangle(int x, int y, int width, int height, unsigned int color) = 0;
422
431 virtual void DrawRectangleLines(int x, int y, int width, int height, unsigned int color) = 0;
432
441 virtual void DrawText(const char *text, int x, int y, int fontSize, unsigned int color) = 0;
442
443 // ========== Colorblind Filter ==========
444
450
455 [[nodiscard]] virtual ColorblindFilterType GetColorblindFilter() const = 0;
456
461 virtual void BeginColorblindCapture() = 0;
462
467 virtual void EndColorblindCapture() = 0;
468 // ========== Audio Management ==========
469
474 virtual void InitAudioDevice() = 0;
475
479 virtual void CloseAudioDevice() = 0;
480
485 virtual bool IsAudioDeviceReady() const = 0;
486
493 virtual bool LoadSound(const char *soundName, const char *filepath) = 0;
494
499 virtual void UnloadSound(const char *soundName) = 0;
500
505 virtual void PlaySound(const char *soundName) = 0;
506
512 virtual void SetSoundVolume(const char *soundName, float volume) = 0;
513
519 virtual bool IsSoundPlaying(const char *soundName) const = 0;
520 };
521} // namespace Graphics
Abstract interface for graphics rendering operations.
Definition IGraphics.hpp:32
virtual void SetWindowTitle(const char *title)=0
Change the window title.
virtual bool IsMouseButtonDown(int button) const =0
Check if a mouse button is currently being held down.
virtual bool LoadSound(const char *soundName, const char *filepath)=0
Load a sound from file.
virtual void DrawText(const char *text, int x, int y, int fontSize, unsigned int color)=0
Draw text using default font (simplified version)
virtual bool IsGamepadButtonDown(int gamepad, int button) const =0
Check if a gamepad button is currently held down.
virtual void SetTargetFPS(int fps)=0
Set the target frames per second for rendering.
virtual void PlaySound(const char *soundName)=0
Play a loaded sound.
virtual bool IsKeyPressed(int key) const =0
Check if a key was pressed (triggered once when key goes down)
virtual int GetWindowHeight() const =0
Get current window height in pixels.
virtual void ClearWindow()=0
Clear the window with the current clear color.
virtual void UnloadSound(const char *soundName)=0
Unload a previously loaded sound.
virtual void DrawCircleFilled(int x, int y, int radius, unsigned int color)=0
Draw a filled circle.
virtual void UpdateTexture(const char *textureName, const void *pixels)=0
Update an existing texture with new pixel data.
virtual void DrawRectFilled(int x, int y, int width, int height, unsigned int color)=0
Draw a filled rectangle.
virtual bool IsAudioDeviceReady() const =0
Check if audio device is ready.
virtual void DisplayWindow()=0
Display the current frame to the window (end drawing and swap buffers)
virtual void DrawText(int fontHandle, const char *text, int x, int y, int fontSize, unsigned int color)=0
Draw text using a loaded font.
virtual void GetMousePosition(float &x, float &y) const =0
Get the current mouse cursor position.
virtual bool IsWindowOpen() const =0
Check if the window is still open.
virtual int CreateTextureFromMemory(const char *textureName, const void *pixels, int width, int height, int format)=0
Create a texture from raw pixel data in memory.
virtual int GetMouseX() const =0
Get the current X position of the mouse cursor.
virtual void CloseAudioDevice()=0
Close the audio device and cleanup audio resources.
virtual bool IsKeyReleased(int key) const =0
Check if a key was released (triggered once when key goes up)
virtual void SetClearColor(unsigned int color)=0
Set the background clear color.
virtual int GetWindowWidth() const =0
Get current window width in pixels.
virtual void DrawTexturePro(const char *textureName, int srcX, int srcY, int srcW, int srcH, float destX, float destY, float destW, float destH, unsigned int tint)=0
Draw a texture with separate width/height scaling (for non-uniform scaling)
virtual void InitWindow(int width, int height, const char *title)=0
Initialize the graphics window.
virtual bool IsSoundPlaying(const char *soundName) const =0
Check if a sound is currently playing.
virtual void StartDrawing()=0
Begin drawing frame (setup canvas for drawing operations)
virtual void SetColorblindFilter(ColorblindFilterType filter)=0
Set the colorblind filter type.
virtual void DrawRect(int x, int y, int width, int height, unsigned int color)=0
Draw a rectangle outline.
virtual void ToggleFullScreen()=0
Toggle between fullscreen and windowed mode.
virtual void UnloadTexture(const char *textureName)=0
Unload a previously loaded texture.
virtual void DrawTexture(const char *textureName, int x, int y, unsigned int tint)=0
Draw a texture at the specified position.
virtual void SetWindowSize(int width, int height)=0
Resize the window.
virtual bool IsGamepadAvailable(int gamepad) const =0
Check if a gamepad is available/connected.
virtual void CloseWindow()=0
Close the graphics window and cleanup resources.
virtual bool IsGamepadButtonPressed(int gamepad, int button) const =0
Check if a gamepad button was pressed this frame.
virtual int GetScreenHeight() const =0
Get the screen height (same as window height)
virtual int LoadTexture(const char *textureName, const char *filepath)=0
Load a texture from an image file.
virtual void DrawTextureEx(const char *textureName, int srcX, int srcY, int srcW, int srcH, float destX, float destY, float rotation, float scale, unsigned int tint)=0
Draw a texture with advanced parameters (rotation, scale, source rectangle)
virtual void BeginColorblindCapture()=0
Begin capturing frame for colorblind filter processing.
virtual float GetTime() const =0
Get elapsed time since initialization.
virtual int GetMouseY() const =0
Get the current Y position of the mouse cursor.
virtual int LoadFont(const char *filepath, int size)=0
Load a font from file.
virtual int GetFontHeight(int fontHandle, int fontSize)=0
Get the height of a font at a given size.
virtual float GetGamepadAxisMovement(int gamepad, int axis) const =0
Get gamepad axis value (for analog sticks and triggers)
virtual void EndColorblindCapture()=0
End capturing and apply the colorblind filter.
virtual int GetCharPressed() const =0
Get the next character from the keyboard input queue.
virtual void SetSoundVolume(const char *soundName, float volume)=0
Set volume for a specific sound.
virtual ColorblindFilterType GetColorblindFilter() const =0
Get the current colorblind filter type.
virtual ~IGraphics()=default
Virtual destructor.
virtual bool IsMouseButtonPressed(int button) const =0
Check if a mouse button was pressed (triggered once when button goes down)
virtual void DrawRectangleLines(int x, int y, int width, int height, unsigned int color)=0
Draw a rectangle outline (alias for DrawRect)
virtual void UnloadFont(int fontHandle)=0
Unload a previously loaded font.
virtual float GetDeltaTime() const =0
Get the time elapsed for the last frame.
virtual bool WindowShouldClose() const =0
Check if the window should close.
virtual bool IsKeyDown(int key) const =0
Check if a key is currently being held down.
virtual void InitAudioDevice()=0
Initialize the audio device.
virtual int GetScreenWidth() const =0
Get the screen width (same as window width)
virtual void TakeScreenshot(const char *filepath)=0
Capture the current screen and save it to a file.
virtual void DrawCircle(int x, int y, int radius, unsigned int color)=0
Draw a circle outline.
virtual void DrawRectangle(int x, int y, int width, int height, unsigned int color)=0
Draw a filled rectangle (alias for DrawRectFilled)
virtual bool GetTextureSize(const char *textureName, int &width, int &height) const =0
Get the dimensions of a loaded texture.
ColorblindFilterType
Colorblind filter types for accessibility.
Definition IGraphics.hpp:15
@ DEUTERANOPIA
Green-blind (reduced green sensitivity)
@ PROTANOPIA
Red-blind (reduced red sensitivity)
@ MONOCHROMACY
Complete color blindness (grayscale)
@ TRITANOPIA
Blue-blind (reduced blue sensitivity)
@ NONE
No filter applied.