| 1 |
/* |
| 2 |
* This file is part of Bino, a 3D video player. |
| 3 |
* |
| 4 |
* Copyright (C) 2022, 2023, 2024, 2025 |
| 5 |
* Martin Lambers <[email protected]> |
| 6 |
* |
| 7 |
* This program is free software; you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU General Public License as published by |
| 9 |
* the Free Software Foundation; either version 3 of the License, or |
| 10 |
* (at your option) any later version. |
| 11 |
* |
| 12 |
* This program is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
* GNU General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU General Public License |
| 18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
|
| 21 |
#pragma once |
| 22 |
|
| 23 |
#include <QOpenGLWidget> |
| 24 |
#include <QOpenGLExtraFunctions> |
| 25 |
|
| 26 |
#include "modes.hpp" |
| 27 |
#include "bino.hpp" |
| 28 |
|
| 29 |
|
| 30 |
class Widget : public QOpenGLWidget, protected QOpenGLExtraFunctions |
| 31 |
{ |
| 32 |
Q_OBJECT |
| 33 |
|
| 34 |
private: |
| 35 |
QSize _sizeHint; |
| 36 |
int _width, _height; |
| 37 |
|
| 38 |
OutputMode _outputMode; |
| 39 |
int _alternatingLastView; // last view displayed in Mode_Alternating (0 or 1) |
| 40 |
|
| 41 |
float _surroundVerticalFOVDefault; |
| 42 |
float _surroundVerticalFOV; |
| 43 |
bool _inSurroundMovement; |
| 44 |
QPointF _surroundMovementStart; |
| 45 |
float _surroundHorizontalAngleBase; |
| 46 |
float _surroundVerticalAngleBase; |
| 47 |
float _surroundHorizontalAngleCurrent; |
| 48 |
float _surroundVerticalAngleCurrent; |
| 49 |
|
| 50 |
unsigned int _viewTex[2]; |
| 51 |
int _viewTexWidth[2], _viewTexHeight[2]; |
| 52 |
unsigned int _quadVao; |
| 53 |
QOpenGLShaderProgram _displayPrg; |
| 54 |
int _displayPrgOutputMode; |
| 55 |
|
| 56 |
void rebuildDisplayPrgIfNecessary(OutputMode outputMode); |
| 57 |
|
| 58 |
public: |
| 59 |
Widget(OutputMode outputMode, float surroundVerticalFOV, QWidget* parent = nullptr); |
| 60 |
|
| 61 |
bool isOpenGLStereo() const; |
| 62 |
OutputMode outputMode() const; |
| 63 |
void setOutputMode(OutputMode mode); |
| 64 |
void setSurroundVerticalFieldOfView(float vfov); |
| 65 |
void resetSurroundView(); |
| 66 |
|
| 67 |
virtual QSize sizeHint() const override; |
| 68 |
virtual void initializeGL() override; |
| 69 |
virtual void paintGL() override; |
| 70 |
virtual void resizeGL(int w, int h) override; |
| 71 |
|
| 72 |
virtual void keyPressEvent(QKeyEvent* e) override; |
| 73 |
virtual void mousePressEvent(QMouseEvent* e) override; |
| 74 |
virtual void mouseReleaseEvent(QMouseEvent* e) override; |
| 75 |
virtual void mouseMoveEvent(QMouseEvent* e) override; |
| 76 |
virtual void wheelEvent(QWheelEvent* e) override; |
| 77 |
|
| 78 |
public slots: |
| 79 |
void mediaChanged(PlaylistEntry entry); |
| 80 |
|
| 81 |
signals: |
| 82 |
void toggleFullscreen(); |
| 83 |
}; |