mirror of
https://github.com/bailwillharr/engine.git
synced 2024-09-21 04:51:18 +00:00
Attempt to fix coordinate system
This commit is contained in:
parent
604513f44d
commit
591d0ea3c2
2
dependencies/VulkanMemoryAllocator
vendored
2
dependencies/VulkanMemoryAllocator
vendored
@ -1 +1 @@
|
||||
Subproject commit c351692490513cdb0e5a2c925aaf7ea4a9b672f4
|
||||
Subproject commit 0e89587db3ebee4d463f191bd296374c5fafc8ea
|
@ -107,8 +107,9 @@ class Scene {
|
||||
|
||||
private:
|
||||
Application* const app_;
|
||||
public:
|
||||
Entity next_entity_id_ = 1; // 0 is not a valid entity
|
||||
|
||||
private:
|
||||
uint64_t framecount_ = 0;
|
||||
|
||||
/* ecs stuff */
|
||||
|
@ -21,4 +21,5 @@ void main() {
|
||||
vec3 position = mat3(frameSetUniformBuffer.view) * vec3(constants.model * vec4(inPosition, 1.0));
|
||||
gl_Position = (globalSetUniformBuffer.proj * vec4(position, 0.0)).xyzz;
|
||||
fragUV = inUV;
|
||||
gl_Position.y *= -1.0;
|
||||
}
|
||||
|
@ -30,4 +30,6 @@ void main() {
|
||||
|
||||
vec3 lightPos = vec3(2000.0, 2000.0, -2000.0);
|
||||
fragLightPos = vec3(frameSetUniformBuffer.view * vec4(lightPos, 1.0));
|
||||
|
||||
gl_Position.y *= -1.0;
|
||||
}
|
||||
|
@ -47,6 +47,8 @@
|
||||
#include "log.h"
|
||||
#include "util/files.h"
|
||||
|
||||
static constexpr bool flip_viewport = false;
|
||||
|
||||
inline static void checkVulkanError(VkResult errorCode, int lineNo) {
|
||||
if (errorCode != VK_SUCCESS) {
|
||||
const std::string message("VULKAN ERROR ON LINE " + std::to_string(lineNo));
|
||||
@ -398,8 +400,6 @@ GFXDevice::GFXDevice(const char* appName, const char* appVersion,
|
||||
DeviceRequirements deviceRequirements{};
|
||||
deviceRequirements.requiredExtensions.push_back(
|
||||
VK_KHR_SWAPCHAIN_EXTENSION_NAME);
|
||||
deviceRequirements.requiredExtensions.push_back(
|
||||
VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
|
||||
deviceRequirements.optionalExtensions.push_back(
|
||||
VK_EXT_MEMORY_PRIORITY_EXTENSION_NAME);
|
||||
deviceRequirements.optionalExtensions.push_back(
|
||||
@ -728,10 +728,17 @@ gfx::DrawBuffer* GFXDevice::BeginRender() {
|
||||
VK_SUBPASS_CONTENTS_INLINE);
|
||||
|
||||
VkViewport viewport{};
|
||||
if (flip_viewport) {
|
||||
viewport.x = 0.0f;
|
||||
viewport.y = (float)pimpl->swapchain.extent.height;
|
||||
viewport.width = (float)pimpl->swapchain.extent.width;
|
||||
viewport.height = -(float)pimpl->swapchain.extent.height;
|
||||
} else {
|
||||
viewport.x = 0.0f;
|
||||
viewport.y = 0.0f;
|
||||
viewport.width = (float)pimpl->swapchain.extent.width;
|
||||
viewport.height = (float)pimpl->swapchain.extent.height;
|
||||
}
|
||||
viewport.minDepth = 0.0f;
|
||||
viewport.maxDepth = 1.0f;
|
||||
vkCmdSetViewport(frameData.drawBuf, 0, 1, &viewport);
|
||||
@ -950,10 +957,17 @@ gfx::Pipeline* GFXDevice::CreatePipeline(const gfx::PipelineInfo& info) {
|
||||
inputAssembly.primitiveRestartEnable = VK_FALSE;
|
||||
|
||||
VkViewport viewport{};
|
||||
if (flip_viewport) {
|
||||
viewport.x = 0.0f;
|
||||
viewport.y = (float)pimpl->swapchain.extent.height;
|
||||
viewport.width = (float)pimpl->swapchain.extent.width;
|
||||
viewport.height = -(float)pimpl->swapchain.extent.height;
|
||||
} else {
|
||||
viewport.x = 0.0f;
|
||||
viewport.y = 0.0f;
|
||||
viewport.width = (float)pimpl->swapchain.extent.width;
|
||||
viewport.height = (float)pimpl->swapchain.extent.height;
|
||||
}
|
||||
viewport.minDepth = 0.0f;
|
||||
viewport.maxDepth = 1.0f;
|
||||
|
||||
@ -1172,7 +1186,8 @@ gfx::DescriptorSet* GFXDevice::AllocateDescriptorSet(
|
||||
void GFXDevice::FreeDescriptorSet(const gfx::DescriptorSet* set) {
|
||||
assert(set != nullptr);
|
||||
VKCHECK(vkFreeDescriptorSets(pimpl->device.device, pimpl->descriptorPool,
|
||||
static_cast<uint32_t>(set->sets.size()), set->sets.data()));
|
||||
static_cast<uint32_t>(set->sets.size()),
|
||||
set->sets.data()));
|
||||
}
|
||||
|
||||
void GFXDevice::UpdateDescriptorUniformBuffer(const gfx::DescriptorSet* set,
|
||||
|
@ -4,6 +4,24 @@
|
||||
#include <glm/trigonometric.hpp>
|
||||
#include <glm/ext/matrix_clip_space.hpp>
|
||||
|
||||
[[maybe_unused]] static glm::mat4 GenPerspectiveMatrix(float vertical_fov_radians,
|
||||
float aspect_ratio, float znear,
|
||||
float zfar) {
|
||||
float g = 1.0f / tan(vertical_fov_radians * 0.5);
|
||||
float k1 = zfar / (zfar - znear);
|
||||
float k2 = -(zfar * znear) / (znear - zfar);
|
||||
glm::mat4 m{1.0f};
|
||||
|
||||
m[0][0] = g / aspect_ratio;
|
||||
m[1][1] = g;
|
||||
m[2][2] = k1;
|
||||
m[2][3] = -1.0f;
|
||||
m[3][2] = k2;
|
||||
m[3][3] = 0.0f;
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
namespace engine {
|
||||
|
||||
Renderer::Renderer(const char* app_name, const char* app_version,
|
||||
@ -71,7 +89,7 @@ void Renderer::PreRender(bool window_is_resized, glm::mat4 camera_transform) {
|
||||
uint32_t w, h;
|
||||
device_->GetViewportSize(&w, &h);
|
||||
viewport_aspect_ratio_ = (float)w / (float)h;
|
||||
const glm::mat4 proj_matrix = glm::perspectiveZO(
|
||||
const glm::mat4 proj_matrix = glm::perspectiveRH_ZO(
|
||||
camera_settings_.vertical_fov_radians, viewport_aspect_ratio_,
|
||||
camera_settings_.clip_near, camera_settings_.clip_far);
|
||||
/* update SET 0 (rarely changing uniforms)*/
|
||||
|
@ -144,7 +144,7 @@ namespace engine::util {
|
||||
aiProcess_GenSmoothNormals |
|
||||
aiProcess_GenUVCoords |
|
||||
aiProcess_TransformUVCoords |
|
||||
aiProcess_FlipUVs | // Maybe?
|
||||
aiProcess_FlipUVs | // Collada uses bottom-left origin
|
||||
0
|
||||
);
|
||||
|
||||
|
@ -147,8 +147,6 @@ namespace engine {
|
||||
const std::vector<const char*> windowExtensions = getWindowExtensions(window);
|
||||
std::vector<const char*> instanceExtensionsToUse = windowExtensions;
|
||||
|
||||
instanceExtensionsToUse.push_back(VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
|
||||
|
||||
const char* validationLayer = nullptr;
|
||||
if (useValidation) {
|
||||
validationLayer = getValidationLayer();
|
||||
|
@ -117,14 +117,9 @@ namespace engine {
|
||||
|
||||
/* create swapchain */
|
||||
|
||||
VkSurfaceFullScreenExclusiveInfoEXT fullscreenInfo{};
|
||||
fullscreenInfo.sType = VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT;
|
||||
fullscreenInfo.pNext = nullptr;
|
||||
fullscreenInfo.fullScreenExclusive = VK_FULL_SCREEN_EXCLUSIVE_ALLOWED_EXT;
|
||||
|
||||
VkSwapchainCreateInfoKHR scInfo{
|
||||
.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
|
||||
.pNext = &fullscreenInfo,
|
||||
.pNext = nullptr,
|
||||
.flags = 0,
|
||||
.surface = info.surface,
|
||||
.minImageCount = minImageCount,
|
||||
|
BIN
test/res/models/MY_AXES.dae
(Stored with Git LFS)
Normal file
BIN
test/res/models/MY_AXES.dae
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
test/res/models/cobble_house/_stone_bricks.png
Normal file
BIN
test/res/models/cobble_house/_stone_bricks.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.0 MiB |
BIN
test/res/models/terrain.dae
(Stored with Git LFS)
BIN
test/res/models/terrain.dae
(Stored with Git LFS)
Binary file not shown.
BIN
test/res/models/uvcheck.dae
(Stored with Git LFS)
Normal file
BIN
test/res/models/uvcheck.dae
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
test/res/textures/uvcheck.png
Normal file
BIN
test/res/textures/uvcheck.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 MiB |
@ -142,16 +142,17 @@ void PlayGame(GameSettings settings) {
|
||||
LOG_DEBUG("Textbox custom component initialised!");
|
||||
};
|
||||
|
||||
textboxComponent->onUpdate = [](float ts) {
|
||||
textboxComponent->onUpdate = [&](float ts) {
|
||||
static float time_elapsed;
|
||||
time_elapsed += ts;
|
||||
if (time_elapsed >= 1.0f) {
|
||||
time_elapsed = 0.0f;
|
||||
LOG_INFO("COMPONENT UPDATE");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
engine::util::LoadMeshFromFile(my_scene, app.GetResourcePath("models/MY_AXES.dae"), true);
|
||||
my_scene->GetComponent<engine::TransformComponent>(engine::util::LoadMeshFromFile(my_scene, app.GetResourcePath("models/uvcheck.dae"), true))->position += glm::vec3{20.0f, 20.0f, 20.0f};
|
||||
/* teapot */
|
||||
my_scene
|
||||
->GetComponent<engine::TransformComponent>(
|
||||
|
Loading…
Reference in New Issue
Block a user