-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathColorMap.hpp
52 lines (38 loc) · 1.59 KB
/
ColorMap.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
////////////////////////////////////////////////////////////////////////////////////////////////////
// This file is part of CosmoScout VR //
////////////////////////////////////////////////////////////////////////////////////////////////////
// SPDX-FileCopyrightText: German Aerospace Center (DLR) <[email protected]>
// SPDX-License-Identifier: MIT
#ifndef CS_GRAPHICS_COLOR_MAP_HPP
#define CS_GRAPHICS_COLOR_MAP_HPP
#include "cs_graphics_export.hpp"
#include <VistaOGLExt/VistaTexture.h>
#include <boost/filesystem.hpp>
#include <glm/glm.hpp>
#include <memory>
#include <string>
#include <vector>
namespace cs::graphics {
/// A color map specified by a json file.
class CS_GRAPHICS_EXPORT ColorMap {
public:
/// Creates a ColorMap from a json string.
explicit ColorMap(std::string const& sJsonString);
/// Creates a ColorMap from the json file at sJsonPath.
explicit ColorMap(boost::filesystem::path const& sJsonPath);
/// Binds the color map for use in rendering.
void bind(unsigned unit);
/// Unbinds the color map after rendering.
void unbind(unsigned unit);
/// Returns the color map as a vector of RGBA values.
std::vector<glm::vec4> getRawData();
/// Returns true if the alpha channel of the color map is not everywhere set to one.
bool getUsesAlpha() const;
private:
int mResolution = 256;
std::unique_ptr<VistaTexture> mTexture;
std::vector<glm::vec4> mRawData;
bool mUsesAlpha = false;
};
} // namespace cs::graphics
#endif // CS_GRAPHICS_COLOR_MAP_HPP