CMSC23740 Common Code Library
Support code for CS23740 programming projects
Loading...
Searching...
No Matches
attachment.hpp
Go to the documentation of this file.
1
7
8/*
9 * COPYRIGHT (c) 2026 John Reppy (https://cs.uchicago.edu/~jhr)
10 * All rights reserved.
11 */
12
13#ifndef _CS237_ATTACHMENT_HPP_
14#define _CS237_ATTACHMENT_HPP_
15
16#ifndef _CS237_HPP_
17#error "cs237/attachment.hpp should not be included directly"
18#endif
19
20namespace cs237 {
21
24public:
25
34 uint32_t wid,
35 uint32_t ht,
36 vk::Format fmt,
37 vk::ImageUsageFlags usage);
38
41
43 uint32_t width() const { return this->_wid; }
44
46 uint32_t height() const { return this->_ht; }
47
49 vk::Format format() const { return this->_fmt; }
50
52 vk::ImageView imageView () const { return this->_view; }
53
55 vk::Image image () const { return this->_img; }
56
57protected:
59 vk::Image _img;
60 vk::DeviceMemory _mem;
61 vk::ImageView _view;
62 uint32_t _wid;
63 uint32_t _ht;
64 vk::Format _fmt;
65
66};
67
70public:
71
77 DepthAttachment (cs237::Application *app, uint32_t wid, uint32_t ht)
78 : Attachment (app, wid, ht,
79 app->_depthStencilBufferFormat(true, false),
80 vk::ImageUsageFlagBits::eDepthStencilAttachment)
81 { }
82
85
86};
87
88} // namespace cs237
89
90#endif // !_CS237_ATTACHMENT_HPP_
the base class for applications
Definition application.hpp:25
vk::ImageView _view
image view for attachment image
Definition attachment.hpp:61
vk::DeviceMemory _mem
device memory for the attachment image
Definition attachment.hpp:60
vk::Image image() const
return the image for the attachment
Definition attachment.hpp:55
uint32_t _wid
attachment width
Definition attachment.hpp:62
~Attachment()
destructor
vk::Format _fmt
the pixel format
Definition attachment.hpp:64
Attachment(cs237::Application *app, uint32_t wid, uint32_t ht, vk::Format fmt, vk::ImageUsageFlags usage)
Construct a frame-buffer attachment.
uint32_t height() const
get the height of the buffer
Definition attachment.hpp:46
uint32_t _ht
attachment height
Definition attachment.hpp:63
uint32_t width() const
get the width of the buffer
Definition attachment.hpp:43
vk::ImageView imageView() const
return the image view for the attachment
Definition attachment.hpp:52
vk::Format format() const
get the pixel format
Definition attachment.hpp:49
vk::Image _img
Vulkan image to hold the attachment.
Definition attachment.hpp:59
cs237::Application * _app
the owning application
Definition attachment.hpp:58
~DepthAttachment()
destructor
Definition attachment.hpp:84
DepthAttachment(cs237::Application *app, uint32_t wid, uint32_t ht)
Construct a depth-buffer attachment using the "best" format for a depth buffer.
Definition attachment.hpp:77
Definition aabb.hpp:22