Just™ Game Engine
shader.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021-2022 Konstanty Misiak
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7#pragma once
8#include "jng/core/base.hpp"
9
10namespace jng {
11
12 class Shader final
13 {
14 public:
15 enum class Type {
16 Vertex,
17 Fragment
18 };
19
20 Shader(const std::filesystem::path& vertexShaderFilename, const std::filesystem::path& fragmentShaderFilename);
21 ~Shader();
22
23 void bind() const;
24 void unbind() const;
25 private:
26 std::filesystem::path getCacheDirectory() const;
27 void createCacheDirectoryIfNeeded() const;
28 std::vector<u32> compileToSPIRV(const std::filesystem::path& filename, Type type) const;
29 static const char* shaderTypeToHashFileExtension(Type type);
30 static const char* shaderTypeToCachedVlkFileExtension(Type type);
31 static u32 shaderTypeToShaderCKind(Type type);
32
33 u32 compileShader(const std::filesystem::path& filename, Type type) const;
34
35 mutable bool m_isCacheDirty = true;
36 u32 m_id;
37 };
38
39} // namespace jng
Definition: shader.hpp:13
Type
Definition: shader.hpp:15
Shader(const std::filesystem::path &vertexShaderFilename, const std::filesystem::path &fragmentShaderFilename)
Definition: shader_ogl.cpp:27
void bind() const
Definition: shader_ogl.cpp:60
~Shader()
Definition: shader_ogl.cpp:55
void unbind() const
Definition: shader_ogl.cpp:65
Definition: base.hpp:11
uint32_t u32
Definition: base.hpp:41