mirror of
https://github.com/AxioDL/boo.git
synced 2025-12-20 02:15:34 +00:00
Initial integration of Metal API
This commit is contained in:
41
lib/mac/CocoaCommon.hpp
Normal file
41
lib/mac/CocoaCommon.hpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef BOO_COCOACOMMON_HPP
|
||||
#define BOO_COCOACOMMON_HPP
|
||||
#if __APPLE__
|
||||
|
||||
#include <Metal/Metal.h>
|
||||
#include <QuartzCore/CAMetalLayer.h>
|
||||
|
||||
template <class T>
|
||||
class NSPtr
|
||||
{
|
||||
T m_ptr = 0;
|
||||
public:
|
||||
NSPtr() = default;
|
||||
~NSPtr() {[m_ptr release];}
|
||||
NSPtr(T&& recv) : m_ptr(recv) {}
|
||||
NSPtr& operator=(T&& recv) {[m_ptr release]; m_ptr = recv; return *this;}
|
||||
NSPtr(const NSPtr& other) = delete;
|
||||
NSPtr(NSPtr&& other) = default;
|
||||
NSPtr& operator=(const NSPtr& other) = delete;
|
||||
NSPtr& operator=(NSPtr&& other) = default;
|
||||
operator bool() const {return m_ptr != 0;}
|
||||
T get() const {return m_ptr;}
|
||||
void reset() {[m_ptr release]; m_ptr = 0;}
|
||||
};
|
||||
|
||||
namespace boo
|
||||
{
|
||||
struct MetalContext
|
||||
{
|
||||
NSPtr<id<MTLDevice>> m_dev;
|
||||
NSPtr<id<MTLCommandQueue>> m_q;
|
||||
struct Window
|
||||
{
|
||||
CAMetalLayer* m_metalLayer = nullptr;
|
||||
};
|
||||
std::unordered_map<IWindow*, Window> m_windows;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // __APPLE__
|
||||
#endif // BOO_COCOACOMMON_HPP
|
||||
Reference in New Issue
Block a user