window creation
This commit is contained in:
@@ -1,24 +1,28 @@
|
|||||||
|
|
||||||
cmake_minimum_required(VERSION 3.2)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
|
||||||
project(ouros)
|
project(ouros)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -O3")
|
|
||||||
|
if(MSVC)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 /Oi /Ot /GT")
|
||||||
|
elseif(LINUX)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -O3")
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR})
|
set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR})
|
||||||
|
|
||||||
#add_subdirectory(src)
|
#add_subdirectory(src)
|
||||||
|
set(SDL3_DIR "${SDL3_PATH}/cmake")
|
||||||
set(SDL3_DIR "C:/Users/pmcge/Downloads/SDL3-devel-3.4.4-VC/SDL3-3.4.4")
|
|
||||||
|
|
||||||
find_package(SDL3 REQUIRED)
|
find_package(SDL3 REQUIRED)
|
||||||
|
|
||||||
# TODO: cascade cmakelists.txt
|
# TODO: cascade cmakelists.txt
|
||||||
add_executable(ouros
|
add_executable(ouros
|
||||||
src/main.cpp
|
src/main.cpp
|
||||||
src/app/App.cpp
|
src/app/App.cpp
|
||||||
|
src/app/Window.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(ouros PRIVATE
|
target_include_directories(ouros PRIVATE
|
||||||
@@ -26,6 +30,15 @@ target_include_directories(ouros PRIVATE
|
|||||||
"${CMAKE_CURRENT_SOURCE_DIR}/src"
|
"${CMAKE_CURRENT_SOURCE_DIR}/src"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set(SDL3_DLL "${SDL3_PATH}/lib/x64/SDL3.dll") # assuming youre not arm or 32 bit
|
||||||
|
add_custom_command(TARGET ouros POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
"${SDL3_DLL}"
|
||||||
|
$<TARGET_FILE_DIR:ouros>
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(ouros PRIVATE
|
target_link_libraries(ouros PRIVATE
|
||||||
SDL3::SDL3
|
SDL3::SDL3
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ $ git clone https://git.vxbard.net/homeburger/ouros.git --recursive
|
|||||||
```
|
```
|
||||||
### Configure and build project:
|
### Configure and build project:
|
||||||
```bash
|
```bash
|
||||||
$ cmake -S . -B build
|
$ cmake -S . -B build -DSDL3_PATH="${SDL3_INSTALL_PATH}"
|
||||||
$ cmake --build build -j
|
$ cmake --build build -j
|
||||||
```
|
```
|
||||||
### Execute application:
|
### Execute application:
|
||||||
|
|||||||
@@ -15,12 +15,27 @@ void App::init() {
|
|||||||
|
|
||||||
utils::debugPrint(__FUNCTION__, __LINE__, "Init app.");
|
utils::debugPrint(__FUNCTION__, __LINE__, "Init app.");
|
||||||
|
|
||||||
|
window_ = new Window();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int App::run() {
|
int App::run() {
|
||||||
|
|
||||||
utils::debugPrint(__FUNCTION__, __LINE__, "Run app.");
|
utils::debugPrint(__FUNCTION__, __LINE__, "Run app.");
|
||||||
|
|
||||||
|
bool quit = false;
|
||||||
|
while (!quit) {
|
||||||
|
// app loop for as long as the window is open
|
||||||
|
// poll events here
|
||||||
|
// other threads might be able to change quit to true to auto close
|
||||||
|
|
||||||
|
while( SDL_PollEvent( &e ) != 0 ) {
|
||||||
|
if( e.type == SDL_QUIT ) {
|
||||||
|
// Ctrl + C in console !
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "Window.hpp"
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -16,4 +18,6 @@ private:
|
|||||||
// things like creating a window, creating the rendering engine, etc.
|
// things like creating a window, creating the rendering engine, etc.
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
Window* window_;
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
Window::Window() {
|
Window::Window() {
|
||||||
|
|
||||||
init();
|
(void)init();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11,4 +11,6 @@ int Window::init() {
|
|||||||
|
|
||||||
window_ = SDL_CreateWindow("How to Vulkan", 1280u, 720u, SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE);
|
window_ = SDL_CreateWindow("How to Vulkan", 1280u, 720u, SDL_WINDOW_VULKAN | SDL_WINDOW_RESIZABLE);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#include "SDL3/SDL.h"
|
#include "SDL3/SDL.h"
|
||||||
#include "SDL3/SDL_Vulkan.h"
|
#include "SDL3/SDL_Vulkan.h"
|
||||||
|
|
||||||
|
// reference: https://wiki.libsdl.org/SDL3/SDL_CreateWindow
|
||||||
|
|
||||||
class Window {
|
class Window {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -17,5 +19,4 @@ private:
|
|||||||
|
|
||||||
SDL_Window* window_;
|
SDL_Window* window_;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -6,8 +6,6 @@
|
|||||||
|
|
||||||
int main(int arg, char *argv[]) {
|
int main(int arg, char *argv[]) {
|
||||||
|
|
||||||
std::cout << "[" << __FUNCTION__ << ": "<< __LINE__ << "] " << "main()" << std::endl;
|
|
||||||
|
|
||||||
std::string message = "main()";
|
std::string message = "main()";
|
||||||
utils::debugPrint(__FUNCTION__, __LINE__, message);
|
utils::debugPrint(__FUNCTION__, __LINE__, message);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user