API Documentation
Loading...
Searching...
No Matches
QtVulkanSession.h
Go to the documentation of this file.
1#pragma once
6#include <QString>
7#include <QIODevice>
8#include <QFile>
9namespace NDEVR
10{
12 {
13 public:
17 virtual void readShader(const String& shader) override
18 {
20 {
21 String shader_name = shader + "/" + VulkanShaderManager::formats[i];
22 ResourceResolver::ResolveResource("Shaders/" + shader_name + ".spv", [this, shader, i](bool success, const String& s)
23 {
24 if (success)
25 {
26 QFile file(s.getAs<QString>());
27 uint04 file_size = cast<uint04>(file.size());
28 Buffer<char> code(file_size, '\0');
29 success |= file.open(QIODevice::ReadOnly);
30 if (success)
31 {
32 code.setSize(cast<uint04>(file.read(code.begin(), cast<uint04>(file_size))));
33 shaderManager()->addShader(shader, cast<VulkanShaderManager::ShaderType>(i), code);
34 }
35 }
36 lib_assert(success, "Bad shader: " + s);
37 });
38
39 }
40 }
41 };
42}
#define lib_assert(expression, message)
Asserts some logic in the code. Disabled in non debug mode by default. Can be re-enabled in release u...
Definition LibAssert.h:70
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
void setSize(t_index_type new_size)
Definition Buffer.hpp:1413
decltype(auto) begin()
Definition Buffer.hpp:504
Definition Pointer.hpp:303
Definition QtVulkanSession.h:12
virtual void readShader(const String &shader) override
Definition QtVulkanSession.h:17
QtVulkanSession(const DynamicPointer< VulkanDevice > &device)
Definition QtVulkanSession.h:14
static bool ResolveResource(const String &resource, const std::function< void(bool, const String &)> &on_finished=nullptr, bool ensure_unzipped=false)
Attempts to resolved a resource. Resource could be in an online or offline database,...
Definition ResourceResolver.cpp:13
Definition String.h:40
t_type getAs() const
Definition String.h:334
Definition VulkanSession.h:45
virtual const ConstPointer< GraphicsDevice > & device() const final override
Definition VulkanSession.h:52
DynamicPointer< VulkanShaderManager > shaderManager()
Definition VulkanSession.h:75
@ e_shader_type_size
Definition Shader.h:74
static const String formats[6]
Definition Shader.h:83
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:514