1 // Copyright (C) 2012-2019 The VPaint Developers. 2 // See the COPYRIGHT file at the top-level directory of this distribution 3 // and at https://github.com/dalboris/vpaint/blob/master/COPYRIGHT 4 // 5 // Licensed under the Apache License, Version 2.0 (the "License"); 6 // you may not use this file except in compliance with the License. 7 // You may obtain a copy of the License at 8 // 9 // http://www.apache.org/licenses/LICENSE-2.0 10 // 11 // Unless required by applicable law or agreed to in writing, software 12 // distributed under the License is distributed on an "AS IS" BASIS, 13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 // See the License for the specific language governing permissions and 15 // limitations under the License. 16 17 #ifndef GLUTILS_H 18 #define GLUTILS_H 19 20 #include <QPolygonF> 21 #include <QRectF> 22 23 #include <Eigen/Core> 24 25 class QOpenGLTexture; 26 27 class GLUtils 28 { 29 public: 30 /// This function must be called before creating the first 31 /// OpenGLWidget. It sets the appropriate Qt OpenGLFormat and 32 /// sets the Qt::AA_UseDesktopOpenGL attribute. 33 static void init(); 34 35 //static void UnitCircleZ(); 36 //static void UnitSphere(); 37 //static void Sphere(double radius); 38 static void multMatrix_RectInsideRect(const QRectF & rect1, 39 const QRectF & rect2); 40 static void multMatrix_RectToRect(const QRectF & rect1, 41 const QRectF & rect2); 42 static void multMatrix_QuadToQuad(const QPolygonF & quad1, 43 const QPolygonF & quad2); 44 45 static void drawX(double x1, double y1, double z1, 46 double x2, double y2, double z2, 47 double x3, double y3, double z3, 48 double x4, double y4, double z4); 49 static void drawY(double x1, double y1, double z1, 50 double x2, double y2, double z2, 51 double x3, double y3, double z3, 52 double x4, double y4, double z4); 53 static void drawTime(double x1, double y1, double z1, 54 double x2, double y2, double z2, 55 double x3, double y3, double z3, 56 double x4, double y4, double z4); 57 58 static void drawArrow(const Eigen::Vector2d & p, const Eigen::Vector2d & u); 59 60 private: 61 // drawing text 62 static QOpenGLTexture * genTex(const QString & filename); 63 static void drawTex(QOpenGLTexture * tex, 64 double x1, double y1, double z1, 65 double x2, double y2, double z2, 66 double x3, double y3, double z3, 67 double x4, double y4, double z4); 68 static QOpenGLTexture * textureX; 69 static QOpenGLTexture * textureY; 70 static QOpenGLTexture * textureTime; 71 }; 72 73 #endif 74