CMSC23700 Common Code Library
Support code for CS23700 programming projects
Loading...
Searching...
No Matches
cs237-texture.hpp
Go to the documentation of this file.
1
9/*
10 * COPYRIGHT (c) 2023 John Reppy (http://cs.uchicago.edu/~jhr)
11 * All rights reserved.
12 */
13
14#ifndef _CS237_TEXTURE_HPP_
15#define _CS237_TEXTURE_HPP_
16
17namespace cs237 {
18
19namespace __detail {
20
22public:
24 vk::ImageView view () const { return this->_view; }
25
27 vk::Format format () const { return this->_fmt; }
28
29protected:
31 vk::Image _img;
32 vk::DeviceMemory _mem;
33 vk::ImageView _view;
37 vk::Format _fmt;
38
40 Application *app,
44
49 vk::Buffer _createBuffer (size_t size, vk::BufferUsageFlags usage)
50 {
51 return this->_app->_createBuffer (size, usage);
52 }
53
58 vk::DeviceMemory _allocBufferMemory (vk::Buffer buf, vk::MemoryPropertyFlags props)
59 {
60 return this->_app->_allocBufferMemory (buf, props);
61 }
62
66
67};
68
69} // namespace __detail
70
71// 1D Textures
73public:
74
78 Texture1D (Application *app, Image1D const *img);
79
80};
81
82// 2D Textures
84public:
85
90 Texture2D (Application *app, Image2D const *img, bool mipmap = false);
91
92private:
95 void _generateMipMaps (cs237::Image2D const *img);
96
97};
98
99} // namespace cs237
100
101#endif // !_CS237_TEXTURE_HPP_
Definition cs237-image.hpp:58
Definition cs237-texture.hpp:21
vk::Format format() const
get the texel format
Definition cs237-texture.hpp:27
vk::DeviceMemory _allocBufferMemory(vk::Buffer buf, vk::MemoryPropertyFlags props)
A helper function for allocating and binding device memory for a buffer.
Definition cs237-texture.hpp:58
uint32_t _ht
teture height (1 for 1D textures)
Definition cs237-texture.hpp:35
void _init(cs237::__detail::ImageBase const *img)
initialize a texture by copying data into it using a staging buffer.
vk::ImageView _view
image view for texture image
Definition cs237-texture.hpp:33
uint32_t _wid
texture width
Definition cs237-texture.hpp:34
Application * _app
the owning application
Definition cs237-texture.hpp:30
vk::Buffer _createBuffer(size_t size, vk::BufferUsageFlags usage)
create a vk::Buffer object
Definition cs237-texture.hpp:49
uint32_t _nMipLevels
number of mipmap levels
Definition cs237-texture.hpp:36
vk::ImageView view() const
return the image view for the texture
Definition cs237-texture.hpp:24
vk::Image _img
Vulkan image to hold the texture.
Definition cs237-texture.hpp:31
vk::DeviceMemory _mem
device memory for the texture image
Definition cs237-texture.hpp:32
TextureBase(Application *app, uint32_t wid, uint32_t ht, uint32_t mipLvls, cs237::__detail::ImageBase const *img)
vk::Format _fmt
the texel format
Definition cs237-texture.hpp:37
the base class for applications
Definition cs237-application.hpp:25
vk::DeviceMemory _allocBufferMemory(vk::Buffer buf, vk::MemoryPropertyFlags props)
A helper function for allocating and binding device memory for a buffer.
vk::Buffer _createBuffer(size_t size, vk::BufferUsageFlags usage)
create a vk::Buffer object
Definition cs237-image.hpp:112
Definition cs237-image.hpp:139
Definition cs237-texture.hpp:72
Texture1D(Application *app, Image1D const *img)
Construct a 1D texture from a 1D image.
Definition cs237-texture.hpp:83
Texture2D(Application *app, Image2D const *img, bool mipmap=false)
Construct a 2D texture from a 2D image.
Definition cs237-aabb.hpp:22
Axis-Aligned Bounding Box parameterized over the scalar type.
Definition cs237-aabb.hpp:28