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:
2026-02-09 15:51:37 -07:00
parent 6df2657eb9
commit 9584471932
4 changed files with 166 additions and 5 deletions

38
src/ViewportWidget.h Normal file
View 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