Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions assets/shaders/default.vert
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ layout(binding = 0) uniform UniformBufferObject {
mat4 proj;
} ubo;

layout(location = 0) in vec2 inPosition;
layout(location = 0) in vec3 inPosition;
layout(location = 1) in vec3 inColor;
layout(location = 2) in vec2 inTexCoord;

layout(location = 0) out vec3 fragColor;
layout(location = 1) out vec2 fragTexCoord;

void main() {
gl_Position = ubo.proj * ubo.view * ubo.model * vec4(inPosition, 0.0, 1.0);
gl_Position = ubo.proj * ubo.view * ubo.model * vec4(inPosition, 1.0);
fragColor = inColor;
fragTexCoord = inTexCoord;
}
7 changes: 5 additions & 2 deletions src/runtime/application/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@ namespace segfault::application {
}

mRHI = new RHI;
mRHI->init(appName, mSdlWindow);
const bool ret = mRHI->init(appName, mSdlWindow);
if (!ret) {
logMessage(LogType::Error, "Failed to init RHI.");
}

return true;
return ret;
Comment thread
kimkulling marked this conversation as resolved.
}

bool App::mainloop() {
Expand Down
27 changes: 26 additions & 1 deletion src/runtime/application/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ struct SDL_Window;

namespace segfault::application {

//---------------------------------------------------------------------------------------------
/// @class App
/// @brief The App class serves as the main entry point for the application.
///
/// Managing the lifecycle of the application, including initialization, main loop, and
/// shutdown. It encapsulates the core functionality of the application, such as window
/// management, rendering, and event handling.
//---------------------------------------------------------------------------------------------
class SEGFAULT_EXPORT App final {
public:
using Rect = core::Rect;
Expand All @@ -16,11 +24,28 @@ namespace segfault::application {
App(const App &rhs) = delete;
App& operator = (const App& rhs) = delete;

/// @brief The class constructor.
App();

/// @brief The class destructor.
~App();
bool init(const char* appName, const Rect &rect, const char* title, bool fullscreen);

/// @brief Initializes the application with the specified parameters.
/// @param[ in ] appName The name of the application.
/// @param[ in ] rect The dimensions of the application window.
/// @param[ in ] title The title of the application window.
/// @param[ in ] fullscreen Whether to start the application in fullscreen mode.
/// @return True if initialization was successful, false otherwise.
bool init(const char* appName, const Rect &rect, const char* title,bool fullscreen);

/// @brief The main loop of the application, which processes events and renders frames.
/// @return True if the main loop should continue running, false if it should exit.
bool mainloop();

/// @brief Shuts down the application and releases all resources.
void shutdown();

/// @brief Draws a single frame of the application.
void drawFrame();

private:
Expand Down
25 changes: 24 additions & 1 deletion src/runtime/renderer/RHI.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,40 @@ namespace segfault::renderer {

struct RHIImpl;

//---------------------------------------------------------------------------------------------
/// @class RHI
/// @brief RHI (Rendering Hardware Interface) class provides an abstraction layer for rendering operations.
///
/// Allowing for flexibility in choosing different graphics APIs (e.g., Vulkan, DirectX, OpenGL)
/// without changing the higher-level rendering code. It manages the initialization, rendering,
/// and cleanup of graphics resources.
//---------------------------------------------------------------------------------------------
class RHI {
public:
/// @brief Constructs a new RHI instance.
RHI();

/// @brief Destroys the RHI instance.
~RHI();

/// @brief Initializes the RHI with the specified application name and window.
/// @param[ in ] appName The name of the application.
/// @param[ in ] window The SDL window to use for rendering.
/// @return True if initialization was successful, false otherwise.
bool init(const char* appName, SDL_Window* window);

/// @brief Shuts down the RHI.
/// @return True if shutdown was successful, false otherwise.
bool shutdown();

/// @brief Draws a single frame.
void drawFrame();

/// @brief Resizes the rendering surface.
void resize();

private:
RHIImpl *mImpl;
RHIImpl* mImpl{ nullptr };
};

} // namespace segfault::renderer
Loading
Loading