일단 완성
This commit is contained in:
47
src/main.cpp
47
src/main.cpp
@@ -1,10 +1,15 @@
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
#include "glfw/glfw_initialization.h"
|
||||
#include "glfw/glfw_monitor.h"
|
||||
#include "glfw/glfw_window.h"
|
||||
#include "precomp.h"
|
||||
#include "vulkan/graphics.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
std::int32_t main(std::int32_t argc, gsl::zstring* argv) {
|
||||
const veng::GlfwInitialization _glfw;
|
||||
|
||||
@@ -13,9 +18,51 @@ std::int32_t main(std::int32_t argc, gsl::zstring* argv) {
|
||||
|
||||
veng::Graphics graphics(&window);
|
||||
|
||||
std::array<veng::Vertex, 4> vertices = {
|
||||
veng::Vertex{{-.5f, -.5f, 0.f}, {0.f, 1.f}},
|
||||
veng::Vertex{{.5f, -.5f, 0.f}, {1.f, 1.f}},
|
||||
veng::Vertex{{-.5f, .5f, 0.f}, {0.f, 0.f}},
|
||||
veng::Vertex{{.5f, .5f, 0.f}, {1.f, 0.f}}};
|
||||
veng::BufferHandle buffer = graphics.CreateVertexBuffer(vertices);
|
||||
|
||||
std::array<std::uint32_t, 6> indices = {0, 3, 2, 0, 1, 3};
|
||||
veng::BufferHandle index_buffer = graphics.CreateIndexBuffer(indices);
|
||||
|
||||
glm::mat4 rotation = glm::rotate(glm::mat4(1.0f), glm::radians(45.f),
|
||||
glm::vec3(0.f, 1.f, 0.f));
|
||||
glm::mat4 view = glm::translate(glm::mat4(1.f), glm::vec3(0.f, 0.f, -2.f));
|
||||
glm::mat4 projection =
|
||||
glm::perspective(glm::radians(60.f), 800.f / 600.f, 0.1f, 100.f);
|
||||
graphics.SetViewProjection(view, projection);
|
||||
|
||||
veng::TextureHandle texture = graphics.CreateTexture("assets/paving-stones.jpg");
|
||||
|
||||
double last_time = glfwGetTime();
|
||||
|
||||
while (!window.ShouldClose()) {
|
||||
glfwPollEvents();
|
||||
|
||||
if (graphics.BeginFrame()) {
|
||||
double current_time = glfwGetTime();
|
||||
float delta_time = static_cast<float>(current_time - last_time);
|
||||
last_time = current_time;
|
||||
|
||||
std::cout << 1.f / delta_time << std::endl;
|
||||
|
||||
graphics.SetTexture(texture);
|
||||
graphics.RenderIndexedBuffer(buffer, index_buffer, indices.size());
|
||||
rotation = glm::rotate(rotation, delta_time * glm::radians(3600.f),
|
||||
glm::vec3(0.f, 0.f, 1.f));
|
||||
graphics.SetModelMatrix(rotation);
|
||||
graphics.RenderIndexedBuffer(buffer, index_buffer, indices.size());
|
||||
|
||||
graphics.EndFrame();
|
||||
}
|
||||
}
|
||||
|
||||
graphics.DestroyTexture(texture);
|
||||
graphics.DestroyBuffer(buffer);
|
||||
graphics.DestroyBuffer(index_buffer);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user