mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-27 01:00:13 +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
|
|
@ -1,6 +1,7 @@
|
|||
#include "ui/spellbook_screen.hpp"
|
||||
#include "core/input.hpp"
|
||||
#include "core/application.hpp"
|
||||
#include "rendering/vk_context.hpp"
|
||||
#include "pipeline/asset_manager.hpp"
|
||||
#include "pipeline/dbc_loader.hpp"
|
||||
#include "pipeline/blp_loader.hpp"
|
||||
|
|
@ -201,44 +202,41 @@ void SpellbookScreen::categorizeSpells(const std::unordered_set<uint32_t>& known
|
|||
lastKnownSpellCount = knownSpells.size();
|
||||
}
|
||||
|
||||
GLuint SpellbookScreen::getSpellIcon(uint32_t iconId, pipeline::AssetManager* assetManager) {
|
||||
if (iconId == 0 || !assetManager) return 0;
|
||||
VkDescriptorSet SpellbookScreen::getSpellIcon(uint32_t iconId, pipeline::AssetManager* assetManager) {
|
||||
if (iconId == 0 || !assetManager) return VK_NULL_HANDLE;
|
||||
|
||||
auto cit = spellIconCache.find(iconId);
|
||||
if (cit != spellIconCache.end()) return cit->second;
|
||||
|
||||
auto pit = spellIconPaths.find(iconId);
|
||||
if (pit == spellIconPaths.end()) {
|
||||
spellIconCache[iconId] = 0;
|
||||
return 0;
|
||||
spellIconCache[iconId] = VK_NULL_HANDLE;
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
std::string iconPath = pit->second + ".blp";
|
||||
auto blpData = assetManager->readFile(iconPath);
|
||||
if (blpData.empty()) {
|
||||
spellIconCache[iconId] = 0;
|
||||
return 0;
|
||||
spellIconCache[iconId] = VK_NULL_HANDLE;
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
auto image = pipeline::BLPLoader::load(blpData);
|
||||
if (!image.isValid()) {
|
||||
spellIconCache[iconId] = 0;
|
||||
return 0;
|
||||
spellIconCache[iconId] = VK_NULL_HANDLE;
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
GLuint texId = 0;
|
||||
glGenTextures(1, &texId);
|
||||
glBindTexture(GL_TEXTURE_2D, texId);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, image.width, image.height, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, image.data.data());
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
auto* window = core::Application::getInstance().getWindow();
|
||||
auto* vkCtx = window ? window->getVkContext() : nullptr;
|
||||
if (!vkCtx) {
|
||||
spellIconCache[iconId] = VK_NULL_HANDLE;
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
spellIconCache[iconId] = texId;
|
||||
return texId;
|
||||
VkDescriptorSet ds = vkCtx->uploadImGuiTexture(image.data.data(), image.width, image.height);
|
||||
spellIconCache[iconId] = ds;
|
||||
return ds;
|
||||
}
|
||||
|
||||
const SpellInfo* SpellbookScreen::getSpellInfo(uint32_t spellId) const {
|
||||
|
|
@ -320,7 +318,7 @@ void SpellbookScreen::render(game::GameHandler& gameHandler, pipeline::AssetMana
|
|||
bool isPassive = info->isPassive();
|
||||
bool isDim = isPassive || onCooldown;
|
||||
|
||||
GLuint iconTex = getSpellIcon(info->iconId, assetManager);
|
||||
VkDescriptorSet iconTex = getSpellIcon(info->iconId, assetManager);
|
||||
|
||||
// Selectable consumes clicks properly (prevents window drag)
|
||||
ImGui::Selectable("##row", false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue