LCOV - code coverage report
Current view: top level - source/renderer - ModelVertexRenderer.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 0 2 0.0 %
Date: 2023-01-19 00:18:29 Functions: 0 3 0.0 %

          Line data    Source code
       1             : /* Copyright (C) 2022 Wildfire Games.
       2             :  * This file is part of 0 A.D.
       3             :  *
       4             :  * 0 A.D. is free software: you can redistribute it and/or modify
       5             :  * it under the terms of the GNU General Public License as published by
       6             :  * the Free Software Foundation, either version 2 of the License, or
       7             :  * (at your option) any later version.
       8             :  *
       9             :  * 0 A.D. 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 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
      16             :  */
      17             : 
      18             : /*
      19             :  * Definition of ModelVertexRenderer, the abstract base class for model
      20             :  * vertex transformation implementations.
      21             :  */
      22             : 
      23             : #ifndef INCLUDED_MODELVERTEXRENDERER
      24             : #define INCLUDED_MODELVERTEXRENDERER
      25             : 
      26             : #include "graphics/MeshManager.h"
      27             : #include "graphics/ShaderProgramPtr.h"
      28             : #include "renderer/backend/IDeviceCommandContext.h"
      29             : #include "renderer/backend/IShaderProgram.h"
      30             : 
      31             : class CModel;
      32             : class CModelRData;
      33             : 
      34             : /**
      35             :  * Class ModelVertexRenderer: Normal ModelRenderer implementations delegate
      36             :  * vertex array management and vertex transformation to an implementation of
      37             :  * ModelVertexRenderer.
      38             :  *
      39             :  * ModelVertexRenderer implementations should be designed so that one
      40             :  * instance of the implementation can be used with more than one ModelRenderer
      41             :  * simultaneously.
      42             :  */
      43           0 : class ModelVertexRenderer
      44             : {
      45             : public:
      46           0 :     virtual ~ModelVertexRenderer() { }
      47             : 
      48             : 
      49             :     /**
      50             :      * CreateModelData: Create internal data for one model.
      51             :      *
      52             :      * ModelRenderer implementations must call this once for every
      53             :      * model that will later be rendered, with @p key set to a value
      54             :      * that's unique to that ModelRenderer.
      55             :      *
      56             :      * ModelVertexRenderer implementations should use this function to
      57             :      * create per-CModel and per-CModelDef data like vertex arrays.
      58             :      *
      59             :      * @param key An opaque pointer to pass to the CModelRData constructor
      60             :      * @param model The model.
      61             :      *
      62             :      * @return A new CModelRData that will be passed into other
      63             :      * ModelVertexRenderer functions whenever the same CModel is used again.
      64             :      */
      65             :     virtual CModelRData* CreateModelData(const void* key, CModel* model) = 0;
      66             : 
      67             : 
      68             :     /**
      69             :      * UpdateModelData: Calculate per-model data for each frame.
      70             :      *
      71             :      * ModelRenderer implementations must call this once per frame for
      72             :      * every model that is to be rendered in this frame, even if the
      73             :      * value of updateflags will be zero.
      74             :      * This implies that this function will also be called at least once
      75             :      * between a call to CreateModelData and a call to RenderModel.
      76             :      *
      77             :      * ModelVertexRenderer implementations should use this function to
      78             :      * perform software vertex transforms and potentially other per-frame
      79             :      * calculations.
      80             :      *
      81             :      * @param model The model.
      82             :      * @param data Private data as returned by CreateModelData.
      83             :      * @param updateflags Flags indicating which data has changed during
      84             :      * the frame. The value is the same as the value of the model's
      85             :      * CRenderData::m_UpdateFlags.
      86             :      */
      87             :     virtual void UpdateModelData(CModel* model, CModelRData* data, int updateflags) = 0;
      88             : 
      89             :     /**
      90             :      * Upload per-model data to backend.
      91             :      *
      92             :      * ModelRenderer implementations must call this after UpdateModelData once
      93             :      * per frame for every model that is to be rendered in this frame.
      94             :      *
      95             :      * ModelVertexRenderer implementations should use this function to
      96             :      * upload all needed data to backend.
      97             :      */
      98             :     virtual void UploadModelData(
      99             :         Renderer::Backend::IDeviceCommandContext* deviceCommandContext,
     100             :         CModel* model, CModelRData* data) = 0;
     101             : 
     102             :     /**
     103             :      * PrepareModelDef: Setup backend state for rendering of models that
     104             :      * use the given CModelDef object as base.
     105             :      *
     106             :      * ModelRenderer implementations must call this function before
     107             :      * rendering a sequence of models based on the given CModelDef.
     108             :      * When a ModelRenderer switches back and forth between CModelDefs,
     109             :      * it must call PrepareModelDef for every switch.
     110             :      *
     111             :      * @param def The model definition.
     112             :      */
     113             :     virtual void PrepareModelDef(
     114             :         Renderer::Backend::IDeviceCommandContext* deviceCommandContext,
     115             :         const CModelDef& def) = 0;
     116             : 
     117             : 
     118             :     /**
     119             :      * RenderModel: Invoke the rendering commands for the given model.
     120             :      *
     121             :      * ModelRenderer implementations must call this function to perform
     122             :      * the actual rendering.
     123             :      *
     124             :      * preconditions  : The most recent call to PrepareModelDef since
     125             :      * BeginPass has been for model->GetModelDef().
     126             :      *
     127             :      * @param model The model that should be rendered.
     128             :      * @param data Private data for the model as returned by CreateModelData.
     129             :      *
     130             :      * postconditions : Subsequent calls to RenderModel for models
     131             :      * that use the same CModelDef object and the same texture must
     132             :      * succeed.
     133             :      */
     134             :     virtual void RenderModel(
     135             :         Renderer::Backend::IDeviceCommandContext* deviceCommandContext,
     136             :         Renderer::Backend::IShaderProgram* shader, CModel* model, CModelRData* data) = 0;
     137             : };
     138             : 
     139             : 
     140             : #endif // INCLUDED_MODELVERTEXRENDERER

Generated by: LCOV version 1.13