Starting repo
This commit is contained in:
commit
d318b72c3b
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Ignore all files in any directory named build
|
||||||
|
build/
|
||||||
9
CMakeLists.txt
Normal file
9
CMakeLists.txt
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
cmake_minimum_required(VERSION 3.28)
|
||||||
|
|
||||||
|
project(low-level_setup
|
||||||
|
VERSION 1.0
|
||||||
|
LANGUAGES CXX
|
||||||
|
)
|
||||||
|
|
||||||
|
add_subdirectory(dependencies)
|
||||||
|
add_subdirectory(src)
|
||||||
48
dependencies/CMakeLists.txt
vendored
Normal file
48
dependencies/CMakeLists.txt
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
include(FetchContent)
|
||||||
|
|
||||||
|
set(SFML_VERSION 3.0.0)
|
||||||
|
set(IMGUI_VERSION 1.91.1)
|
||||||
|
|
||||||
|
option(LINK_DEPS_STATIC CACHE ON)
|
||||||
|
|
||||||
|
# Don't build shared libs if we want to link to deps statically
|
||||||
|
if(LINK_DEPS_STATIC)
|
||||||
|
set(BUILD_SHARED_LIBS OFF)
|
||||||
|
else()
|
||||||
|
set(BUILD_SHARED_LIBS ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Get stripped down release zips
|
||||||
|
FetchContent_Declare(
|
||||||
|
SFML
|
||||||
|
URL "https://github.com/SFML/SFML/archive/${SFML_VERSION}.zip"
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_Declare(
|
||||||
|
imgui
|
||||||
|
URL "https://github.com/ocornut/imgui/archive/v${IMGUI_VERSION}.zip"
|
||||||
|
)
|
||||||
|
|
||||||
|
# imgui_sfml full repo
|
||||||
|
FetchContent_Declare(
|
||||||
|
imgui-sfml
|
||||||
|
GIT_REPOSITORY https://github.com/SFML/imgui-sfml.git
|
||||||
|
GIT_TAG v3.0
|
||||||
|
)
|
||||||
|
|
||||||
|
# BUILDING
|
||||||
|
|
||||||
|
# SFML
|
||||||
|
option(SFML_BUILD_AUDIO "Build audio" OFF)
|
||||||
|
option(SFML_BUILD_NETWORK "Build network" OFF)
|
||||||
|
FetchContent_MakeAvailable(sfml)
|
||||||
|
|
||||||
|
# IMGUI
|
||||||
|
FetchContent_MakeAvailable(imgui)
|
||||||
|
|
||||||
|
# IMGUI-SFML
|
||||||
|
set(IMGUI_DIR ${imgui_SOURCE_DIR})
|
||||||
|
option(IMGUI_SFML_FIND_SFML "Use find_package to find SFML" OFF)
|
||||||
|
option(IMGUI_SFML_IMGUI_DEMO "Build imgui_demo.cpp" ON)
|
||||||
|
|
||||||
|
FetchContent_MakeAvailable(imgui-sfml)
|
||||||
11
src/CMakeLists.txt
Normal file
11
src/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
add_executable(low-level_setup
|
||||||
|
main.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(low-level_setup
|
||||||
|
PUBLIC
|
||||||
|
ImGui-SFML::ImGui-SFML
|
||||||
|
)
|
||||||
|
|
||||||
|
# Do we need this?
|
||||||
|
# include(Install.cmake)
|
||||||
43
src/main.cpp
Normal file
43
src/main.cpp
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
#include "imgui.h"
|
||||||
|
#include "imgui-SFML.h"
|
||||||
|
|
||||||
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
sf::RenderWindow window;
|
||||||
|
window.create(sf::VideoMode({ 1280, 720 }), "My window");
|
||||||
|
window.setFramerateLimit(60);
|
||||||
|
window.setVerticalSyncEnabled(true);
|
||||||
|
|
||||||
|
if (!ImGui::SFML::Init(window))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
sf::Clock deltaClock;
|
||||||
|
while (window.isOpen())
|
||||||
|
{
|
||||||
|
float deltaTime = deltaClock.restart().asSeconds();
|
||||||
|
|
||||||
|
// Event Polling
|
||||||
|
while (const std::optional event = window.pollEvent())
|
||||||
|
{
|
||||||
|
ImGui::SFML::ProcessEvent(window, *event);
|
||||||
|
|
||||||
|
// "close requested" event: we close the window
|
||||||
|
if (event->is<sf::Event::Closed>())
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update
|
||||||
|
ImGui::SFML::Update(window, deltaClock.restart());
|
||||||
|
// ImGui::ShowDemoWindow();
|
||||||
|
|
||||||
|
// Render
|
||||||
|
window.clear();
|
||||||
|
|
||||||
|
ImGui::SFML::Render(window);
|
||||||
|
|
||||||
|
window.display();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue