feat: Render 3D cube with camera controls (zoom, pan, rotate)
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
38
src/ViewportWidget.h
Normal file
38
src/ViewportWidget.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef VIEWPORTWIDGET_H
|
||||
#define VIEWPORTWIDGET_H
|
||||
|
||||
#include <QOpenGLWidget>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QMatrix4x4>
|
||||
#include <QPoint>
|
||||
|
||||
class ViewportWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ViewportWidget(QWidget *parent = nullptr);
|
||||
|
||||
protected:
|
||||
void initializeGL() override;
|
||||
void paintGL() override;
|
||||
void resizeGL(int w, int h) override;
|
||||
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
void wheelEvent(QWheelEvent *event) override;
|
||||
|
||||
private:
|
||||
void drawCube();
|
||||
|
||||
QMatrix4x4 projection;
|
||||
|
||||
float xRot = 0;
|
||||
float yRot = 0;
|
||||
float zoom = -5.0f;
|
||||
float panX = 0;
|
||||
float panY = 0;
|
||||
QPoint lastPos;
|
||||
};
|
||||
|
||||
#endif // VIEWPORTWIDGET_H
|
||||
Reference in New Issue
Block a user