File: cavaGLSL.hpp

package info (click to toggle)
waybar 0.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,464 kB
  • sloc: cpp: 25,331; xml: 742; python: 146; ansic: 77; makefile: 29
file content (43 lines) | stat: -rw-r--r-- 1,087 bytes parent folder | download
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
#pragma once

#include <epoxy/gl.h>

#include "AModule.hpp"
#include "cava_backend.hpp"

namespace waybar::modules::cava {

class CavaGLSL final : public AModule, public Gtk::GLArea {
 public:
  CavaGLSL(const std::string&, const Json::Value&);
  ~CavaGLSL() = default;

 private:
  std::shared_ptr<CavaBackend> backend_;
  struct ::cava::config_params prm_;
  int frame_counter{0};
  bool silence_{false};
  bool hide_on_silence_{false};
  // Cava method
  auto onUpdate(const ::cava::audio_raw& input) -> void;
  auto onSilence() -> void;
  // Member variable to store the shared pointer
  std::shared_ptr<::cava::audio_raw> m_data_;
  GLuint shaderProgram_;
  // OpenGL variables
  GLuint fbo_;
  GLuint texture_;
  GLint uniform_bars_;
  GLint uniform_previous_bars_;
  GLint uniform_bars_count_;
  GLint uniform_time_;
  // Methods
  void onRealize();
  bool onRender(const Glib::RefPtr<Gdk::GLContext>& context);

  void initShaders();
  void initSurface();
  void initGLSL();
  GLuint loadShader(const std::string& fileName, GLenum type);
};
}  // namespace waybar::modules::cava