Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transition to SDL3 #962

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
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
23 changes: 15 additions & 8 deletions .github/workflows/build-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- cron: '0 0 * * *'

jobs:

windows:
runs-on: windows-latest
steps:
Expand All @@ -24,7 +24,7 @@ jobs:
run: |
"C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/MSBuild.exe" WickedEngine.sln /t:clean /m /p:Configuration=Release /p:Platform=x64
"C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/MSBuild.exe" WickedEngine.sln /t:Editor_Windows /m /p:Configuration=Release /p:Platform=x64

- name: Move files
shell: cmd
run: |
Expand All @@ -33,7 +33,7 @@ jobs:
move Editor\startup.lua .\
move Editor\languages .\
move Editor\fonts .\

- name: Package Editor
uses: actions/upload-artifact@v4
with:
Expand All @@ -45,7 +45,7 @@ jobs:
startup.lua
Editor_Windows.exe


linux:
runs-on: ubuntu-latest
steps:
Expand All @@ -54,15 +54,22 @@ jobs:
- name: Install dependencies
run: |
sudo apt update
sudo apt install libsdl2-dev
# sudo apt install libsdl3-dev
git clone https://github.com/libsdl-org/SDL
cd SDL
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release --parallel
sudo cmake --install . --config Release

- name: Initial compile
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)

- name: Generate shader dump
run: |
cd build/WickedEngine
Expand All @@ -73,15 +80,15 @@ jobs:
run: |
cd build
make -B -j $(nproc)

- name: Move files
run: |
mv build/Editor/WickedEngineEditor ./Editor_Linux
mv Editor/config.ini ./
mv Editor/startup.lua ./
mv Editor/languages ./
mv Editor/fonts ./

- name: Package Editor
uses: actions/upload-artifact@v4
with:
Expand Down
23 changes: 16 additions & 7 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: |
"C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/MSBuild.exe" WickedEngine.sln /t:clean /m /p:Configuration=Release /p:Platform=x64
"C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/MSBuild.exe" WickedEngine.sln /t:Editor_Windows /m /p:Configuration=Release /p:Platform=x64

- name: Move files
shell: cmd
run: |
Expand All @@ -32,7 +32,7 @@ jobs:
move Editor\startup.lua .\
move Editor\languages .\
move Editor\fonts .\

- name: Package Editor
uses: actions/upload-artifact@v4
with:
Expand All @@ -44,7 +44,7 @@ jobs:
startup.lua
Editor_Windows.exe


linux:
runs-on: ubuntu-latest
steps:
Expand All @@ -60,15 +60,24 @@ jobs:
- name: Install dependencies
run: |
sudo apt update
sudo apt install libsdl2-dev ccache
# sudo apt install libsdl3-dev ccache
sudo apt install ccache
git clone https://github.com/libsdl-org/SDL
cd SDL
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release --parallel
sudo cmake --install . --config Release


- name: Initial compile
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
CCACHE_NODIRECT=1 make -j$(nproc)

- name: Generate shader dump
run: |
cd build/WickedEngine
Expand All @@ -80,15 +89,15 @@ jobs:
cd build
CCACHE_NODIRECT=1 make -B -j $(nproc)


- name: Move binaries
run: |
mv build/Editor/WickedEngineEditor ./Editor_Linux
mv Editor/config.ini ./
mv Editor/startup.lua ./
mv Editor/languages ./
mv Editor/fonts ./

- name: Package Editor
uses: actions/upload-artifact@v4
with:
Expand Down
22 changes: 15 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: |
"C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/MSBuild.exe" WickedEngine.sln /t:clean /m /p:Configuration=Release /p:Platform=x64
"C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/MSBuild.exe" WickedEngine.sln /t:Editor_Windows /m /p:Configuration=Release /p:Platform=x64

- name: Move files
shell: cmd
run: |
Expand All @@ -33,7 +33,7 @@ jobs:
move Editor\startup.lua .\
move Editor\languages .\
move Editor\fonts .\

