Move back to C++
This commit is contained in:
13 files changed
+44
-83
No files matched your search
@@ -1,18 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
project(GraphicsEngine)
|
||||
|
||||
add_library(${PROJECT_NAME} SHARED
|
||||
src/window.c
|
||||
src/vmaInit.cpp
|
||||
src/vulkanBase.c)
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||
${PROJECT_SOURCE_DIR}/include
|
||||
${PROJECT_SOURCE_DIR}/locales
|
||||
${CMAKE_SOURCE_DIR}/third_party/vma/include
|
||||
${CMAKE_SOURCE_DIR}/Utilities/include)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
vulkan
|
||||
glfw)
|
||||
@@ -1,26 +0,0 @@
|
||||
/**
|
||||
* @file vmaInit.cpp
|
||||
* @author Piotr Krygier (everyonecancode@gmail.com)
|
||||
* @brief VMA is written in C, but has C++ compatible interface. It still needs to compiled as C++ though, hence the
|
||||
* file
|
||||
* @version 0.1
|
||||
* @date 2022-05-23
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic warning "-Wunused"
|
||||
# pragma GCC diagnostic warning "-Wpedantic"
|
||||
# pragma GCC diagnostic warning "-Wignored-qualifiers"
|
||||
# pragma GCC diagnostic warning "-Wmissing-field-initializers"
|
||||
# pragma GCC diagnostic warning "-Wimplicit-fallthrough"
|
||||
# pragma GCC diagnostic warning "-Wswitch"
|
||||
# pragma GCC diagnostic warning "-Wparentheses"
|
||||
#define VMA_IMPLEMENTATION
|
||||
#define VMA_STATIC_VULKAN_FUNCTIONS 0
|
||||
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 1
|
||||
#define VMA_STATS_STRING_ENABLED 0
|
||||
#include <vk_mem_alloc.h>
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -0,0 +1,20 @@
|
||||
CC := /usr/bin/g++
|
||||
INCLUDE_DIR := -I./include -I./third_party/vma/include
|
||||
CFLAGS := -g -Werror -Wall -std=c++17 $(INCLUDE_DIR)
|
||||
SRC_DIR := src
|
||||
BUILD_DIR := ./build
|
||||
TARGET := RedScarfEngine
|
||||
SOURCES := main.cpp \
|
||||
vulkanBase.cpp \
|
||||
window.cpp
|
||||
|
||||
OBJECTS := $(SOURCES:.cpp=.o)
|
||||
|
||||
all: $(BUILD_DIR)/$(OBJECTS)
|
||||
$(CC) $(CFLAGS) -o $(BUILD_DIR)/$(TARGET) $(BUILD_DIR)/$(OBJECTS)
|
||||
|
||||
$(BUILD_DIR)/main.o: $(SRC_DIR)/main.cpp $(BUILD_DIR)/vulkanBase.o
|
||||
$(CC) $(CFLAGS) -c $(SRC_DIR)/main.cpp
|
||||
|
||||
$(BUILD_DIR)/vulkanBase.o: $(SRC_DIR)/vulkanBase.cpp
|
||||
$(CC) $(CFLAGS) -c $(SRC_DIR)/vulkanBase.cpp
|
||||
@@ -1,10 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
add_executable(${PROJECT_NAME} src/main.c)
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/Utilities/include)
|
||||
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
GraphicsEngine)
|
||||
@@ -12,7 +12,7 @@
|
||||
#ifndef LOCALE_VULKAN_H
|
||||
#define LOCALE_VULKAN_H
|
||||
|
||||
#include "localization.h"
|
||||
#include "localization.hpp"
|
||||
|
||||
enum Errors
|
||||
{
|
||||
@@ -101,4 +101,4 @@ const struct MessageString_t vulkanErrorMesssages[LAST_MESSAGE] =
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,6 +1,6 @@
|
||||
#include "log.h"
|
||||
#include "window.h"
|
||||
#include "vulkanBase.h"
|
||||
#include "log.hpp"
|
||||
#include "window.hpp"
|
||||
#include "vulkanBase.hpp"
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
@@ -19,4 +19,4 @@ int main(int argc, char** argv)
|
||||
windowTerminate();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file vulkanBase.c
|
||||
* @file vulkanBase.cpp
|
||||
* @author Piotr Krygier (everyonecancode@gmail.com)
|
||||
* @brief Base configuration for Vulkan API
|
||||
* @version 0.1
|
||||
@@ -12,18 +12,18 @@
|
||||
/* TODO: Replace with more dynamic include */
|
||||
#define VK_USE_PLATFORM_XCB_KHR
|
||||
|
||||
#include "vulkanBase.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include "vulkanBase.hpp"
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <vk_mem_alloc.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include "localeVulkan.h"
|
||||
#include "log.h"
|
||||
#include "window.h"
|
||||
#include "localeVulkan.hpp"
|
||||
#include "log.hpp"
|
||||
#include "window.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
enum VULKAN_ERROR
|
||||
{
|
||||
@@ -54,20 +54,15 @@ enum VULKAN_ERROR
|
||||
|
||||
/* Define Validation Layers for debug build */
|
||||
#ifndef NDEBUG
|
||||
#define ENABLED_INSTANCE_LAYERS_COUNT 1U
|
||||
std::vector<std::string> gEnabledInstanceLayersNames = {"VK_LAYER_KHRONOS_validation"};
|
||||
#else
|
||||
#define ENABLED_INSTANCE_LAYERS_COUNT 0U
|
||||
std::vector<std::string> gEnabledInstanceLayersNames = {};
|
||||
#endif
|
||||
|
||||
#define ENABLED_INSTANCE_EXTENSIONS_COUNT 4U
|
||||
#define ENABLED_DEVICE_EXTENSIONS_COUNT 1U
|
||||
|
||||
#ifndef NDEBUG
|
||||
const char* gEnabledInstanceLayersNames[ENABLED_INSTANCE_LAYERS_COUNT] = {"VK_LAYER_KHRONOS_validation"};
|
||||
#endif
|
||||
|
||||
/* Extensions required by GLFW. TODO: Check for extensions required on other platforms */
|
||||
const char* gEnabledInstanceExtensionsNames[ENABLED_INSTANCE_EXTENSIONS_COUNT] = {
|
||||
std::vector<std::string> gEnabledInstanceExtensionsNames = {
|
||||
"VK_KHR_surface",
|
||||
"VK_KHR_xcb_surface",
|
||||
"VK_KHR_device_group_creation",
|
||||
@@ -76,7 +71,7 @@ const char* gEnabledInstanceExtensionsNames[ENABLED_INSTANCE_EXTENSIONS_COUNT] =
|
||||
#endif
|
||||
};
|
||||
|
||||
const char* gEnabledDeviceExtensionsNames[ENABLED_DEVICE_EXTENSIONS_COUNT] = {
|
||||
std::vector<std::string> gEnabledDeviceExtensionsNames[ENABLED_DEVICE_EXTENSIONS_COUNT] = {
|
||||
"VK_KHR_swapchain",
|
||||
};
|
||||
|
||||
@@ -265,12 +260,12 @@ static int createInstance()
|
||||
uint32_t layersCount = 0;
|
||||
VkApplicationInfo applicationInfo;
|
||||
VkInstanceCreateInfo createInfo;
|
||||
VkLayerProperties* layerProperties = NULL;
|
||||
VkExtensionProperties* extensionsProperties = NULL;
|
||||
std::vector<VkLayerProperties> layerProperties;
|
||||
std::vector<VkExtensionProperties> extensionsProperties;
|
||||
|
||||
/* TODO: Remove or use later layer and extension properties */
|
||||
vkEnumerateInstanceLayerProperties(&layersCount, NULL);
|
||||
layerProperties = malloc(sizeof(VkLayerProperties) * layersCount);
|
||||
layerProperties.resize(layersCount);
|
||||
vkEnumerateInstanceLayerProperties(&layersCount, layerProperties);
|
||||
|
||||
vkEnumerateInstanceExtensionProperties(NULL, &extensionCount, NULL);
|
||||
@@ -299,13 +294,13 @@ static int createInstance()
|
||||
createInfo.pNext = NULL;
|
||||
createInfo.flags = 0U;
|
||||
createInfo.pApplicationInfo = &applicationInfo;
|
||||
createInfo.enabledLayerCount = ENABLED_INSTANCE_LAYERS_COUNT;
|
||||
createInfo.enabledLayerCount = gEnabledInstanceLayersNames.size();
|
||||
#ifndef NDEBUG
|
||||
createInfo.ppEnabledLayerNames = gEnabledInstanceLayersNames;
|
||||
#else
|
||||
createInfo.ppEnabledLayerNames = NULL;
|
||||
#endif
|
||||
createInfo.enabledExtensionCount = ENABLED_INSTANCE_EXTENSIONS_COUNT;
|
||||
createInfo.enabledExtensionCount = gEnabledInstanceExtensionsNames.size();
|
||||
createInfo.ppEnabledExtensionNames = gEnabledInstanceExtensionsNames;
|
||||
|
||||
VkResult result = vkCreateInstance(&createInfo, NULL, &gVulkanInstance);
|
||||
@@ -607,4 +602,4 @@ void deinitVulkan()
|
||||
#endif
|
||||
vkDestroySurfaceKHR(gVulkanInstance, gSurface, NULL);
|
||||
vkDestroyInstance(gVulkanInstance, NULL);
|
||||
}
|
||||
}
|
||||
File renamed without changes.
Reference in new issue
Block a user