Fix compile (#199)
* Fixes made so far * Fixes up until linking * Moved GetInterpreter() to a single function under the Engine.h * Updated shader files included with assets, added exception for Linux for including SDL2_net * Removed osSetTime stub(for now) * Adjustments to get it to compile + run * Decoupled GetInterpreter() from the GameEngine Class, corrected a invalid include in SpaghettiGui.cpp --------- Co-authored-by: sitton76 <58642183+sitton76@users.noreply.github.com>
This commit is contained in:
parent
e7415ec072
commit
7cc9894aa1
|
|
@ -401,6 +401,9 @@ if(USE_NETWORKING)
|
|||
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_NETWORKING)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch")
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2_net)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
find_package(SDL2_net REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2_net::SDL2_net)
|
||||
else()
|
||||
find_package(SDL2_net REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2_net::SDL2_net-static)
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ float4 PSMain(PSInput input, float4 screenSpace : SV_Position) : SV_TARGET {
|
|||
float2 tc@{i} = input.uv@{i};
|
||||
@{s = o_clamp[i][0]}
|
||||
@{t = o_clamp[i][1]}
|
||||
@if(s && t)
|
||||
@if(s || t)
|
||||
int2 texSize@{i};
|
||||
g_texture@{i}.GetDimensions(texSize@{i}.x, texSize@{i}.y);
|
||||
@if(s && t)
|
||||
|
|
@ -224,7 +224,7 @@ float4 PSMain(PSInput input, float4 screenSpace : SV_Position) : SV_TARGET {
|
|||
@else
|
||||
float4 blendVal@{i} = float4(0, 0, 0, 0);
|
||||
@end
|
||||
texval@{i} = lerp(texVal@{i}, blendVal@{i}, g_textureMask@{i}.Sample(g_sampler@{i}, tc@{i}).a);
|
||||
texVal@{i} = lerp(texVal@{i}, blendVal@{i}, g_textureMask@{i}.Sample(g_sampler@{i}, tc@{i}).a);
|
||||
@end
|
||||
}
|
||||
@else
|
||||
|
|
|
|||
|
|
@ -147,17 +147,6 @@ float random(float3 value) {
|
|||
return fract(sin(random) * 143758.5453);
|
||||
}
|
||||
|
||||
float4 fromLinear(float4 linearRGB) {
|
||||
float3 threshold = float3(0.0031308);
|
||||
float3 gamma = float3(1.0 / 2.4);
|
||||
float3 scale = float3(12.92);
|
||||
float3 offset = float3(1.055);
|
||||
float3 subtract = float3(0.055);
|
||||
float3 higher = offset * fast::pow(linearRGB.xyz, gamma) - subtract;
|
||||
float3 lower = linearRGB.xyz * scale;
|
||||
return float4(select(higher, lower, linearRGB.xyz < threshold), linearRGB.w);
|
||||
}
|
||||
|
||||
fragment float4 fragmentShader(ProjectedVertex in [[stage_in]], constant FrameUniforms &frameUniforms [[buffer(0)]]
|
||||
@if(o_textures[0])
|
||||
, texture2d<float> uTex0 [[texture(0)]], sampler uTex0Smplr [[sampler(0)]]
|
||||
|
|
@ -288,8 +277,8 @@ fragment float4 fragmentShader(ProjectedVertex in [[stage_in]], constant FrameUn
|
|||
@if(o_invisible)
|
||||
texel.w = 0.0;
|
||||
@end
|
||||
return fromLinear(texel);
|
||||
return texel;
|
||||
@else
|
||||
return fromLinear(float4(texel, 1.0));
|
||||
return float4(texel, 1.0);
|
||||
@end
|
||||
}
|
||||
|
|
@ -44,6 +44,10 @@ out vec4 vOutColor;
|
|||
uniform int frame_count;
|
||||
uniform float noise_scale;
|
||||
|
||||
uniform int texture_width[2];
|
||||
uniform int texture_height[2];
|
||||
uniform int texture_filtering[2];
|
||||
|
||||
#define TEX_OFFSET(off) @{texture}(tex, texCoord - off / texSize)
|
||||
#define WRAP(x, low, high) mod((x)-(low), (high)-(low)) + (low)
|
||||
|
||||
|
|
@ -59,7 +63,6 @@ vec4 fromLinear(vec4 linearRGB){
|
|||
return vec4(mix(higher, lower, cutoff), linearRGB.a);
|
||||
}
|
||||
|
||||
@if(o_current_filter == FILTER_THREE_POINT)
|
||||
vec4 filter3point(in sampler2D tex, in vec2 texCoord, in vec2 texSize) {
|
||||
vec2 offset = fract(texCoord*texSize - vec2(0.5));
|
||||
offset -= step(1.0, offset.x + offset.y);
|
||||
|
|
@ -69,14 +72,16 @@ vec4 filter3point(in sampler2D tex, in vec2 texCoord, in vec2 texSize) {
|
|||
return c0 + abs(offset.x)*(c1-c0) + abs(offset.y)*(c2-c0);
|
||||
}
|
||||
|
||||
vec4 hookTexture2D(in sampler2D tex, in vec2 uv, in vec2 texSize) {
|
||||
vec4 hookTexture2D(in int id, sampler2D tex, in vec2 uv, in vec2 texSize) {
|
||||
@if(o_three_point_filtering)
|
||||
if(texture_filtering[id] == @{FILTER_THREE_POINT}) {
|
||||
return filter3point(tex, uv, texSize);
|
||||
}
|
||||
@else
|
||||
vec4 hookTexture2D(in sampler2D tex, in vec2 uv, in vec2 texSize) {
|
||||
}
|
||||
@end
|
||||
return @{texture}(tex, uv);
|
||||
}
|
||||
@end
|
||||
|
||||
#define TEX_SIZE(tex) vec2(texture_width[tex], texture_height[tex])
|
||||
|
||||
void main() {
|
||||
@for(i in 0..2)
|
||||
|
|
@ -84,11 +89,7 @@ void main() {
|
|||
@{s = o_clamp[i][0]}
|
||||
@{t = o_clamp[i][1]}
|
||||
|
||||
@if(opengles)
|
||||
vec2 texSize@{i} = vec2(textureSize(uTex@{i}, 0));
|
||||
@else
|
||||
vec2 texSize@{i} = textureSize(uTex@{i}, 0);
|
||||
@end
|
||||
vec2 texSize@{i} = TEX_SIZE(@{i});
|
||||
|
||||
@if(!s && !t)
|
||||
vec2 vTexCoordAdj@{i} = vTexCoord@{i};
|
||||
|
|
@ -102,7 +103,7 @@ void main() {
|
|||
@end
|
||||
@end
|
||||
|
||||
vec4 texVal@{i} = hookTexture2D(uTex@{i}, vTexCoordAdj@{i}, texSize@{i});
|
||||
vec4 texVal@{i} = hookTexture2D(@{i}, uTex@{i}, vTexCoordAdj@{i}, texSize@{i});
|
||||
|
||||
@if(o_masks[i])
|
||||
@if(opengles)
|
||||
|
|
@ -111,10 +112,10 @@ void main() {
|
|||
vec2 maskSize@{i} = textureSize(uTexMask@{i}, 0);
|
||||
@end
|
||||
|
||||
vec4 maskVal@{i} = hookTexture2D(uTexMask@{i}, vTexCoordAdj@{i}, maskSize@{i});
|
||||
vec4 maskVal@{i} = hookTexture2D(@{i}, uTexMask@{i}, vTexCoordAdj@{i}, maskSize@{i});
|
||||
|
||||
@if(o_blend[i])
|
||||
vec4 blendVal@{i} = hookTexture2D(uTexBlend@{i}, vTexCoordAdj@{i}, texSize@{i});
|
||||
vec4 blendVal@{i} = hookTexture2D(@{i}, uTexBlend@{i}, vTexCoordAdj@{i}, texSize@{i});
|
||||
@else
|
||||
vec4 blendVal@{i} = vec4(0, 0, 0, 0);
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ typedef u64 OSTime;
|
|||
/* Functions */
|
||||
|
||||
OSTime osGetTime(void);
|
||||
void osSetTime(OSTime time);
|
||||
u32 osSetTimer(OSTimer*, OSTime, u64, OSMesgQueue*, OSMesg);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ s32 osPfsDeleteFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name,
|
|||
s32 osPfsReadWriteFile(OSPfs* pfs, s32 file_no, u8 flag, int offset, int size_in_bytes, u8* data_buffer);
|
||||
s32 osPfsAllocateFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name, u8* ext_name, int file_size_in_bytes,
|
||||
s32* file_no);
|
||||
void osSetTime(OSTime time);
|
||||
s32 osPfsIsPlug(OSMesgQueue* queue, u8* pattern);
|
||||
s32 osPfsInit(OSMesgQueue* queue, OSPfs* pfs, int channel);
|
||||
s32 osPfsNumFiles(OSPfs* pfs, s32* max_files, s32* files_used);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ namespace Editor {
|
|||
Editor::Editor() {
|
||||
}
|
||||
|
||||
std::vector<Mtx> EditorMatrix;
|
||||
void Editor::Load() {
|
||||
printf("Editor: Loading Editor...\n");
|
||||
eObjectPicker.Load();
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ bool IsInGameScreen() {
|
|||
Ship::Coords mouse = wnd->GetMousePos();
|
||||
|
||||
// Define viewport boundaries
|
||||
auto gfx_current_game_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
|
||||
auto gfx_current_game_window_viewport = GetInterpreter()->mGameWindowViewport;
|
||||
int left = gfx_current_game_window_viewport.width;
|
||||
int right = left + OTRGetGameRenderWidth();
|
||||
int top = gfx_current_game_window_viewport.height;
|
||||
|
|
@ -43,7 +43,7 @@ FVector ScreenRayTrace() {
|
|||
Camera* camera = &cameras[0];
|
||||
|
||||
Ship::Coords mouse = wnd->GetMousePos();
|
||||
auto gfx_current_game_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
|
||||
auto gfx_current_game_window_viewport = GetInterpreter()->mGameWindowViewport;
|
||||
mouse.x -= gfx_current_game_window_viewport.width;
|
||||
mouse.y -= gfx_current_game_window_viewport.height;
|
||||
// Get screen dimensions
|
||||
|
|
|
|||
|
|
@ -49,14 +49,11 @@ float gInterpolationStep = 0.0f;
|
|||
#include "audio/GameAudio.h"
|
||||
}
|
||||
|
||||
std::weak_ptr<Fast::Interpreter> GameEngine::mInterpreter;
|
||||
|
||||
std::shared_ptr<Fast::Interpreter> GameEngine::GetInterpreter() {
|
||||
auto intP = mInterpreter.lock();
|
||||
if (!intP) {
|
||||
assert(false && "Lost reference to Fast::Interpreter");
|
||||
}
|
||||
return intP;
|
||||
Fast::Interpreter* GetInterpreter() {
|
||||
return static_pointer_cast<Fast::Fast3dWindow>(Ship::Context::GetInstance()->GetWindow())
|
||||
->GetInterpreterWeak()
|
||||
.lock()
|
||||
.get();
|
||||
}
|
||||
|
||||
GameEngine* GameEngine::Instance;
|
||||
|
|
@ -543,7 +540,7 @@ extern "C" void GameEngine_UnloadSequence(const uint8_t seqId) {
|
|||
}
|
||||
|
||||
extern "C" float GameEngine_GetAspectRatio() {
|
||||
auto gfx_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
|
||||
auto gfx_current_dimensions = GetInterpreter()->mCurDimensions;
|
||||
return gfx_current_dimensions.aspect_ratio;
|
||||
}
|
||||
|
||||
|
|
@ -617,8 +614,7 @@ extern "C" void Timer_SetValue(int32_t* address, int32_t value) {
|
|||
// }
|
||||
|
||||
extern "C" float OTRGetAspectRatio() {
|
||||
auto gfx_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
|
||||
return gfx_current_dimensions.aspect_ratio;
|
||||
return GetInterpreter()->mCurDimensions.aspect_ratio;
|
||||
}
|
||||
|
||||
extern "C" float OTRGetDimensionFromLeftEdge(float v) {
|
||||
|
|
@ -661,22 +657,18 @@ extern "C" uint32_t OTRCalculateCenterOfAreaFromLeftEdge(int32_t center) {
|
|||
|
||||
// Gets the width of the current render target area
|
||||
extern "C" uint32_t OTRGetGameRenderWidth() {
|
||||
auto gfx_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
|
||||
return gfx_current_dimensions.width;
|
||||
return GetInterpreter()->mCurDimensions.width;
|
||||
}
|
||||
|
||||
// Gets the height of the current render target area
|
||||
extern "C" uint32_t OTRGetGameRenderHeight() {
|
||||
auto gfx_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
|
||||
return gfx_current_dimensions.height;
|
||||
return GetInterpreter()->mCurDimensions.height;
|
||||
}
|
||||
|
||||
extern "C" uint32_t OTRGetGameViewportWidth() {
|
||||
auto gfx_current_game_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
|
||||
return gfx_current_game_window_viewport.width;
|
||||
return GetInterpreter()->mGameWindowViewport.width;
|
||||
}
|
||||
|
||||
extern "C" uint32_t OTRGetGameViewportHeight() {
|
||||
auto gfx_current_game_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
|
||||
return gfx_current_game_window_viewport.height;
|
||||
return GetInterpreter()->mGameWindowViewport.height;
|
||||
}
|
||||
|
|
@ -25,6 +25,8 @@
|
|||
#define NUM_AUDIO_CHANNELS 2
|
||||
#define SAMPLES_PER_FRAME (SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 2)
|
||||
|
||||
Fast::Interpreter* GetInterpreter();
|
||||
|
||||
struct CtlEntry;
|
||||
struct AudioBankSample;
|
||||
struct AudioSequenceData;
|
||||
|
|
@ -46,9 +48,6 @@ class GameEngine {
|
|||
ImFont* fontMonoLarger;
|
||||
ImFont* fontMonoLargest;
|
||||
|
||||
static std::weak_ptr<Fast::Interpreter> mInterpreter;
|
||||
static std::shared_ptr<Fast::Interpreter> GetInterpreter();
|
||||
|
||||
std::unordered_map<std::string, uint8_t> bankMapTable;
|
||||
GameEngine();
|
||||
static bool GenAssetFile();
|
||||
|
|
@ -82,6 +81,7 @@ class GameEngine {
|
|||
private:
|
||||
ImFont* CreateFontWithSize(float size, std::string fontPath = "");
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#endif
|
||||
|
||||
#if defined(ENABLE_DX11) || defined(ENABLE_DX12)
|
||||
#include <graphic/Fast3D/gfx_direct3d11.h>
|
||||
#include <graphic/Fast3D/backends/gfx_direct3d11.h>
|
||||
#include <imgui_impl_dx11.h>
|
||||
#include <imgui_impl_win32.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -50,10 +50,10 @@ void SetupGuiElements() {
|
|||
mPortMenu = std::make_shared<PortMenu>("gOpenMenu", "Port Menu");
|
||||
gui->SetMenu(mPortMenu);
|
||||
|
||||
mMultiplayerWindow = gui->GetGuiWindow("Multiplayer");
|
||||
if (mMultiplayerWindow == nullptr) {
|
||||
SPDLOG_ERROR("Could not find multiplayer window");
|
||||
}
|
||||
//mMultiplayerWindow = gui->GetGuiWindow("Multiplayer");
|
||||
//if (mMultiplayerWindow == nullptr) {
|
||||
// SPDLOG_ERROR("Could not find multiplayer window");
|
||||
//}
|
||||
|
||||
mStatsWindow = gui->GetGuiWindow("Stats");
|
||||
if (mStatsWindow == nullptr) {
|
||||
|
|
|
|||
|
|
@ -96,12 +96,12 @@ void RegisterResolutionWidgets() {
|
|||
|
||||
// Resolution visualiser
|
||||
mPortMenu->AddWidget(path, "Viewport dimensions: {} x {}", WIDGET_TEXT).PreFunc([](WidgetInfo& info) {
|
||||
auto captured_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
|
||||
auto captured_window_viewport = GetInterpreter()->mGameWindowViewport;
|
||||
info.name = fmt::format("Viewport dimensions: {} x {}", captured_window_viewport.width,
|
||||
captured_window_viewport.height);
|
||||
});
|
||||
mPortMenu->AddWidget(path, "Internal resolution: {} x {}", WIDGET_TEXT).PreFunc([](WidgetInfo& info) {
|
||||
auto captured_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
|
||||
auto captured_current_dimensions = GetInterpreter()->mCurDimensions;
|
||||
info.name =
|
||||
fmt::format("Internal resolution: {} x {}", captured_current_dimensions.width, captured_current_dimensions.height);
|
||||
});
|
||||
|
|
@ -174,8 +174,8 @@ void RegisterResolutionWidgets() {
|
|||
}
|
||||
} else if (showHorizontalResField) { // Show calculated aspect ratio
|
||||
if (item_aspectRatio) {
|
||||
auto gfx_current_game_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
|
||||
auto gfx_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
|
||||
auto gfx_current_game_window_viewport = GetInterpreter()->mGameWindowViewport;
|
||||
auto gfx_current_dimensions = GetInterpreter()->mCurDimensions;
|
||||
ImGui::Dummy({ 0, 2 });
|
||||
const float resolvedAspectRatio = (float)gfx_current_dimensions.width / gfx_current_dimensions.height;
|
||||
ImGui::Text("Aspect ratio: %.2f:1", resolvedAspectRatio);
|
||||
|
|
@ -502,8 +502,8 @@ void UpdateResolutionVars() {
|
|||
|
||||
short integerScale_maximumBounds = 1; // can change when window is resized
|
||||
// This is mostly just for UX purposes, as Fit Automatically logic is part of LUS.
|
||||
auto gfx_current_game_window_viewport = GameEngine::GetInterpreter().get()->mGameWindowViewport;
|
||||
auto gfx_current_dimensions = GameEngine::GetInterpreter().get()->mCurDimensions;
|
||||
auto gfx_current_game_window_viewport = GetInterpreter()->mGameWindowViewport;
|
||||
auto gfx_current_dimensions = GetInterpreter()->mCurDimensions;
|
||||
if (((float)gfx_current_game_window_viewport.width / gfx_current_game_window_viewport.height) >
|
||||
((float)gfx_current_dimensions.width / gfx_current_dimensions.height)) {
|
||||
// Scale to window height
|
||||
|
|
|
|||
|
|
@ -96,11 +96,6 @@ s32 osPfsAllocateFile(OSPfs* pfs, u16 company_code, u32 game_code, u8* game_name
|
|||
return PFS_NO_ERROR;
|
||||
}
|
||||
|
||||
#ifndef __SWITCH__
|
||||
void osSetTime(OSTime time) {
|
||||
}
|
||||
#endif
|
||||
|
||||
s32 osPfsIsPlug(OSMesgQueue* queue, u8* pattern) {
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue