mirror of
https://github.com/johndoe6345789/SDL3CPlusPlus.git
synced 2026-04-25 06:04:57 +00:00
various fixes
This commit is contained in:
11
.github/workflows/release.yml
vendored
11
.github/workflows/release.yml
vendored
@@ -47,9 +47,10 @@ jobs:
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
libwayland-dev \
|
||||
libwayland-egl1-mesa-dev \
|
||||
libegl-dev \
|
||||
libxkbcommon-dev
|
||||
libxkbcommon-dev \
|
||||
libxrandr-dev \
|
||||
cmake
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
@@ -59,6 +60,9 @@ jobs:
|
||||
- name: Install Conan
|
||||
run: pip install 'conan>=2'
|
||||
|
||||
- name: Detect Conan profile
|
||||
run: conan profile detect
|
||||
|
||||
- name: Vendor SDL3/Vulkan
|
||||
run: python scripts/setup_vendor_dependencies.py
|
||||
|
||||
@@ -66,7 +70,7 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -d "$BUILD_DIR" ]; then rm -rf "$BUILD_DIR"; fi
|
||||
conan install . --install-folder "$BUILD_DIR" --build=missing
|
||||
conan install . --output-folder "$BUILD_DIR" --build=missing -c tools.system.package_manager:mode=install
|
||||
|
||||
- name: Configure CMake
|
||||
shell: bash
|
||||
@@ -118,6 +122,7 @@ jobs:
|
||||
PY
|
||||
|
||||
- name: Publish GitHub release asset
|
||||
if: github.ref != 'refs/tags/local'
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: release/${{ env.ZIP_NAME }}
|
||||
|
||||
@@ -34,6 +34,7 @@ if(BUILD_SDL3_APP)
|
||||
src/app/sdl3_app_render.cpp
|
||||
src/script/cube_script.cpp
|
||||
)
|
||||
target_include_directories(sdl3_app PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
||||
target_link_libraries(sdl3_app PRIVATE SDL3::SDL3 Vulkan::Vulkan lua::lua)
|
||||
target_compile_definitions(sdl3_app PRIVATE SDL_MAIN_HANDLED)
|
||||
|
||||
|
||||
@@ -65,7 +65,13 @@ def main():
|
||||
["-DSDL_SHARED=OFF", "-DSDL_STATIC=ON", "-DSDL_TEST=OFF", "-DBUILD_SHARED_LIBS=OFF"],
|
||||
)
|
||||
|
||||
fetch_repo("Vulkan-Loader", "https://github.com/KhronosGroup/Vulkan-Loader.git", "sdk-1.3.275")
|
||||
fetch_repo("Vulkan-Loader", "https://github.com/KhronosGroup/Vulkan-Loader.git", "sdk-1.3.261.1")
|
||||
fetch_repo("Vulkan-Headers", "https://github.com/KhronosGroup/Vulkan-Headers.git", "sdk-1.3.261.1")
|
||||
build_and_install(
|
||||
VENDOR_DIR / "Vulkan-Headers",
|
||||
VENDOR_DIR / "build-vulkan-headers",
|
||||
)
|
||||
|
||||
build_and_install(
|
||||
VENDOR_DIR / "Vulkan-Loader",
|
||||
VENDOR_DIR / "build-vulkan-loader",
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
namespace sdl3cpp::app {
|
||||
|
||||
namespace script = sdl3cpp::script;
|
||||
|
||||
constexpr uint32_t kWidth = 1024;
|
||||
constexpr uint32_t kHeight = 768;
|
||||
|
||||
@@ -120,10 +122,10 @@ private:
|
||||
VkDeviceMemory indexBufferMemory_ = VK_NULL_HANDLE;
|
||||
VkSemaphore imageAvailableSemaphore_ = VK_NULL_HANDLE;
|
||||
VkSemaphore renderFinishedSemaphore_ = VK_NULL_HANDLE;
|
||||
CubeScript cubeScript_;
|
||||
script::CubeScript cubeScript_;
|
||||
std::vector<core::Vertex> vertices_;
|
||||
std::vector<uint16_t> indices_;
|
||||
std::unordered_map<std::string, CubeScript::ShaderPaths> shaderPathMap_;
|
||||
std::unordered_map<std::string, script::CubeScript::ShaderPaths> shaderPathMap_;
|
||||
std::unordered_map<std::string, VkPipeline> graphicsPipelines_;
|
||||
std::string defaultShaderKey_;
|
||||
VkFence inFlightFence_ = VK_NULL_HANDLE;
|
||||
|
||||
@@ -32,8 +32,7 @@ void Sdl3App::InitSDL() {
|
||||
throw std::runtime_error(std::string("SDL_Init failed: ") + SDL_GetError());
|
||||
}
|
||||
SDL_Vulkan_LoadLibrary(nullptr);
|
||||
window_ = SDL_CreateWindow("SDL3 Vulkan Demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
|
||||
kWidth, kHeight, SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE);
|
||||
window_ = SDL_CreateWindow("SDL3 Vulkan Demo", kWidth, kHeight, SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE);
|
||||
if (!window_) {
|
||||
throw std::runtime_error(std::string("SDL_CreateWindow failed: ") + SDL_GetError());
|
||||
}
|
||||
@@ -65,7 +64,7 @@ void Sdl3App::MainLoop() {
|
||||
while (SDL_PollEvent(&event)) {
|
||||
if (event.type == SDL_EVENT_QUIT) {
|
||||
running = false;
|
||||
} else if (event.type == SDL_EVENT_WINDOW_SIZE_CHANGED) {
|
||||
} else if (event.type == SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED) {
|
||||
framebufferResized_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,20 +16,18 @@ void Sdl3App::CreateInstance() {
|
||||
appInfo.apiVersion = VK_API_VERSION_1_2;
|
||||
|
||||
uint32_t extensionCount = 0;
|
||||
if (!SDL_Vulkan_GetInstanceExtensions(window_, &extensionCount, nullptr)) {
|
||||
const char* const* extensions = SDL_Vulkan_GetInstanceExtensions(&extensionCount);
|
||||
if (!extensions) {
|
||||
throw std::runtime_error("Failed to query Vulkan extensions from SDL");
|
||||
}
|
||||
|
||||
std::vector<const char*> extensions(extensionCount);
|
||||
if (!SDL_Vulkan_GetInstanceExtensions(window_, &extensionCount, extensions.data())) {
|
||||
throw std::runtime_error("Failed to store Vulkan extensions from SDL");
|
||||
}
|
||||
std::vector<const char*> extensionList(extensions, extensions + extensionCount);
|
||||
|
||||
VkInstanceCreateInfo createInfo{};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
||||
createInfo.pApplicationInfo = &appInfo;
|
||||
createInfo.enabledExtensionCount = static_cast<uint32_t>(extensions.size());
|
||||
createInfo.ppEnabledExtensionNames = extensions.data();
|
||||
createInfo.enabledExtensionCount = static_cast<uint32_t>(extensionList.size());
|
||||
createInfo.ppEnabledExtensionNames = extensionList.data();
|
||||
|
||||
if (vkCreateInstance(&createInfo, nullptr, &instance_) != VK_SUCCESS) {
|
||||
throw std::runtime_error("Failed to create Vulkan instance");
|
||||
@@ -37,7 +35,7 @@ void Sdl3App::CreateInstance() {
|
||||
}
|
||||
|
||||
void Sdl3App::CreateSurface() {
|
||||
if (!SDL_Vulkan_CreateSurface(window_, instance_, &surface_)) {
|
||||
if (!SDL_Vulkan_CreateSurface(window_, instance_, nullptr, &surface_)) {
|
||||
throw std::runtime_error("Failed to create Vulkan surface");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ void Sdl3App::RecreateSwapChain() {
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
while (width == 0 || height == 0) {
|
||||
SDL_Vulkan_GetDrawableSize(window_, &width, &height);
|
||||
SDL_GetWindowSize(window_, &width, &height);
|
||||
SDL_Event event;
|
||||
SDL_WaitEvent(&event);
|
||||
}
|
||||
@@ -179,7 +179,7 @@ VkPresentModeKHR Sdl3App::ChooseSwapPresentMode(const std::vector<VkPresentModeK
|
||||
|
||||
VkExtent2D Sdl3App::ChooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities) {
|
||||
int width, height;
|
||||
SDL_Vulkan_GetDrawableSize(window_, &width, &height);
|
||||
SDL_GetWindowSize(window_, &width, &height);
|
||||
VkExtent2D actualExtent = {
|
||||
static_cast<uint32_t>(std::clamp(width, static_cast<int>(capabilities.minImageExtent.width),
|
||||
static_cast<int>(capabilities.maxImageExtent.width))),
|
||||
|
||||
Reference in New Issue
Block a user