diff --git a/.gitmodules b/.gitmodules index 07177a9..d848d52 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "vendor/stb"] path = vendor/stb url = https://github.com/nothings/stb.git +[submodule "vendor/glfw"] + path = vendor/glfw + url = https://github.com/glfw/glfw.git diff --git a/CMakeLists.txt b/CMakeLists.txt index f791c41..cc0bfb7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,89 +14,110 @@ option(PD_BUILD_SHARED "Build Shared Library" OFF) option(PD_BUILD_TOOLS "Build Palladium Tools" OFF) if(${PD_BUILD_TOOLS}) - add_subdirectory(tools) + add_subdirectory(tools) endif() add_subdirectory(vendor) # # Include Library Source set(PD_SOURCES + # Common + source/common.cpp - # Core - source/core/bits.cpp - source/core/color.cpp - source/core/mat.cpp - source/core/strings.cpp + # Core + source/core/bits.cpp + source/core/color.cpp + source/core/mat.cpp + source/core/strings.cpp - source/drivers/os.cpp - source/drivers/gfx.cpp + # Drivers + source/drivers/os.cpp + source/drivers/gfx.cpp + + # Lithium + source/lithium/pools.cpp ) if(${PD_BUILD_SHARED}) - add_library(palladium SHARED ${PD_SOURCES}) - target_compile_definitions(palladium PRIVATE -DPD_BUILD_SHARED) + add_library(palladium SHARED ${PD_SOURCES}) + target_compile_definitions(palladium PRIVATE -DPD_BUILD_SHARED) else() - add_library(palladium STATIC ${PD_SOURCES}) - target_compile_definitions(palladium PUBLIC -DPD_BUILD_STATIC) + add_library(palladium STATIC ${PD_SOURCES}) + target_compile_definitions(palladium PUBLIC -DPD_BUILD_STATIC) endif() +target_compile_definitions(palladium PUBLIC -DPD_DEBUG=1) +target_compile_options(palladium + PUBLIC + -fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}/source=source + -fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}/include=include +) + add_library(palladium::palladium ALIAS palladium) target_include_directories(palladium - PUBLIC - $ - $ + PUBLIC + $ + $ ) -target_compile_options(palladium PRIVATE - $<$:-O0 -g> - $<$:-O3> +target_compile_options(palladium + PRIVATE + $<$:-O0 -g> + $<$:-O3> ) -install(TARGETS palladium - EXPORT palladiumTargets - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +install( + TARGETS palladium + EXPORT palladiumTargets + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) -install(DIRECTORY include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} +install( + DIRECTORY include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) install(EXPORT palladiumTargets - FILE palladiumTargets.cmake - NAMESPACE palladium:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/palladium + FILE palladiumTargets.cmake + NAMESPACE palladium:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/palladium ) include(CMakePackageConfigHelpers) configure_package_config_file( - cmake/palladiumConfig.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/palladiumConfig.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/palladium + cmake/palladiumConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/palladiumConfig.cmake + INSTALL_DESTINATION + ${CMAKE_INSTALL_LIBDIR}/cmake/palladium ) write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/palladiumConfigVersion.cmake - VERSION ${PROJECT_VERSION} - COMPATIBILITY SameMajorVersion + ${CMAKE_CURRENT_BINARY_DIR}/palladiumConfigVersion.cmake + VERSION + ${PROJECT_VERSION} + COMPATIBILITY + SameMajorVersion ) -install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/palladiumConfig.cmake - ${CMAKE_CURRENT_BINARY_DIR}/palladiumConfigVersion.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/palladium +install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/palladiumConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/palladiumConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/palladium ) find_program(CLANG_FORMAT clang-format) -file(GLOB_RECURSE PD_FMTFILES CONFIGURE_DEPENDS - ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp +file(GLOB_RECURSE PD_FMTFILES + CONFIGURE_DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp ) add_custom_target(pd-clang-format - COMMAND ${CLANG_FORMAT} --style=file -i ${PD_FMTFILES} - COMMENT "Formatting Project Sources" + COMMAND ${CLANG_FORMAT} --style=file -i ${PD_FMTFILES} + COMMENT "Formatting Project Sources" ) add_subdirectory(backends) diff --git a/backends/CMakeLists.txt b/backends/CMakeLists.txt index 890755b..f0e7d6e 100644 --- a/backends/CMakeLists.txt +++ b/backends/CMakeLists.txt @@ -7,15 +7,23 @@ option(PD_ENABLE_OPENGL3 "Enable OpenGL 3.3 (On Supported Hardware)" ON) option(PD_ENABLE_VULKAN "Not implemented yet" OFF) add_library(pd-system STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_opengl.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_opengl.cpp ) + target_include_directories(pd-system - PUBLIC - $ - $ + PUBLIC + $ + $ ) + +target_compile_options(pd-system + PUBLIC + -fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}/source=source + -fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}/include=include +) + target_link_libraries(pd-system - PUBLIC - palladium::palladium - glad + PUBLIC + palladium::palladium + glad ) \ No newline at end of file diff --git a/backends/include/gfx_opengl.hpp b/backends/include/gfx_opengl.hpp index b2aa851..4b48698 100644 --- a/backends/include/gfx_opengl.hpp +++ b/backends/include/gfx_opengl.hpp @@ -17,7 +17,7 @@ struct GfxOpenGLConfig { }; class GfxOpenGL : public GfxDriverBase { public: - GfxOpenGL() {} + GfxOpenGL(): GfxDriverBase("OpenGL2") {} ~GfxOpenGL() {} void SysInit() override; diff --git a/backends/source/gfx_opengl.cpp b/backends/source/gfx_opengl.cpp index d09befc..5e525a9 100644 --- a/backends/source/gfx_opengl.cpp +++ b/backends/source/gfx_opengl.cpp @@ -2,6 +2,9 @@ #include +#include "pd/common.hpp" +#include "pd/drivers/gfx.hpp" + namespace PD { GLuint compileShader(const std::string& source, GLenum type) { GLuint shader = glCreateShader(type); @@ -42,6 +45,8 @@ GLuint createShaderProgram(const std::string& vertexShaderSource, glDeleteShader(vertexShader); glDeleteShader(fragmentShader); + if (success) PDLOG("Shader [{}] compiled sucessfully", shaderProgram); + return shaderProgram; } @@ -118,16 +123,36 @@ void GfxOpenGL::SysInit() { glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + PDLOG( + "GfxOpenGL::SysInit():\n pShader = {}\n pLocTex = {}\n pLocAlfa = " + "{}\n pLocProjection = {}\n VBO = {}\n IBO = {}", + pShader, pLocTex, pLocAlfa, pLocProjection, VBO, IBO); } void GfxOpenGL::SysDeinit() { glDeleteBuffers(1, &VBO); glDeleteBuffers(1, &IBO); + PDLOG("GfxOpenGL::SysDeinit()"); } void GfxOpenGL::Submit(size_t count, size_t start) { + BindTexture(CurrentTex); + glUseProgram(pShader); + pSetupShaderAttribs(pShader); + glUniformMatrix4fv(pLocProjection, 1, GL_FALSE, Projection.m.data()); + glBindBuffer(GL_ARRAY_BUFFER, VBO); + glBufferData(GL_ARRAY_BUFFER, CurrentVertex * sizeof(PD::Li::Vertex), + GetVertexBufPtr(0), GL_DYNAMIC_DRAW); + + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, IBO); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, CurrentIndex * sizeof(PD::u16), + GetIndexBufPtr(0), GL_DYNAMIC_DRAW); + glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_INT, - (void*)GetIndexBufPtr(start)); + reinterpret_cast(start * sizeof(u16))); + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + BindTexture(0); } void GfxOpenGL::BindTexture(TextureID id) { @@ -139,12 +164,37 @@ void GfxOpenGL::BindTexture(TextureID id) { glUniform1i(pLocAlfa, fmt == GL_ALPHA); } -void GfxOpenGL::SysReset() {} +void GfxOpenGL::SysReset() { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +} TextureID GfxOpenGL::LoadTexture(const std::vector& pixels, int w, int h, TextureFormat type, TextureFilter filter) { - return 0; + GLuint texID; + glGenTextures(1, &texID); + glBindTexture(GL_TEXTURE_2D, texID); + + // Set base format (Always using RGBA as base) + GLenum fmt = GL_RGBA; + /*if (type == PD::Li::Texture::Type::RGB24) { + fmt = GL_RGB; + } else if (type == PD::Li::Texture::Type::A8) { + fmt = GL_ALPHA; + }*/ + glTexImage2D(GL_TEXTURE_2D, 0, fmt, w, h, 0, fmt, GL_UNSIGNED_BYTE, + pixels.data()); + if (filter == TextureFilter::Linear) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + } else if (filter == TextureFilter::Nearest) { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + } + glBindTexture(GL_TEXTURE_2D, 0); + PDLOG("GfxOpenGL::LoadTexture -> [{}] {}", PD::ivec2(w, h), texID); + return texID; } void GfxOpenGL::DeleteTexture(const TextureID& tex) { diff --git a/include/palladium b/include/palladium index 90b9605..7b93830 100755 --- a/include/palladium +++ b/include/palladium @@ -24,4 +24,5 @@ SOFTWARE. */ #include -#include \ No newline at end of file +#include +#include \ No newline at end of file diff --git a/include/pd/common.hpp b/include/pd/common.hpp index 11cf40f..4635fde 100644 --- a/include/pd/common.hpp +++ b/include/pd/common.hpp @@ -25,6 +25,7 @@ SOFTWARE. #include #include +#include #include #include #include @@ -42,4 +43,17 @@ using u16 = unsigned short; using u32 = unsigned int; using u64 = unsigned long long; using ptr = uintptr_t; -} // namespace PD \ No newline at end of file +void Log(const std::string& txt); +template +void Log(std::format_string fmt, Args&&... args) { + std::string msg = std::format(fmt, std::forward(args)...); + Log(msg); +} +} // namespace PD + +#ifdef PD_DEBUG +#define PDLOG(fmt, ...) \ + PD::Log("[{}:{}]: " fmt, __FILE__, __LINE__, ##__VA_ARGS__) +#else +#define PDLOG(fmt, ...) +#endif \ No newline at end of file diff --git a/include/pd/core/pool.hpp b/include/pd/core/pool.hpp index 609148c..9ad6a2a 100644 --- a/include/pd/core/pool.hpp +++ b/include/pd/core/pool.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include namespace PD { template > @@ -24,6 +25,10 @@ class Pool { pPos = 0; pCap = size; pData = pAlloc.allocate(size); + for (size_t i = 0; i < pCap; i++) { + std::allocator_traits::construct(pAlloc, &pData[i]); + } + PDLOG("Pool::Init({})", size); } Pool(const Pool&) = delete; @@ -49,7 +54,15 @@ class Pool { return false; } - void Reset() { pPos = 0; } + void Reset() { + for (size_t i = 0; i < pCap; i++) { + std::allocator_traits::destroy(pAlloc, &pData[i]); + } + pPos = 0; + for (size_t i = 0; i < pCap; i++) { + std::allocator_traits::construct(pAlloc, &pData[i]); + } + } size_t size() const { return pPos; } size_t capacity() const { return pCap; } diff --git a/include/pd/drivers/gfx.hpp b/include/pd/drivers/gfx.hpp index 1a06956..bbc0920 100755 --- a/include/pd/drivers/gfx.hpp +++ b/include/pd/drivers/gfx.hpp @@ -29,6 +29,7 @@ class PD_API GfxDriver : public DriverInterface { virtual ~GfxDriver() = default; virtual void Init() {} + virtual void Deinit() { SysDeinit(); } void SetViewPort(const ivec2& size); void SetViewPort(int x, int y); @@ -93,7 +94,6 @@ class PD_API GfxDriverBase : public GfxDriver { void Draw(const Pool& commands) override { CountCommands += commands.size(); - Projection = Mat4::Ortho(0.f, ViewPort.x, ViewPort.y, 0.f, 1.f, -1.f); size_t index = 0; while (index < commands.size()) { CurrentTex = commands[index].Tex; @@ -144,6 +144,22 @@ class PD_API Gfx { driver = std::make_unique(std::forward(args)...); } + static void Init() { driver->Init(); } + static void Deinit() { driver->Deinit(); } + static void SetViewPort(const ivec2& vp) { driver->SetViewPort(vp); } + static void SetViewPort(int w, int h) { driver->SetViewPort(w, h); } + static void Reset() { driver->Reset(); } + static void Draw(const Pool& commands) { + driver->Draw(commands); + } + static TextureID LoadTexture(const std::vector& pixels, int w, int h, + TextureFormat type = TextureFormat::RGBA32, + TextureFilter filter = TextureFilter::Linear) { + return driver->LoadTexture(pixels, w, h, type, filter); + } + + static const char* GetDriverName() { return driver->GetName(); } + private: static std::unique_ptr driver; }; diff --git a/include/pd/lithium/command.hpp b/include/pd/lithium/command.hpp index 818f937..825bd88 100644 --- a/include/pd/lithium/command.hpp +++ b/include/pd/lithium/command.hpp @@ -1,24 +1,61 @@ #pragma once +#include #include +#include #include namespace PD { namespace Li { class Command { public: - Command() {} + Command() { Reset(); } ~Command() {} + void Reserve(size_t vtx, size_t idx) { + if (!FirstVertex) + FirstVertex = AllocateVertices(vtx); + else + AllocateVertices(vtx); + if (!FirstIndex) + FirstIndex = AllocateIndices(idx); + else + AllocateIndices(idx); + } + + void Reset() { + Layer = 0; + Tex = 0; + FirstIndex = nullptr; + FirstVertex = nullptr; + IndexCount = 0; + VertexCount = 0; + } + + Command& Add(const Vertex& vtx) { + FirstVertex[VertexCount++] = vtx; + return *this; + } + Command& Add(u16 idx) { + FirstIndex[IndexCount++] = VertexCount + idx; + return *this; + } + Command& Add(u16 a, u16 b, u16 c) { + FirstIndex[IndexCount++] = VertexCount + a; + FirstIndex[IndexCount++] = VertexCount + b; + FirstIndex[IndexCount++] = VertexCount + c; + return *this; + } + int Layer = 0; ptr Tex = 0; Vertex* FirstVertex = nullptr; u16* FirstIndex = nullptr; - size_t VertexCount; - size_t IndexCount; - - PD::Pool* pVpool; - PD::Pool* pIpool; + size_t VertexCount = 0; + size_t IndexCount = 0; + // Todo: implement + size_t VertexCountMax = 0; + size_t IndexCountMax = 0; }; } // namespace Li } // namespace PD \ No newline at end of file diff --git a/include/pd/lithium/lithium.hpp b/include/pd/lithium/lithium.hpp new file mode 100644 index 0000000..73e316e --- /dev/null +++ b/include/pd/lithium/lithium.hpp @@ -0,0 +1,5 @@ +#pragma once + +#include +#include +#include \ No newline at end of file diff --git a/include/pd/lithium/pools.hpp b/include/pd/lithium/pools.hpp new file mode 100644 index 0000000..da82cfd --- /dev/null +++ b/include/pd/lithium/pools.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include +#include + +namespace PD { +namespace Li { +void InitPools(size_t max_vertices = 32768); +Vertex* AllocateVertices(size_t count); +u16* AllocateIndices(size_t count); +} // namespace Li +} // namespace PD \ No newline at end of file diff --git a/source/common.cpp b/source/common.cpp new file mode 100644 index 0000000..b1c1b7a --- /dev/null +++ b/source/common.cpp @@ -0,0 +1,6 @@ +#include +#include + +void PD::Log(const std::string& txt) { + std::cout << "[PD] " << txt << std::endl; +} \ No newline at end of file diff --git a/source/drivers/gfx.cpp b/source/drivers/gfx.cpp index e8dfc39..5e64aeb 100755 --- a/source/drivers/gfx.cpp +++ b/source/drivers/gfx.cpp @@ -5,15 +5,20 @@ PD_API std::unique_ptr Gfx::driver; GfxDriver::GfxDriver(std::string_view name) : DriverInterface(name) {} -void GfxDriver::SetViewPort(const ivec2& size) { ViewPort = size; } +void GfxDriver::SetViewPort(const ivec2& size) { + ViewPort = size; + Projection = Mat4::Ortho(0.f, ViewPort.x, ViewPort.y, 0.f, 1.f, -1.f); +} void GfxDriver::SetViewPort(int x, int y) { ViewPort.x = x; ViewPort.y = y; + Projection = Mat4::Ortho(0.f, ViewPort.x, ViewPort.y, 0.f, 1.f, -1.f); } void GfxDriver::Reset() { CurrentVertex = 0; CurrentIndex = 0; + ResetPools(); SysReset(); } } // namespace PD \ No newline at end of file diff --git a/source/lithium/pools.cpp b/source/lithium/pools.cpp new file mode 100644 index 0000000..e5be94f --- /dev/null +++ b/source/lithium/pools.cpp @@ -0,0 +1,26 @@ +#include + +#include "pd/common.hpp" +#include "pd/core/pool.hpp" +#include "pd/lithium/vertex.hpp" + +namespace PD { +namespace Li { +PD::Pool pVtxPool; +PD::Pool pIdxPool; + +void InitPools(size_t max_vertices) { + pVtxPool.Init(max_vertices); + pIdxPool.Init(max_vertices * 2); +} + +Vertex* AllocateVertices(size_t count) { return pVtxPool.Allocate(count); } + +u16* AllocateIndices(size_t count) { return pIdxPool.Allocate(count); } + +void ResetPools() { + pVtxPool.Reset(); + pIdxPool.Reset(); +} +} // namespace Li +} // namespace PD \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 4ddc2f0..b0e7a20 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,3 +1,4 @@ cmake_minimum_required(VERSION 3.22) -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/core) \ No newline at end of file +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/core) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/gfx) \ No newline at end of file diff --git a/tests/gfx/CMakeLists.txt b/tests/gfx/CMakeLists.txt new file mode 100644 index 0000000..4128ff4 --- /dev/null +++ b/tests/gfx/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.22) + +project(gfx-tests) + +add_executable(gfx-tests ${CMAKE_CURRENT_SOURCE_DIR}/source/main.cpp) +target_link_libraries(gfx-tests PRIVATE palladium::palladium pd-system glfw) diff --git a/tests/gfx/source/main.cpp b/tests/gfx/source/main.cpp new file mode 100644 index 0000000..fc3d2f8 --- /dev/null +++ b/tests/gfx/source/main.cpp @@ -0,0 +1,73 @@ +#include +////////////////////////// +#include + +#include +#include +#include +#include + +#include "pd/core/vec2.hpp" +#include "pd/lithium/pools.hpp" +#include "pd/lithium/vertex.hpp" + +class App { + public: + App() { + PD::Os::UseDriver(); + PD::Gfx::UseDriver(); + glfwInit(); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); + window = glfwCreateWindow(1280, 720, "gfx_tests", nullptr, nullptr); + glfwMakeContextCurrent(window); + gladLoadGLLoader(reinterpret_cast(glfwGetProcAddress)); + glfwSwapInterval(1); + PD::Gfx::Init(); + PD::Li::InitPools(8192); + std::vector img(16 * 16 * 4, 0xff); + pTex = PD::Gfx::LoadTexture(img, 16, 16); + std::cout << "GfxDriver: " << PD::Gfx::GetDriverName() << std::endl; + pPool.Init(10); + auto cmd = pPool.Allocate(1); + cmd->Reserve(4, 6); + cmd->Add(PD::Li::Vertex(PD::fvec2(0, 0), PD::fvec2(0, 0), 0xffffffff)); + cmd->Add(PD::Li::Vertex(PD::fvec2(50, 0), PD::fvec2(1, 0), 0xffffffff)); + cmd->Add(PD::Li::Vertex(PD::fvec2(50, 50), PD::fvec2(1, 1), 0xffffffff)); + cmd->Add(PD::Li::Vertex(PD::fvec2(0, 50), PD::fvec2(0, 1), 0xffffffff)); + cmd->Add(0, 1, 2); + cmd->Add(0, 2, 3); + cmd->Tex = pTex; + } + ~App() { + PD::Gfx::Deinit(); + glfwDestroyWindow(window); + glfwTerminate(); + } + + void Run() { + while (!glfwWindowShouldClose(window)) { + glViewport(0, 0, 1280, 720); + glClearColor(0.1, 0.1, 0.1, 0.1); + glClear(GL_COLOR_BUFFER_BIT); + PD::Gfx::Reset(); + PD::Gfx::SetViewPort(1280, 720); + PD::Gfx::Draw(pPool); + glfwPollEvents(); + glfwSwapBuffers(window); + } + } + + private: + GLFWwindow* window = nullptr; + PD::Pool pPool; + PD::ptr pTex = 0; +}; + +int main() { + App app; + app.Run(); + return 0; +} \ No newline at end of file diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index d3d0333..64cdd42 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -5,4 +5,10 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glad) # STB add_library(stb INTERFACE) -target_include_directories(stb INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/stb) \ No newline at end of file +target_include_directories(stb INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/stb) + +# GLFW +set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "") +set(GLFW_BUILD_TESTS OFF CACHE BOOL "") +set(GLFW_BUILD_DOCS OFF CACHE BOOL "") +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glfw) \ No newline at end of file diff --git a/vendor/glfw b/vendor/glfw new file mode 160000 index 0000000..7b6aead --- /dev/null +++ b/vendor/glfw @@ -0,0 +1 @@ +Subproject commit 7b6aead9fb88b3623e3b3725ebb42670cbe4c579