- name: Package Editor
uses: actions/upload-artifact@v4
with:
Expand All @@ -45,7 +45,7 @@ jobs:
startup.lua
Editor_Windows.exe


linux:
runs-on: ubuntu-latest
steps:
Expand All @@ -62,15 +62,23 @@ jobs:
- name: Install dependencies
run: |
sudo apt update
sudo apt install libsdl2-dev ccache
# sudo apt install libsdl3-dev ccache
sudo apt install ccache
git clone https://github.com/libsdl-org/SDL
cd SDL
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --config Release --parallel
sudo cmake --install . --config Release

- name: Initial compile
run: |
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
CCACHE_NODIRECT=1 make -j$(nproc)

- name: Generate shader dump
run: |
cd build/WickedEngine
Expand All @@ -82,15 +90,15 @@ jobs:
cd build
CCACHE_NODIRECT=1 make -B -j $(nproc)


- name: Move files
run: |
mv build/Editor/WickedEngineEditor ./Editor_Linux
mv Editor/config.ini ./
mv Editor/startup.lua ./
mv Editor/languages ./
mv Editor/fonts ./

- name: Package Editor
uses: actions/upload-artifact@v4
with:
Expand Down
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ if (WIN32)
# add_compile_definitions(_WIN32=1) this is a given from the compiler
set(DXC_TARGET "${CMAKE_CURRENT_SOURCE_DIR}/WickedEngine/dxc.exe")
elseif(UNIX)
set(PLATFORM "SDL2")
add_compile_definitions(SDL2=1)
set(PLATFORM "SDL3")
set(DXC_TARGET "dxc")
endif()

Expand Down
5 changes: 3 additions & 2 deletions Editor/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using namespace wi::ecs;
extern BOOL CreateEditorWindow(int nCmdShow);
extern bool window_recreating;
#elif defined(PLATFORM_LINUX)
#include "sdl2.h"
#include "sdl3.h"
#endif // PLATFORM_WINDOWS

enum class FileType
Expand Down Expand Up @@ -1068,7 +1068,8 @@ void EditorComponent::Load()
main->window = {};
CreateEditorWindow(SW_SHOWNORMAL);
#elif defined(PLATFORM_LINUX)
SDL_SetWindowFullscreen(main->window, fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
// wi::graphics::GetDevice()->WaitForGPU();
SDL_SetWindowFullscreen(main->window, fullscreen);
#endif // PLATFORM_WINDOWS_DESKTOP

});
Expand Down
80 changes: 39 additions & 41 deletions Editor/main_SDL2.cpp → Editor/main_SDL3.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#include "stdafx.h"
#include "Editor.h"

#include "sdl2.h"
#include "sdl3.h"
#include <SDL3/SDL_events.h>
#include <SDL3/SDL_pixels.h>
#include <SDL3/SDL_video.h>
#include <fstream>

