Skip to content

Commit

Permalink
Add documentation comments and refactor bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
mogemimi committed Apr 26, 2020
1 parent ea25369 commit 6d4b8ea
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 16 deletions.
7 changes: 7 additions & 0 deletions include/Pomdog/Platform/Cocoa/Bootstrap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,25 @@ namespace Pomdog::Cocoa {

class POMDOG_EXPORT Bootstrap final {
public:
/// Sets the window where the video is drawn.
void SetWindow(NSWindow* window);

/// Sets to true if OpenGL is enabled, false if Metal is enabled. false by default.
void SetOpenGLEnabled(bool enabled);

/// Sets the format of the back buffer when using the OpenGL renderer.
void SetOpenGLSurfaceFormat(SurfaceFormat surfaceFormat);

/// Sets the format of the depth stencil buffer when using the OpenGL renderer.
void SetOpenGLDepthFormat(DepthFormat depthFormat);

/// Sets an error event handler to a log stream.
void OnError(std::function<void(const std::exception&)>&& onError);

/// Sets an completion event handler to a log stream.
void OnCompleted(std::function<void()>&& onCompleted);

/// Begins running a game loop.
void Run(std::function<std::shared_ptr<Game>(const std::shared_ptr<GameHost>&)>&& createGame);

private:
Expand Down
26 changes: 18 additions & 8 deletions include/Pomdog/Platform/Win32/Bootstrap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,49 @@
#include <memory>

namespace Pomdog {

class Game;
class GameHost;
} // namespace Pomdog

namespace Win32 {
namespace Pomdog::Win32 {

class POMDOG_EXPORT Bootstrap {
class POMDOG_EXPORT Bootstrap final {
public:
/// Sets the instance handle.
void SetInstance(HINSTANCE hInstance) noexcept;

/// Sets the WinMain function's `nCmdShow` parameter.
void SetCommandShow(int cmdShow) noexcept;

/// Sets a window's icon.
void SetIcon(HICON icon) noexcept;

/// Sets a window's small icon.
void SetIconSmall(HICON iconSmall) noexcept;

/// Sets the format of the back buffer.
void SetSurfaceFormat(SurfaceFormat surfaceFormat) noexcept;

/// Sets the format of the depth stencil buffer.
void SetDepthFormat(DepthFormat depthFormat) noexcept;

/// Sets the maximum rate at which the back buffers can be presented. 60 by default.
void SetPresentationInterval(int presentationInterval) noexcept;

/// Sets the size of the swap chain, in pixels.
void SetBackBufferSize(int width, int height) noexcept;

/// Sets to true if the window is in full screen mode, false if it is window mode. false by default.
void SetFullScreen(bool isFullScreen) noexcept;

void SetOpenGLEnabled(bool openGLEnabled) noexcept;
/// Sets to true if OpenGL is enabled, false if Direct3D is enabled. false by default.
void SetOpenGLEnabled(bool enabled) noexcept;

/// Sets an error event handler to a log stream.
void OnError(std::function<void(const std::exception&)> onError);

void Run(
const std::function<std::unique_ptr<Game>(const std::shared_ptr<GameHost>&)>& createApp);
/// Begins running a game loop.
void Run(const std::function<std::unique_ptr<Game>(const std::shared_ptr<GameHost>&)>& createGame);

private:
std::function<void(const std::exception&)> onError;
Expand All @@ -58,5 +69,4 @@ class POMDOG_EXPORT Bootstrap {
bool openGLEnabled = false;
};

} // namespace Win32
} // namespace Pomdog
} // namespace Pomdog::Win32
22 changes: 14 additions & 8 deletions include/Pomdog/Platform/X11/Bootstrap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,37 @@
#include <memory>

namespace Pomdog {

class Game;
class GameHost;
} // namespace Pomdog

namespace X11 {
namespace Pomdog::X11 {

class POMDOG_EXPORT Bootstrap {
class POMDOG_EXPORT Bootstrap final {
public:
/// Sets the format of the back buffer.
void SetSurfaceFormat(SurfaceFormat surfaceFormat) noexcept;

/// Sets the format of the depth stencil buffer.
void SetDepthFormat(DepthFormat depthFormat) noexcept;

/// Sets the maximum rate at which the back buffers can be presented. 60 by default.
void SetPresentationInterval(int presentationInterval) noexcept;

/// Sets the size of the swap chain, in pixels.
void SetBackBufferSize(int width, int height) noexcept;

/// Sets to true if the window is in full screen mode, false if it is window mode. false by default.
void SetFullScreen(bool isFullScreen) noexcept;

void SetOpenGLEnabled(bool openGLEnabled) noexcept;
/// Sets to true if OpenGL is enabled, false if Direct3D is enabled. false by default.
void SetOpenGLEnabled(bool enabled) noexcept;

/// Sets an error event handler to a log stream.
void OnError(std::function<void(const std::exception&)> onError);

void Run(
const std::function<std::unique_ptr<Game>(const std::shared_ptr<GameHost>&)>& createApp);
/// Begins running a game loop.
void Run(const std::function<std::unique_ptr<Game>(const std::shared_ptr<GameHost>&)>& createGame);

private:
std::function<void(const std::exception&)> onError;
Expand All @@ -44,5 +51,4 @@ class POMDOG_EXPORT Bootstrap {
bool isFullScreen = false;
};

} // namespace X11
} // namespace Pomdog
} // namespace Pomdog::X11

0 comments on commit 6d4b8ea

Please sign in to comment.