Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
omni::ui::AboutGL Class Reference

#include <AboutGL.h>

Inheritance diagram for omni::ui::AboutGL:
Inheritance graph
[legend]
Collaboration diagram for omni::ui::AboutGL:
Collaboration graph
[legend]

Public Member Functions

 AboutGL (QWidget *_parent=nullptr)
 
 ~AboutGL ()
 
- Public Member Functions inherited from omni::ui::GLView
 GLView (QWidget *_parent=nullptr)
 
virtual ~GLView ()
 
float aspect () const
 Return aspect ratio of widget. More...
 
QPointF mousePosition () const
 Return mouse position. More...
 
bool initialized () const
 Return boolean value if widget has been initialized. More...
 
float updateFrequency () const
 Return update frequency. More...
 
void setUpdateFrequency (float _updateFrequency)
 Return update frequency. More...
 

Protected Member Functions

void mousePressEvent (QMouseEvent *)
 Mouse press event sets mouse position. More...
 
void resizeGL (int _w, int _h)
 Resize GL and viewport. More...
 
void paintGL ()
 Paint GL routine. More...
 
- Protected Member Functions inherited from omni::ui::GLView
void initializeGL ()
 Initialize OpenGL contents. More...
 
void timerEvent (QTimerEvent *)
 
void paintGLReady ()
 

Protected Attributes

double startTime_
 
- Protected Attributes inherited from omni::ui::GLView
bool updateTriggered_ = false
 
QPointF mousePosition_
 Mouse position stored. More...
 

Private Member Functions

bool initialize ()
 Pure virtual function to initialize GL contents. More...
 

Private Attributes

ContextBoundPtr
< QOpenGLShaderProgram > 
shader_
 
ContextBoundPtr< QOpenGLTexture > tex_
 

Additional Inherited Members

- Public Slots inherited from omni::ui::GLView
void triggerUpdate ()
 
void paintGLDone ()
 

Constructor & Destructor Documentation

AboutGL::AboutGL ( QWidget *  _parent = nullptr)
explicit

"Random" start time

39  :
40  GLView(_parent)
41 {
42  QTimer *timer = new QTimer(this);
43 
44  connect(timer, SIGNAL(timeout()), this, SLOT(update()));
45  timer->start(20);
46 
47  /// "Random" start time
49  double(reinterpret_cast<long long>(timer) & ((1 << 16) - 1));
50 }
double now()
Get current time in nano seconds.
Definition: util.cpp:33
double startTime_
Definition: AboutGL.h:45
GLView(QWidget *_parent=nullptr)
Definition: GLView.cpp:35
AboutGL::~AboutGL ( )
53 {}

Member Function Documentation

bool AboutGL::initialize ( )
privatevirtual

Pure virtual function to initialize GL contents.

Initialize Shader

Implements omni::ui::GLView.

56 {
57  /// Initialize Shader
58  static QString _vertSrc = util::fileToStr(":/shaders/frustum.vert");
59  static QString _fragmentSrc = util::fileToStr(":/shaders/slow_fractal.frag");
60 
61  primaryContextSwitch([&](QOpenGLFunctions& _) {
62  shader_.reset(new QOpenGLShaderProgram(this));
63  shader_->addShaderFromSourceCode(QOpenGLShader::Vertex, _vertSrc);
64  shader_->addShaderFromSourceCode(QOpenGLShader::Fragment, _fragmentSrc);
65  shader_->link();
66 
67  QImage _image(QString(":/omnicredits.png"));//, QImage::Format_ARGB32);
68 
69 /*
70  _image.fill(Qt::transparent);
71  QPainter _p(&_image);
72  {
73  _p.setBrush(QBrush("#000000"));
74  _p.setPen(QPen("#FFFFFF"));
75  QFont _font;
76  _font.setPixelSize(44);
77  _p.setFont(_font);
78  _p.drawText(8, 60, "Omnidome is a product by CR8TR.");
79  _p.drawText(8, 124, "Code written by Michael Winkelmann.");
80  _p.drawText(8, 188, "GUI design by Brook Cronin + Michael Winkelmann.");
81  _p.drawText(8, 252, QString("Version ") + OMNIDOME_VERSION_STRING);
82  _p.drawText(8, 316, "Copyright (C) 2016");
83  }
84  _p.end();*/
85  tex_.reset(new QOpenGLTexture(_image.rgbSwapped().mirrored()));
86 
87  _.glFinish();
88  });
89  return true;
90 }
ContextBoundPtr< QOpenGLTexture > tex_
Definition: AboutGL.h:50
QString fileToStr(const QString &_filename)
Return content of file from a file name.
Definition: util.cpp:29
void primaryContextSwitch(ContextFunctor f)
Switch to primary context to create OpenGL objects like textures etc.
Definition: ContextSwitch.cpp:40
ContextBoundPtr< QOpenGLShaderProgram > shader_
Definition: AboutGL.h:49
void AboutGL::mousePressEvent ( QMouseEvent *  event)
protectedvirtual