#include "icon.c"
Expand All @@ -18,37 +21,32 @@ int sdl_loop(Editor &editor)
while(SDL_PollEvent(&event)){
bool textinput_action_delete = false;
switch(event.type){
case SDL_QUIT:
case SDL_EVENT_QUIT:
quit = true;
break;
case SDL_WINDOWEVENT:
switch (event.window.event) {
case SDL_WINDOWEVENT_CLOSE: // exit editor
quit = true;
break;
case SDL_WINDOWEVENT_RESIZED:
// Tells the engine to reload window configuration (size and dpi)
editor.SetWindow(editor.window);
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
editor.is_window_active = false;
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
editor.is_window_active = true;
editor.HotReload();
break;
default:
break;
}
case SDL_KEYDOWN:
if(event.key.keysym.scancode == SDL_SCANCODE_BACKSPACE
|| event.key.keysym.scancode == SDL_SCANCODE_DELETE
|| event.key.keysym.scancode == SDL_SCANCODE_KP_BACKSPACE){
case SDL_EVENT_WINDOW_CLOSE_REQUESTED: // exit editor
quit = true;
break;
case SDL_EVENT_WINDOW_RESIZED:
// Tells the engine to reload window configuration (size and dpi)
editor.SetWindow(editor.window);
break;
case SDL_EVENT_WINDOW_FOCUS_LOST:
editor.is_window_active = false;
break;
case SDL_EVENT_WINDOW_FOCUS_GAINED:
editor.is_window_active = true;
editor.HotReload();
break;
case SDL_EVENT_KEY_DOWN:
if(event.key.scancode == SDL_SCANCODE_BACKSPACE
|| event.key.scancode == SDL_SCANCODE_DELETE
|| event.key.scancode == SDL_SCANCODE_KP_BACKSPACE){
wi::gui::TextInputField::DeleteFromInput();
textinput_action_delete = true;
}
break;
case SDL_TEXTINPUT:
case SDL_EVENT_TEXT_INPUT:
if(!textinput_action_delete){
if(event.text.text[0] >= 21){
wi::gui::TextInputField::AddInput(event.text.text[0]);
Expand Down Expand Up @@ -81,13 +79,15 @@ void set_window_icon(SDL_Window *window) {
bmask = 0x00ff0000;
amask = (gimp_image.bytes_per_pixel == 3) ? 0 : 0xff000000;
#endif
SDL_Surface* icon = SDL_CreateRGBSurfaceFrom((void*)gimp_image.pixel_data, gimp_image.width,
gimp_image.height, gimp_image.bytes_per_pixel*8, gimp_image.bytes_per_pixel*gimp_image.width,
rmask, gmask, bmask, amask);
const int depth = gimp_image.bytes_per_pixel*8;
const int pitch = gimp_image.bytes_per_pixel*gimp_image.width;
SDL_Surface* icon = SDL_CreateSurfaceFrom(gimp_image.width, gimp_image.height,
SDL_GetPixelFormatForMasks(depth, rmask, gmask, bmask, amask),
(void*)gimp_image.pixel_data, pitch);

SDL_SetWindowIcon(window, icon);
SDL_FreeSurface(icon);

SDL_DestroySurface(icon);
}

int main(int argc, char *argv[])
Expand All @@ -96,9 +96,9 @@ int main(int argc, char *argv[])

wi::arguments::Parse(argc, argv);

sdl2::sdlsystem_ptr_t system = sdl2::make_sdlsystem(SDL_INIT_EVERYTHING | SDL_INIT_EVENTS);
if (*system) {
throw sdl2::SDLError("Error creating SDL2 system");
sdl3::sdlsystem_ptr_t system = sdl3::make_sdlsystem(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_GAMEPAD);
if (!system) {
throw sdl3::SDLError("Error creating SDL3 system");
}

int width = 1920;
Expand All @@ -122,22 +122,20 @@ int main(int argc, char *argv[])
width = std::max(100, width);
height = std::max(100, height);

sdl2::window_ptr_t window = sdl2::make_window(
sdl3::window_ptr_t window = sdl3::make_window(
"Wicked Engine Editor",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
width, height,
SDL_WINDOW_SHOWN | SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY);
if (!window) {
throw sdl2::SDLError("Error creating window");
throw sdl3::SDLError("Error creating window");
}

set_window_icon(window.get());

if (fullscreen)
{
//SDL_SetWindowFullscreen(window.get(), SDL_TRUE);
//SDL_SetWindowFullscreen(window.get(), SDL_WINDOW_FULLSCREEN);
SDL_SetWindowFullscreen(window.get(), SDL_WINDOW_FULLSCREEN_DESKTOP);
// SDL_SetWindowFullscreenMode(window.get(), TODO);
SDL_SetWindowFullscreen(window.get(), true);
}

editor.SetWindow(window.get());
Expand Down
2 changes: 1 addition & 1 deletion Editor/tiny_gltf.h
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ class TinyGLTF {
bool preserve_image_channels_ = false; /// Default false(expand channels to
/// RGBA) for backward compatibility.

// Warning & error messages
// Warning & error messages
std::string warn_;
std::string err_;

Expand Down
Loading
Loading