src/gl/partrenderer.h

Fri, 07 Feb 2020 02:01:21 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Fri, 07 Feb 2020 02:01:21 +0200
changeset 49
d56cc7387dad
parent 48
3c10f0e2fbe0
child 51
1a9eac27698d
permissions
-rw-r--r--

wrote the id color in terms of the id value in the shader now that I can get the id to the shader properly

#pragma once
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QQuaternion>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLBuffer>
#include <QOpenGLShader>
#include <QOpenGLShaderProgram>
#include <glm/glm.hpp>
#include "main.h"
#include "gl/common.h"
#include "gl/compiler.h"

class PartRenderer : public QOpenGLWidget, protected QOpenGLFunctions
{
	Q_OBJECT
public:
	PartRenderer(
		Model* model,
		DocumentManager* documents,
		const ldraw::ColorTable& colorTable,
		QWidget* parent = nullptr);
	~PartRenderer() override;
	void setRenderPreferences(const gl::RenderPreferences& newPreferences);
	void setHighlight(ldraw::Id highlightedId);
protected:
	ldraw::Id pick(const QPoint& where);
	void initializeGL() override;
	void resizeGL(int width, int height) override;
	void paintGL() override;
	void mouseMoveEvent(QMouseEvent* event) override;
	void wheelEvent(QWheelEvent* event) override;
private:
	void setFragmentStyle(gl::FragmentStyle fragStyle);
	void renderAllArrays();
	void renderScene();
	void updateViewMatrix();
	Model* const model;
	DocumentManager* const documents;
	const ldraw::ColorTable& colorTable;
	QPointF lastMousePosition;
	gl::Compiler* compiler;
	gl::RenderPreferences renderPreferences;
	glm::mat4 projectionMatrix;
	glm::mat4 viewMatrix;
	glm::quat modelQuaternion;
	ldraw::Id highlighted = ldraw::NULL_ID;
	static constexpr double MIN_ZOOM = 0.0;
	static constexpr double MAX_ZOOM = 3.0;
	double zoom = 1.0;
	bool initialized = false;
	void renderVao(const gl::ArrayClass arrayClass);
	void checkForGLErrors();
};

mercurial