Skip to content

Commit

Permalink
WIP ImGui and DrawRequest/DrawCallHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
desatur committed Dec 12, 2024
1 parent 12d2bf7 commit a454d93
Show file tree
Hide file tree
Showing 223 changed files with 107,092 additions and 36 deletions.
15 changes: 0 additions & 15 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
[submodule "lib/benchmark"]
path = thirdParty/benchmark
url = https://github.com/google/benchmark.git
[submodule "thirdParty/SDL"]
path = thirdParty/SDL
url = https://github.com/libsdl-org/SDL/
branch = SDL2
[submodule "thirdParty/glfw"]
path = thirdParty/glfw
url = https://github.com/glfw/glfw
[submodule "thirdParty/gv"]
path = thirdParty/gv
url = https://github.com/kohakow/gv
Expand All @@ -20,18 +14,9 @@
[submodule "thirdParty/glm"]
path = thirdParty/glm
url = https://github.com/g-truc/glm
[submodule "thirdParty/json"]
path = thirdParty/json
url = https://github.com/nlohmann/json
[submodule "thirdParty/tinygltf"]
path = thirdParty/tinygltf
url = https://github.com/syoyo/tinygltf/
[submodule "thirdParty/entt"]
path = thirdParty/entt
url = https://github.com/skypjack/entt
[submodule "thirdParty/imgui"]
path = thirdParty/imgui
url = https://github.com/ocornut/imgui
[submodule "thirdParty/assimp"]
path = thirdParty/assimp
url = https://github.com/assimp/assimp
16 changes: 8 additions & 8 deletions Future/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ project(Future)

add_subdirectory(${THIRD_PARTY_LIB_DIR}/spdlog spdlog)
add_subdirectory(${THIRD_PARTY_LIB_DIR}/SDL SDL)
add_subdirectory(${THIRD_PARTY_LIB_DIR}/glfw glfw)
add_subdirectory(${THIRD_PARTY_LIB_DIR}/glm glm)
add_subdirectory(${THIRD_PARTY_LIB_DIR}/json json)
set(BUILD_SHARED_LIBS ON)
add_subdirectory(${THIRD_PARTY_LIB_DIR}/assimp assimp)
#add_subdirectory(${THIRD_PARTY_LIB_DIR}/imgui_cmake imgui)

