07/src/main.cpp

73 lines
2.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "vk.h"
#include <iostream>
#include "Model.h"
int main(int argc, char* argv[])
{
// объект класса-обертки Vulkan API
extern Vulkan vulkan;
//Вершины, записываемые в буфер
Vertex vertices[] = {
{ {-0.5f, -0.5f}, {1.0f, 0.0f, 0.0f} },
{ { 0.5f, -0.5f}, {0.0f, 1.0f, 0.0f} },
{ { 0.5f, 0.5f}, {0.0f, 0.0f, 1.0f} },
{ {-0.5f, 0.5f}, {1.0f, 1.0f, 1.0f} }
};
// Индексы, записываемые в буфер
uint32_t indices[] = {0, 1, 2, 2, 3, 0};
I_Model * model;
// Инициализация GLFW
glfwInit();
// Проверка доступности Vulkan
if (glfwVulkanSupported())
{
// Отключим создание контекста
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
// Отключим возможность изменения размеров окна
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
// Создание окна
GLFWwindow* window = glfwCreateWindow(800, 600, "Vulkan window", nullptr, nullptr);
// Инициализация Vulkan API
vulkan.init(window);
model = new Model_w_indexes(vertices, 4, indices, 6);
vulkan.addToRenderList(model);
// Жизненный цикл
while(!glfwWindowShouldClose(window))
{
// Обработка событий
glfwPollEvents();
vulkan.renderFrame();
}
delete model;
// Уничтожение окна
glfwDestroyWindow(window);
// Завершение работы с Vulkan
vulkan.destroy();
}
else
std::cout << "There is no Vulkan Supported\n";
// Завершение работы с GLFW
glfwTerminate();
return 0;
}