#include "asteroid/game.h" #include "glfw/glfw_initialization.h" #include "glfw/glfw_monitor.h" #include "glfw/glfw_window.h" #include "socket/iocp.h" #include "socket/packet.h" #include "socket/tcp_socket.h" #include "socket/udp_socket.h" #include "socket/wsa_manager.h" #include "utils/log.h" #include "utils/snowflake.h" #include "utils/utils.h" #include "vulkan_engine/vulkan/engine.h" #include "vulkan_engine/vulkan/graphics.h" std::uint8_t CLIENTID = 0; std::int32_t main(std::int32_t argc, gsl::zstring* argv) { Network::WSAManager wsamanager; #if !defined(NDEBUG) utils::setDefaultLogger(spdlog::level::level_enum::debug, "log.log", 1024, 2); #endif utils::ThreadPool tp(0); Network::IOCP iocp; iocp.init(&tp, SessionProtocol::TCP); Network::Address addr; in6_addr in6addr; addr.set(AF_INET6, "::1", 9010); std::shared_ptr TCPSock = std::make_shared(); TCPSock->init(AF_INET6); if (TCPSock->connect(addr) == INVALID_SOCKET) { spdlog::error("connect()"); std::exit(EXIT_FAILURE); } iocp.registerSocket(TCPSock); auto result = iocp.recv(TCPSock, 14); auto header_serialized = utils::CvtListToVector(result.get()); Packet::Header header; header.Deserialize(header_serialized); result = iocp.recv(TCPSock, header.body_length); std::vector data = utils::CvtListToVector(result.get()); ::memcpy(&CLIENTID, data.data(), 1); // id 받기 const veng::GlfwInitialization _glfw; veng::Window window("Asteroid", {800, 600}); window.TryMoveToMonitor(0); veng::Graphics graphics(&window); veng::Engine engine(&graphics, &tp, &iocp); 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(); tp.enqueueJob( [engine = &engine, TCPSock](utils::ThreadPool* tp, std::uint32_t __) { engine->ResponseToServerAndRefresh(TCPSock); }, 0); while (!window.ShouldClose()) { glfwPollEvents(); engine.Update(); engine.NetUpdate(TCPSock); } return EXIT_SUCCESS; }