Animación Vulkan 1.0
Animación de tiro libre baloncesto con motor gráfico desarrollado en clase
Cargando...
Buscando...
Nada coincide
GEDrawingContext.h
Ir a la documentación de este archivo.
1
5
6#pragma once
7
8#include <vulkan/vulkan.h>
9#include <vector>
10#include "GEGraphicsContext.h"
11#include "GEWindowPosition.h"
12
18{
19public:
20 std::vector<VkImageView> imageViews;
21
22private:
23 // ===== Campos auxiliares =====
24 uint32_t imageCount;
25 uint32_t frameCount;
26 size_t currentFrame = 0;
27 uint32_t currentImage = 0;
28
29 // ===== Componentes gráficos =====
30 VkSwapchainKHR swapChain;
31 VkFormat imageFormat;
32 VkExtent2D imageExtent;
33 std::vector<VkImage> images;
34 VkQueue graphicsQueue;
35 VkQueue presentQueue;
36
37 // ===== Sincronización entre imágenes =====
38 std::vector<VkSemaphore> imageAvailableSemaphores;
39 std::vector<VkSemaphore> renderFinishedSemaphores;
40 std::vector<VkFence> inFlightFences;
41 std::vector<VkFence> imagesInFlight;
42
43public:
50
55 void destroy(GEGraphicsContext* gc);
56
63
68 VkFormat getFormat();
69
74 VkExtent2D getExtent();
75
80 uint32_t getImageCount();
81
86 uint32_t getCurrentImage();
87
88 // ===== Métodos de generación de la imagen =====
94
100 void submitGraphicsCommands(GEGraphicsContext* gc, std::vector<VkCommandBuffer> commandBuffers);
101
107
108private:
109 // ===== Métodos de creación de componentes =====
111 void createImageViews(VkDevice device);
112 void createSyncObjects(VkDevice device);
114
115 // ===== Métodos auxiliares =====
116 VkSurfaceFormatKHR chooseSwapSurfaceFormat(const std::vector<VkSurfaceFormatKHR>& availableFormats);
117 VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities, GEWindowPosition wpos);
118};
119
Declaración de la clase GEGraphicsContext que almacena el contexto gráfico de Vulkan.
Declaración de la estructura GEWindowPosition para ventanas.
std::vector< VkFence > imagesInFlight
Fence por imagen.
Definition GEDrawingContext.h:41
VkExtent2D imageExtent
Extensión de las imágenes.
Definition GEDrawingContext.h:32
VkQueue presentQueue
Cola de presentación.
Definition GEDrawingContext.h:35
uint32_t imageCount
Número de imágenes en la swapchain.
Definition GEDrawingContext.h:24
std::vector< VkImage > images
Imágenes de la swapchain.
Definition GEDrawingContext.h:33
GEDrawingContext(GEGraphicsContext *gc, GEWindowPosition wpos)
Crea el contexto de dibujo (swapchain, vistas y sincronización).
Definition GEDrawingContext.cpp:23
VkSwapchainKHR swapChain
Swapchain de Vulkan.
Definition GEDrawingContext.h:30
std::vector< VkSemaphore > renderFinishedSemaphores
Semáforos de render terminado.
Definition GEDrawingContext.h:39
VkSurfaceFormatKHR chooseSwapSurfaceFormat(const std::vector< VkSurfaceFormatKHR > &availableFormats)
Escoge el formato de imagen entre los soportados por la superficie.
Definition GEDrawingContext.cpp:363
uint32_t currentImage
Índice de la imagen actual.
Definition GEDrawingContext.h:27
void waitForNextImage(GEGraphicsContext *gc)
Espera y adquiere la siguiente imagen disponible.
Definition GEDrawingContext.cpp:273
void submitGraphicsCommands(GEGraphicsContext *gc, std::vector< VkCommandBuffer > commandBuffers)
Envía los comandos gráficos para la imagen actual.
Definition GEDrawingContext.cpp:292
std::vector< VkImageView > imageViews
Vistas de las imágenes del swapchain.
Definition GEDrawingContext.h:20
void destroy(GEGraphicsContext *gc)
Destruye los recursos del contexto de dibujo.
Definition GEDrawingContext.cpp:35
void createQueues(GEGraphicsContext *gc)
Obtiene las colas gráficas y de presentación del dispositivo.
Definition GEDrawingContext.cpp:257
uint32_t getImageCount()
Obtiene el número de imágenes de la swapchain.
Definition GEDrawingContext.cpp:90
std::vector< VkSemaphore > imageAvailableSemaphores
Semáforos de imagen disponible.
Definition GEDrawingContext.h:38
uint32_t frameCount
Número de frames en vuelo.
Definition GEDrawingContext.h:25
VkExtent2D getExtent()
Obtiene la extensión de la imagen.
Definition GEDrawingContext.cpp:81
void recreate(GEGraphicsContext *gc, GEWindowPosition wpos)
Reconstruye el contexto de dibujo tras un cambio de tamaño.
Definition GEDrawingContext.cpp:56
VkFormat getFormat()
Obtiene el formato de la imagen.
Definition GEDrawingContext.cpp:72
void createSyncObjects(VkDevice device)
Crea semáforos y fences para sincronización entre frames.
Definition GEDrawingContext.cpp:227
VkQueue graphicsQueue
Cola gráfica.
Definition GEDrawingContext.h:34
VkExtent2D chooseSwapExtent(const VkSurfaceCapabilitiesKHR &capabilities, GEWindowPosition wpos)
Selecciona la extensión (tamaño) adecuada para las imágenes del swapchain.
Definition GEDrawingContext.cpp:382
std::vector< VkFence > inFlightFences
Fences por frame.
Definition GEDrawingContext.h:40
size_t currentFrame
Índice del frame actual.
Definition GEDrawingContext.h:26
void createSwapChain(GEGraphicsContext *gc, GEWindowPosition wpos)
Crea el swapchain y obtiene las imágenes y formatos adecuados.
Definition GEDrawingContext.cpp:115
uint32_t getCurrentImage()
Obtiene el índice de la imagen actual.
Definition GEDrawingContext.cpp:99
void submitPresentCommands(GEGraphicsContext *gc)
Envía los comandos de presentación para la imagen actual.
Definition GEDrawingContext.cpp:328
void createImageViews(VkDevice device)
Crea una vista para cada imagen del swapchain.
Definition GEDrawingContext.cpp:194
VkFormat imageFormat
Formato de imagen.
Definition GEDrawingContext.h:31
Clase que almacena el contexto gráfico de Vulkan (instancia y dispositivo).
Definition GEGraphicsContext.h:17
Estructura que almacena la posición y el tamaño de la ventana gráfica.
Definition GEWindowPosition.h:12