-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for MTKView and Metal APIs
- Loading branch information
Showing
4 changed files
with
754 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
include/Pomdog/Platform/Cocoa/PomdogMetalViewController.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) 2013-2017 mogemimi. Distributed under the MIT license. | ||
|
||
#pragma once | ||
|
||
#include "Pomdog/Basic/Export.hpp" | ||
#include "Pomdog/Signals/detail/ForwardDeclarations.hpp" | ||
#include <memory> | ||
#include <functional> | ||
|
||
#import <Cocoa/Cocoa.h> | ||
#import <MetalKit/MTKView.h> | ||
|
||
namespace Pomdog { | ||
|
||
class Game; | ||
class GameHost; | ||
class GraphicsDevice; | ||
class GraphicsCommandQueue; | ||
|
||
} // namespace Pomdog | ||
|
||
POMDOG_EXPORT | ||
@interface PomdogMetalViewController : NSViewController<MTKViewDelegate> | ||
|
||
- (void)loadAssetsPomdog:(std::shared_ptr<Pomdog::GameHost>)gameHost; | ||
- (void)startGame:(std::shared_ptr<Pomdog::Game>)game; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright (c) 2013-2017 mogemimi. Distributed under the MIT license. | ||
|
||
#pragma once | ||
|
||
#include "Pomdog/Signals/EventQueue.hpp" | ||
#include "Pomdog/Application/GameHost.hpp" | ||
#include <memory> | ||
|
||
#import <MetalKit/MTKView.h> | ||
|
||
namespace Pomdog { | ||
|
||
class Game; | ||
struct PresentationParameters; | ||
|
||
namespace Detail { | ||
namespace Cocoa { | ||
|
||
class GameWindowCocoa; | ||
|
||
class GameHostMetal final : public GameHost { | ||
public: | ||
GameHostMetal( | ||
MTKView* metalView, | ||
const std::shared_ptr<GameWindowCocoa>& window, | ||
const std::shared_ptr<EventQueue>& eventQueue, | ||
const PresentationParameters& presentationParameters); | ||
|
||
~GameHostMetal(); | ||
|
||
void InitializeGame( | ||
const std::weak_ptr<Game>& game, | ||
const std::function<void()>& onCompleted); | ||
|
||
void GameLoop(); | ||
|
||
bool IsMetalSupported() const; | ||
|
||
void Exit() override; | ||
|
||
std::shared_ptr<GameWindow> GetWindow() override; | ||
|
||
std::shared_ptr<GameClock> GetClock() override; | ||
|
||
std::shared_ptr<GraphicsDevice> GetGraphicsDevice() override; | ||
|
||
std::shared_ptr<GraphicsCommandQueue> GetGraphicsCommandQueue() override; | ||
|
||
std::shared_ptr<AudioEngine> GetAudioEngine() override; | ||
|
||
std::shared_ptr<AssetManager> GetAssetManager() override; | ||
|
||
std::shared_ptr<Keyboard> GetKeyboard() override; | ||
|
||
std::shared_ptr<Mouse> GetMouse() override; | ||
|
||
SurfaceFormat GetBackBufferSurfaceFormat() const override; | ||
|
||
DepthFormat GetBackBufferDepthStencilFormat() const override; | ||
|
||
private: | ||
class Impl; | ||
std::unique_ptr<Impl> impl; | ||
}; | ||
|
||
} // namespace Cocoa | ||
} // namespace Detail | ||
} // namespace Pomdog |
Oops, something went wrong.