mirror of
https://github.com/bailwillharr/engine.git
synced 2024-09-21 04:51:18 +00:00
Add assimp library
This commit is contained in:
parent
f06ccecd33
commit
6c50c37825
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,6 +3,7 @@
|
||||
.vs/
|
||||
out/
|
||||
build/
|
||||
/build*/
|
||||
Debug/
|
||||
Release/
|
||||
MinSizeRel/
|
||||
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -22,3 +22,6 @@
|
||||
[submodule "dependencies/VulkanMemoryAllocator"]
|
||||
path = dependencies/VulkanMemoryAllocator
|
||||
url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
|
||||
[submodule "dependencies/assimp"]
|
||||
path = dependencies/assimp
|
||||
url = https://github.com/assimp/assimp
|
||||
|
@ -203,10 +203,18 @@ set(FT_DISABLE_BZIP2 TRUE CACHE INTERNAL "" FORCE)
|
||||
set(FT_DISABLE_PNG TRUE CACHE INTERNAL "" FORCE)
|
||||
set(FT_DISABLE_HARFBUZZ TRUE CACHE INTERNAL "" FORCE)
|
||||
set(FT_DISABLE_BROTLI TRUE CACHE INTERNAL "" FORCE)
|
||||
set(BUILD_SHARED_LIBS ON)
|
||||
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "" FORCE)
|
||||
add_subdirectory(dependencies/freetype)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE freetype)
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE dependencies/freetype/include)
|
||||
|
||||
# stb
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE dependencies/stb)
|
||||
|
||||
# assimp
|
||||
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "" FORCE)
|
||||
set(ASSIMP_BUILD_TESTS OFF CACHE INTERNAL "" FORCE)
|
||||
set(ASSIMP_INSTALL OFF CACHE INTERNAL "" FORCE)
|
||||
add_subdirectory(dependencies/assimp)
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE dependencies/assimp/include)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE assimp)
|
1
dependencies/assimp
vendored
Submodule
1
dependencies/assimp
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 6392dbfe4d9b0e23d4e573d0f3e45a198412ece1
|
@ -24,7 +24,7 @@ public:
|
||||
void render(glm::mat4 model, glm::mat4 view);
|
||||
|
||||
void setMesh(const std::string& name);
|
||||
void setTexture(const std::string& name);
|
||||
void setTexture(const std::string& name, bool invertV = false);
|
||||
|
||||
std::shared_ptr<resources::Mesh> m_mesh = nullptr;
|
||||
std::shared_ptr<resources::Texture> m_texture;
|
||||
|
@ -73,9 +73,9 @@ void Camera::usePerspective(float fovDeg)
|
||||
m_mode = Modes::PERSPECTIVE;
|
||||
m_fovDeg = fovDeg;
|
||||
|
||||
glm::vec2 viewportDim = getViewportSize();
|
||||
|
||||
float fovRad = glm::radians(fovDeg);
|
||||
|
||||
glm::vec2 viewportDim = getViewportSize();
|
||||
m_projMatrix = glm::perspectiveFovRH_ZO(fovRad, viewportDim.x, viewportDim.y, NEAR, FAR);
|
||||
}
|
||||
|
||||
|
@ -40,9 +40,15 @@ void Renderer::setMesh(const std::string& name)
|
||||
m_mesh = parent.res.get<resources::Mesh>(name);
|
||||
}
|
||||
|
||||
void Renderer::setTexture(const std::string& name)
|
||||
void Renderer::setTexture(const std::string& name, bool invertV)
|
||||
{
|
||||
if (invertV) {
|
||||
// append a special character to file name
|
||||
m_texture = parent.res.get<resources::Texture>(name + "_");
|
||||
}
|
||||
else {
|
||||
m_texture = parent.res.get<resources::Texture>(name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ namespace engine {
|
||||
*h = (uint32_t)height;
|
||||
}
|
||||
|
||||
void GFXDevice::draw(const gfx::Pipeline* pipeline, const gfx::Buffer* vertexBuffer, const gfx::Buffer* indexBuffer, uint32_t count, const void* pushConstantData, size_t pushConstantSize)
|
||||
void draw(const gfx::Pipeline* pipeline, const gfx::Buffer* vertexBuffer, const gfx::Buffer* indexBuffer, uint32_t count, const void* pushConstantData, size_t pushConstantSize, const gfx::Texture* texture)
|
||||
{
|
||||
assert(vertexBuffer->type == gfx::BufferType::VERTEX);
|
||||
assert(vertexBuffer != nullptr);
|
||||
|
@ -500,11 +500,12 @@ namespace engine {
|
||||
|
||||
static VkSampleCountFlagBits getMaxSampleCount(VkPhysicalDevice physicalDevice)
|
||||
{
|
||||
|
||||
VkPhysicalDeviceProperties physicalDeviceProperties;
|
||||
vkGetPhysicalDeviceProperties(physicalDevice, &physicalDeviceProperties);
|
||||
|
||||
VkSampleCountFlags counts = physicalDeviceProperties.limits.framebufferColorSampleCounts & physicalDeviceProperties.limits.framebufferDepthSampleCounts;
|
||||
counts %= VK_SAMPLE_COUNT_8_BIT; // restricts it to 8
|
||||
//counts %= VK_SAMPLE_COUNT_8_BIT; // restricts it to 8
|
||||
if (counts & VK_SAMPLE_COUNT_64_BIT) { INFO("64"); return VK_SAMPLE_COUNT_64_BIT; }
|
||||
if (counts & VK_SAMPLE_COUNT_32_BIT) { INFO("32"); return VK_SAMPLE_COUNT_32_BIT; }
|
||||
if (counts & VK_SAMPLE_COUNT_16_BIT) { INFO("16"); return VK_SAMPLE_COUNT_16_BIT; }
|
||||
@ -542,7 +543,30 @@ namespace engine {
|
||||
res = vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, surface, &surfacePresentModeCount, presentModes.data());
|
||||
assert(res == VK_SUCCESS);
|
||||
|
||||
VkExtent2D oldExtent = swapchain->extent;
|
||||
|
||||
if (caps.currentExtent.width != std::numeric_limits<uint32_t>::max()) {
|
||||
swapchain->extent = caps.currentExtent;
|
||||
}
|
||||
else {
|
||||
// if fb size isn't already found, get it from SDL
|
||||
int width, height;
|
||||
SDL_Vulkan_GetDrawableSize(window, &width, &height);
|
||||
|
||||
swapchain->extent.width = static_cast<uint32_t>(width);
|
||||
swapchain->extent.height = static_cast<uint32_t>(height);
|
||||
|
||||
swapchain->extent.width = std::clamp(
|
||||
swapchain->extent.width,
|
||||
caps.minImageExtent.width, caps.maxImageExtent.width);
|
||||
swapchain->extent.height = std::clamp(
|
||||
swapchain->extent.height,
|
||||
caps.minImageExtent.height, caps.maxImageExtent.height);
|
||||
}
|
||||
|
||||
if (swapchain->extent.width == 0 || swapchain->extent.height == 0) {
|
||||
swapchain->extent = oldExtent;
|
||||
}
|
||||
|
||||
// delete old framebuffers
|
||||
for (VkFramebuffer fb : swapchain->framebuffers) {
|
||||
@ -570,27 +594,6 @@ namespace engine {
|
||||
}
|
||||
}
|
||||
|
||||
VkExtent2D oldExtent = swapchain->extent;
|
||||
|
||||
if (caps.currentExtent.width != std::numeric_limits<uint32_t>::max()) {
|
||||
swapchain->extent = caps.currentExtent;
|
||||
}
|
||||
else {
|
||||
// if fb size isn't already found, get it from SDL
|
||||
int width, height;
|
||||
SDL_Vulkan_GetDrawableSize(window, &width, &height);
|
||||
|
||||
swapchain->extent.width = static_cast<uint32_t>(width);
|
||||
swapchain->extent.height = static_cast<uint32_t>(height);
|
||||
|
||||
swapchain->extent.width = std::clamp(
|
||||
swapchain->extent.width,
|
||||
caps.minImageExtent.width, caps.maxImageExtent.width);
|
||||
swapchain->extent.height = std::clamp(
|
||||
swapchain->extent.height,
|
||||
caps.minImageExtent.height, caps.maxImageExtent.height);
|
||||
}
|
||||
|
||||
uint32_t imageCount = caps.minImageCount + 1;
|
||||
if (caps.maxImageCount > 0 && imageCount > caps.maxImageCount) {
|
||||
imageCount = caps.maxImageCount;
|
||||
@ -1507,10 +1510,17 @@ namespace engine {
|
||||
{
|
||||
int width, height;
|
||||
SDL_Vulkan_GetDrawableSize(pimpl->window, &width, &height);
|
||||
if (width == 0 || height == 0) {
|
||||
*w = (uint32_t)pimpl->swapchain.extent.width;
|
||||
*h = (uint32_t)pimpl->swapchain.extent.height;
|
||||
}
|
||||
else {
|
||||
*w = (uint32_t)width;
|
||||
*h = (uint32_t)height;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void GFXDevice::draw(const gfx::Pipeline* pipeline, const gfx::Buffer* vertexBuffer, const gfx::Buffer* indexBuffer, uint32_t count, const void* pushConstantData, size_t pushConstantSize, const gfx::Texture* texture)
|
||||
{
|
||||
assert(vertexBuffer->type == gfx::BufferType::VERTEX);
|
||||
|
@ -63,9 +63,18 @@ static bool readGLRaw(const std::string& path, std::vector<uint8_t>* texbuf, int
|
||||
|
||||
}
|
||||
|
||||
Texture::Texture(const std::filesystem::path& resPath) : Resource(resPath, "texture")
|
||||
Texture::Texture(const std::filesystem::path& originalResPath) : Resource(originalResPath, "texture")
|
||||
{
|
||||
|
||||
std::string resString = originalResPath.string();
|
||||
bool flipV = false;
|
||||
if (resString.back() == '_') {
|
||||
flipV = true;
|
||||
resString.pop_back();
|
||||
}
|
||||
|
||||
std::filesystem::path resPath{ resString };
|
||||
|
||||
auto texbuf = std::make_unique<std::vector<uint8_t>>();
|
||||
|
||||
int width, height;
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 6.6 MiB After Width: | Height: | Size: 7.6 MiB |
@ -153,5 +153,10 @@ void playGame()
|
||||
boundsRen->m_mesh = genSphereMesh(100.0f, 100, true);
|
||||
boundsRen->setTexture("textures/metal.jpg");
|
||||
|
||||
auto pyramid = app.scene()->createChild("pyramid");
|
||||
auto pyramidRen = pyramid->createComponent<engine::components::Renderer>();
|
||||
pyramidRen->setMesh("meshes/pyramid.mesh");
|
||||
pyramidRen->setTexture("textures/pyramid.png");
|
||||
|
||||
app.gameLoop();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user