Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions AI/Interfaces/C/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ macro (configure_native_skirmish_ai mySourceDirRel_var additionalSources_var

# Create a list of all the AIs own source files
get_native_sources_recursive(mySources "${mySourceDir}" "${myDir}")
if (APPLE AND CMAKE_OSX_ARCHITECTURES MATCHES "arm64|aarch64")
set(appleArm64AngelScriptCallfunc "${mySourceDir}/lib/angelscript/source/as_callfunc_arm64_xcode.S")
if (EXISTS "${appleArm64AngelScriptCallfunc}")
enable_language(ASM)
list(APPEND mySources "${appleArm64AngelScriptCallfunc}")
endif (EXISTS "${appleArm64AngelScriptCallfunc}")
endif (APPLE AND CMAKE_OSX_ARCHITECTURES MATCHES "arm64|aarch64")

# Compile the library
add_library(${myTarget} MODULE ${mySources} ${additionalSources} ${myVersionDepFile})
Expand Down
1 change: 0 additions & 1 deletion AI/Wrappers/CUtils/Util.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,4 +911,3 @@ const char* util_map_getValueByKey(

return value;
}

8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ if (USE_ASAN)
endif (MSVC)
endif (USE_ASAN)

option(RECOIL_MACOS_SDL3_EGL "Use project-local SDL3 Cocoa windowing and Mesa Cocoa EGL/Zink on macOS" ${APPLE})

### Tracy related stuff
option(RECOIL_DETAILED_TRACY_ZONING "Enable additional detailed tracy zones (only enable this for testing/debugging)" FALSE)
if (RECOIL_DETAILED_TRACY_ZONING)
Expand All @@ -315,6 +317,9 @@ endif (RECOIL_DETAILED_TRACY_ZONING)
# Note the missing REQUIRED, as headless & dedi may not depend on those.
# So req. checks are done in the build target's CMakeLists.txt.
find_package(SDL2 MODULE)
if (APPLE AND RECOIL_MACOS_SDL3_EGL)
find_package(MesaEGL MODULE)
endif()

find_package_static(DevIL 1.8.0 REQUIRED)

Expand Down Expand Up @@ -442,6 +447,9 @@ option(ENABLE_STREFLOP "build Spring with streflop support (REQUIRED FOR MULTIPL

if (ENABLE_STREFLOP)
set(STREFLOP_AUTO ON CACHE BOOL "Enable STREFLOP autodetection" FORCE)
if (IS_ARM64_BUILD)
set(STREFLOP_NEON ON CACHE BOOL "Use ARM NEON for deterministic ARM64 streflop" FORCE)
endif ()
else ()
add_definitions(-DNOT_USING_STREFLOP)
endif ()
Expand Down
4 changes: 4 additions & 0 deletions rts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ if(DEBUG_GLSTATE)
add_definitions(-DDEBUG_GLSTATE)
endif()

if(ENABLE_STREFLOP AND STREFLOP_NEON)
add_definitions(-DSTREFLOP_NEON)
endif()

### give error when not found
find_package_static(DevIL REQUIRED)

Expand Down
2 changes: 1 addition & 1 deletion rts/Game/Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ void CCamera::LoadMatrices() const
void CCamera::LoadViewport() const
{
RECOIL_DETAILED_TRACY_ZONE;
glViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
globalRendering->LoadDefaultFramebufferViewport(viewport[0], viewport[1], viewport[2], viewport[3]);
}


Expand Down
5 changes: 2 additions & 3 deletions rts/Game/UI/MiniMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,12 @@ void CMiniMap::SetAspectRatioGeometry(const float& viewSizeX, const float& viewS

void CMiniMap::LoadDualViewport() const {
glEnable(GL_SCISSOR_TEST);
glScissor(globalRendering->dualViewPosX, globalRendering->dualViewPosY, globalRendering->dualViewSizeX, globalRendering->dualViewSizeY);
globalRendering->LoadDefaultFramebufferScissor(globalRendering->dualViewPosX, globalRendering->dualViewPosY, globalRendering->dualViewSizeX, globalRendering->dualViewSizeY);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glDisable(GL_SCISSOR_TEST);

glViewport(curPos.x, curPos.y, curDim.x, curDim.y);
globalRendering->LoadDefaultFramebufferViewport(curPos.x, curPos.y, curDim.x, curDim.y);
}


Expand Down Expand Up @@ -2065,4 +2065,3 @@ void CMiniMap::SetClipPlanes(const bool lua) const


/******************************************************************************/

8 changes: 8 additions & 0 deletions rts/Game/UI/MouseHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,11 @@ void CMouseHandler::ShowMouse()

hideCursor = false;

#if defined(RECOIL_MACOS_SDL3_EGL)
SDL_SetWindowRelativeMouseMode(globalRendering->GetWindow(), false);
#else
SDL_SetRelativeMouseMode(SDL_FALSE);
#endif

// don't use SDL_ShowCursor here since it would cause flickering with hwCursor
// (by switching between default cursor and later the real one, e.g. `attack`)
Expand All @@ -802,7 +806,11 @@ void CMouseHandler::HideMouse()
// this way the mouse position will never change so it is also unnecessary to call
// SDL_WarpMouseInWindow and handle the associated wart of filtering motion events
// technically supersedes SDL_ShowCursor as well
#if defined(RECOIL_MACOS_SDL3_EGL)
SDL_SetWindowRelativeMouseMode(globalRendering->GetWindow(), true);
#else
SDL_SetRelativeMouseMode(SDL_TRUE);
#endif

const int2 viewMouseCenter = GetViewMouseCenter();

Expand Down
23 changes: 11 additions & 12 deletions rts/Lua/LuaOpenGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "Map/BaseGroundDrawer.h"
#include "Map/MapInfo.h"
#include "Map/ReadMap.h"
#include "Rendering/Fonts/CFontTexture.h"
#include "Rendering/Fonts/glFont.h"
#include "Rendering/GlobalRendering.h"
#include "Rendering/LineDrawer.h"
Expand Down Expand Up @@ -829,6 +830,8 @@ void LuaOpenGL::EnableDrawScreenCommon()
EnableCommon(DRAW_SCREEN);
resetMatrixFunc = ResetScreenMatrices;

glMatrixMode(GL_TEXTURE);
glLoadIdentity();
SetupScreenMatrices();
SetupScreenLighting();
ResetGLState();
Expand Down Expand Up @@ -2856,8 +2859,9 @@ int LuaOpenGL::TexRect(lua_State* L)
const float x2 = luaL_checkfloat(L, 3);
const float y2 = luaL_checkfloat(L, 4);

// Spring's textures get loaded with a vertical flip
// We change that for the default settings.
// Legacy Lua textured-quad helper, not GL_TEXTURE_RECTANGLE semantics:
// 4/6-arg calls use normalized coords with Spring's default vertical flip,
// while 8-arg calls pass explicit caller-provided coords through unchanged.

if (args <= 6) {
float s1 = 0.0f;
Expand Down Expand Up @@ -3184,7 +3188,7 @@ int LuaOpenGL::Scissor(lua_State* L)
const GLsizei h = (GLsizei)luaL_checkint(L, 4);
if (w < 0) luaL_argerror(L, 3, "<width> must be greater than or equal zero!");
if (h < 0) luaL_argerror(L, 4, "<height> must be greater than or equal zero!");
glScissor(x + globalRendering->viewPosX, y + globalRendering->viewPosY, w, h);
globalRendering->LoadDefaultFramebufferScissor(x + globalRendering->viewPosX, y + globalRendering->viewPosY, w, h);
}
else {
luaL_error(L, "Incorrect arguments to gl.Scissor()");
Expand Down Expand Up @@ -3212,7 +3216,7 @@ int LuaOpenGL::Viewport(lua_State* L)
if (w < 0) luaL_argerror(L, 3, "<width> must be greater than or equal zero!");
if (h < 0) luaL_argerror(L, 4, "<height> must be greater than or equal zero!");

glViewport(x, y, w, h);
globalRendering->LoadDefaultFramebufferViewport(x, y, w, h);
return 0;
}

Expand Down Expand Up @@ -4355,9 +4359,6 @@ int LuaOpenGL::CopyToTexture(lua_State* L)
if (tex == nullptr)
return 0;

glBindTexture(tex->target, tex->id);
glEnable(tex->target); // leave it bound and enabled

const auto xoff = (GLint)luaL_checknumber(L, 2);
const auto yoff = (GLint)luaL_checknumber(L, 3);
const auto x = (GLint)luaL_checknumber(L, 4);
Expand All @@ -4367,10 +4368,9 @@ int LuaOpenGL::CopyToTexture(lua_State* L)
const auto target = (GLenum)luaL_optnumber(L, 8, tex->target);
const auto level = (GLenum)luaL_optnumber(L, 9, 0);

const auto texBind = GL::TexBind(tex->target, tex->id);
glCopyTexSubImage2D(target, level, xoff, yoff, x, y, w, h);

if (tex->target != GL_TEXTURE_2D) {glDisable(tex->target);}

return 0;
}

Expand Down Expand Up @@ -4401,9 +4401,7 @@ int LuaOpenGL::RenderToTexture(lua_State* L)
return 0;

GLint currentFBO = 0;
if (drawMode == DRAW_WORLD_SHADOW) {
glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &currentFBO);
}
glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &currentFBO);

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, tex->fbo);

