iocp 구현하기
This commit is contained in:
8
Client/include/asteroid/game.h
Normal file
8
Client/include/asteroid/game.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
namespace veng {
|
||||
class Engine;
|
||||
}
|
||||
|
||||
void BeginPlay(veng::Engine& engine);
|
||||
void Tick(veng::Engine& engine, std::float_t delta_time);
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "asset/object/model.h"
|
||||
#include "vulkan_engine/asset/object/model.h"
|
||||
#include "assimp/Importer.hpp"
|
||||
#include "assimp/postprocess.h"
|
||||
#include "assimp/scene.h"
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "vulkan/texture_handle.h"
|
||||
#include "vulkan_engine/vulkan/texture_handle.h"
|
||||
|
||||
namespace veng {
|
||||
struct Material {
|
||||
@@ -5,8 +5,8 @@
|
||||
#include <vector>
|
||||
|
||||
#include "material.h"
|
||||
#include "vulkan/buffer_handle.h"
|
||||
#include "vulkan/vertex.h"
|
||||
#include "vulkan_engine/vulkan/buffer_handle.h"
|
||||
#include "vulkan_engine/vulkan/vertex.h"
|
||||
|
||||
namespace veng {
|
||||
struct Model {
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "asset/object/model.h"
|
||||
#include "vulkan_engine/asset/object/model.h"
|
||||
|
||||
namespace std {
|
||||
template <>
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "asset/loader.h"
|
||||
#include "vulkan_engine/asset/loader.h"
|
||||
#include "graphics.h"
|
||||
#include "physics.h"
|
||||
#include "utils/thread_pool.h"
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "asset/object/model.h"
|
||||
#include "vulkan/vertex.h"
|
||||
#include "vulkan_engine/asset/object/model.h"
|
||||
#include "vulkan_engine/vulkan/vertex.h"
|
||||
#include "utils/thread_pool.h"
|
||||
|
||||
namespace veng {
|
||||
64
Client/src/asteroid/begin_play.cpp
Normal file
64
Client/src/asteroid/begin_play.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
#include "asteroid/game.h"
|
||||
|
||||
#include "vulkan_engine/vulkan/engine.h"
|
||||
|
||||
void BeginPlay(veng::Engine& engine) {
|
||||
veng::Model* const player = engine.SpawnModel("player", "player");
|
||||
player->scale = glm::vec3(.02f);
|
||||
player->colision = true;
|
||||
player->OnColision = [](veng::Model* self, veng::Model* other) {
|
||||
if (other->owner == self) return;
|
||||
spdlog::info("{} and {} is nearby.", (void*)self, (void*)other);
|
||||
|
||||
spdlog::info("{} 's owner: {}", (void*)self, (void*)self->owner);
|
||||
spdlog::info("{} 's owner: {}", (void*)other, (void*)other->owner);
|
||||
|
||||
other->colision = false;
|
||||
other->visible = false;
|
||||
};
|
||||
veng::Model* const player_flame =
|
||||
engine.SpawnModel("player_flame", "player_flame");
|
||||
player_flame->scale = player->scale;
|
||||
player_flame->colision = false;
|
||||
|
||||
spdlog::info("player addr: {}", (void*)player);
|
||||
|
||||
veng::Model* const other_player = engine.SpawnModel("player", "other_player");
|
||||
other_player->position = glm::vec3(1.f, 0.f, 0.f);
|
||||
other_player->scale = glm::vec3(.02f);
|
||||
other_player->colision = true;
|
||||
other_player->OnColision = [](veng::Model* self, veng::Model* other) {
|
||||
if (other->owner == self) return;
|
||||
spdlog::info("{} and {} is nearby.", (void*)self, (void*)other);
|
||||
|
||||
spdlog::info("{} 's owner: {}", (void*)self, (void*)self->owner);
|
||||
spdlog::info("{} 's owner: {}", (void*)other, (void*)other->owner);
|
||||
|
||||
other->colision = false;
|
||||
other->visible = false;
|
||||
};
|
||||
|
||||
spdlog::info("other player addr: {}", (void*)other_player);
|
||||
|
||||
veng::Model* const camera_lag = engine.SpawnModel("", "camera_lag");
|
||||
camera_lag->colision = false;
|
||||
camera_lag->position = player->position;
|
||||
|
||||
veng::Model* const background = engine.SpawnModel("", "background");
|
||||
background->colision = false;
|
||||
background->position = {background->position.x, background->position.y, 30.f};
|
||||
background->scale *= 100;
|
||||
|
||||
veng::Model* const background0 =
|
||||
engine.SpawnModel("background", "background0");
|
||||
background0->scale = background->scale;
|
||||
veng::Model* const background1 =
|
||||
engine.SpawnModel("background", "background1");
|
||||
background1->scale = background->scale;
|
||||
veng::Model* const background2 =
|
||||
engine.SpawnModel("background", "background2");
|
||||
background2->scale = background->scale;
|
||||
veng::Model* const background3 =
|
||||
engine.SpawnModel("background", "background3");
|
||||
background3->scale = background->scale;
|
||||
}
|
||||
37
Client/src/asteroid/main.cpp
Normal file
37
Client/src/asteroid/main.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "asteroid/game.h"
|
||||
#include "glfw/glfw_initialization.h"
|
||||
#include "glfw/glfw_monitor.h"
|
||||
#include "glfw/glfw_window.h"
|
||||
#include "vulkan_engine/vulkan/engine.h"
|
||||
#include "vulkan_engine/vulkan/graphics.h"
|
||||
#include "socket/iocp.h"
|
||||
|
||||
std::int32_t main(std::int32_t argc, gsl::zstring* argv) {
|
||||
Network::IOCP iocp;
|
||||
|
||||
const veng::GlfwInitialization _glfw;
|
||||
|
||||
veng::Window window("Vulkan Engine", {800, 600});
|
||||
window.TryMoveToMonitor(0);
|
||||
|
||||
veng::Graphics graphics(&window);
|
||||
veng::Engine engine(&graphics);
|
||||
|
||||
engine.LoadModelAsset("assets/player.fbx", "player");
|
||||
engine.LoadModelAsset("assets/player_flame.fbx", "player_flame");
|
||||
engine.LoadModelAsset("assets/bullet.fbx", "bullet");
|
||||
engine.LoadModelAsset("assets/background.fbx", "background");
|
||||
|
||||
engine.BeginPlay = BeginPlay;
|
||||
engine.Tick = Tick;
|
||||
|
||||
engine.init();
|
||||
|
||||
while (!window.ShouldClose()) {
|
||||
glfwPollEvents();
|
||||
|
||||
engine.Update();
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,79 +1,6 @@
|
||||
#include <GLFW/glfw3.h>
|
||||
#include "asteroid/game.h"
|
||||
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
#include "glfw/glfw_initialization.h"
|
||||
#include "glfw/glfw_monitor.h"
|
||||
#include "glfw/glfw_window.h"
|
||||
#include "precomp.h"
|
||||
#include "vulkan/coordinate.h"
|
||||
#include "vulkan/engine.h"
|
||||
#include "vulkan/graphics.h"
|
||||
|
||||
void BeginPlay(veng::Engine& engine) {
|
||||
veng::Model* const player = engine.SpawnModel("player", "player");
|
||||
player->scale = glm::vec3(.02f);
|
||||
player->colision = true;
|
||||
player->OnColision = [](veng::Model* self, veng::Model* other) {
|
||||
if (other->owner == self) return;
|
||||
std::cout << self << " and " << other << " is Nearby." << std::endl;
|
||||
|
||||
std::cout << self << "'s owner: " << self->owner << std::endl;
|
||||
std::cout << other << "'s owner: " << other->owner << std::endl;
|
||||
|
||||
std::cout << "Colided." << std::endl;
|
||||
other->colision = false;
|
||||
other->visible = false;
|
||||
};
|
||||
veng::Model* const player_flame =
|
||||
engine.SpawnModel("player_flame", "player_flame");
|
||||
player_flame->scale = player->scale;
|
||||
player_flame->colision = false;
|
||||
|
||||
std::cout << "player addr: " << player << std::endl;
|
||||
|
||||
veng::Model* const other_player = engine.SpawnModel("player", "other_player");
|
||||
other_player->position = glm::vec3(1.f, 0.f, 0.f);
|
||||
other_player->scale = glm::vec3(.02f);
|
||||
other_player->colision = true;
|
||||
other_player->OnColision = [](veng::Model* self, veng::Model* other) {
|
||||
if (other->owner == self) return;
|
||||
std::cout << self << " and " << other << " is Nearby." << std::endl;
|
||||
|
||||
std::cout << self << "'s owner: " << self->owner << std::endl;
|
||||
std::cout << other << "'s owner: " << other->owner << std::endl;
|
||||
|
||||
std::cout << "Colided." << std::endl;
|
||||
other->colision = false;
|
||||
other->visible = false;
|
||||
};
|
||||
|
||||
std::cout << "other player addr: " << other_player << std::endl;
|
||||
|
||||
veng::Model* const camera_lag = engine.SpawnModel("", "camera_lag");
|
||||
camera_lag->colision = false;
|
||||
camera_lag->position = player->position;
|
||||
|
||||
veng::Model* const background = engine.SpawnModel("", "background");
|
||||
background->colision = false;
|
||||
background->position = {background->position.x, background->position.y, 30.f};
|
||||
background->scale *= 100;
|
||||
|
||||
veng::Model* const background0 =
|
||||
engine.SpawnModel("background", "background0");
|
||||
background0->scale = background->scale;
|
||||
veng::Model* const background1 =
|
||||
engine.SpawnModel("background", "background1");
|
||||
background1->scale = background->scale;
|
||||
veng::Model* const background2 =
|
||||
engine.SpawnModel("background", "background2");
|
||||
background2->scale = background->scale;
|
||||
veng::Model* const background3 =
|
||||
engine.SpawnModel("background", "background3");
|
||||
background3->scale = background->scale;
|
||||
}
|
||||
#include "vulkan_engine/vulkan/engine.h"
|
||||
|
||||
void Tick(veng::Engine& engine, std::float_t delta_time) {
|
||||
static std::float_t bullet_cooldown = 0.f;
|
||||
@@ -123,7 +50,7 @@ void Tick(veng::Engine& engine, std::float_t delta_time) {
|
||||
if (glfwGetKey(engine.vulkan_graphics->window->GetHandle(), GLFW_KEY_SPACE) ==
|
||||
GLFW_PRESS) {
|
||||
if (bullet_cooldown > std::numeric_limits<std::float_t>::epsilon()) {
|
||||
bullet_cooldown - delta_time;
|
||||
bullet_cooldown -= delta_time;
|
||||
} else {
|
||||
bullet_cooldown = .2f;
|
||||
veng::Model* const bullet =
|
||||
@@ -134,7 +61,7 @@ void Tick(veng::Engine& engine, std::float_t delta_time) {
|
||||
bullet->scale = player->scale;
|
||||
bullet->colision = true;
|
||||
|
||||
std::cout << "bullet address: " << bullet << std::endl;
|
||||
spdlog::info("bullet address: {}", (void*)bullet);
|
||||
}
|
||||
}
|
||||
if (glfwGetKey(engine.vulkan_graphics->window->GetHandle(), GLFW_KEY_A) ==
|
||||
@@ -178,31 +105,3 @@ void Tick(veng::Engine& engine, std::float_t delta_time) {
|
||||
sparse = glm::vec3(-1.f, -1.f, 0.f);
|
||||
background3->position = background->position + sparse * background->scale;
|
||||
}
|
||||
|
||||
std::int32_t main(std::int32_t argc, gsl::zstring* argv) {
|
||||
const veng::GlfwInitialization _glfw;
|
||||
|
||||
veng::Window window("Vulkan Engine", {800, 600});
|
||||
window.TryMoveToMonitor(0);
|
||||
|
||||
veng::Graphics graphics(&window);
|
||||
veng::Engine engine(&graphics);
|
||||
|
||||
engine.LoadModelAsset("assets/player.fbx", "player");
|
||||
engine.LoadModelAsset("assets/player_flame.fbx", "player_flame");
|
||||
engine.LoadModelAsset("assets/bullet.fbx", "bullet");
|
||||
engine.LoadModelAsset("assets/background.fbx", "background");
|
||||
|
||||
engine.BeginPlay = BeginPlay;
|
||||
engine.Tick = Tick;
|
||||
|
||||
engine.init();
|
||||
|
||||
while (!window.ShouldClose()) {
|
||||
glfwPollEvents();
|
||||
|
||||
engine.Update();
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#include "vulkan/graphics.h"
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
namespace veng {
|
||||
|
||||
} // namespace veng
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "asset/loader.h"
|
||||
#include "vulkan_engine/asset/loader.h"
|
||||
|
||||
#include "stb/stb_image.h"
|
||||
#include "vulkan_engine/utilities.h"
|
||||
|
||||
namespace veng {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "asset/object/model.h"
|
||||
#include "vulkan_engine/asset/object/model.h"
|
||||
|
||||
#include "vulkan/graphics.h"
|
||||
#include "vulkan_engine/vulkan/graphics.h"
|
||||
|
||||
namespace veng {
|
||||
|
||||
@@ -6,4 +6,4 @@
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define __OPTIMIZE__ 1
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,9 +1,7 @@
|
||||
#include "utilities.h"
|
||||
#include "vulkan_engine/utilities.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
namespace veng {
|
||||
bool streq(gsl::czstring left, gsl::czstring right) {
|
||||
return std::strcmp(left, right) == 0;
|
||||
@@ -1,9 +1,8 @@
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#include "asset/object/model.h"
|
||||
#include "precomp.h"
|
||||
#include "vulkan/graphics.h"
|
||||
#include "vulkan/uniform_transformations.h"
|
||||
#include "vulkan_engine/asset/object/model.h"
|
||||
#include "vulkan_engine/vulkan/graphics.h"
|
||||
#include "vulkan_engine/vulkan/uniform_transformations.h"
|
||||
|
||||
namespace veng {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include "precomp.h"
|
||||
#include "vulkan/graphics.h"
|
||||
#include "vulkan_engine/vulkan/graphics.h"
|
||||
|
||||
namespace veng {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "vulkan/coordinate.h"
|
||||
#include "vulkan_engine/vulkan/coordinate.h"
|
||||
|
||||
namespace veng {
|
||||
Coord Coord::operator+(const Coord& other) const {
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <set>
|
||||
|
||||
#include "precomp.h"
|
||||
#include "vulkan/graphics.h"
|
||||
#include "vulkan_engine/vulkan/graphics.h"
|
||||
|
||||
namespace veng {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include "precomp.h"
|
||||
#include "vulkan/graphics.h"
|
||||
#include "vulkan_engine/vulkan/graphics.h"
|
||||
|
||||
namespace veng {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "vulkan/engine.h"
|
||||
#include "vulkan_engine/vulkan/engine.h"
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include "precomp.h"
|
||||
#include "vulkan/graphics.h"
|
||||
#include "vulkan_engine/vulkan/graphics.h"
|
||||
#include "vulkan_engine/utilities.h"
|
||||
|
||||
namespace veng {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include "precomp.h"
|
||||
#include "vulkan/graphics.h"
|
||||
#include "vulkan_engine/vulkan/graphics.h"
|
||||
#include "vulkan_engine/utilities.h"
|
||||
|
||||
namespace veng {
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#include "vulkan/physics.h"
|
||||
#include "vulkan_engine/vulkan/physics.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
#include "precomp.h"
|
||||
|
||||
namespace veng {
|
||||
void Physics::invokeOnColisionEvent(
|
||||
gsl::not_null<utils::ThreadPool*> thread_pool, gsl::span<Model*> models) {
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "vulkan/graphics.h"
|
||||
#include "vulkan_engine/vulkan/graphics.h"
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include "precomp.h"
|
||||
@@ -1,7 +1,8 @@
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#include "stb/stb_image.h"
|
||||
#include "vulkan/graphics.h"
|
||||
#include "vulkan_engine/vulkan/graphics.h"
|
||||
#include "vulkan_engine/utilities.h"
|
||||
|
||||
namespace veng {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "precomp.h"
|
||||
#include "vulkan/graphics.h"
|
||||
#include "vulkan_engine/vulkan/graphics.h"
|
||||
#include "vulkan_engine/utilities.h"
|
||||
|
||||
namespace veng {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "precomp.h"
|
||||
#include "vulkan/graphics.h"
|
||||
#include "vulkan_engine/vulkan/graphics.h"
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugUtilsMessengerEXT(
|
||||
VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo,
|
||||
Reference in New Issue
Block a user