1 // This file belongs to the "MiniCore" game engine. 2 // Copyright (C) 2015 Jussi Lind <jussi.lind@iki.fi> 3 // 4 // This program is free software; you can redistribute it and/or 5 // modify it under the terms of the GNU General Public License 6 // as published by the Free Software Foundation; either version 2 7 // of the License, or (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with this program; if not, write to the Free Software 16 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 17 // MA 02110-1301, USA. 18 // 19 20 #ifndef MCSURFACEOBJECTRENDERER_HH 21 #define MCSURFACEOBJECTRENDERER_HH 22 23 #include <MCGLEW> 24 25 #include "mcmacros.hh" 26 #include "mcobjectrendererbase.hh" 27 #include "mcworldrenderer.hh" 28 29 #include <vector> 30 31 class MCSurface; 32 class MCSurfaceObject; 33 class MCCamera; 34 class MCObject; 35 36 /*! Renders surface Object (textured Objects) batches. 37 * Each MCSurfaceObject id should have a corresponding MCSurfaceObjectRenderer 38 * registered to MCWorldRenderer. */ 39 class MCSurfaceObjectRenderer : public MCObjectRendererBase 40 { 41 public: 42 explicit MCSurfaceObjectRenderer(size_t maxBatchSize = 1024); 43 44 //! Destructor. 45 virtual ~MCSurfaceObjectRenderer() override = default; 46 47 private: 48 DISABLE_COPY(MCSurfaceObjectRenderer); 49 DISABLE_ASSI(MCSurfaceObjectRenderer); 50 DISABLE_MOVE(MCSurfaceObjectRenderer); 51 52 /*! Populate the current batch. 53 * \param Objects The vector of Object data to be rendered. 54 * \param camera The camera window. */ 55 void setBatch(MCRenderLayer::ObjectBatch & batch, MCCamera * camera = nullptr, bool isShadow = false) override; 56 57 //! Render the current Object batch. 58 void render() override; 59 60 //! Render the current Object batch as shadows. 61 void renderShadows() override; 62 63 const size_t m_numVerticesPerSurface = 6; 64 65 std::vector<MCGLVertex> m_vertices; 66 67 std::vector<MCGLVertex> m_normals; 68 69 std::vector<MCGLTexCoord> m_texCoords; 70 71 std::vector<MCGLColor> m_colors; // Vertex colors 72 73 MCSurfacePtr m_surface; 74 75 friend class MCWorldRenderer; 76 }; 77 78 #endif // MCSURFACEOBJECTRENDERER_HH 79