CAVAPA-GUI  30.5.2014
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
gridengine.h
1 /****************************************************************************
2  * Copyright (c) 2014, Joel Kivelä, Erkki Koskenkorva, Oskari Leppäaho,
3  * Mika Lehtinen and Petri Partanen.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * * Neither the name of the copyright holders nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
22  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 ****************************************************************************/
30 #ifndef GRIDENGINE_H
31 #define GRIDENGINE_H
32 
33 #include <QGLFunctions>
34 #include <QGLShaderProgram>
35 #include <QOpenGLFunctions>
36 
37 namespace cavapa_gui {
38 
48 class GridEngine : protected QOpenGLFunctions
49 {
50 public:
51 
55  void initialize();
56 
61  void drawGridGeometry(QGLShaderProgram *program);
62 
63 private:
64 
71  void initGridGeometry();
72 
73  const int gridWidth = 80; // Width of the grid
74  const int gridDepth = 80; // Depth of the grid
75 
76  int gridVerticesN; // Number of vertices in the grid
77  int gridIndicesN; // Number of indices required
78 
79 
80  int axissize; // size of axis cross
81  int axisdistance; // distance of axis cross from camera
82 
83  int axisVerticesN; // Number of vertices in the axis cross
84  int axisIndicesN;
85 
86 
87  int cubesize; // same for axis cube
88  int cubedistance;
89 
90  int cubeVerticesN;
91  int cubeIndicesN;
92 
93  std::vector<GLfloat> vertices;
94  std::vector<GLushort> indices;
95 
96  std::vector<GLfloat> axisvertices;
97  std::vector<GLushort> axisindices;
98 
99  std::vector<GLfloat> cubevertices;
100  std::vector<GLushort> cubeindices;
101 
102 
103 };
104 
105 }
106 
107 #endif // GRIDENGINE_H
Draws a grid with OpenGL.
Definition: gridengine.h:48
void initialize()
Definition: gridengine.cpp:53
void drawGridGeometry(QGLShaderProgram *program)
Draws the grid.
Definition: gridengine.cpp:189