Mouse press event sets mouse position.

Reimplemented from omni::ui::GLView.

101 {
102  QDesktopServices::openUrl(QUrl("http://omnido.me", QUrl::TolerantMode));
103 }
void AboutGL::paintGL ( )
protectedvirtual

Paint GL routine.

Setup orthogonal projection

Reimplemented from omni::ui::GLView.

106 {
107  if (!shader_ || !tex_) {
108  return;
109  }
110 
111  makeCurrent();
112  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
113  glDisable(GL_CULL_FACE);
114 
115  /// Setup orthogonal projection
116  glMatrixMode(GL_PROJECTION);
117  {
118  glLoadIdentity();
119  QMatrix4x4 _m;
120  _m.ortho(-0.5, 0.5, -0.5, 0.5, -1.0, 1.0);
121  glMultMatrixf(_m.constData());
122  }
123 
124  glMatrixMode(GL_MODELVIEW);
125  glLoadIdentity();
126 
127  using namespace visual;
128 
129  viewport(this);
130 
131  double _time =
132  std::chrono::high_resolution_clock::now().time_since_epoch().
133  count() / 1000000000.0 - startTime_;
134 
135  useShader(*shader_, [&](UniformHandler& _handler) {
136  _handler.uniform("time", GLfloat(_time));
137  _handler.uniform("resolution", GLfloat(width()*devicePixelRatio()),
138  GLfloat(height()*devicePixelRatio()));
139  _handler.texUniform("tex", *tex_);
140  _handler.uniform("tex_size", QVector2D(tex_->width(),tex_->height()));
141 
143  });
144 }
ContextBoundPtr< QOpenGLTexture > tex_
Definition: AboutGL.h:50
static void draw(float _left=-0.5, float _right=0.5, float _top=0.5, float _bottom=-0.5)
Draw rectangle from border coordinates.
Definition: Rectangle.cpp:28
void useShader(QOpenGLShaderProgram &_s, std::function< void(UniformHandler &)>f)
Use shader with and do uniform assignment and drawing inside functor.
Definition: Shader.cpp:59
double now()
Get current time in nano seconds.
Definition: util.cpp:33
double startTime_
Definition: AboutGL.h:45
void viewport(WIDGET *_widget)
Set viewport for widget.
Definition: util.h:131
ContextBoundPtr< QOpenGLShaderProgram > shader_
Definition: AboutGL.h:49
void AboutGL::resizeGL ( int  _w,
int  _h 
)
protectedvirtual

Resize GL and viewport.

Reimplemented from omni::ui::GLView.

93 {
94  _w = _w & ~1;
95  _h = _h & ~1;
96  glViewport(0, 0, (GLint)_w, (GLint)_h);
97  glClearColor(0.0, 0.0, 0.0, 1.0);
98 }

Field Documentation

ContextBoundPtr<QOpenGLShaderProgram> omni::ui::AboutGL::shader_
private
double omni::ui::AboutGL::startTime_
protected
ContextBoundPtr<QOpenGLTexture> omni::ui::AboutGL::tex_
private

The documentation for this class was generated from the following files: