Skip to content

Commit

Permalink
Trying to load textures
Browse files Browse the repository at this point in the history
  • Loading branch information
tomheeleynz committed Sep 5, 2021
1 parent ca022d8 commit 1f6064d
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
[submodule "Arcane/vendor/imgui"]
path = Arcane/vendor/imgui
url = https://github.com/tomheeleynz/imgui.git
[submodule "Arcane/vendor/stb"]
path = Arcane/vendor/stb
url = https://github.com/tomheeleynz/stb.git
1 change: 1 addition & 0 deletions Arcane/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ project "Arcane"
"%{IncludeDirs.vulkan}",
"%{IncludeDirs.glm}",
"%{IncludeDirs.imgui}",
"%{IncludeDirs.stb}",
"src"
}

Expand Down
10 changes: 10 additions & 0 deletions Arcane/src/Arcane.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
#pragma once

/////////////////////////////////////////////////////
////////// Core
/////////////////////////////////////////////////////
#include "Arcane/Core/Application.h"
#include "Arcane/Core/Layer.h"

/////////////////////////////////////////////////////
////////// Rendering
/////////////////////////////////////////////////////
#include "Arcane/Renderer/Renderer.h"
#include "Arcane/Renderer/Pipeline.h"
#include "Arcane/Renderer/Shader.h"
#include "Arcane/Renderer/RenderPass.h"
#include "Arcane/Renderer/VertexDescriptor.h"
#include "Arcane/Renderer/Buffer.h"
#include "Arcane/Renderer/UniformBuffer.h"
#include "Arcane/Renderer/Texture.h"

/////////////////////////////////////////////////////
////////// ImGui
/////////////////////////////////////////////////////
#include "Arcane/ImGui/ImGuiLayer.h"
14 changes: 14 additions & 0 deletions Arcane/src/Arcane/Platform/Vulkan/VulkanTexture.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "VulkanTexture.h"

namespace Arcane
{
VulkanTexture::VulkanTexture(std::string fileName)
{
int width, height, channels = 0;
stbi_uc* pixels = stbi_load(fileName.c_str(), &width, &height, &channels, STBI_rgb_alpha);

if (pixels) {
printf("Data loaded\n");
}
}
}
16 changes: 16 additions & 0 deletions Arcane/src/Arcane/Platform/Vulkan/VulkanTexture.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
#include "Arcane/Renderer/Texture.h"

namespace Arcane
{
class VulkanTexture : public Texture
{
public:
VulkanTexture(std::string fileName);
private:

};
}
16 changes: 16 additions & 0 deletions Arcane/src/Arcane/Renderer/Texture.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "RendererAPI.h"
#include "Texture.h"

#include "Arcane/Platform/Vulkan/VulkanTexture.h"


namespace Arcane {
Texture* Texture::Create(std::string fileName) {
switch (RendererAPI::Current())
{
case RendererAPIType::Vulkan: return new VulkanTexture(fileName);
default:
return nullptr;
}
}
}
1 change: 1 addition & 0 deletions Arcane/vendor/stb
Submodule stb added at c0c982
3 changes: 2 additions & 1 deletion EnchantingTable/premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ project "EnchantingTable"
"%{IncludeDirs.vulkan}",
"%{IncludeDirs.glm}",
"%{IncludeDirs.glfw}",
"%{IncludeDirs.imgui}"
"%{IncludeDirs.imgui}",
"%{IncludeDirs.stb}"
}

links {
Expand Down
Binary file added EnchantingTable/src/Assets/Textures/shield.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion EnchantingTable/src/EditorLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>

#include <cmath>
#include "EditorLayer.h"

struct TestVertex
Expand Down Expand Up @@ -61,6 +61,8 @@ void EditorLayer::OnAttach()
Arcane::IndexBuffer* indexBuffer = Arcane::IndexBuffer::Create(indices.data(), indices.size());
m_VertexBuffer->AddIndexBuffer(indexBuffer);

Arcane::Texture* testTexture = Arcane::Texture::Create(".\\src\\Assets\\Textures\\shield.png");

}

void EditorLayer::OnDetach()
Expand Down
1 change: 1 addition & 0 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ IncludeDirs["glfw"] = "%{wks.location}/Arcane/vendor/glfw/include"
IncludeDirs["vulkan"] = "%{VULKAN_SDK}/Include"
IncludeDirs["glm"] ="%{wks.location}/Arcane/vendor/glm"
IncludeDirs["imgui"] = "%{wks.location}/Arcane/vendor/imgui"
IncludeDirs["stb"] = "%{wks.location}/Arcane/vendor/stb"

-- Library Includes
LibDirs = {}
Expand Down

0 comments on commit 1f6064d

Please sign in to comment.