Skip to content
Open
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
2 changes: 1 addition & 1 deletion code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ TARGET_LINK_LIBRARIES(code PUBLIC ${PNG_LIBS})
TARGET_LINK_LIBRARIES(code PUBLIC ${JPEG_LIBS})
TARGET_LINK_LIBRARIES(code PUBLIC lz4)

TARGET_LINK_LIBRARIES(code PUBLIC sdl2)
TARGET_LINK_LIBRARIES(code PUBLIC sdl3)

if (FSO_BUILD_WITH_FFMPEG)
TARGET_LINK_LIBRARIES(code PUBLIC ffmpeg)
Expand Down
34 changes: 10 additions & 24 deletions code/bmpman/bmpman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define WIN32_LEAN_AND_MEAN
#define BMPMAN_INTERNAL

#include "globalincs/pstypes.h"
#include "anim/animplay.h"
#include "anim/packunpack.h"
#include "bmpman/bm_internal.h"
Expand Down Expand Up @@ -3397,37 +3398,22 @@ bool bm_validate_filename(const SCP_string& file, bool single_frame, bool animat
}
return false;
}
SDL_Surface* bm_to_sdl_surface(int handle) {

SDL_Surface* bm_to_sdl_surface(int handle)
{
Assertion(bm_is_valid(handle), "%d is no valid bitmap handle!", handle);

int w;
int h;
bitmap* bmp = bm_lock(handle, 32, BMP_TEX_XPARENT);

bm_get_info(handle, &w, &h, nullptr, nullptr);
Uint32 rmask, gmask, bmask, amask;
auto bitmapSurface = SDL_CreateSurface(bmp->w, bmp->h, SDL_PIXELFORMAT_BGRA32);

#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0x0000ff00;
gmask = 0x00ff0000;
bmask = 0xff000000;
amask = 0x000000ff;
#else
rmask = 0x00ff0000;
gmask = 0x0000ff00;
bmask = 0x000000ff;
amask = 0xff000000;
#endif

SDL_Surface* bitmapSurface = SDL_CreateRGBSurface(0, w, h, 32, rmask, gmask, bmask, amask);
if (SDL_LockSurface(bitmapSurface) < 0) {
return nullptr;
if (bitmapSurface) {
memcpy(bitmapSurface->pixels, reinterpret_cast<void *>(bmp->data),
bmp->w * bmp->h * (bmp->bpp >> 3));
}
bitmap* bmp = bm_lock(handle, 32, BMP_TEX_XPARENT);

memcpy(bitmapSurface->pixels, reinterpret_cast<void*>(bmp->data), static_cast<size_t>(w * h * 4));

bm_unlock(handle);
SDL_UnlockSurface(bitmapSurface);
bm_unload(handle);

return bitmapSurface;

Expand Down
2 changes: 1 addition & 1 deletion code/controlconfig/controlsconfigcommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ const char *textify_scancode(int code)
}

SCP_string name;
unicode::convert_encoding(name, SDL_GetKeyName(SDL_GetKeyFromScancode(fs2_to_sdl(keycode))), unicode::Encoding::Encoding_utf8);
unicode::convert_encoding(name, SDL_GetKeyName(SDL_GetKeyFromScancode(fs2_to_sdl(keycode), SDL_KMOD_NONE, false)), unicode::Encoding::Encoding_utf8);
strcat_s(text, name.c_str());
return text;
}
Expand Down
6 changes: 3 additions & 3 deletions code/cutscene/movie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include <windows.h>
#endif

#include "freespace.h"
#include "globalincs/pstypes.h"
#include "freespace.h"
#include "globalincs/alphacolors.h"
#include "globalincs/systemvars.h"
#include "io/cursor.h"
Expand Down Expand Up @@ -208,7 +208,7 @@ void movie_display_loop(Player* player, PlaybackState* state) {
auto sleepTime = static_cast<std::uint64_t>((1. / (4. * player->getMovieProperties().fps)) * 1000.);

auto listener = [state](const SDL_Event& event) {
switch (event.key.keysym.sym) {
switch (event.key.key) {
case SDLK_ESCAPE:
case SDLK_KP_ENTER:
case SDLK_RETURN:
Expand All @@ -220,7 +220,7 @@ void movie_display_loop(Player* player, PlaybackState* state) {
}
};
// Use a dedicated listener here since we want to listen for the KEYUP event
auto key_handle = os::events::addEventListener(SDL_KEYUP, os::events::DEFAULT_LISTENER_WEIGHT - 10, listener);
auto key_handle = os::events::addEventListener(SDL_EVENT_KEY_UP, os::events::DEFAULT_LISTENER_WEIGHT - 10, listener);

// slight hack to make sure that game_set_frametime() doesn't also try to cap the framerate
auto fpsCapSave = Cmdline_NoFPSCap;
Expand Down
16 changes: 9 additions & 7 deletions code/debugconsole/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,15 @@ void dc_putc(char c)
}

bool handle_textInputEvent(const SDL_Event& event) {
if (event.text.text[0] != '\0' && event.text.text[0] != '\1') {
for (char c : event.text.text) {
if (c < 32)
const char *p = event.text.text;

if (*p != '\0' && *p != '\1') {
for (; *p; ++p) {
if (*p < 32)
break;

if (dc_command_buf.size() < MAX_CLI_LEN) {
dc_command_buf.push_back(c);
dc_command_buf.push_back(*p);
}
}
}
Expand All @@ -515,8 +517,8 @@ void debug_console(void (*_func)(void))
dc_init();
}

auto textListener = os::events::addEventListener(SDL_TEXTINPUT, 10000, &handle_textInputEvent);
SDL_StartTextInput();
auto textListener = os::events::addEventListener(SDL_EVENT_TEXT_INPUT, 10000, &handle_textInputEvent);
SDL_StartTextInput(os::getSDLMainWindow());

dc_draw(TRUE);

Expand Down Expand Up @@ -618,7 +620,7 @@ void debug_console(void (*_func)(void))
dc_draw(TRUE);
}

SDL_StopTextInput();
SDL_StopTextInput(os::getSDLMainWindow());
os::events::removeEventListener(textListener);

while( key_inkey() ) {
Expand Down
5 changes: 2 additions & 3 deletions code/external_dll/externalcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "globalincs/pstypes.h"

#include <SDL_loadso.h>

/* This class loads external libraries for FSO use.
* Uses SDL to do the actual loading so this should be supported on most platforms
Expand Down Expand Up @@ -44,7 +43,7 @@ class SCP_ExternalCode
{
if (m_library != NULL && functionname != NULL)
{
void* func = SDL_LoadFunction(m_library, functionname);
void* func = reinterpret_cast<void *>(SDL_LoadFunction(m_library, functionname));

#ifndef NDEBUG
if (func == NULL)
Expand All @@ -66,7 +65,7 @@ class SCP_ExternalCode
}

private:
void* m_library;
SDL_SharedObject* m_library;
};

/* These are available if you're compiling an external DLL
Expand Down
12 changes: 8 additions & 4 deletions code/globalincs/pstypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ const float PI2 = (PI*2.0f);
const float PI_2 = (PI/2.0f);
const float PI_4 = (PI/4.0f);

// not defined generally on Windows, no longer included in SDL
#ifndef M_PI
#define M_PI SDL_PI_F
#endif

extern int Fred_running; // Is Fred running, or FreeSpace?
extern bool running_unittests;
Expand Down Expand Up @@ -391,10 +395,10 @@ const size_t INVALID_SIZE = static_cast<size_t>(-1);
// turn off inline asm
#undef USE_INLINE_ASM

#define INTEL_INT(x) SDL_Swap32(x)
#define INTEL_LONG(x) SDL_Swap64(x)
#define INTEL_SHORT(x) SDL_Swap16(x)
#define INTEL_FLOAT(x) SDL_SwapFloat((*x))
#define INTEL_INT(x) SDL_Swap32LE(x)
#define INTEL_LONG(x) SDL_Swap64LE(x)
#define INTEL_SHORT(x) SDL_Swap16LE(x)
#define INTEL_FLOAT(x) SDL_SwapFloatLE((*x))

#else // Little Endian -
#define INTEL_INT(x) x
Expand Down
Loading