Debian Codegraph @

src/main.h

raw symbols SCIP
1 /*
2 * Copyright (C) 2005-2021 Team Kodi (https://kodi.tv)
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 * See LICENSE.md for more information.
6 */
7
8 #pragma once
9
10 #include <kodi/addon-instance/Screensaver.h>
11 #include <kodi/gui/gl/Shader.h>
12 #include <glm/glm.hpp>
13 #include <glm/ext.hpp>
14 #include <glm/gtc/type_ptr.hpp>
15
16 #include <array>
17
18 struct Preset
19 {
20 std::string name;
21 std::string file;
22 std::array <std::string, 4> channel;
23 };
24
25 class ATTR_DLL_LOCAL CScreensaverShadertoy
26 : public kodi::addon::CAddonBase
27 , public kodi::addon::CInstanceScreensaver
28 {
29 public:
30 CScreensaverShadertoy();
31 ~CScreensaverShadertoy() override = default;
32
33 bool Start() override;
34 void Stop() override;
35 void Render() override;
36
37 private:
38 void RenderTo(GLuint shader, GLuint effect_fb);
39 void Launch(int preset);
40 void LoadPreset(const std::string& shaderPath);
41 void UnloadPreset();
42 GLint LoadTexture(int number);
43 void UnloadTextures();
44 GLuint CreateTexture(GLint format, unsigned int w, unsigned int h, const GLvoid* data);
45 GLuint CreateTexture(const GLvoid* data, GLint format, unsigned int w, unsigned int h, GLint internalFormat, GLint scaling, GLint repeat);
46 GLuint CreateTexture(const std::string& file, GLint internalFormat, GLint scaling, GLint repeat);
47 int DetermineBitsPrecision();
48 double MeasurePerformance(const std::string& shaderPath, int size);
49
50 static const std::vector<Preset> g_presets;
51 int m_numberPresets = g_presets.size();
52
53 bool m_initialized = false;
54 int64_t m_initialTime = 0; // in ms
55 int m_bitsPrecision = 0;
56 int m_currentPreset = 0;
57
58 GLint m_attrResolutionLoc = 0;
59 GLint m_attrGlobalTimeLoc = 0;
60 GLint m_attrChannelTimeLoc = 0;
61 GLint m_attrMouseLoc = 0;
62 GLint m_attrDateLoc = 0;
63 GLint m_attrSampleRateLoc = 0;
64 GLint m_attrChannelResolutionLoc = 0;
65 GLint m_attrChannelLoc[4] = {0};
66 GLuint m_channelTextures[4] = {0};
67
68 kodi::gui::gl::CShaderProgram m_shadertoyShader;
69 kodi::gui::gl::CShaderProgram m_displayShader;
70
71 struct
72 {
73 GLuint vertex_buffer;
74 GLuint attr_vertex_e;
75 GLuint attr_vertex_r, uTexture;
76 GLuint effect_fb;
77 GLuint framebuffer_texture;
78 GLuint uScale;
79 int fbwidth, fbheight;
80 } m_state;
81
82 bool m_settingsUseOwnshader = false;
83 std::string m_usedShaderFile;
84 std::string m_shaderTextures[4];
85 };