mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-26 00:40:15 +00:00
Vulcan Nightmare
Experimentally bringing up vulcan support
This commit is contained in:
parent
863a786c48
commit
83b576e8d9
189 changed files with 12147 additions and 7820 deletions
|
|
@ -363,11 +363,14 @@ void CharacterCreateScreen::render(game::GameHandler& /*gameHandler*/) {
|
|||
static_cast<float>(preview_->getHeight()));
|
||||
}
|
||||
|
||||
ImGui::Image(
|
||||
static_cast<ImTextureID>(preview_->getTextureId()),
|
||||
ImVec2(imgW, imgH),
|
||||
ImVec2(0.0f, 1.0f), // UV top-left (flipped Y)
|
||||
ImVec2(1.0f, 0.0f)); // UV bottom-right (flipped Y)
|
||||
// TODO: Vulkan offscreen preview render target
|
||||
if (preview_->getTextureId()) {
|
||||
ImGui::Image(
|
||||
static_cast<ImTextureID>(0),
|
||||
ImVec2(imgW, imgH),
|
||||
ImVec2(0.0f, 1.0f),
|
||||
ImVec2(1.0f, 0.0f));
|
||||
}
|
||||
|
||||
// Mouse drag rotation on the preview image
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseDragging(ImGuiMouseButton_Left)) {
|
||||
|
|
|
|||
|
|
@ -301,11 +301,14 @@ void CharacterScreen::render(game::GameHandler& gameHandler) {
|
|||
imgW = imgH * (static_cast<float>(preview_->getWidth()) /
|
||||
static_cast<float>(preview_->getHeight()));
|
||||
}
|
||||
ImGui::Image(
|
||||
static_cast<ImTextureID>(preview_->getTextureId()),
|
||||
ImVec2(imgW, imgH),
|
||||
ImVec2(0.0f, 1.0f), // flip Y for OpenGL
|
||||
ImVec2(1.0f, 0.0f));
|
||||
// TODO: Vulkan offscreen preview render target
|
||||
if (preview_->getTextureId()) {
|
||||
ImGui::Image(
|
||||
static_cast<ImTextureID>(0),
|
||||
ImVec2(imgW, imgH),
|
||||
ImVec2(0.0f, 1.0f),
|
||||
ImVec2(1.0f, 0.0f));
|
||||
}
|
||||
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseDragging(ImGuiMouseButton_Left)) {
|
||||
preview_->rotate(ImGui::GetIO().MouseDelta.x * 0.2f);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#include "rendering/renderer.hpp"
|
||||
#include "rendering/terrain_manager.hpp"
|
||||
#include "rendering/minimap.hpp"
|
||||
#include "rendering/world_map.hpp"
|
||||
#include "rendering/character_renderer.hpp"
|
||||
#include "rendering/camera.hpp"
|
||||
#include "rendering/camera_controller.hpp"
|
||||
|
|
@ -3129,8 +3130,8 @@ void GameScreen::updateCharacterTextures(game::Inventory& inventory) {
|
|||
charRenderer->clearCompositeCache();
|
||||
// Use per-instance texture override (not model-level) to avoid deleting cached composites.
|
||||
uint32_t instanceId = renderer->getCharacterInstanceId();
|
||||
GLuint newTex = charRenderer->compositeWithRegions(bodySkinPath, underwearPaths, regionLayers);
|
||||
if (newTex != 0 && instanceId != 0) {
|
||||
auto* newTex = charRenderer->compositeWithRegions(bodySkinPath, underwearPaths, regionLayers);
|
||||
if (newTex != nullptr && instanceId != 0) {
|
||||
charRenderer->setTextureSlotOverride(instanceId, static_cast<uint16_t>(skinSlot), newTex);
|
||||
}
|
||||
|
||||
|
|
@ -3155,8 +3156,8 @@ void GameScreen::updateCharacterTextures(game::Inventory& inventory) {
|
|||
std::string capeName = displayInfoDbc->getString(static_cast<uint32_t>(recIdx), dispL ? (*dispL)["LeftModelTexture"] : 3);
|
||||
if (!capeName.empty()) {
|
||||
std::string capePath = "Item\\ObjectComponents\\Cape\\" + capeName + ".blp";
|
||||
GLuint capeTex = charRenderer->loadTexture(capePath);
|
||||
if (capeTex != 0) {
|
||||
auto* capeTex = charRenderer->loadTexture(capePath);
|
||||
if (capeTex != nullptr) {
|
||||
charRenderer->setTextureSlotOverride(instanceId, static_cast<uint16_t>(cloakSlot), capeTex);
|
||||
LOG_INFO("Cloak texture applied: ", capePath);
|
||||
}
|
||||
|
|
@ -3176,17 +3177,17 @@ void GameScreen::updateCharacterTextures(game::Inventory& inventory) {
|
|||
void GameScreen::renderWorldMap(game::GameHandler& gameHandler) {
|
||||
auto& app = core::Application::getInstance();
|
||||
auto* renderer = app.getRenderer();
|
||||
auto* assetMgr = app.getAssetManager();
|
||||
if (!renderer || !assetMgr) return;
|
||||
if (!renderer) return;
|
||||
|
||||
worldMap.initialize(assetMgr);
|
||||
auto* wm = renderer->getWorldMap();
|
||||
if (!wm) return;
|
||||
|
||||
// Keep map name in sync with minimap's map name
|
||||
auto* minimap = renderer->getMinimap();
|
||||
if (minimap) {
|
||||
worldMap.setMapName(minimap->getMapName());
|
||||
wm->setMapName(minimap->getMapName());
|
||||
}
|
||||
worldMap.setServerExplorationMask(
|
||||
wm->setServerExplorationMask(
|
||||
gameHandler.getPlayerExploredZoneMasks(),
|
||||
gameHandler.hasPlayerExploredZoneMasks());
|
||||
|
||||
|
|
@ -3194,7 +3195,7 @@ void GameScreen::renderWorldMap(game::GameHandler& gameHandler) {
|
|||
auto* window = app.getWindow();
|
||||
int screenW = window ? window->getWidth() : 1280;
|
||||
int screenH = window ? window->getHeight() : 720;
|
||||
worldMap.render(playerPos, screenW, screenH);
|
||||
wm->render(playerPos, screenW, screenH);
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@
|
|||
#include "core/logger.hpp"
|
||||
#include "auth/auth_handler.hpp"
|
||||
#include "game/game_handler.hpp"
|
||||
#include "rendering/vk_context.hpp"
|
||||
#include <imgui.h>
|
||||
#include <imgui_impl_sdl2.h>
|
||||
#include <imgui_impl_opengl3.h>
|
||||
#include <imgui_impl_vulkan.h>
|
||||
|
||||
namespace wowee {
|
||||
namespace ui {
|
||||
|
|
@ -26,6 +27,12 @@ bool UIManager::initialize(core::Window* win) {
|
|||
window = win;
|
||||
LOG_INFO("Initializing UI manager");
|
||||
|
||||
auto* vkCtx = window->getVkContext();
|
||||
if (!vkCtx) {
|
||||
LOG_ERROR("No Vulkan context available for ImGui initialization");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Initialize ImGui
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
|
|
@ -56,19 +63,37 @@ bool UIManager::initialize(core::Window* win) {
|
|||
colors[ImGuiCol_HeaderHovered] = ImVec4(0.25f, 0.30f, 0.50f, 0.80f);
|
||||
colors[ImGuiCol_HeaderActive] = ImVec4(0.20f, 0.25f, 0.45f, 1.00f);
|
||||
|
||||
// Initialize ImGui for SDL2 and OpenGL3
|
||||
ImGui_ImplSDL2_InitForOpenGL(window->getSDLWindow(), window->getGLContext());
|
||||
ImGui_ImplOpenGL3_Init("#version 330 core");
|
||||
// Initialize ImGui for SDL2 + Vulkan
|
||||
ImGui_ImplSDL2_InitForVulkan(window->getSDLWindow());
|
||||
|
||||
ImGui_ImplVulkan_InitInfo initInfo{};
|
||||
initInfo.ApiVersion = VK_API_VERSION_1_1;
|
||||
initInfo.Instance = vkCtx->getInstance();
|
||||
initInfo.PhysicalDevice = vkCtx->getPhysicalDevice();
|
||||
initInfo.Device = vkCtx->getDevice();
|
||||
initInfo.QueueFamily = vkCtx->getGraphicsQueueFamily();
|
||||
initInfo.Queue = vkCtx->getGraphicsQueue();
|
||||
initInfo.DescriptorPool = vkCtx->getImGuiDescriptorPool();
|
||||
initInfo.MinImageCount = 2;
|
||||
initInfo.ImageCount = vkCtx->getSwapchainImageCount();
|
||||
initInfo.PipelineInfoMain.RenderPass = vkCtx->getImGuiRenderPass();
|
||||
initInfo.PipelineInfoMain.MSAASamples = VK_SAMPLE_COUNT_1_BIT;
|
||||
|
||||
ImGui_ImplVulkan_Init(&initInfo);
|
||||
|
||||
imguiInitialized = true;
|
||||
|
||||
LOG_INFO("UI manager initialized successfully");
|
||||
LOG_INFO("UI manager initialized successfully (Vulkan)");
|
||||
return true;
|
||||
}
|
||||
|
||||
void UIManager::shutdown() {
|
||||
if (imguiInitialized) {
|
||||
ImGui_ImplOpenGL3_Shutdown();
|
||||
auto* vkCtx = window ? window->getVkContext() : nullptr;
|
||||
if (vkCtx) {
|
||||
vkDeviceWaitIdle(vkCtx->getDevice());
|
||||
}
|
||||
ImGui_ImplVulkan_Shutdown();
|
||||
ImGui_ImplSDL2_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
imguiInitialized = false;
|
||||
|
|
@ -80,7 +105,7 @@ void UIManager::update([[maybe_unused]] float deltaTime) {
|
|||
if (!imguiInitialized) return;
|
||||
|
||||
// Start ImGui frame
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
ImGui_ImplVulkan_NewFrame();
|
||||
ImGui_ImplSDL2_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
}
|
||||
|
|
@ -126,7 +151,6 @@ void UIManager::render(core::AppState appState, auth::AuthHandler* authHandler,
|
|||
|
||||
case core::AppState::DISCONNECTED:
|
||||
authScreen->stopLoginMusic();
|
||||
// Show disconnected message
|
||||
ImGui::SetNextWindowSize(ImVec2(400, 150), ImGuiCond_Always);
|
||||
ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x * 0.5f - 200,
|
||||
ImGui::GetIO().DisplaySize.y * 0.5f - 75),
|
||||
|
|
@ -141,9 +165,8 @@ void UIManager::render(core::AppState appState, auth::AuthHandler* authHandler,
|
|||
break;
|
||||
}
|
||||
|
||||
// Render ImGui
|
||||
// Finalize ImGui draw data (actual rendering happens in the command buffer)
|
||||
ImGui::Render();
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
}
|
||||
|
||||
void UIManager::processEvent(const SDL_Event& event) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue