/usr/include/crystalspace-2.0/ivideo/rendermesh.h is in libcrystalspace-dev 2.0+dfsg-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | /*
Copyright (C) 2002 by Marten Svanfeldt
Anders Stenberg
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __CS_IVIDEO_RENDERMESH_H__
#define __CS_IVIDEO_RENDERMESH_H__
/** \file
* Rendermesh interface
*/
/**
* \addtogroup gfx3d
* @{ */
#include "csgeom/box.h"
#include "csgeom/transfrm.h"
#include "csgeom/vector3.h"
#include "iengine/material.h"
#include "ivideo/graph3d.h"
#include "ivideo/shader/shader.h"
struct iPortalContainer;
namespace CS
{
namespace Graphics
{
/// Rendering priority.
class RenderPriority
{
uint value;
public:
RenderPriority () : value (uint (~0)) {}
explicit RenderPriority (uint value) : value (value) {}
CS_DEPRECATED_METHOD_MSG("Please use CS::Graphics::RenderPriority to store render priorities")
RenderPriority (long value) : value (value) {}
CS_DEPRECATED_METHOD_MSG("Please use CS::Graphics::RenderPriority to store render priorities")
RenderPriority (int value) : value (value) {}
bool IsValid() const { return value != uint (~0); }
operator uint () const { return value; }
};
/// Culling mode of a mesh.
enum MeshCullMode
{
cullNormal, /*!< Normal culling. */
cullFlipped, /*!< Flipped culling. */
cullDisabled /*!< Culling is disabled. */
};
/**
* Returns inverse culling mode for a given culling mode.
* Specifically, for "normal" culling, "flipped" is returned; for "flipped"
* culling, "normal" is returned.
*/
static inline MeshCullMode GetFlippedCullMode (MeshCullMode cullMode)
{
switch (cullMode)
{
case cullNormal:
return cullFlipped;
case cullFlipped:
return cullNormal;
case cullDisabled:
return cullDisabled;
}
// Should not happen ...
return cullNormal;
}
/**
* Alpha test function.
* The alpha test function specifies how the source pixel alpha value
* (left side of comparison) and alpha test threshold value (right side of
* comparison) are compared. If the comparison is \c true, the pixel is
* drawn; otherwise, it is discarded.
*/
enum AlphaTestFunction
{
/**
* Draw pixel if source alpha value is greater or equal than the threshold
* value.
*/
atfGreaterEqual,
/**
* Draw pixel if source alpha value is greater than the threshold
* value.
*/
atfGreater,
/**
* Draw pixel if source alpha value is lower or equal than the threshold
* value.
*/
atfLowerEqual,
/**
* Draw pixel if source alpha value is lower than the threshold
* value.
*/
atfLower
};
/**
* Alpha test options.
* These options take effect if:
* - The mixmode alpha test type (bits #CS_MIXMODE_ALPHATEST_MASK)
* is #CS_MIXMODE_ALPHATEST_ENABLE.
* - The alpha test type (bits #CS_MIXMODE_ALPHATEST_MASK)
* is #CS_MIXMODE_ALPHATEST_AUTO and the alpha type used is
* csAlphaMode::alphaBinary.
*/
struct AlphaTestOptions
{
/**
* Threshold value the source pixel alpha is compared against.
* Default is 0.5
*/
float threshold;
/**
* Comparison between source pixel alpha and threshold value.
* Default atfGreaterEqual
*/
AlphaTestFunction func;
AlphaTestOptions() : threshold (0.5f), func (atfGreaterEqual) {}
};
/**
* Mesh render mode information. Contains the Z, mix and alpha modes to use
* for rendering a mesh.
* \remarks Is separate from CS::Graphics::CoreRenderMesh to allow preprocessing steps
* to modify the mode data.
*/
struct RenderMeshModes
{
RenderMeshModes () : z_buf_mode ((csZBufMode)~0), mixmode (CS_FX_COPY),
alphaToCoverage (false), atcMixmode (CS_MIXMODE_BLEND (ONE, ZERO)),
cullMode (cullNormal),
alphaType (csAlphaMode::alphaNone), zoffset (false), doInstancing (false),
instParams (nullptr), instParamBuffers (nullptr)
{
}
RenderMeshModes (RenderMeshModes const& x) :
z_buf_mode (x.z_buf_mode),
mixmode (x.mixmode),
alphaToCoverage (x.alphaToCoverage),
atcMixmode (x.atcMixmode),
renderPrio (x.renderPrio),
cullMode (x.cullMode),
alphaType (x.alphaType),
alphaTest (x.alphaTest),
zoffset (x.zoffset),
buffers (x.buffers),
doInstancing (x.doInstancing),
instParamNum (x.instParamNum),
instParamsTargets (x.instParamsTargets),
instanceNum (x.instanceNum),
instParams (x.instParams),
instParamBuffers (x.instParamBuffers)
{
}
~RenderMeshModes () { }
/// Z mode to use
csZBufMode z_buf_mode;
/// mixmode to use
uint mixmode;
/**
* Whether to enable alpha to coverage.
* Note that alpha to coverage requires enabled multisampling
* If that is the case alpha to coverage is
* enabled and the mixmode from \c atcMixmode is used.
* Otherwise, the normal mixmode is used.
*/
bool alphaToCoverage;
/// Mixmode to use together with alpha to coverage
uint atcMixmode;
/// Mesh render priority
RenderPriority renderPrio;
/// Mesh culling mode
MeshCullMode cullMode;
/**
* Alpha mode this mesh is drawn.
*
* - If the mixmode mode type (bits #CS_MIXMODE_TYPE_MASK) is
* #CS_MIXMODE_TYPE_AUTO, the alpha type affects blending.
* - If the mixmode alpha test type (bits #CS_MIXMODE_ALPHATEST_MASK)
* is #CS_MIXMODE_ALPHATEST_AUTO, the alpha type affects whether alpha
* test is used or not.
*/
csAlphaMode::AlphaType alphaType;
/// Alpha test setting (take effect when mixmode enables alpha test)
AlphaTestOptions alphaTest;
/// Whether Z value offsetting should be enabled.
bool zoffset;
/// Holder of default render buffers
csRef<csRenderBufferHolder> buffers;
/// Whether to enable instancing.
bool doInstancing;
/// Number of instance parameters.
size_t instParamNum;
/// Targets of instance parameters.
const csVertexAttrib* instParamsTargets;
/// Number of instances.
size_t instanceNum;
/**
* Instance parameters, as shader variables.
* The "instance" array (elements of type csShaderVariable**) has one
* "parameter" array for each instance. The parameter array (elements of
* type csShaderVariable*) has one shader variable for each instance
* parameter.
*/
csShaderVariable** const * instParams;
/**
* Instance parameters, as shader variables.
* Each element in the array is a render buffer with the values
* for an instance parameter; there must be as many render buffers
* as parameters.
*
* The instance data can be given in both the instParams and
* instParamsBuffers array; in that case, the render buffer takes
* precedence. Only when a buffer is null the shader variable data
* is taken.
*/
iRenderBuffer** instParamBuffers;
};
/**
* Start and end for a range of indices to render.
* The indices are used in the range from \a start (inclusive) to \a end
* (exclusive): start <= n < end
*/
struct RenderMeshIndexRange
{
/// Start index.
unsigned int start;
/// End index.
unsigned int end;
};
/**
* Data required by the renderer to draw a mesh.
*/
struct CoreRenderMesh
{
/**
* To make debugging easier we add the name of the mesh object
* here in debug mode.
*/
const char* db_mesh_name;
CoreRenderMesh () : db_mesh_name ("<unknown>"), clip_portal (0),
clip_plane (0), clip_z_plane (0), do_mirror (false),
multiRanges (0), rangesNum (0), indexstart (0), indexend (0)
{
}
~CoreRenderMesh () {}
/// Clipping parameter
int clip_portal;
/// Clipping parameter
int clip_plane;
/// Clipping parameter
int clip_z_plane;
// @@@ FIXME: should prolly be handled by component managing rendering
/**
* Mirror mode - whether the mesh should be mirrored.
* Essentially toggles between back- and front-face culling.
* It should be set to \p true if \a object2camera contains a negative
* scaling. Basically, in almost any case it should be set to the camera's
* mirror mode.
*
* \code
* iCamera* camera;
* csRenderMesh myMesh;
* ...
* myMesh.object2camera = camera->GetTransform () /
* movable->GetFullTransform ();
* myMesh.do_mirror = camera->IsMirrored ();
* \endcode
*/
bool do_mirror;
/// Mesh type
csRenderMeshType meshtype;
/**
* Index ranges to render. If ranges are specified they have precedence
* over \a indexstart and \a indexend.
*/
RenderMeshIndexRange* multiRanges;
/// Number of index ranges in \a multiRanges.
size_t rangesNum;
/** @{ */
/**
* Start and end of the range of indices to use. The indices are
* used in the range from \a indexstart (inclusive) to \a indexend
* (exclusive): indexstart <= n < indexend
*/
unsigned int indexstart;
unsigned int indexend;
/** @} */
/**
* Material used for this mesh.
* Used for e.g. sorting by material.
*/
iMaterialWrapper* material;
/**
* Transform object space -> world space.
* \remarks 'this' space is object space, 'other' space is world space
*/
csReversibleTransform object2world;
/// Render mesh bounding box, object space
csBox3 bbox;
};
/**
* Mesh data as returned by mesh plugins. Contains both the data needed for
* rendering as well as some additional data for preprocessing.
*/
struct RenderMesh : public CoreRenderMesh, public RenderMeshModes
{
RenderMesh () : geometryInstance (0), portal (0)
{
}
~RenderMesh () {}
/**
* Some unique ID for the geometry used to render this mesh.
* Used for sorting purposes, and is allowed to be 0, although
* that means non-optimal mesh sorting at rendering.
*/
void *geometryInstance;
/// Pointer to a portalcontainer, if there is any
iPortalContainer* portal;
/// \todo Document me!
csRef<iShaderVariableContext> variablecontext;
/// Worldspace origin of the mesh
csVector3 worldspace_origin;
};
} // namespace Graphics
} // namespace CS
typedef CS::Graphics::RenderMeshModes csRenderMeshModes;
typedef CS::Graphics::CoreRenderMesh csCoreRenderMesh;
typedef CS::Graphics::RenderMesh csRenderMesh;
/** @} */
#endif // __CS_IVIDEO_RENDERMESH_H__
|