secondvoice/test_opengl.cpp
StillHammer 7dec7a6eed fix: Résolution complète du problème OpenGL/ImGui avec threading
PROBLÈME RÉSOLU: Les shaders ImGui compilent maintenant avec succès!

Changements majeurs:
- Remplacé vcpkg ImGui par FetchContent (compilation from source)
- Créé wrapper GLAD pour ImGui (imgui_opengl3_glad.cpp)
- Ajout de makeContextCurrent() pour gérer le contexte OpenGL multi-thread
- Release du contexte dans initialize(), puis rendu current dans uiThread()

Root Cause Analysis:
1. Rendering s'exécute dans uiThread() (thread séparé)
2. Contexte OpenGL créé dans thread principal n'était pas accessible
3. glCreateShader retournait 0 avec GL_INVALID_OPERATION (erreur 1282)
4. Solution: Transfer du contexte OpenGL du thread principal vers uiThread

Debugging profond:
- Ajout de logs debug dans ImGui pour tracer glCreateShader
- Découvert que handle=0 indiquait échec de création (pas compilation)
- Identifié erreur WGL \"ressource en cours d'utilisation\" = contexte locked

Fichiers modifiés:
- vcpkg.json: Supprimé imgui
- CMakeLists.txt: FetchContent pour ImGui + imgui_backends library
- src/imgui_opengl3_glad.cpp: Nouveau wrapper GLAD
- src/ui/TranslationUI.{h,cpp}: Ajout makeContextCurrent()
- src/core/Pipeline.cpp: Appel makeContextCurrent() dans uiThread()
- build/.../imgui_impl_opengl3.cpp: Debug logs (temporaire)

Résultat: UI fonctionne! NVIDIA RTX 4060 GPU, OpenGL 3.3.0, shaders compilent

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 16:37:47 +08:00

60 lines
2.2 KiB
C++

#include <GLFW/glfw3.h>
#include <iostream>
#include <windows.h>
int main() {
std::cout << "=== OpenGL Diagnostics ===" << std::endl;
// Initialize GLFW
if (!glfwInit()) {
std::cerr << "Failed to initialize GLFW" << std::endl;
return 1;
}
// Create a window
GLFWwindow* window = glfwCreateWindow(100, 100, "Test", nullptr, nullptr);
if (!window) {
std::cerr << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return 1;
}
glfwMakeContextCurrent(window);
// Query OpenGL info
const GLubyte* vendor = glGetString(GL_VENDOR);
const GLubyte* renderer = glGetString(GL_RENDERER);
const GLubyte* version = glGetString(GL_VERSION);
std::cout << "\nVendor: " << (vendor ? (const char*)vendor : "Unknown") << std::endl;
std::cout << "Renderer: " << (renderer ? (const char*)renderer : "Unknown") << std::endl;
std::cout << "Version: " << (version ? (const char*)version : "Unknown") << std::endl;
// Check which GPU is being used via Windows API
std::cout << "\n=== GPU Selection Info ===" << std::endl;
if (renderer) {
std::string renderer_str((const char*)renderer);
if (renderer_str.find("NVIDIA") != std::string::npos) {
std::cout << "✓ Using NVIDIA GPU (Good!)" << std::endl;
} else if (renderer_str.find("AMD") != std::string::npos ||
renderer_str.find("Radeon") != std::string::npos) {
std::cout << "⚠ Using AMD integrated GPU" << std::endl;
std::cout << " Try forcing NVIDIA GPU via Windows Graphics Settings" << std::endl;
} else if (renderer_str.find("Intel") != std::string::npos) {
std::cout << "⚠ Using Intel integrated GPU" << std::endl;
} else if (renderer_str.find("Microsoft") != std::string::npos ||
renderer_str.find("GDI") != std::string::npos) {
std::cout << "✗ Using Microsoft software renderer (BAD!)" << std::endl;
std::cout << " GPU drivers may not be properly installed" << std::endl;
}
}
std::cout << "\nPress Enter to exit..." << std::endl;
std::cin.get();
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}