Bonjour,
j'aurai voulu avoir quelques explications concernant ce code :
C'est celui du tutoriel vulkan dispo ici : https://vulkan-tutorial.com/code/16_...recreation.cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 void initWindow() { glfwInit(); glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); window = glfwCreateWindow(WIDTH, HEIGHT, "Vulkan", nullptr, nullptr); glfwSetWindowUserPointer(window, this); glfwSetFramebufferSizeCallback(window, framebufferResizeCallback); } static void framebufferResizeCallback(GLFWwindow* window, int width, int height) { auto app = reinterpret_cast<HelloTriangleApplication*>(glfwGetWindowUserPointer(window)); app->framebufferResized = true; }
Principalement concernant "glfwSetWindowUserPointer(window, this);" , le tutoriel indique :
Mais du coup je ne comprend pas leurs explications.Nous devons utiliser une fonction statique car GLFW ne sait pas correctement appeler une fonction membre d'une classe avec this.
Nous récupérons une référence à la GLFWwindow dans la fonction de rappel que nous fournissons. De plus nous pouvons paramétrer un pointeur de notre choix qui sera accessible à toutes nos fonctions de rappel. Nous pouvons y mettre la classe elle-même.
Et enfin, "auto app = reinterpret_cast<HelloTriangleApplication*>(glfwGetWindowUserPointer(window));" qui m'est incompréhensible.
Par avance, merci !![]()





.
Répondre avec citation





Partager