![]() |
CMSC23740 Common Code Library
Support code for CS23740 programming projects
|
abstract base class for simple GLFW windows used to view buffers, etc. More...
#include <window.hpp>
Classes | |
struct | DepthStencilBuffer |
information about the optional depth/stencil buffers for the window More... | |
struct | FrameData |
A container for the per-frame rendering state. More... | |
struct | SwapChain |
the collected information about the swap-chain for a window More... | |
struct | SwapChainDetails |
information about swap-chain support More... | |
Public Member Functions | |
virtual | ~Window () |
destructor: it destroys the underlying GLFW window | |
void | initialize () |
Application * | app () |
return the application pointer | |
vk::Device | device () const |
return the logical device for this window | |
vk::Queue | graphicsQ () const |
the graphics queue | |
vk::Queue | presentationQ () const |
the presentation queue | |
vk::Queue | computeQ () const |
the compute queue | |
void | refresh () |
void | hide () |
Hide the window. | |
void | show () |
Show the window (a no-op if it is already visible) | |
virtual void | draw ()=0 |
virtual void | reshape (int wid, int ht) |
virtual void | iconify (bool iconified) |
method invoked on Iconify events. | |
bool | windowShouldClose () |
get the value of the "close" flag for the window | |
virtual void | key (int key, int scancode, int action, int mods) |
virtual void | cursorPos (double xpos, double ypos) |
virtual void | cursorEnter (bool entered) |
virtual void | mouseButton (int button, int action, int mods) |
virtual void | scroll (double xoffset, double yoffset) |
void | enableKeyEvent (bool enable) |
void | setCursorMode (int mode) |
void | enableCursorPosEvent (bool enable) |
void | enableCursorEnterEvent (bool enable) |
void | enableMouseButtonEvent (bool enable) |
void | enableScrollEvent (bool enable) |
int | width () const |
the width of the window | |
int | height () const |
the height of the window | |
Protected Member Functions | |
Window (Application *app, CreateWindowInfo const &info) | |
the Window base-class constructor | |
virtual void | _init () |
subclasses can override this method to handle any additional initialization that needs to be run after the window object is constructed. | |
SwapChainDetails | _getSwapChainDetails () |
Get the swap-chain details for a physical device. | |
void | _createSwapChain (bool depth, bool stencil) |
Create the swap chain for this window; this initializes the _swap instance variable. | |
void | _recreateSwapChain () |
Recreate the swap chain for this window; this redefines the _swap instance variable and is used when some aspect of the presentation surface changes. | |
virtual FrameData * | _allocFrameData (Window *w) |
virtual function for allocating a FrameData object. Subclasses of the Window class can define a subclass of FrameData and then override this method to allocate the subclass objects. | |
FrameData * | _currentFrame () |
get a pointer to the current per-frame rendering state | |
FrameData * | _prevFrame () |
get a pointer to the previous per-frame rendering state | |
FrameData * | _nextFrame () |
get a pointer to the next per-frame rendering state | |
void | _advanceFrame () |
advance the current frame | |
vk::Result | _acquireNextImage () |
acquire the next image from the swap chain. This method has the side effect of setting the index of the current frame to the index of the swap-chain image that we are using. | |
void | _initAttachments (std::vector< vk::AttachmentDescription > &descs, std::vector< vk::AttachmentReference > &refs) |
initialize the attachment descriptors and references for the color and optional depth/stencil-buffer | |
uint32_t | _graphicsQIdx () const |
the graphics queue-family index | |
uint32_t | _presentationQIdx () const |
the presentation queue | |
uint32_t | _computeQIdx () const |
the compute queue index | |
vk::Viewport | _getViewport (bool oglView=false) |
get the natural viewport for the window | |
vk::Rect2D | _getScissorsRect () |
get the scissors rectangle for this window | |
void | _setViewportCmd (vk::CommandBuffer cmdBuf, bool oglView=false) |
add a command to set the viewport and scissor to the whole window | |
void | _setViewportCmd (vk::CommandBuffer cmdBuf, int32_t x, int32_t y, int32_t wid, int32_t ht) |
add a viewport command to the command buffer; this also sets the scissor rectangle. | |
vk::DeviceMemory | _allocImageMemory (vk::Image img, vk::MemoryPropertyFlags props) |
A helper function for allocating and binding device memory for an image. | |
vk::ImageView | _createImageView (vk::Image img, vk::Format fmt, vk::ImageAspectFlags aspectFlags) |
A helper function for creating a Vulkan image view object for an image. | |
void | _transitionImageLayout (vk::Image img, vk::Format fmt, vk::ImageLayout oldLayout, vk::ImageLayout newLayout) |
A helper function for changing the layout of an image. | |
Protected Attributes | |
Application * | _app |
the owning application | |
GLFWwindow * | _win |
the underlying window | |
int | _wid |
int | _ht |
window dimensions | |
bool | _isVis |
true when the window is visible | |
bool | _keyEnabled |
true when the Key callback is enabled | |
bool | _cursorPosEnabled |
true when the CursorPos callback is enabled | |
bool | _cursorEnterEnabled |
true when the CursorEnter callback is enabled | |
bool | _mouseButtonEnabled |
true when the MouseButton callback is enabled | |
bool | _scrollEnabled |
true when the Scroll callback is enabled | |
vk::SurfaceKHR | _surf |
the Vulkan surface to render to | |
SwapChain | _swap |
buffer-swapping information | |
FrameData * | _frames [kMaxFrames] |
the per-frame rendering state | |
uint32_t | _curFrameIdx |
index into _frames array for current frame data | |
abstract base class for simple GLFW windows used to view buffers, etc.
|
virtual |
destructor: it destroys the underlying GLFW window
|
protected |
the Window base-class constructor
app | the owning application |
info | information for creating the window, such as size and title |
|
protected |
acquire the next image from the swap chain. This method has the side effect of setting the index
of the current frame to the index of the swap-chain image that we are using.
Result::eSuccess
for success
|
inlineprotected |
advance the current frame
|
inlineprotected |
A helper function for allocating and binding device memory for an image.
img | the image to allocate memory for |
props | requred memory properties |
|
inlineprotected |
the compute queue index
This method is a wrapper to allow subclasses access to this information
|
inlineprotected |
A helper function for creating a Vulkan image view object for an image.
img | the image on which the view is created |
fmt | the format and type used to interpret image texels |
aspectFlags | a bitmask specifying which aspect(s) of the image are included in the view. |
|
protected |
Create the swap chain for this window; this initializes the _swap instance variable.
depth | set to true if requesting depth-buffer support |
stencil | set to true if requesting stencil-buffer support |
|
inlineprotected |
get a pointer to the current per-frame rendering state
|
inlineprotected |
get the scissors rectangle for this window
|
protected |
Get the swap-chain details for a physical device.
|
inlineprotected |
get the natural viewport for the window
oglView | if true then use the OpenGL convention where Y = 0 maps to the bottom of the screen and Y increases going up. |
|
inlineprotected |
the graphics queue-family index
This method is a wrapper to allow subclasses access to this information
|
protectedvirtual |
subclasses can override this method to handle any additional initialization that needs to be run after the window object is constructed.
|
protected |
initialize the attachment descriptors and references for the color and optional depth/stencil-buffer
[out] | descs | vector that will contain the attachment descriptors |
[out] | refs | vector that will contain the attachment references |
|
inlineprotected |
get a pointer to the next per-frame rendering state
|
inlineprotected |
the presentation queue
This method is a wrapper to allow subclasses access to this information
|
inlineprotected |
get a pointer to the previous per-frame rendering state
|
protected |
Recreate the swap chain for this window; this redefines the _swap instance variable and is used when some aspect of the presentation surface changes.
|
inlineprotected |
add a command to set the viewport and scissor to the whole window
cmdBuf | the command buffer |
oglView | if true then use the OpenGL convention where Y = 0 maps to the bottom of the screen and Y increases going up. |
Vulkan follows the Direct3D convention of using a right-handed NDC space, which means that Y = 0 maps to the top of the screen, instead of the bottom (as in OpenGL). pass true
as the second argument to use the OpenGL convention.
|
protected |
add a viewport command to the command buffer; this also sets the scissor rectangle.
cmdBuf | the command buffer |
x | specifies the Y coordinate of the upper-left corner |
y | specifies the X coordinate of the upper-left corner |
wid | specifies the width of the viewport |
ht | specifies the height of the viewport |
To use the OpenGL convention of the Y axis pointing up, specify the OpenGL Y coordinate and a negative height.
|
inlineprotected |
A helper function for changing the layout of an image.
img | the image to change |
fmt | the image's format |
oldLayout | the current layout of img |
newLayout | the new layout of img |
|
inline |
return the application pointer
|
inline |
the compute queue
|
virtual |
|
virtual |
|
inline |
return the logical device for this window
|
pure virtual |
virtual draw method provided by derived classes to draw the contents of the window. It is called by Refresh.
void cs237::Window::enableCursorEnterEvent | ( | bool | enable | ) |
void cs237::Window::enableCursorPosEvent | ( | bool | enable | ) |
void cs237::Window::enableKeyEvent | ( | bool | enable | ) |
{ enable/disable handling of events
void cs237::Window::enableMouseButtonEvent | ( | bool | enable | ) |
void cs237::Window::enableScrollEvent | ( | bool | enable | ) |
|
inline |
the graphics queue
|
inline |
the height of the window
|
inline |
Hide the window.
|
virtual |
method invoked on Iconify events.
void cs237::Window::initialize | ( | ) |
method for completing the initialization of a window. This function allocates the per-frame data array and also invokes the virtual _init
method to handle and sub-class specific initialization that was not handled in the constructor.
|
virtual |
{ Input handling methods; override these in the derived window classes to do something useful.
|
virtual |
|
inline |
the presentation queue
|
inline |
Refresh the contents of the window. This method is also invoked on Refresh events.
|
virtual |
method invoked on Reshape events.
wid | specifies the width of the viewport |
ht | specifies the height of the viewport |
This method takes care of updating the cached size of the window and recreating the swap chain. Other updates, including allocating new framebuffers should be handled by overriding this method in the subclass.
|
virtual |
void cs237::Window::setCursorMode | ( | int | mode | ) |
|
inline |
Show the window (a no-op if it is already visible)
|
inline |
the width of the window
|
inline |
get the value of the "close" flag for the window
|
protected |
the owning application
|
protected |
index into _frames
array for current frame data
|
protected |
true when the CursorEnter callback is enabled
|
protected |
true when the CursorPos callback is enabled
|
protected |
the per-frame rendering state
|
protected |
window dimensions
|
protected |
true when the window is visible
|
protected |
true when the Key callback is enabled
|
protected |
true when the MouseButton callback is enabled
|
protected |
true when the Scroll callback is enabled
|
protected |
the Vulkan surface to render to
|
protected |
buffer-swapping information
|
protected |
|
protected |
the underlying window