mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-02 15:53:51 +00:00
Port UI icon textures from OpenGL to Vulkan, fix loading screen clear values
Replace all glGenTextures/glTexImage2D calls in UI code with Vulkan texture uploads via new VkContext::uploadImGuiTexture() helper. This fixes segfaults from calling OpenGL functions without a GL context (null GLEW function pointers). - Add uploadImGuiTexture() to VkContext with staging buffer upload pattern - Convert game_screen, inventory_screen, spellbook_screen, talent_screen from GLuint/GL calls to VkDescriptorSet/Vulkan uploads - Fix loading_screen clearValueCount (was 1, needs 2 or 3 for MSAA)
This commit is contained in:
parent
b1a9d231c7
commit
325254dfcb
11 changed files with 314 additions and 136 deletions
|
|
@ -76,6 +76,12 @@ public:
|
|||
void setMsaaSamples(VkSampleCountFlagBits samples);
|
||||
VkSampleCountFlagBits getMaxUsableSampleCount() const;
|
||||
|
||||
// UI texture upload: creates a Vulkan texture from RGBA data and returns
|
||||
// a VkDescriptorSet suitable for use as ImTextureID.
|
||||
// The caller does NOT need to free the result — resources are tracked and
|
||||
// cleaned up when the VkContext is destroyed.
|
||||
VkDescriptorSet uploadImGuiTexture(const uint8_t* rgba, int width, int height);
|
||||
|
||||
private:
|
||||
bool createInstance(SDL_Window* window);
|
||||
bool createSurface(SDL_Window* window);
|
||||
|
|
@ -144,6 +150,17 @@ private:
|
|||
VkRenderPass imguiRenderPass = VK_NULL_HANDLE;
|
||||
VkDescriptorPool imguiDescriptorPool = VK_NULL_HANDLE;
|
||||
|
||||
// Shared sampler for UI textures (created on first uploadImGuiTexture call)
|
||||
VkSampler uiTextureSampler_ = VK_NULL_HANDLE;
|
||||
|
||||
// Tracked UI textures for cleanup
|
||||
struct UiTexture {
|
||||
VkImage image;
|
||||
VkDeviceMemory memory;
|
||||
VkImageView view;
|
||||
};
|
||||
std::vector<UiTexture> uiTextures_;
|
||||
|
||||
#ifndef NDEBUG
|
||||
bool enableValidation = true;
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include "ui/quest_log_screen.hpp"
|
||||
#include "ui/spellbook_screen.hpp"
|
||||
#include "ui/talent_screen.hpp"
|
||||
#include <GL/glew.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <imgui.h>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
|
@ -217,21 +217,21 @@ private:
|
|||
// WorldMap is now owned by Renderer (accessed via renderer->getWorldMap())
|
||||
|
||||
// Spell icon cache: spellId -> GL texture ID
|
||||
std::unordered_map<uint32_t, GLuint> spellIconCache_;
|
||||
std::unordered_map<uint32_t, VkDescriptorSet> spellIconCache_;
|
||||
// SpellIconID -> icon path (from SpellIcon.dbc)
|
||||
std::unordered_map<uint32_t, std::string> spellIconPaths_;
|
||||
// SpellID -> SpellIconID (from Spell.dbc field 133)
|
||||
std::unordered_map<uint32_t, uint32_t> spellIconIds_;
|
||||
bool spellIconDbLoaded_ = false;
|
||||
GLuint getSpellIcon(uint32_t spellId, pipeline::AssetManager* am);
|
||||
VkDescriptorSet getSpellIcon(uint32_t spellId, pipeline::AssetManager* am);
|
||||
|
||||
// Action bar drag state (-1 = not dragging)
|
||||
int actionBarDragSlot_ = -1;
|
||||
GLuint actionBarDragIcon_ = 0;
|
||||
VkDescriptorSet actionBarDragIcon_ = VK_NULL_HANDLE;
|
||||
|
||||
// Bag bar state
|
||||
GLuint backpackIconTexture_ = 0;
|
||||
GLuint emptyBagSlotTexture_ = 0;
|
||||
VkDescriptorSet backpackIconTexture_ = VK_NULL_HANDLE;
|
||||
VkDescriptorSet emptyBagSlotTexture_ = VK_NULL_HANDLE;
|
||||
int bagBarPickedSlot_ = -1; // Visual drag in progress (-1 = none)
|
||||
int bagBarDragSource_ = -1; // Mouse pressed on this slot, waiting for drag or click (-1 = none)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include "game/inventory.hpp"
|
||||
#include "game/character.hpp"
|
||||
#include "game/world_packets.hpp"
|
||||
#include <GL/glew.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <imgui.h>
|
||||
#include <array>
|
||||
#include <functional>
|
||||
|
|
@ -93,9 +93,9 @@ private:
|
|||
pipeline::AssetManager* assetManager_ = nullptr;
|
||||
|
||||
// Item icon cache: displayInfoId -> GL texture
|
||||
std::unordered_map<uint32_t, GLuint> iconCache_;
|
||||
std::unordered_map<uint32_t, VkDescriptorSet> iconCache_;
|
||||
public:
|
||||
GLuint getItemIcon(uint32_t displayInfoId);
|
||||
VkDescriptorSet getItemIcon(uint32_t displayInfoId);
|
||||
private:
|
||||
|
||||
// Character model preview
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "game/game_handler.hpp"
|
||||
#include <GL/glew.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <imgui.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
|
@ -41,7 +41,7 @@ public:
|
|||
// Drag-and-drop state for action bar assignment
|
||||
bool isDraggingSpell() const { return draggingSpell_; }
|
||||
uint32_t getDragSpellId() const { return dragSpellId_; }
|
||||
void consumeDragSpell() { draggingSpell_ = false; dragSpellId_ = 0; dragSpellIconTex_ = 0; }
|
||||
void consumeDragSpell() { draggingSpell_ = false; dragSpellId_ = 0; dragSpellIconTex_ = VK_NULL_HANDLE; }
|
||||
|
||||
private:
|
||||
bool open = false;
|
||||
|
|
@ -55,7 +55,7 @@ private:
|
|||
// Icon data (loaded from SpellIcon.dbc)
|
||||
bool iconDbLoaded = false;
|
||||
std::unordered_map<uint32_t, std::string> spellIconPaths; // SpellIconID -> path
|
||||
std::unordered_map<uint32_t, GLuint> spellIconCache; // SpellIconID -> GL texture
|
||||
std::unordered_map<uint32_t, VkDescriptorSet> spellIconCache; // SpellIconID -> GL texture
|
||||
|
||||
// Skill line data (loaded from SkillLine.dbc + SkillLineAbility.dbc)
|
||||
bool skillLineDbLoaded = false;
|
||||
|
|
@ -71,13 +71,13 @@ private:
|
|||
// Drag-and-drop from spellbook to action bar
|
||||
bool draggingSpell_ = false;
|
||||
uint32_t dragSpellId_ = 0;
|
||||
GLuint dragSpellIconTex_ = 0;
|
||||
VkDescriptorSet dragSpellIconTex_ = VK_NULL_HANDLE;
|
||||
|
||||
void loadSpellDBC(pipeline::AssetManager* assetManager);
|
||||
void loadSpellIconDBC(pipeline::AssetManager* assetManager);
|
||||
void loadSkillLineDBCs(pipeline::AssetManager* assetManager);
|
||||
void categorizeSpells(const std::unordered_set<uint32_t>& knownSpells);
|
||||
GLuint getSpellIcon(uint32_t iconId, pipeline::AssetManager* assetManager);
|
||||
VkDescriptorSet getSpellIcon(uint32_t iconId, pipeline::AssetManager* assetManager);
|
||||
const SpellInfo* getSpellInfo(uint32_t spellId) const;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "game/game_handler.hpp"
|
||||
#include <imgui.h>
|
||||
#include <GL/glew.h>
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ private:
|
|||
|
||||
void loadSpellDBC(pipeline::AssetManager* assetManager);
|
||||
void loadSpellIconDBC(pipeline::AssetManager* assetManager);
|
||||
GLuint getSpellIcon(uint32_t iconId, pipeline::AssetManager* assetManager);
|
||||
VkDescriptorSet getSpellIcon(uint32_t iconId, pipeline::AssetManager* assetManager);
|
||||
|
||||
bool open = false;
|
||||
bool nKeyWasDown = false;
|
||||
|
|
@ -35,7 +35,7 @@ private:
|
|||
bool iconDbcLoaded = false;
|
||||
std::unordered_map<uint32_t, uint32_t> spellIconIds; // spellId -> iconId
|
||||
std::unordered_map<uint32_t, std::string> spellIconPaths; // iconId -> path
|
||||
std::unordered_map<uint32_t, GLuint> spellIconCache; // iconId -> texture
|
||||
std::unordered_map<uint32_t, VkDescriptorSet> spellIconCache; // iconId -> texture
|
||||
std::unordered_map<uint32_t, std::string> spellTooltips; // spellId -> description
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue