Katana Plug-in APIs 0.1

DrawableMesh.h

00001 // Copyright (c) 2016 The Foundry Visionmongers Ltd. All Rights Reserved.
00002 
00003 #ifndef DRAWABLEMESH_H_
00004 #define DRAWABLEMESH_H_
00005 
00006 #if defined(_WIN32)
00007 #include <FnPlatform/Windows.h>
00008 #endif
00009 
00010 #include "GL/glew.h"
00011 #include "FnViewer/utils/FnGLShaderProgram.h"
00012 #include <FnAttribute/FnAttribute.h>
00013 #include <vector>
00014 
00021 class DrawableMesh
00022 {
00023 public:
00024     enum BUFFERS {
00025         VERTEX_BUFFER,
00026         COLOR_BUFFER,
00027         INDEX_BUFFER,
00028         TEXCOORD_BUFFER,
00029         NORMAL_BUFFER,
00030 
00031         NUM_BUFFERS
00032     };
00033 
00034     DrawableMesh();
00035     virtual ~DrawableMesh();
00036 
00038     void clearGLResources();
00039 
00041     void deleteShader();
00042 
00044     void setDrawAttribute(const std::string& name, FnAttribute::Attribute attr);
00045 
00047     void draw();
00048 
00053     void pickerDraw(Foundry::Katana::ViewerUtils::GLShaderProgram& shaderProgram);
00054 
00059     void setupGeometry(const FnAttribute::GroupAttribute& attributes);
00060 
00067     void setupMaterials(const FnAttribute::GroupAttribute& attributes);
00068 
00070     bool isValid() const;
00071 
00073     Foundry::Katana::ViewerUtils::GLShaderProgram* getCustomShader() const { return m_customShader; }
00074 
00075 private:
00077     FnAttribute::FloatAttribute m_pointsAttr;
00079     GLuint m_vao;
00081     GLuint m_vbo[NUM_BUFFERS];
00083     int m_numDrawElements;
00085     Foundry::Katana::ViewerUtils::GLShaderProgram* m_customShader;
00087     FnAttribute::DoubleAttribute m_viewMatrixAttr;
00089     FnAttribute::DoubleAttribute m_projectionMatrixAttr;
00091     FnAttribute::DoubleAttribute m_worldMatrixAttr;
00093     FnAttribute::FloatAttribute m_colorAttr;
00094 };
00095 
00096 
00097 #endif /* DRAWABLEMESH_H_ */
 All Classes Functions Variables Typedefs Enumerations Enumerator