Plugins agregados
This commit is contained in:
11
libultraship/include/fast/backends/gfx_direct3d11.h
Normal file
11
libultraship/include/fast/backends/gfx_direct3d11.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifdef ENABLE_DX11
|
||||
|
||||
#ifndef GFX_DIRECT3D11_H
|
||||
#define GFX_DIRECT3D11_H
|
||||
|
||||
#include "gfx_rendering_api.h"
|
||||
#include <imgui.h>
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
185
libultraship/include/fast/backends/gfx_direct3d_common.h
Normal file
185
libultraship/include/fast/backends/gfx_direct3d_common.h
Normal file
@@ -0,0 +1,185 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(ENABLE_DX11) || defined(ENABLE_DX12)
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "../interpreter.h"
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include "gfx_rendering_api.h"
|
||||
#include "d3d11.h"
|
||||
#include "d3dcompiler.h"
|
||||
|
||||
namespace Fast {
|
||||
|
||||
struct PerFrameCB {
|
||||
uint32_t noise_frame;
|
||||
float noise_scale;
|
||||
uint32_t padding[2]; // constant buffers must be multiples of 16 bytes in size
|
||||
};
|
||||
|
||||
struct PerDrawCB {
|
||||
struct Texture {
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t linear_filtering;
|
||||
uint32_t padding;
|
||||
} mTextures[SHADER_MAX_TEXTURES];
|
||||
};
|
||||
|
||||
struct Coord {
|
||||
int x, y;
|
||||
};
|
||||
|
||||
struct TextureData {
|
||||
Microsoft::WRL::ComPtr<ID3D11Texture2D> texture;
|
||||
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> resource_view;
|
||||
Microsoft::WRL::ComPtr<ID3D11SamplerState> sampler_state;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
bool linear_filtering;
|
||||
};
|
||||
|
||||
struct FramebufferDX11 {
|
||||
Microsoft::WRL::ComPtr<ID3D11RenderTargetView> render_target_view;
|
||||
Microsoft::WRL::ComPtr<ID3D11DepthStencilView> depth_stencil_view;
|
||||
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> depth_stencil_srv;
|
||||
uint32_t texture_id;
|
||||
bool has_depth_buffer;
|
||||
uint32_t msaa_level;
|
||||
};
|
||||
|
||||
struct ShaderProgramD3D11 {
|
||||
Microsoft::WRL::ComPtr<ID3D11VertexShader> vertex_shader;
|
||||
Microsoft::WRL::ComPtr<ID3D11PixelShader> pixel_shader;
|
||||
Microsoft::WRL::ComPtr<ID3D11InputLayout> input_layout;
|
||||
Microsoft::WRL::ComPtr<ID3D11BlendState> blend_state;
|
||||
|
||||
uint64_t shader_id0;
|
||||
uint32_t shader_id1;
|
||||
uint8_t numInputs;
|
||||
uint8_t numFloats;
|
||||
bool usedTextures[SHADER_MAX_TEXTURES];
|
||||
};
|
||||
|
||||
class GfxWindowBackendDXGI;
|
||||
|
||||
class GfxRenderingAPIDX11 final : public GfxRenderingAPI {
|
||||
public:
|
||||
GfxRenderingAPIDX11() = default;
|
||||
~GfxRenderingAPIDX11() override;
|
||||
GfxRenderingAPIDX11(GfxWindowBackendDXGI* backend);
|
||||
const char* GetName() override;
|
||||
int GetMaxTextureSize() override;
|
||||
GfxClipParameters GetClipParameters() override;
|
||||
void UnloadShader(struct ShaderProgram* oldPrg) override;
|
||||
void LoadShader(struct ShaderProgram* newPrg) override;
|
||||
struct ShaderProgram* CreateAndLoadNewShader(uint64_t shaderId0, uint32_t shaderId1) override;
|
||||
struct ShaderProgram* LookupShader(uint64_t shaderId0, uint32_t shaderId1) override;
|
||||
void ShaderGetInfo(struct ShaderProgram* prg, uint8_t* numInputs, bool usedTextures[2]) override;
|
||||
uint32_t NewTexture() override;
|
||||
void SelectTexture(int tile, uint32_t textureId) override;
|
||||
void UploadTexture(const uint8_t* rgba32Buf, uint32_t width, uint32_t height) override;
|
||||
void SetSamplerParameters(int sampler, bool linear_filter, uint32_t cms, uint32_t cmt) override;
|
||||
void SetDepthTestAndMask(bool depth_test, bool z_upd) override;
|
||||
void SetZmodeDecal(bool decal) override;
|
||||
void SetViewport(int x, int y, int width, int height) override;
|
||||
void SetScissor(int x, int y, int width, int height) override;
|
||||
void SetUseAlpha(bool useAlpha) override;
|
||||
void DrawTriangles(float buf_vbo[], size_t buf_vbo_len, size_t buf_vbo_num_tris) override;
|
||||
void Init() override;
|
||||
void OnResize() override;
|
||||
void StartFrame() override;
|
||||
void EndFrame() override;
|
||||
void FinishRender() override;
|
||||
int CreateFramebuffer() override;
|
||||
void UpdateFramebufferParameters(int fb_id, uint32_t width, uint32_t height, uint32_t msaa_level,
|
||||
bool opengl_invertY, bool render_target, bool has_depth_buffer,
|
||||
bool can_extract_depth) override;
|
||||
void StartDrawToFramebuffer(int fbId, float noiseScale) override;
|
||||
void CopyFramebuffer(int fbDstId, int fbSrcId, int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0,
|
||||
int dstX1, int dstY1) override;
|
||||
void ClearFramebuffer(bool color, bool depth) override;
|
||||
void ReadFramebufferToCPU(int fbId, uint32_t width, uint32_t height, uint16_t* rgba16Buf) override;
|
||||
void ResolveMSAAColorBuffer(int fbIdTarger, int fbIdSrc) override;
|
||||
std::unordered_map<std::pair<float, float>, uint16_t, hash_pair_ff>
|
||||
GetPixelDepth(int fb_id, const std::set<std::pair<float, float>>& coordinates) override;
|
||||
void* GetFramebufferTextureId(int fbId) override;
|
||||
void SelectTextureFb(int fbId) override;
|
||||
void DeleteTexture(uint32_t texId) override;
|
||||
void SetTextureFilter(FilteringMode mode) override;
|
||||
FilteringMode GetTextureFilter() override;
|
||||
void SetSrgbMode() override;
|
||||
ImTextureID GetTextureById(int id) override;
|
||||
|
||||
PFN_D3D11_CREATE_DEVICE mDX11CreateDevice;
|
||||
Microsoft::WRL::ComPtr<ID3D11DeviceContext> mContext;
|
||||
Microsoft::WRL::ComPtr<ID3D11Device> mDevice;
|
||||
GfxWindowBackendDXGI* mWindowBackend = nullptr;
|
||||
D3D_FEATURE_LEVEL mFeatureLevel;
|
||||
|
||||
private:
|
||||
void CreateDepthStencilObjects(uint32_t width, uint32_t height, uint32_t msaa_count, ID3D11DepthStencilView** view,
|
||||
ID3D11ShaderResourceView** srv);
|
||||
|
||||
HMODULE mDX11Module;
|
||||
|
||||
HMODULE mCompilerModule;
|
||||
pD3DCompile mD3dCompile;
|
||||
|
||||
uint32_t mMsaaNumQualityLevels[D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT];
|
||||
|
||||
Microsoft::WRL::ComPtr<ID3D11RasterizerState> mRasterizerState;
|
||||
Microsoft::WRL::ComPtr<ID3D11DepthStencilState> mDepthStencilState;
|
||||
Microsoft::WRL::ComPtr<ID3D11Buffer> mVertexBuffer;
|
||||
Microsoft::WRL::ComPtr<ID3D11Buffer> mPerFrameCb;
|
||||
Microsoft::WRL::ComPtr<ID3D11Buffer> mPerDrawCb;
|
||||
Microsoft::WRL::ComPtr<ID3D11Buffer> mCoordBuffer;
|
||||
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> mCoordBufferSrv;
|
||||
Microsoft::WRL::ComPtr<ID3D11Buffer> mDepthValueOutputBuffer;
|
||||
Microsoft::WRL::ComPtr<ID3D11Buffer> mDepthValueOutputBufferCopy;
|
||||
Microsoft::WRL::ComPtr<ID3D11UnorderedAccessView> mDepthValueOutputUav;
|
||||
Microsoft::WRL::ComPtr<ID3D11ComputeShader> mComputeShader;
|
||||
Microsoft::WRL::ComPtr<ID3D11ComputeShader> mComputeShaderMsaa;
|
||||
Microsoft::WRL::ComPtr<ID3DBlob> mComputeShaderMsaaBlob;
|
||||
size_t mCoordBufferSize;
|
||||
|
||||
#if DEBUG_D3D
|
||||
Microsoft::WRL::ComPtr<ID3D11Debug> debug;
|
||||
#endif
|
||||
|
||||
PerFrameCB mPerFrameCbData;
|
||||
PerDrawCB mPerDrawCbData;
|
||||
|
||||
std::map<std::pair<uint64_t, uint32_t>, struct ShaderProgramD3D11> mShaderProgramPool;
|
||||
|
||||
std::vector<struct TextureData> mTextures;
|
||||
int mCurrentTile;
|
||||
uint32_t mCurrentTextureIds[SHADER_MAX_TEXTURES];
|
||||
|
||||
std::vector<FramebufferDX11> mFrameBuffers;
|
||||
|
||||
// Current state
|
||||
|
||||
struct ShaderProgramD3D11* mShaderProgram;
|
||||
|
||||
int32_t mRenderTargetHeight;
|
||||
int mCurrentFramebuffer;
|
||||
FilteringMode mCurrentFilterMode = FILTER_NONE;
|
||||
|
||||
// Previous states (to prevent setting states needlessly)
|
||||
|
||||
struct ShaderProgramD3D11* mLastShaderProgram = nullptr;
|
||||
uint32_t mLastVertexBufferStride = 0;
|
||||
Microsoft::WRL::ComPtr<ID3D11BlendState> mLastBlendState = nullptr;
|
||||
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> mLastResourceViews[SHADER_MAX_TEXTURES] = { nullptr, nullptr };
|
||||
Microsoft::WRL::ComPtr<ID3D11SamplerState> mLastSamplerStates[SHADER_MAX_TEXTURES] = { nullptr, nullptr };
|
||||
|
||||
D3D_PRIMITIVE_TOPOLOGY mLastPrimitaveTopology = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED;
|
||||
};
|
||||
|
||||
std::string gfx_direct3d_common_build_shader(size_t& numFloats, const CCFeatures& cc_features,
|
||||
bool include_root_signature, bool three_point_filtering, bool use_srgb);
|
||||
} // namespace Fast
|
||||
#endif
|
||||
#endif
|
||||
120
libultraship/include/fast/backends/gfx_dxgi.h
Normal file
120
libultraship/include/fast/backends/gfx_dxgi.h
Normal file
@@ -0,0 +1,120 @@
|
||||
#pragma once
|
||||
#if defined(ENABLE_DX11) || defined(ENABLE_DX12)
|
||||
|
||||
#include "gfx_rendering_api.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <dxgi1_2.h>
|
||||
|
||||
namespace Fast {
|
||||
|
||||
class GfxWindowBackendDXGI final : public GfxWindowBackend {
|
||||
public:
|
||||
GfxWindowBackendDXGI() = default;
|
||||
~GfxWindowBackendDXGI() override;
|
||||
|
||||
void Init(const char* gameName, const char* apiName, bool startFullScreen, uint32_t width, uint32_t height,
|
||||
int32_t posX, int32_t posY) override;
|
||||
void Close() override;
|
||||
void SetKeyboardCallbacks(bool (*onKeyDown)(int scancode), bool (*onKeyUp)(int scancode),
|
||||
void (*onnAllKeysUp)()) override;
|
||||
void SetMouseCallbacks(bool (*onMouseButtonDown)(int btn), bool (*onnMouseButtonUp)(int btn)) override;
|
||||
void SetFullscreenChangedCallback(void (*onnFullscreenChanged)(bool is_now_fullscreen)) override;
|
||||
void SetFullscreen(bool fullscreen) override;
|
||||
void GetActiveWindowRefreshRate(uint32_t* refreshRate) override;
|
||||
void SetCursorVisibility(bool visability) override;
|
||||
void SetMousePos(int32_t posX, int32_t posY) override;
|
||||
void GetMousePos(int32_t* x, int32_t* y) override;
|
||||
void GetMouseDelta(int32_t* x, int32_t* y) override;
|
||||
void GetMouseWheel(float* x, float* y) override;
|
||||
bool GetMouseState(uint32_t btn) override;
|
||||
void SetMouseCapture(bool capture) override;
|
||||
bool IsMouseCaptured() override;
|
||||
void GetDimensions(uint32_t* width, uint32_t* height, int32_t* posX, int32_t* posY) override;
|
||||
void HandleEvents() override;
|
||||
bool IsFrameReady() override;
|
||||
void SwapBuffersBegin() override;
|
||||
void SwapBuffersEnd() override;
|
||||
double GetTime() override;
|
||||
int GetTargetFps();
|
||||
void SetTargetFps(int fps) override;
|
||||
void SetMaxFrameLatency(int latency) override;
|
||||
const char* GetKeyName(int scancode) override;
|
||||
bool CanDisableVsync() override;
|
||||
bool IsRunning() override;
|
||||
void Destroy() override;
|
||||
bool IsFullscreen() override;
|
||||
|
||||
HWND GetWindowHandle();
|
||||
IDXGISwapChain1* GetSwapChain();
|
||||
// These need to be public to be accessible in the window callback
|
||||
void CreateSwapChain(IUnknown* mDevice, std::function<void()>&& before_destroy_fn);
|
||||
void CreateFactoryAndDevice(bool debug, int d3d_version, class GfxRenderingAPIDX11* self,
|
||||
bool (*createFunc)(class GfxRenderingAPIDX11* self, bool SoftwareRenderer));
|
||||
void OnKeydown(WPARAM wParam, LPARAM lParam);
|
||||
void OnKeyup(WPARAM wParam, LPARAM lParam);
|
||||
void OnMouseButtonDown(int btn);
|
||||
void OnMouseButtonUp(int btn);
|
||||
void HandleRawInputBuffered();
|
||||
void UpdateMousePrevPos();
|
||||
void ApplyMouseCaptureClip();
|
||||
|
||||
std::tuple<HMONITOR, RECT, BOOL> mMonitor; // 0: Handle, 1: Display Monitor Rect, 2: Is_Primary
|
||||
uint32_t current_width, current_height; // Width and height of client areas
|
||||
std::vector<std::tuple<HMONITOR, RECT, BOOL>> monitor_list;
|
||||
int32_t mPosX, mPosY; // Screen coordinates
|
||||
double mDetectedHz;
|
||||
double mDisplayPeriod; // (1000 / dxgi.mDetectedHz) in ms
|
||||
void (*mOnAllKeysUp)(void);
|
||||
POINT mRawMouseDeltaBuf;
|
||||
float mMouseWheel[2];
|
||||
bool mIsMouseCaptured;
|
||||
bool mIsMouseHovered;
|
||||
bool mInFocus;
|
||||
bool mHasMousePosition;
|
||||
|
||||
private:
|
||||
void LoadDxgi();
|
||||
void ApplyMaxFrameLatency(bool first);
|
||||
void ToggleBorderlessWindowFullScreen(bool enable, bool callCallback);
|
||||
|
||||
HWND h_wnd;
|
||||
// These four only apply in windowed mode.
|
||||
|
||||
HMODULE dxgi_module;
|
||||
HRESULT(__stdcall* CreateDXGIFactory1)(REFIID riid, void** factory);
|
||||
HRESULT(__stdcall* CreateDXGIFactory2)(UINT flags, REFIID iid, void** factory);
|
||||
|
||||
bool mLastMaximizedState;
|
||||
|
||||
bool mDXGI11_4;
|
||||
Microsoft::WRL::ComPtr<IDXGIFactory2> mFactory;
|
||||
Microsoft::WRL::ComPtr<IDXGISwapChain1> swap_chain;
|
||||
HANDLE mWaitableObject;
|
||||
Microsoft::WRL::ComPtr<IUnknown> mSwapChainDevice; // D3D11 Device or D3D12 Command Queue
|
||||
std::function<void()> mBeforeDestroySwapChainFn;
|
||||
uint64_t mFrameTimeStamp; // in units of 1/FRAME_INTERVAL_NS_DENOMINATOR nanoseconds
|
||||
std::map<UINT, DXGI_FRAME_STATISTICS> mFrameStats;
|
||||
std::set<std::pair<UINT, UINT>> mPendingFrameStats;
|
||||
bool mDroppedFrame;
|
||||
bool mZeroLatency;
|
||||
uint32_t mMaxFrameLatency;
|
||||
uint32_t mAppliedMaxFrameLatency;
|
||||
HANDLE mTimer;
|
||||
bool mTearingSupport;
|
||||
bool mMousePressed[5];
|
||||
LARGE_INTEGER mPreviousPresentTime;
|
||||
|
||||
RAWINPUTDEVICE mRawInputDevice[1];
|
||||
POINT mPrevMouseCursorPos;
|
||||
};
|
||||
|
||||
} // namespace Fast
|
||||
|
||||
#ifdef DECLARE_GFX_DXGI_FUNCTIONS
|
||||
void ThrowIfFailed(HRESULT res);
|
||||
void ThrowIfFailed(HRESULT res, HWND h_wnd, const char* message);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
224
libultraship/include/fast/backends/gfx_metal.h
Normal file
224
libultraship/include/fast/backends/gfx_metal.h
Normal file
@@ -0,0 +1,224 @@
|
||||
//
|
||||
// gfx_metal.h
|
||||
// libultraship
|
||||
//
|
||||
// Created by David Chavez on 16.08.22.
|
||||
//
|
||||
#pragma once
|
||||
#ifdef __APPLE__
|
||||
|
||||
#include "gfx_rendering_api.h"
|
||||
#include "../interpreter.h"
|
||||
|
||||
#include <imgui_impl_sdl2.h>
|
||||
#include <simd/simd.h>
|
||||
|
||||
static constexpr size_t kMaxVertexBufferPoolSize = 3;
|
||||
static constexpr size_t METAL_MAX_MULTISAMPLE_SAMPLE_COUNT = 8;
|
||||
static constexpr size_t MAX_PIXEL_DEPTH_COORDS = 1024;
|
||||
|
||||
namespace MTL {
|
||||
class Texture;
|
||||
class SamplerState;
|
||||
class CommandBuffer;
|
||||
class RenderPassDescriptor;
|
||||
class RenderCommandEncoder;
|
||||
class SamplerState;
|
||||
class ScissorRect;
|
||||
class Device;
|
||||
class Function;
|
||||
class Buffer;
|
||||
class RenderPipelineState;
|
||||
class CommandQueue;
|
||||
class Viewport;
|
||||
} // namespace MTL
|
||||
|
||||
namespace CA {
|
||||
class MetalDrawable;
|
||||
class MetalLayer;
|
||||
} // namespace CA
|
||||
|
||||
namespace NS {
|
||||
class AutoreleasePool;
|
||||
}
|
||||
|
||||
static int cantor(uint64_t a, uint64_t b) {
|
||||
return (a + b + 1.0) * (a + b) / 2 + b;
|
||||
}
|
||||
|
||||
struct hash_pair_shader_ids {
|
||||
size_t operator()(const std::pair<uint64_t, uint32_t>& p) const {
|
||||
auto value1 = p.first;
|
||||
auto value2 = p.second;
|
||||
return cantor(value1, value2);
|
||||
}
|
||||
};
|
||||
|
||||
namespace Fast {
|
||||
|
||||
struct ShaderProgramMetal {
|
||||
uint64_t shader_id0;
|
||||
uint32_t shader_id1;
|
||||
|
||||
uint8_t numInputs;
|
||||
uint8_t numFloats;
|
||||
bool usedTextures[SHADER_MAX_TEXTURES];
|
||||
|
||||
// hashed by msaa_level
|
||||
MTL::RenderPipelineState* pipeline_state_variants[9];
|
||||
};
|
||||
|
||||
struct TextureDataMetal {
|
||||
MTL::Texture* texture;
|
||||
MTL::Texture* msaaTexture;
|
||||
MTL::SamplerState* sampler;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t filtering;
|
||||
bool linear_filtering;
|
||||
};
|
||||
|
||||
struct FramebufferMetal {
|
||||
MTL::CommandBuffer* mCommandBuffer;
|
||||
MTL::RenderPassDescriptor* mRenderPassDescriptor;
|
||||
MTL::RenderCommandEncoder* mCommandEncoder;
|
||||
|
||||
MTL::Texture* mDepthTexture;
|
||||
MTL::Texture* mMsaaDepthTexture;
|
||||
uint32_t mTextureId;
|
||||
bool mHasDepthBuffer;
|
||||
uint32_t mMsaaLevel;
|
||||
bool mRenderTarget;
|
||||
|
||||
// State
|
||||
bool mHasEndedEncoding;
|
||||
bool mHasBoundVertexShader;
|
||||
bool mHasBoundFragShader;
|
||||
|
||||
struct ShaderProgramMetal* mLastShaderProgram;
|
||||
MTL::Texture* mLastBoundTextures[SHADER_MAX_TEXTURES];
|
||||
MTL::SamplerState* mLastBoundSamplers[SHADER_MAX_TEXTURES];
|
||||
MTL::ScissorRect* mScissorRect;
|
||||
MTL::Viewport* mViewport;
|
||||
|
||||
int8_t mLastDepthTest = -1;
|
||||
int8_t mLastDepthMask = -1;
|
||||
int8_t mLastZmodeDecal = -1;
|
||||
};
|
||||
|
||||
struct FrameUniforms {
|
||||
simd::int1 frameCount;
|
||||
simd::float1 noiseScale;
|
||||
};
|
||||
|
||||
struct DrawUniforms {
|
||||
simd::int1 textureFiltering[SHADER_MAX_TEXTURES];
|
||||
};
|
||||
|
||||
struct CoordUniforms {
|
||||
simd::uint2 coords[MAX_PIXEL_DEPTH_COORDS];
|
||||
};
|
||||
|
||||
class GfxRenderingAPIMetal final : public GfxRenderingAPI {
|
||||
public:
|
||||
~GfxRenderingAPIMetal() override = default;
|
||||
const char* GetName() override;
|
||||
int GetMaxTextureSize() override;
|
||||
GfxClipParameters GetClipParameters() override;
|
||||
void UnloadShader(ShaderProgram* oldPrg) override;
|
||||
void LoadShader(ShaderProgram* newPrg) override;
|
||||
ShaderProgram* CreateAndLoadNewShader(uint64_t shaderId0, uint32_t shaderId1) override;
|
||||
ShaderProgram* LookupShader(uint64_t shaderId0, uint32_t shaderId1) override;
|
||||
void ShaderGetInfo(ShaderProgram* prg, uint8_t* numInputs, bool usedTextures[2]) override;
|
||||
uint32_t NewTexture() override;
|
||||
void SelectTexture(int tile, uint32_t textureId) override;
|
||||
void UploadTexture(const uint8_t* rgba32Buf, uint32_t width, uint32_t height) override;
|
||||
void SetSamplerParameters(int sampler, bool linear_filter, uint32_t cms, uint32_t cmt) override;
|
||||
void SetDepthTestAndMask(bool depth_test, bool z_upd) override;
|
||||
void SetZmodeDecal(bool decal) override;
|
||||
void SetViewport(int x, int y, int width, int height) override;
|
||||
void SetScissor(int x, int y, int width, int height) override;
|
||||
void SetUseAlpha(bool useAlpha) override;
|
||||
void DrawTriangles(float buf_vbo[], size_t buf_vbo_len, size_t buf_vbo_num_tris) override;
|
||||
void Init() override;
|
||||
void OnResize() override;
|
||||
void StartFrame() override;
|
||||
void EndFrame() override;
|
||||
void FinishRender() override;
|
||||
int CreateFramebuffer() override;
|
||||
void UpdateFramebufferParameters(int fb_id, uint32_t width, uint32_t height, uint32_t msaa_level,
|
||||
bool opengl_invertY, bool render_target, bool has_depth_buffer,
|
||||
bool can_extract_depth) override;
|
||||
void StartDrawToFramebuffer(int fbId, float noiseScale) override;
|
||||
void CopyFramebuffer(int fbDstId, int fbSrcId, int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0,
|
||||
int dstX1, int dstY1) override;
|
||||
void ClearFramebuffer(bool color, bool depth) override;
|
||||
void ReadFramebufferToCPU(int fbId, uint32_t width, uint32_t height, uint16_t* rgba16Buf) override;
|
||||
void ResolveMSAAColorBuffer(int fbIdTarger, int fbIdSrc) override;
|
||||
std::unordered_map<std::pair<float, float>, uint16_t, hash_pair_ff>
|
||||
GetPixelDepth(int fb_id, const std::set<std::pair<float, float>>& coordinates) override;
|
||||
void* GetFramebufferTextureId(int fbId) override;
|
||||
void SelectTextureFb(int fbId) override;
|
||||
void DeleteTexture(uint32_t texId) override;
|
||||
void SetTextureFilter(FilteringMode mode) override;
|
||||
FilteringMode GetTextureFilter() override;
|
||||
void SetSrgbMode() override;
|
||||
ImTextureID GetTextureById(int id) override;
|
||||
|
||||
void NewFrame();
|
||||
void SetupFloatingFrame();
|
||||
void RenderDrawData(ImDrawData* drawData);
|
||||
bool MetalInit(SDL_Renderer* renderer);
|
||||
|
||||
private:
|
||||
bool NonUniformThreadGroupSupported();
|
||||
void SetupScreenFramebuffer(uint32_t width, uint32_t height);
|
||||
// Elements that only need to be setup once
|
||||
SDL_Renderer* mRenderer;
|
||||
CA::MetalLayer* mLayer; // CA::MetalLayer*
|
||||
MTL::Device* mDevice;
|
||||
MTL::CommandQueue* mCommandQueue;
|
||||
|
||||
int mCurrentVertexBufferPoolIndex = 0;
|
||||
MTL::Buffer* mVertexBufferPool[kMaxVertexBufferPoolSize];
|
||||
std::unordered_map<std::pair<uint64_t, uint32_t>, struct ShaderProgramMetal, hash_pair_shader_ids>
|
||||
mShaderProgramPool;
|
||||
|
||||
std::vector<struct TextureDataMetal> mTextures;
|
||||
std::vector<FramebufferMetal> mFramebuffers;
|
||||
FrameUniforms mFrameUniforms;
|
||||
CoordUniforms mCoordUniforms;
|
||||
DrawUniforms mDrawUniforms;
|
||||
MTL::Buffer* mFrameUniformBuffer;
|
||||
|
||||
uint32_t mMsaaNumQualityLevels[METAL_MAX_MULTISAMPLE_SAMPLE_COUNT];
|
||||
|
||||
// Depth querying
|
||||
MTL::Buffer* mCoordUniformBuffer;
|
||||
MTL::Buffer* mDepthValueOutputBuffer;
|
||||
size_t mCoordBufferSize;
|
||||
MTL::Function* mDepthComputeFunction;
|
||||
MTL::Function* mConvertToRgb5a1Function;
|
||||
|
||||
// Current state
|
||||
struct ShaderProgramMetal* mShaderProgram;
|
||||
CA::MetalDrawable* mCurrentDrawable;
|
||||
std::set<int> mDrawnFramebuffers;
|
||||
NS::AutoreleasePool* mFrameAutoreleasePool;
|
||||
|
||||
int mCurrentTile;
|
||||
uint32_t mCurrentTextureIds[SHADER_MAX_TEXTURES];
|
||||
|
||||
int32_t mRenderTargetHeight;
|
||||
int mCurrentFramebuffer;
|
||||
size_t mCurrentVertexBufferOffset;
|
||||
FilteringMode mCurrentFilterMode = FILTER_THREE_POINT;
|
||||
|
||||
bool mNonUniformThreadgroupSupported;
|
||||
};
|
||||
|
||||
} // namespace Fast
|
||||
|
||||
bool Metal_IsSupported();
|
||||
|
||||
#endif
|
||||
20
libultraship/include/fast/backends/gfx_metal_shader.h
Normal file
20
libultraship/include/fast/backends/gfx_metal_shader.h
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// gfx_metal_shader.h
|
||||
// libultraship
|
||||
//
|
||||
// Created by David Chavez on 16.08.22.
|
||||
//
|
||||
|
||||
#ifdef __APPLE__
|
||||
#ifdef __cplusplus
|
||||
#pragma once
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
struct CCFeatures;
|
||||
|
||||
MTL::VertexDescriptor* gfx_metal_build_shader(std::string& result, size_t& numFloats, const CCFeatures& cc_features,
|
||||
bool three_point_filtering);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
140
libultraship/include/fast/backends/gfx_opengl.h
Normal file
140
libultraship/include/fast/backends/gfx_opengl.h
Normal file
@@ -0,0 +1,140 @@
|
||||
#ifdef ENABLE_OPENGL
|
||||
#pragma once
|
||||
|
||||
#include "gfx_rendering_api.h"
|
||||
#include "../interpreter.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <SDL2/SDL.h>
|
||||
// #define GL_GLEXT_PROTOTYPES 1
|
||||
#include <GL/glew.h>
|
||||
#elif FOR_WINDOWS
|
||||
#include <GL/glew.h>
|
||||
#include "SDL.h"
|
||||
#define GL_GLEXT_PROTOTYPES 1
|
||||
#include "SDL_opengl.h"
|
||||
#elif __APPLE__
|
||||
#include <SDL2/SDL.h>
|
||||
#include <GL/glew.h>
|
||||
#elif USE_OPENGLES
|
||||
#include <SDL2/SDL.h>
|
||||
#include <GLES3/gl3.h>
|
||||
#else
|
||||
#include <SDL2/SDL.h>
|
||||
#define GL_GLEXT_PROTOTYPES 1
|
||||
#include <SDL2/SDL_opengl.h>
|
||||
#endif
|
||||
namespace Fast {
|
||||
struct ShaderProgram {
|
||||
GLuint openglProgramId;
|
||||
uint8_t numInputs;
|
||||
bool usedTextures[SHADER_MAX_TEXTURES];
|
||||
uint8_t numFloats;
|
||||
GLint attribLocations[16];
|
||||
uint8_t attribSizes[16];
|
||||
uint8_t numAttribs;
|
||||
GLint frameCountLocation;
|
||||
GLint noiseScaleLocation;
|
||||
GLint texture_width_location;
|
||||
GLint texture_height_location;
|
||||
GLint texture_filtering_location;
|
||||
};
|
||||
|
||||
struct FramebufferOGL {
|
||||
uint32_t width, height;
|
||||
bool has_depth_buffer;
|
||||
uint32_t msaa_level;
|
||||
bool invertY;
|
||||
|
||||
GLuint fbo, clrbuf, clrbufMsaa, rbo;
|
||||
};
|
||||
|
||||
struct TextureInfo {
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
uint16_t filtering;
|
||||
};
|
||||
|
||||
class GfxRenderingAPIOGL final : public GfxRenderingAPI {
|
||||
public:
|
||||
~GfxRenderingAPIOGL() override = default;
|
||||
const char* GetName() override;
|
||||
int GetMaxTextureSize() override;
|
||||
GfxClipParameters GetClipParameters() override;
|
||||
void UnloadShader(ShaderProgram* oldPrg) override;
|
||||
void LoadShader(ShaderProgram* newPrg) override;
|
||||
ShaderProgram* CreateAndLoadNewShader(uint64_t shaderId0, uint32_t shaderId1) override;
|
||||
ShaderProgram* LookupShader(uint64_t shaderId0, uint32_t shaderId1) override;
|
||||
void ShaderGetInfo(ShaderProgram* prg, uint8_t* numInputs, bool usedTextures[2]) override;
|
||||
uint32_t NewTexture() override;
|
||||
void SelectTexture(int tile, uint32_t textureId) override;
|
||||
void UploadTexture(const uint8_t* rgba32Buf, uint32_t width, uint32_t height) override;
|
||||
void SetSamplerParameters(int sampler, bool linear_filter, uint32_t cms, uint32_t cmt) override;
|
||||
void SetDepthTestAndMask(bool depth_test, bool z_upd) override;
|
||||
void SetZmodeDecal(bool decal) override;
|
||||
void SetViewport(int x, int y, int width, int height) override;
|
||||
void SetScissor(int x, int y, int width, int height) override;
|
||||
void SetUseAlpha(bool useAlpha) override;
|
||||
void DrawTriangles(float buf_vbo[], size_t buf_vbo_len, size_t buf_vbo_num_tris) override;
|
||||
void Init() override;
|
||||
void OnResize() override;
|
||||
void StartFrame() override;
|
||||
void EndFrame() override;
|
||||
void FinishRender() override;
|
||||
int CreateFramebuffer() override;
|
||||
void UpdateFramebufferParameters(int fb_id, uint32_t width, uint32_t height, uint32_t msaa_level,
|
||||
bool opengl_invertY, bool render_target, bool has_depth_buffer,
|
||||
bool can_extract_depth) override;
|
||||
void StartDrawToFramebuffer(int fbId, float noiseScale) override;
|
||||
void CopyFramebuffer(int fbDstId, int fbSrcId, int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0,
|
||||
int dstX1, int dstY1) override;
|
||||
void ClearFramebuffer(bool color, bool depth) override;
|
||||
void ReadFramebufferToCPU(int fbId, uint32_t width, uint32_t height, uint16_t* rgba16Buf) override;
|
||||
void ResolveMSAAColorBuffer(int fbIdTarger, int fbIdSrc) override;
|
||||
std::unordered_map<std::pair<float, float>, uint16_t, hash_pair_ff>
|
||||
GetPixelDepth(int fb_id, const std::set<std::pair<float, float>>& coordinates) override;
|
||||
void* GetFramebufferTextureId(int fbId) override;
|
||||
void SelectTextureFb(int fbId) override;
|
||||
void DeleteTexture(uint32_t texId) override;
|
||||
void SetTextureFilter(FilteringMode mode) override;
|
||||
FilteringMode GetTextureFilter() override;
|
||||
void SetSrgbMode() override;
|
||||
ImTextureID GetTextureById(int id) override;
|
||||
|
||||
private:
|
||||
void SetUniforms(ShaderProgram* prg) const;
|
||||
std::string BuildFsShader(const CCFeatures& cc_features);
|
||||
void SetPerDrawUniforms();
|
||||
|
||||
std::vector<TextureInfo> textures;
|
||||
GLuint mCurrentTextureIds[SHADER_MAX_TEXTURES];
|
||||
GLuint mLastBoundTextures[SHADER_MAX_TEXTURES] = {};
|
||||
uint8_t mCurrentTile;
|
||||
int8_t mLastActiveTexture = -1;
|
||||
int8_t mLastBlendEnabled = -1;
|
||||
int8_t mLastScissorEnabled = -1;
|
||||
|
||||
std::map<std::pair<uint64_t, uint32_t>, ShaderProgram> mShaderProgramPool;
|
||||
ShaderProgram* mCurrentShaderProgram;
|
||||
ShaderProgram* mLastLoadedShader = nullptr;
|
||||
|
||||
GLuint mOpenglVbo = 0;
|
||||
#if defined(__APPLE__) || defined(USE_OPENGLES)
|
||||
GLuint mOpenglVao;
|
||||
#endif
|
||||
|
||||
uint32_t mFrameCount = 0;
|
||||
|
||||
std::vector<FramebufferOGL> mFrameBuffers;
|
||||
size_t mCurrentFrameBuffer = 0;
|
||||
float mCurrentNoiseScale = 0.0f;
|
||||
FilteringMode mCurrentFilterMode = FILTER_THREE_POINT;
|
||||
|
||||
GLint mMaxMsaaLevel = 1;
|
||||
GLuint mPixelDepthRb = 0;
|
||||
GLuint mPixelDepthFb = 0;
|
||||
size_t mPixelDepthRbSize = 0;
|
||||
};
|
||||
|
||||
} // namespace Fast
|
||||
#endif
|
||||
85
libultraship/include/fast/backends/gfx_rendering_api.h
Normal file
85
libultraship/include/fast/backends/gfx_rendering_api.h
Normal file
@@ -0,0 +1,85 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <unordered_map>
|
||||
#include <set>
|
||||
#include "imconfig.h"
|
||||
|
||||
namespace Fast {
|
||||
struct ShaderProgram;
|
||||
|
||||
struct GfxClipParameters {
|
||||
bool z_is_from_0_to_1;
|
||||
bool invertY;
|
||||
};
|
||||
|
||||
enum FilteringMode { FILTER_THREE_POINT, FILTER_LINEAR, FILTER_NONE };
|
||||
|
||||
// A hash function used to hash a: pair<float, float>
|
||||
struct hash_pair_ff {
|
||||
size_t operator()(const std::pair<float, float>& p) const {
|
||||
const auto hash1 = std::hash<float>{}(p.first);
|
||||
const auto hash2 = std::hash<float>{}(p.second);
|
||||
|
||||
// If hash1 == hash2, their XOR is zero.
|
||||
return (hash1 != hash2) ? hash1 ^ hash2 : hash1;
|
||||
}
|
||||
};
|
||||
|
||||
class GfxRenderingAPI {
|
||||
public:
|
||||
virtual ~GfxRenderingAPI() = default;
|
||||
virtual const char* GetName() = 0;
|
||||
virtual int GetMaxTextureSize() = 0;
|
||||
virtual GfxClipParameters GetClipParameters() = 0;
|
||||
virtual void UnloadShader(ShaderProgram* oldPrg) = 0;
|
||||
virtual void LoadShader(ShaderProgram* newPrg) = 0;
|
||||
virtual ShaderProgram* CreateAndLoadNewShader(uint64_t shaderId0, uint32_t shaderId1) = 0;
|
||||
virtual ShaderProgram* LookupShader(uint64_t shaderId0, uint32_t shaderId1) = 0;
|
||||
virtual void ShaderGetInfo(ShaderProgram* prg, uint8_t* numInputs, bool usedTextures[2]) = 0;
|
||||
virtual uint32_t NewTexture() = 0;
|
||||
virtual void SelectTexture(int tile, uint32_t textureId) = 0;
|
||||
virtual void UploadTexture(const uint8_t* rgba32Buf, uint32_t width, uint32_t height) = 0;
|
||||
virtual void SetSamplerParameters(int sampler, bool linear_filter, uint32_t cms, uint32_t cmt) = 0;
|
||||
virtual void SetDepthTestAndMask(bool depth_test, bool z_upd) = 0;
|
||||
virtual void SetZmodeDecal(bool decal) = 0;
|
||||
virtual void SetViewport(int x, int y, int width, int height) = 0;
|
||||
virtual void SetScissor(int x, int y, int width, int height) = 0;
|
||||
virtual void SetUseAlpha(bool useAlpha) = 0;
|
||||
virtual void DrawTriangles(float buf_vbo[], size_t buf_vbo_len, size_t buf_vbo_num_tris) = 0;
|
||||
virtual void Init() = 0;
|
||||
virtual void OnResize() = 0;
|
||||
virtual void StartFrame() = 0;
|
||||
virtual void EndFrame() = 0;
|
||||
virtual void FinishRender() = 0;
|
||||
virtual int CreateFramebuffer() = 0;
|
||||
virtual void UpdateFramebufferParameters(int fb_id, uint32_t width, uint32_t height, uint32_t msaa_level,
|
||||
bool opengl_invertY, bool render_target, bool has_depth_buffer,
|
||||
bool can_extract_depth) = 0;
|
||||
virtual void StartDrawToFramebuffer(int fbId, float noiseScale) = 0;
|
||||
virtual void CopyFramebuffer(int fbDstId, int fbSrcId, int srcX0, int srcY0, int srcX1, int srcY1, int dstX0,
|
||||
int dstY0, int dstX1, int dstY1) = 0;
|
||||
virtual void ClearFramebuffer(bool color, bool depth) = 0;
|
||||
virtual void ReadFramebufferToCPU(int fbId, uint32_t width, uint32_t height, uint16_t* rgba16Buf) = 0;
|
||||
virtual void ResolveMSAAColorBuffer(int fbIdTarger, int fbIdSrc) = 0;
|
||||
virtual std::unordered_map<std::pair<float, float>, uint16_t, hash_pair_ff>
|
||||
GetPixelDepth(int fb_id, const std::set<std::pair<float, float>>& coordinates) = 0;
|
||||
virtual void* GetFramebufferTextureId(int fbId) = 0;
|
||||
virtual void SelectTextureFb(int fbId) = 0;
|
||||
virtual void DeleteTexture(uint32_t texId) = 0;
|
||||
virtual void SetTextureFilter(FilteringMode mode) = 0;
|
||||
virtual FilteringMode GetTextureFilter() = 0;
|
||||
virtual void SetSrgbMode() = 0;
|
||||
virtual ImTextureID GetTextureById(int id) = 0;
|
||||
|
||||
protected:
|
||||
int8_t mCurrentDepthTest = 0;
|
||||
int8_t mCurrentDepthMask = 0;
|
||||
int8_t mCurrentZmodeDecal = 0;
|
||||
int8_t mLastDepthTest = -1;
|
||||
int8_t mLastDepthMask = -1;
|
||||
int8_t mLastZmodeDecal = -1;
|
||||
bool mSrgbMode = false;
|
||||
};
|
||||
} // namespace Fast
|
||||
4
libultraship/include/fast/backends/gfx_screen_config.h
Normal file
4
libultraship/include/fast/backends/gfx_screen_config.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
#define DESIRED_SCREEN_WIDTH 640
|
||||
#define DESIRED_SCREEN_HEIGHT 480
|
||||
65
libultraship/include/fast/backends/gfx_sdl.h
Normal file
65
libultraship/include/fast/backends/gfx_sdl.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#pragma once
|
||||
|
||||
#include "gfx_window_manager_api.h"
|
||||
namespace Fast {
|
||||
class GfxWindowBackendSDL2 final : public GfxWindowBackend {
|
||||
public:
|
||||
GfxWindowBackendSDL2() = default;
|
||||
~GfxWindowBackendSDL2() override;
|
||||
|
||||
void Init(const char* gameName, const char* apiName, bool startFullScreen, uint32_t width, uint32_t height,
|
||||
int32_t posX, int32_t posY) override;
|
||||
void Close() override;
|
||||
void SetKeyboardCallbacks(bool (*onKeyDown)(int scancode), bool (*onKeyUp)(int scancode),
|
||||
void (*onAllKeysUp)()) override;
|
||||
void SetMouseCallbacks(bool (*onMouseButtonDown)(int btn), bool (*onMouseButtonUp)(int btn)) override;
|
||||
void SetFullscreenChangedCallback(void (*onFullscreenChanged)(bool is_now_fullscreen)) override;
|
||||
void SetFullscreen(bool fullscreen) override;
|
||||
void GetActiveWindowRefreshRate(uint32_t* refreshRate) override;
|
||||
void SetCursorVisibility(bool visability) override;
|
||||
void SetMousePos(int32_t posX, int32_t posY) override;
|
||||
void GetMousePos(int32_t* x, int32_t* y) override;
|
||||
void GetMouseDelta(int32_t* x, int32_t* y) override;
|
||||
void GetMouseWheel(float* x, float* y) override;
|
||||
bool GetMouseState(uint32_t btn) override;
|
||||
void SetMouseCapture(bool capture) override;
|
||||
bool IsMouseCaptured() override;
|
||||
void GetDimensions(uint32_t* width, uint32_t* height, int32_t* posX, int32_t* posY) override;
|
||||
void HandleEvents() override;
|
||||
bool IsFrameReady() override;
|
||||
void SwapBuffersBegin() override;
|
||||
void SwapBuffersEnd() override;
|
||||
double GetTime() override;
|
||||
int GetTargetFps();
|
||||
void SetTargetFps(int fps) override;
|
||||
void SetMaxFrameLatency(int latency) override;
|
||||
const char* GetKeyName(int scancode) override;
|
||||
bool CanDisableVsync() override;
|
||||
bool IsRunning() override;
|
||||
void Destroy() override;
|
||||
bool IsFullscreen() override;
|
||||
|
||||
private:
|
||||
void SetFullscreenImpl(bool on, bool call_callback);
|
||||
void HandleSingleEvent(SDL_Event& event);
|
||||
int TranslateScancode(int scancode) const;
|
||||
int UntranslateScancode(int translatedScancode) const;
|
||||
void OnKeydown(int scancode) const;
|
||||
void OnKeyup(int scancode) const;
|
||||
void OnMouseButtonDown(int btn) const;
|
||||
void OnMouseButtonUp(int btn) const;
|
||||
void SyncFramerateWithTime() const;
|
||||
|
||||
SDL_Window* mWnd;
|
||||
SDL_Rect mCursorClip;
|
||||
SDL_GLContext mCtx;
|
||||
SDL_Renderer* mRenderer;
|
||||
int mSdlToLusTable[512];
|
||||
float mMouseWheelX = 0.0f;
|
||||
float mMouseWheelY = 0.0f;
|
||||
// OTRTODO: These are redundant. Info can be queried from SDL.
|
||||
int mWindowWidth = 640;
|
||||
int mWindowHeight = 480;
|
||||
void (*mOnAllKeysUp)();
|
||||
};
|
||||
} // namespace Fast
|
||||
52
libultraship/include/fast/backends/gfx_window_manager_api.h
Normal file
52
libultraship/include/fast/backends/gfx_window_manager_api.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
namespace Fast {
|
||||
class GfxWindowBackend {
|
||||
public:
|
||||
virtual ~GfxWindowBackend() = default;
|
||||
virtual void Init(const char* gameName, const char* apiName, bool startFullScreen, uint32_t width, uint32_t height,
|
||||
int32_t posX, int32_t posY) = 0;
|
||||
virtual void Close() = 0;
|
||||
virtual void SetKeyboardCallbacks(bool (*mOnKeyDown)(int scancode), bool (*mOnKeyUp)(int scancode),
|
||||
void (*mOnAllKeysUp)()) = 0;
|
||||
virtual void SetMouseCallbacks(bool (*mOnMouseButtonDown)(int btn), bool (*mOnMouseButtonUp)(int btn)) = 0;
|
||||
virtual void SetFullscreenChangedCallback(void (*mOnFullscreenChanged)(bool is_now_fullscreen)) = 0;
|
||||
virtual void SetFullscreen(bool fullscreen) = 0;
|
||||
virtual void GetActiveWindowRefreshRate(uint32_t* refreshRate) = 0;
|
||||
virtual void SetCursorVisibility(bool visability) = 0;
|
||||
virtual void SetMousePos(int32_t posX, int32_t posY) = 0;
|
||||
virtual void GetMousePos(int32_t* x, int32_t* y) = 0;
|
||||
virtual void GetMouseDelta(int32_t* x, int32_t* y) = 0;
|
||||
virtual void GetMouseWheel(float* x, float* y) = 0;
|
||||
virtual bool GetMouseState(uint32_t btn) = 0;
|
||||
virtual void SetMouseCapture(bool capture) = 0;
|
||||
virtual bool IsMouseCaptured() = 0;
|
||||
virtual void GetDimensions(uint32_t* width, uint32_t* height, int32_t* posX, int32_t* posY) = 0;
|
||||
virtual void HandleEvents() = 0;
|
||||
virtual bool IsFrameReady() = 0;
|
||||
virtual void SwapBuffersBegin() = 0;
|
||||
virtual void SwapBuffersEnd() = 0;
|
||||
virtual double GetTime() = 0;
|
||||
virtual int GetTargetFps() = 0;
|
||||
virtual void SetTargetFps(int fps) = 0;
|
||||
virtual void SetMaxFrameLatency(int latency) = 0;
|
||||
virtual const char* GetKeyName(int scancode) = 0;
|
||||
virtual bool CanDisableVsync() = 0;
|
||||
virtual bool IsRunning() = 0;
|
||||
virtual void Destroy() = 0;
|
||||
virtual bool IsFullscreen() = 0;
|
||||
|
||||
protected:
|
||||
void (*mOnFullscreenChanged)(bool isNowFullscreen);
|
||||
bool (*mOnKeyDown)(int scancode);
|
||||
bool (*mOnKeyUp)(int scancode);
|
||||
bool (*mOnMouseButtonDown)(int btn);
|
||||
bool (*mOnMouseButtonUp)(int btn);
|
||||
uint32_t mTargetFps = 60;
|
||||
bool mFullScreen;
|
||||
bool mIsRunning = true;
|
||||
bool mVsyncEnabled = true;
|
||||
};
|
||||
} // namespace Fast
|
||||
Reference in New Issue
Block a user