mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-11-19 02:46:35 -05:00
We now have a blank window again.
This commit is contained in:
parent
7fb694d59a
commit
0f601cb024
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -1,6 +1,6 @@
|
|||||||
[submodule "3rdparty/bgfx"]
|
|
||||||
path = 3rdparty/bgfx
|
|
||||||
url = git@github.com:JoshuaBrookover/bgfx.cmake.git
|
|
||||||
[submodule "3rdparty/glfw"]
|
[submodule "3rdparty/glfw"]
|
||||||
path = 3rdparty/glfw
|
path = 3rdparty/glfw
|
||||||
url = git@github.com:glfw/glfw.git
|
url = git@github.com:glfw/glfw.git
|
||||||
|
[submodule "3rdparty/spdlog"]
|
||||||
|
path = 3rdparty/spdlog
|
||||||
|
url = git@github.com:gabime/spdlog.git
|
||||||
|
4
3rdparty/CMakeLists.txt
vendored
Normal file
4
3rdparty/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
|
||||||
|
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||||
|
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||||
|
add_subdirectory(glfw)
|
1
3rdparty/bgfx
vendored
1
3rdparty/bgfx
vendored
@ -1 +0,0 @@
|
|||||||
Subproject commit 95cb070eb2101d42327fa040c50d9703612b09f4
|
|
1
3rdparty/spdlog
vendored
Submodule
1
3rdparty/spdlog
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit bdfc7d2a5a4ad9cc1cebe1feb7e6fcc703840d71
|
@ -1,7 +1,21 @@
|
|||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.0)
|
||||||
project(OpenDiablo2)
|
|
||||||
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
|
||||||
|
message(FATAL_ERROR "Do not build in-source. Please remove CMakeCache.txt and the CMakeFiles/ directory. Then build out-of-source.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
project(OpenDiablo2 CXX)
|
||||||
|
|
||||||
|
include(CTest)
|
||||||
|
include(CMakeDependentOption)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(OpenGL_GL_PREFERENCE "GLVND")
|
||||||
|
|
||||||
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
|
||||||
|
add_subdirectory(3rdparty)
|
||||||
|
|
||||||
add_subdirectory(OpenDiablo2.Game)
|
|
||||||
add_subdirectory(OpenDiablo2.OS)
|
add_subdirectory(OpenDiablo2.OS)
|
||||||
|
add_subdirectory(OpenDiablo2.Graphics)
|
||||||
|
add_subdirectory(OpenDiablo2.Game)
|
||||||
|
@ -1,4 +1,25 @@
|
|||||||
add_executable(OpenDiablo2 src/main.cpp)
|
|
||||||
|
|
||||||
include_directories(OpenDiablo2 ../OpenDiablo2.OS/include)
|
add_executable(OpenDiablo2
|
||||||
target_link_libraries(OpenDiablo2 OpenDiablo2.OS)
|
src/main.cpp
|
||||||
|
src/D2Engine.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
include_directories(OpenDiablo2
|
||||||
|
include
|
||||||
|
../OpenDiablo2.OS/include
|
||||||
|
../OpenDiablo2.Graphics/include
|
||||||
|
../3rdparty/spdlog/include
|
||||||
|
)
|
||||||
|
target_link_libraries(OpenDiablo2
|
||||||
|
PUBLIC
|
||||||
|
OpenDiablo2.OS
|
||||||
|
OpenDiablo2.Graphics
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_features(OpenDiablo2 PRIVATE cxx_std_17)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
target_compile_options(OpenDiablo2 PRIVATE /W4 /WX)
|
||||||
|
else(MSVC)
|
||||||
|
target_compile_options(OpenDiablo2 PRIVATE -Wall -Wextra -pedantic -Werror)
|
||||||
|
endif(MSVC)
|
||||||
|
21
OpenDiablo2.Game/include/OpenDiablo2.Game/D2Engine.h
Normal file
21
OpenDiablo2.Game/include/OpenDiablo2.Game/D2Engine.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef OPENDIABLO2_D2ENGINE_H
|
||||||
|
#define OPENDIABLO2_D2ENGINE_H
|
||||||
|
|
||||||
|
#include <OpenDiablo2.OS/D2Window.h>
|
||||||
|
#include <OpenDiablo2.Graphics/D2Graphics.h>
|
||||||
|
|
||||||
|
namespace OpenDiablo2 {
|
||||||
|
namespace Game {
|
||||||
|
class D2Engine {
|
||||||
|
public:
|
||||||
|
D2Engine();
|
||||||
|
void Run();
|
||||||
|
private:
|
||||||
|
OpenDiablo2::OS::D2WindowPtr window;
|
||||||
|
OpenDiablo2::Graphics::D2GraphicsPtr gfx;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif //OPENDIABLO2_D2ENGINE_H
|
21
OpenDiablo2.Game/src/D2Engine.cpp
Normal file
21
OpenDiablo2.Game/src/D2Engine.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include <OpenDiablo2.Game/D2Engine.h>
|
||||||
|
|
||||||
|
|
||||||
|
OpenDiablo2::Game::D2Engine::D2Engine() {
|
||||||
|
window = std::make_unique<OpenDiablo2::OS::D2Window>();
|
||||||
|
gfx = std::make_unique<OpenDiablo2::Graphics::D2Graphics>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
OpenDiablo2::Game::D2Engine::Run() {
|
||||||
|
window->Initialize();
|
||||||
|
|
||||||
|
while (window->WindowStillOpen()) {
|
||||||
|
window->PollEvents();
|
||||||
|
gfx->Clear();
|
||||||
|
|
||||||
|
window->FlipBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
window->Finalize();
|
||||||
|
}
|
@ -1,10 +1,18 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <D2Window.h>
|
#include <spdlog/spdlog.h>
|
||||||
|
#include <spdlog/sinks/stdout_color_sinks.h>
|
||||||
|
#include <OpenDiablo2.Game/D2Engine.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
main() {
|
main() {
|
||||||
auto window = std::make_unique<OpenDiablo2::OS::D2Window>();
|
spdlog::set_level(spdlog::level::trace);
|
||||||
window->Run();
|
spdlog::set_pattern("[%^%l%$] %v");
|
||||||
|
|
||||||
|
spdlog::info("OpenDiablo 2 has started");
|
||||||
|
|
||||||
|
auto engine = std::make_unique<OpenDiablo2::Game::D2Engine>();
|
||||||
|
engine->Run();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
23
OpenDiablo2.Graphics/CMakeLists.txt
Normal file
23
OpenDiablo2.Graphics/CMakeLists.txt
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
project(libOpenDiablo2.Graphics VERSION 0.1 LANGUAGES CXX)
|
||||||
|
|
||||||
|
find_package(OpenGL)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
include
|
||||||
|
../3rdparty/bgfx/include
|
||||||
|
../3rdparty/spdlog/include
|
||||||
|
${OPENGL_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(OpenDiablo2.Graphics SHARED
|
||||||
|
src/D2Graphics.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
target_link_libraries(OpenDiablo2.Graphics ${OPENGL_LIBRARIES})
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
target_compile_options(OpenDiablo2.Graphics PRIVATE /W4 /WX)
|
||||||
|
else(MSVC)
|
||||||
|
target_compile_options(OpenDiablo2.Graphics PRIVATE -Wall -Wextra -pedantic -Werror)
|
||||||
|
endif(MSVC)
|
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef OPENDIABLO2_D2GRAPHICS_H
|
||||||
|
#define OPENDIABLO2_D2GRAPHICS_H
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace OpenDiablo2 {
|
||||||
|
namespace Graphics {
|
||||||
|
|
||||||
|
class D2Graphics {
|
||||||
|
public:
|
||||||
|
D2Graphics();
|
||||||
|
void Clear();
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::unique_ptr<D2Graphics> D2GraphicsPtr;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //OPENDIABLO2_D2GRAPHICS_H
|
18
OpenDiablo2.Graphics/src/D2Graphics.cpp
Normal file
18
OpenDiablo2.Graphics/src/D2Graphics.cpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#include <OpenDiablo2.Graphics/D2Graphics.h>
|
||||||
|
#include <GL/gl.h>
|
||||||
|
|
||||||
|
#include "OpenDiablo2.Graphics/D2Graphics.h"
|
||||||
|
|
||||||
|
namespace OpenDiablo2 {
|
||||||
|
namespace Graphics {
|
||||||
|
|
||||||
|
D2Graphics::D2Graphics() = default;
|
||||||
|
|
||||||
|
void
|
||||||
|
D2Graphics::Clear() {
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,19 +1,19 @@
|
|||||||
project(libOpenDiablo2.OS VERSION 0.1 LANGUAGES CXX)
|
project(libOpenDiablo2.OS VERSION 0.1 LANGUAGES CXX)
|
||||||
|
|
||||||
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
|
|
||||||
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
|
||||||
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
|
||||||
add_subdirectory(../3rdparty/glfw build)
|
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
include
|
include
|
||||||
../3rdparty/glfw/include
|
../3rdparty/glfw/include
|
||||||
|
../3rdparty/spdlog/include
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(OpenDiablo2.OS
|
add_library(OpenDiablo2.OS SHARED
|
||||||
src/D2Window.cpp
|
src/D2Window.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(OpenDiablo2.OS
|
target_link_libraries(OpenDiablo2.OS glfw)
|
||||||
glfw
|
|
||||||
)
|
if(MSVC)
|
||||||
|
target_compile_options(OpenDiablo2.OS PRIVATE /W4 /WX)
|
||||||
|
else(MSVC)
|
||||||
|
target_compile_options(OpenDiablo2.OS PRIVATE -Wall -Wextra -pedantic -Werror)
|
||||||
|
endif(MSVC)
|
||||||
|
@ -2,23 +2,22 @@
|
|||||||
#define OPENDIABLO2_WINDOW_H
|
#define OPENDIABLO2_WINDOW_H
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <GLFW/glfw3.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
class GLFWwindow;
|
||||||
|
|
||||||
namespace OpenDiablo2 { namespace OS {
|
namespace OpenDiablo2 { namespace OS {
|
||||||
|
|
||||||
class D2Window {
|
class D2Window {
|
||||||
public:
|
public:
|
||||||
D2Window();
|
D2Window();
|
||||||
void Run();
|
void Initialize();
|
||||||
|
void Finalize();
|
||||||
|
bool WindowStillOpen();
|
||||||
|
void FlipBuffer();
|
||||||
|
void PollEvents();
|
||||||
private:
|
private:
|
||||||
GLFWwindow* glfwWindow;
|
GLFWwindow* glfwWindow;
|
||||||
|
|
||||||
void
|
|
||||||
InitializeWindow();
|
|
||||||
|
|
||||||
void
|
|
||||||
FinalizeWindow();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::unique_ptr<D2Window> D2WindowPtr;
|
typedef std::unique_ptr<D2Window> D2WindowPtr;
|
@ -1,37 +1,52 @@
|
|||||||
#include <D2Window.h>
|
#include <OpenDiablo2.OS/D2Window.h>
|
||||||
#define GLFW_INCLUDE_NONE
|
#include <spdlog/spdlog.h>
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
|
||||||
namespace OpenDiablo2 {
|
namespace OpenDiablo2 {
|
||||||
namespace OS {
|
namespace OS {
|
||||||
|
|
||||||
D2Window::D2Window() {
|
D2Window::D2Window() = default;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
D2Window::Run() {
|
D2Window::Initialize() {
|
||||||
InitializeWindow();
|
spdlog::debug("Initializing D2Window");
|
||||||
while (!glfwWindowShouldClose(glfwWindow)) {
|
|
||||||
glfwPollEvents();
|
|
||||||
}
|
|
||||||
FinalizeWindow();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
spdlog::debug("Initializing GLFW");
|
||||||
D2Window::InitializeWindow() {
|
|
||||||
if (!glfwInit()) {
|
if (!glfwInit()) {
|
||||||
|
spdlog::error("Initializing D2Window");
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
"GLFW could not initialize the host window.");
|
"GLFW could not initialize the host window.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spdlog::debug("Creating GLFW window");
|
||||||
glfwWindowHint(GLFW_RESIZABLE, 0);
|
glfwWindowHint(GLFW_RESIZABLE, 0);
|
||||||
glfwWindow = glfwCreateWindow(800, 600, "OpenDiablo 2", NULL, NULL);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||||
|
glfwWindow = glfwCreateWindow(800, 600, "OpenDiablo 2", nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
D2Window::FinalizeWindow() {
|
D2Window::Finalize() {
|
||||||
|
spdlog::debug("Destroying GLFW window");
|
||||||
glfwDestroyWindow(glfwWindow);
|
glfwDestroyWindow(glfwWindow);
|
||||||
|
|
||||||
|
spdlog::debug("Terminating GLFW");
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
D2Window::WindowStillOpen() {
|
||||||
|
return !glfwWindowShouldClose(glfwWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
D2Window::PollEvents() {
|
||||||
|
glfwPollEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
D2Window::FlipBuffer() {
|
||||||
|
glfwSwapBuffers(glfwWindow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user