VAPOR3 3.9.4
TwoDRenderer.h
Go to the documentation of this file.
1//---------------- ----------------------------------------------------------
2//
3// Copyright (C) 2016
4// University Corporation for Atmospheric Research
5// All Rights Reserved
6//
7//----------------------------------------------------------------------------
8
9#ifndef TWODRENDERER_H
10#define TWODRENDERER_H
11
12#include <vapor/glutil.h> // Must be included first!!!
13#include <vapor/DataMgr.h>
14#include <vapor/utils.h>
15#include <vapor/Renderer.h>
16
17namespace VAPoR {
18
24
26public:
31 TwoDRenderer(const ParamsMgr *pm, string winName, string dataSetName, string paramsType, string classType, string instName, DataMgr *dataMgr);
32
34 //
35 virtual ~TwoDRenderer();
36
37protected:
38 // Protected pure virual methods
39 //
40
41 // Return a 2D structured or unstructured mesh
42 //
43 // verts : contains a packed representation of the x,y,z coordinates
44 // of each grid point. Thus size is height * width * sizeof(float) * 3
45 //
46 // normals : contains surface normal at each vertex. Need not be unit length
47 // Same packing as verts
48 //
49 // nverts : number of vertices and number of normals in verts, and
50 // normals, respectively. A single vertex or normal consists of three
51 // components. Thus if nverts == 1 then verts and normals each contain
52 // one three-component element.
53 //
54 // width : For structured grids contains number of grid points along
55 // fastest varying dimension. For unstructured grids contains *total*
56 // number of grid points
57 //
58 // height : For structured grids contains number of grid points along
59 // second fastest varying dimension. For unstructured grids should be set to
60 // one.
61 //
62 // indices : indexes into verts and normals to generate either triangles
63 // (unstructured mesh) or triangle strips (structured mesh).
64 // Compatible with index argument to GLDrawElements
65 //
66 // nindices : num elements in indices
67 //
68 // structuredMesh : bool, true if structured mesh, false if unstructured
69 //
70 virtual int GetMesh(DataMgr *dataMgr, GLfloat **verts, GLfloat **normals, GLsizei &nverts, GLsizei &width, GLsizei &height, GLuint **indices, GLsizei &nindices, bool &structuredMesh) = 0;
71
72 // Return data values for mesh returned with GetMesh(). The returned
73 // array may or may not be coincident with the mesh nodes. In the latter
74 // case the array returned is a uniformally 2D sampling of the data
75 // values on the mesh.
76 //
77 // width : For grid aligned data (gridAligned == true) contains number of
78 // data values along
79 // fastest varying dimension. For non-aligned data (gridAligned == false)
80 // contains *total* number of elements
81 //
82 // height : For grid aligned data (gridAligned == true) contains number of
83 // data values along
84 // second fastest varying dimension. For non-aligned data
85 // (gridAligned == false) should be set to one.
86 //
87 // type : Type of data returned by GetTexture(). If gridAligned
88 // is true, type must be GL_FLOAT
89 //
90 // texelSize: Size, in bytes, of a single element returned by GetTexture.
91 //
92 // gridAligned : bool. If true data are coincident with mesh returned by
93 // GetMesh()
94 //
95 virtual const GLvoid *GetTexture(DataMgr *dataMgr, GLsizei &width, GLsizei &height, GLint &internalFormat, GLenum &format, GLenum &type, size_t &texelSize, bool &gridAligned) = 0;
96
97 virtual void _clearCache() = 0;
98
100 virtual int _initializeGL();
101
103 virtual int _paintGL(bool fast);
104
130 //
131 void ComputeNormals(const GLfloat *verts, GLsizei w, GLsizei h, GLfloat *normals);
132
133private:
134 GLuint _textureID;
135 const GLvoid *_texture;
136 GLfloat * _texCoords;
137 GLsizei _texWidth;
138 GLsizei _texHeight;
139 GLint _texInternalFormat;
140 GLenum _texFormat;
141 GLenum _texType;
142 size_t _texelSize;
143 bool _gridAligned;
144 bool _structuredMesh;
145 GLfloat * _verts;
146 GLfloat * _normals;
147 GLuint * _indices;
148 GLsizei _meshWidth;
149 GLsizei _meshHeight;
150 GLsizei _nindices;
151 GLsizei _nverts;
152 SmartBuf _sb_texCoords;
153
154 GLuint _VAO, _VBO, _dataVBO, _EBO;
155
156 void _openGLInit();
157 void _openGLRestore();
158 void _renderMesh();
159 void _renderMeshUnAligned();
160 void _renderMeshAligned();
161 void _computeTexCoords(GLfloat *tcoords, size_t w, size_t h) const;
162};
163}; // namespace VAPoR
164
165#endif
A cache based data reader.
Definition: DataMgr.h:110
A singleton class for managing Params instances.
Definition: ParamsMgr.h:53
A class that performs rendering in a Visualizer.
Definition: Renderer.h:121
virtual int _paintGL(bool fast)
All OpenGL rendering is performed in the pure virtual paintGL method.
virtual const GLvoid * GetTexture(DataMgr *dataMgr, GLsizei &width, GLsizei &height, GLint &internalFormat, GLenum &format, GLenum &type, size_t &texelSize, bool &gridAligned)=0
void ComputeNormals(const GLfloat *verts, GLsizei w, GLsizei h, GLfloat *normals)
TwoDRenderer(const ParamsMgr *pm, string winName, string dataSetName, string paramsType, string classType, string instName, DataMgr *dataMgr)
virtual void _clearCache()=0
virtual int GetMesh(DataMgr *dataMgr, GLfloat **verts, GLfloat **normals, GLsizei &nverts, GLsizei &width, GLsizei &height, GLuint **indices, GLsizei &nindices, bool &structuredMesh)=0
virtual int _initializeGL()
virtual ~TwoDRenderer()
Destructor.
#define RENDER_API
Definition: common.h:78