Expand Down Expand Up @@ -6147,6 +6145,7 @@ int LuaOpenGL::CreateList(lua_State* L)
SMatrixStateData matData = GetLuaContextData(L)->glMatrixTracker.GetMatrixState();
GetLuaContextData(L)->glMatrixTracker.PopMatrixState(prevMSD, false);
glEndList();
CFontTexture::UploadPendingGlyphAtlasTextures();

if (error != 0) {
glDeleteLists(list, 1);
Expand Down
8 changes: 8 additions & 0 deletions rts/Menu/SelectMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,18 @@ bool SelectMenu::HandleEventSelf(const SDL_Event& ev)
{
switch (ev.type) {
case SDL_KEYDOWN: {
#if defined(RECOIL_MACOS_SDL3_EGL)
if (ev.key.key == SDLK_ESCAPE) {
#else
if (ev.key.keysym.sym == SDLK_ESCAPE) {
#endif
LOG("[SelectMenu] user exited");
Quit();
#if defined(RECOIL_MACOS_SDL3_EGL)
} else if (ev.key.key == SDLK_RETURN) {
#else
} else if (ev.key.keysym.sym == SDLK_RETURN) {
#endif
Single();
return true;
}
Expand Down
14 changes: 14 additions & 0 deletions rts/Rendering/Fonts/CFontTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,20 @@ void CFontTexture::Update() {
eventHandler.FontsChanged();
}

void CFontTexture::UploadPendingGlyphAtlasTextures() {
assert(CFontTexture::sync.GetThreadSafety() || Threading::IsMainThread());
auto lock = CFontTexture::sync.GetScopedLock();

for (const auto& font : allFonts) {
auto lf = font.lock();
if (!lf)
continue;

if (lf->GlyphAtlasTextureNeedsUpload())
lf->UploadGlyphAtlasTexture();
}
}

const GlyphInfo& CFontTexture::GetGlyph(char32_t ch)
{
RECOIL_DETAILED_TRACY_ZONE;
Expand Down
1 change: 1 addition & 0 deletions rts/Rendering/Fonts/CFontTexture.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class CFontTexture
static void InitFonts();
static void KillFonts();
static void Update();
static void UploadPendingGlyphAtlasTextures();
static bool AddFallbackFont(const std::string& fontfile);
static void ClearFallbackFonts();
static bool ClearAllGlyphs();
Expand Down
28 changes: 14 additions & 14 deletions rts/Rendering/GL/myGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ bool CheckAvailableVideoModes()
// Get available fullscreen/hardware modes
const int numDisplays = SDL_GetNumVideoDisplays();

SDL_DisplayMode ddm = {0, 0, 0, 0, nullptr};
SDL_DisplayMode cdm = {0, 0, 0, 0, nullptr};
SDL_DisplayMode ddm = {};
SDL_DisplayMode cdm = {};

// ddm is virtual, contains all displays in multi-monitor setups
// for fullscreen windows with non-native resolutions, ddm holds
Expand All @@ -78,8 +78,8 @@ bool CheckAvailableVideoModes()
continue;
}

SDL_DisplayMode cm = {0, 0, 0, 0, nullptr};
SDL_DisplayMode pm = {0, 0, 0, 0, nullptr};
SDL_DisplayMode cm = {};
SDL_DisplayMode pm = {};
SDL_Rect db;
SDL_GetDisplayBounds(k, &db);
const std::string dn = SDL_GetDisplayName(k);
Expand All @@ -97,16 +97,16 @@ bool CheckAvailableVideoModes()
if (cm.w == pm.w && cm.h == pm.h && (SDL_BPP(cm.format) < SDL_BPP(pm.format) || cm.refresh_rate < pm.refresh_rate))
continue;

globalRenderingInfo.availableVideoModes.emplace_back(GlobalRenderingInfo::AvailableVideoMode{
dn,
k + 1,
cm.w,
cm.h,
static_cast<int32_t>(SDL_BPP(cm.format)),
cm.refresh_rate
});
globalRenderingInfo.availableVideoModes.emplace_back(GlobalRenderingInfo::AvailableVideoMode{
dn,
k + 1,
cm.w,
cm.h,
static_cast<int32_t>(SDL_BPP(cm.format)),
static_cast<int32_t>(cm.refresh_rate)
});

LOG("\t\t[%2i] %ix%ix%ibpp@%iHz", int(i + 1), cm.w, cm.h, SDL_BPP(cm.format), cm.refresh_rate);
LOG("\t\t[%2i] %ix%ix%ibpp@%iHz", int(i + 1), cm.w, cm.h, SDL_BPP(cm.format), static_cast<int>(cm.refresh_rate));
pm = cm;
}
}
Expand Down Expand Up @@ -740,4 +740,4 @@ void glClearErrors(const char* cls, const char* fnc, bool verbose)
} else {
for (int count = 0; (glGetError() != GL_NO_ERROR) && (count < 10000); count++);
}
}
}
Loading