add_library(Future SHARED
# GLAD
Expand Down Expand Up @@ -53,10 +52,10 @@ add_library(Future SHARED
src/Rendering/Textures/Texture.hpp
src/Rendering/Camera.cpp
src/Rendering/Camera.hpp
src/Rendering/Model/Mesh.cpp
src/Rendering/Model/Mesh.hpp
src/Rendering/Model/Model.cpp
src/Rendering/Model/Model.hpp
src/Rendering/Mesh/Mesh.cpp
src/Rendering/Mesh/Mesh.hpp
src/Rendering/Mesh/Model.cpp
src/Rendering/Mesh/Model.hpp
src/Rendering/Vertex.hpp
)

Expand All @@ -66,16 +65,17 @@ target_include_directories(Future PUBLIC
${THIRD_PARTY_LIB_DIR}/glad/include/
${THIRD_PARTY_LIB_DIR}/stb/
${THIRD_PARTY_LIB_DIR}/glm/glm/
${THIRD_PARTY_LIB_DIR}/json/include
${THIRD_PARTY_LIB_DIR}/assimp/include
#${THIRD_PARTY_LIB_DIR}/imgui_cmake
#${THIRD_PARTY_LIB_DIR}/imgui_cmake/backends
)

target_link_libraries(Future PUBLIC spdlog::spdlog $<$<BOOL:${MINGW}>:ws2_32>)
target_link_libraries(Future PUBLIC SDL2::SDL2main)
target_link_libraries(Future PUBLIC SDL2::SDL2)
target_link_libraries(Future PUBLIC glfw)
target_link_libraries(Future PUBLIC glm)
target_link_libraries(Future PUBLIC assimp)
#target_link_libraries(Future PUBLIC imgui)

add_custom_command(TARGET Future POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
Expand Down
1 change: 0 additions & 1 deletion Future/src/Rendering/Camera.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "Shaders.hpp"
#include "../../../thirdParty/glm/glm/vec3.hpp"
#include "../../../thirdParty/glfw/include/GLFW/glfw3.h"
#include "../../../thirdParty/glm/glm/glm.hpp"
#include <glad/glad.h>
#include "../../../thirdParty/glm/glm/gtc/type_ptr.hpp"
Expand Down
27 changes: 27 additions & 0 deletions Future/src/Rendering/DrawCalls/DrawCallHandler.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "DrawCallHandler.hpp"

namespace Future {
unsigned int DrawCallHandler::Push(DrawRequest request) {
drawRequestQueue.push_back(request);
}

bool DrawCallHandler::Pop(unsigned int id) {
auto it = std::find_if(drawRequestQueue.begin(), drawRequestQueue.end(),
[id](const DrawRequest& request) {
return request.ID == id;
});
if (it != drawRequestQueue.end()) {
drawRequestQueue.erase(it);
return true;
}
return false;
}

void DrawCallHandler::DrawFrame() {
for (unsigned int i = 0; i < drawRequestQueue.size(); i++)
{
//drawRequestQueue[i].mesh.Draw(shader, camera, matricesMeshes[i], translationsMeshes[i], rotationsMeshes[i], scalesMeshes[i]);
}
drawRequestQueue.clear();
}
}
16 changes: 16 additions & 0 deletions Future/src/Rendering/DrawCalls/DrawCallHandler.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once
#include "DrawRequest.hpp"
#include <glad.h>

namespace Future {
class DrawCallHandler {
public:
[[nodiscard]] unsigned int GetDrawCalls() const { return drawRequestQueue.size(); }
unsigned int Push(DrawRequest request);
bool Pop(unsigned int ID);
void DrawFrame();

private:
std::vector<DrawRequest> drawRequestQueue;
};
}
12 changes: 12 additions & 0 deletions Future/src/Rendering/DrawCalls/DrawRequest.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once
#include "../Shaders.hpp"
#include "../Mesh/Mesh.hpp"

struct DrawRequest
{
unsigned int ID;
Future::Shaders shaders;
//Future::Material material;
Future::Mesh mesh;
glm::mat4 modelMatrix;
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <../../../thirdParty/json/include/nlohmann/json.hpp>
#include <glm/gtx/matrix_decompose.hpp>

namespace Future
Expand Down
2 changes: 1 addition & 1 deletion Future/src/Rendering/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ namespace Future
m_mainCamera.UpdateMatrix(45.0f, 0.01f, 10000.0f);
m_mainCamera.Matrix(*defaultShaderProgram, "camMatrix");

//helmet.Draw(*defaultShaderProgram, m_mainCamera);
helmet.Draw(*defaultShaderProgram, m_mainCamera);
sponza.Draw(*defaultShaderProgram, m_mainCamera);

glBindFramebuffer(GL_FRAMEBUFFER, 0); // Bind the default framebuffer
Expand Down
2 changes: 1 addition & 1 deletion Future/src/Rendering/Renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <../../../thirdParty/glm/glm/gtc/matrix_transform.hpp>
#include <../../../thirdParty/glm/glm/gtc/type_ptr.hpp>
#include "Shaders.hpp"
#include "Model/Model.hpp"
#include "Mesh/Model.hpp"
#include "Camera.hpp"
#include "Shaders.hpp"
#include "Buffers/EBO.hpp"
Expand Down
5 changes: 1 addition & 4 deletions Future/src/Rendering/Vertex.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef VERTEX_HPP
#define VERTEX_HPP
#pragma once
#include "vec2.hpp"
#include "vec3.hpp"

Expand All @@ -10,5 +9,3 @@ struct Vertex
glm::vec3 color;
glm::vec2 TexCoords;
};

#endif //VERTEX_HPP
1 change: 0 additions & 1 deletion thirdParty/glfw
Submodule glfw deleted from b35641
1 change: 0 additions & 1 deletion thirdParty/gv
Submodule gv deleted from 0340ab
1 change: 0 additions & 1 deletion thirdParty/imgui
Submodule imgui deleted from fb4104
28 changes: 28 additions & 0 deletions thirdParty/imgui_cmake/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# See http://editorconfig.org to read about the EditorConfig format.
# - In theory automatically supported by VS2017+ and most common IDE or text editors.
# - In practice VS2019-VS2022 stills don't trim trailing whitespaces correctly :(
# - Suggest installing this to trim whitespaces:
# GitHub https://github.com/madskristensen/TrailingWhitespace
# VS2019 https://marketplace.visualstudio.com/items?itemName=MadsKristensen.TrailingWhitespaceVisualizer
# VS2022 https://marketplace.visualstudio.com/items?itemName=MadsKristensen.TrailingWhitespace64
# (in spite of its name doesn't only visualize but also trims)
# - Alternative for older VS2010 to VS2015: https://marketplace.visualstudio.com/items?itemName=EditorConfigTeam.EditorConfig

# top-most EditorConfig file
root = true

# Default settings:
# Use 4 spaces as indentation
[*]
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[imstb_*]
indent_size = 3
trim_trailing_whitespace = false

[Makefile]
indent_style = tab
indent_size = 4
30 changes: 30 additions & 0 deletions thirdParty/imgui_cmake/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
* text=auto

*.c text
*.cpp text
*.h text
*.m text
*.mm text
*.md text
*.txt text
*.html text
*.bat text
*.frag text
*.vert text
*.mkb text
*.icf text

*.sln text eol=crlf
*.vcxproj text eol=crlf
*.vcxproj.filters text eol=crlf
*.natvis text eol=crlf

Makefile text eol=lf
*.sh text eol=lf
*.pbxproj text eol=lf
*.storyboard text eol=lf
*.plist text eol=lf

*.png binary
*.ttf binary
*.lib binary
61 changes: 61 additions & 0 deletions thirdParty/imgui_cmake/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
## OSX artifacts
.DS_Store

## Dear ImGui artifacts
imgui.ini
imgui*.ini

## General build artifacts
*.o
*.obj
*.exe
examples/*/Debug/*
examples/*/Release/*
examples/*/x64/*

## Visual Studio artifacts
.vs
ipch
*.opensdf
*.log
*.pdb
*.ilk
*.user
*.sdf
*.suo
*.VC.db
*.VC.VC.opendb

## Getting files created in JSON/Schemas/Catalog/ from a VS2022 update
JSON/

## Commonly used CMake directories
build*/

## Xcode artifacts
project.xcworkspace
xcuserdata

## Emscripten artifacts
examples/*.o.tmp
examples/*.out.js
examples/*.out.wasm
examples/example_glfw_opengl3/web/*
examples/example_glfw_wgpu/web/*
examples/example_glfw_wgpu/external/*
examples/example_sdl2_opengl3/web/*

## JetBrains IDE artifacts
.idea
cmake-build-*

## Unix executables from our example Makefiles
examples/example_glfw_metal/example_glfw_metal
examples/example_glfw_opengl2/example_glfw_opengl2
examples/example_glfw_opengl3/example_glfw_opengl3
examples/example_glut_opengl2/example_glut_opengl2
examples/example_null/example_null
examples/example_sdl2_metal/example_sdl2_metal
examples/example_sdl2_opengl2/example_sdl2_opengl2
examples/example_sdl2_opengl3/example_sdl2_opengl3
examples/example_sdl2_sdlrenderer/example_sdl2_sdlrenderer
24 changes: 24 additions & 0 deletions thirdParty/imgui_cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
set(_target "imgui")

add_library(${_target}
imconfig.h
imgui_demo.cpp
imgui_draw.cpp
imgui_tables.cpp
imgui_widgets.cpp
imgui.cpp
misc/cpp/imgui_stdlib.cpp
misc/cpp/imgui_stdlib.h
backends/imgui_impl_opengl3.cpp
backends/imgui_impl_opengl3.h
backends/imgui_impl_sdl2.cpp
backends/imgui_impl_sdl2.h
)

target_include_directories(${_target}
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/imgui"
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}"
)

target_link_libraries(${_target} PUBLIC SDL2::SDL2main)
target_link_libraries(${_target} PUBLIC SDL2::SDL2)
21 changes: 21 additions & 0 deletions thirdParty/imgui_cmake/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014-2024 Omar Cornut

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit a454d93

Please sign in to comment.