## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# ivideo/graph3d.h File Reference

3D graphics interface More...

`#include "csutil/scf.h"`
`#include "csgeom/transfrm.h"`
`#include "csutil/flags.h"`
`#include "csutil/strset.h"`
`#include "ivideo/rndbuf.h"`

Go to the source code of this file.

## Classes

struct | csAlphaMode
| Describes how to deal with alpha values in textures. More...
struct | csGraphics3DCaps
| Information about 3d renderer capabilities. More...
struct | csSimpleRenderMesh
| A simple render mesh. More...
struct | iGraphics3D
| This is the standard 3D graphics interface. More...

## Clipping requirement for DrawTriangleMesh

#define | CS_CLIP_NEEDED 1
| Clipping may be needed.
#define | CS_CLIP_NOT 0
| No clipping required.

## Type of clipper (for iGraphics3D::SetClipper())

#define | CS_CLIPPER_NONE -1
| There is no clipper.
#define | CS_CLIPPER_OPTIONAL 0
| Clipper is optional.
#define | CS_CLIPPER_REQUIRED 2
| Clipper is required.
#define | CS_CLIPPER_TOPLEVEL 1
| Clipper is top-level.

## Mix mode: Default modes

A set of commonly used mix modes.
#define | CS_FX_ADD (CS_MIXMODE_BLEND(ONE, ONE) | CS_MIXMODE_ALPHATEST_DISABLE)
| Additive blending. Formula: `=SRC+DST`.
#define | CS_FX_ALPHA (CS_MIXMODE_BLEND(SRCALPHA, SRCALPHA_INV) | CS_MIXMODE_ALPHATEST_DISABLE)
| Alpha blending.
#define | CS_FX_COPY (CS_MIXMODE_TYPE_AUTO | CS_MIXMODE_ALPHATEST_AUTO)
| This mixmode uses alpha smooth blending, binary blending (ie enabled alpha test) and no blending depending on the contents of csRenderMesh::alphaMode.
#define | CS_FX_DESTALPHAADD (CS_MIXMODE_BLEND(DSTALPHA, ONE) | CS_MIXMODE_ALPHATEST_DISABLE)
| Multiply source color with destination alpha and add.
#define | CS_FX_FLAT (0x04000000)
| Flat shading flag.
#define | CS_FX_MASK_ALPHA (0x000000FF)
| Mixmode alpha part.
#define | CS_FX_MASK_MIXMODE (0xf0ff0000)
| Bit mask for bits relevant to mix mode comparison; contains type, alpha test flags and blending op factors.
#define | CS_FX_MESH (CS_MIXMODE_TYPE_MESH)
| Use the mix mode of the mesh mix mode.
#define | CS_FX_MULTIPLY (CS_MIXMODE_BLEND(DSTCOLOR, ZERO) | CS_MIXMODE_ALPHATEST_DISABLE)
| Multiplicative blending. Formula: `=SRC*DST`.
#define | CS_FX_MULTIPLY2 (CS_MIXMODE_BLEND(DSTCOLOR, SRCCOLOR) | CS_MIXMODE_ALPHATEST_DISABLE)
| Multiplicative doubling blending. Formula: `=2*SRC*DST`.
#define | CS_FX_PREMULTALPHA (CS_MIXMODE_BLEND(ONE, SRCALPHA_INV) | CS_MIXMODE_ALPHATEST_DISABLE)
| Multiply destination color with inverse source alpha and add source color.
#define | CS_FX_SRCALPHAADD (CS_MIXMODE_BLEND(SRCALPHA, ONE) | CS_MIXMODE_ALPHATEST_DISABLE)
| Multiply source color with source alpha and add.
#define | CS_FX_TRANSPARENT (CS_MIXMODE_BLEND(ZERO, ONE) | CS_MIXMODE_ALPHATEST_DISABLE)
| Transparent blending (keep framebuffer unmodified).

## Mix mode: alpha helpers

#define | CS_FX_SETALPHA(alpha) (CS_FX_ALPHA | uint ((alpha) * CS_FX_MASK_ALPHA))
| Macro for setting of alpha bits into mixmode (alpha between 0 and 1).
#define | CS_FX_SETALPHA_INT(alpha) (CS_FX_ALPHA | uint ((alpha) & CS_FX_MASK_ALPHA))
| Macro for setting of alpha bits into mixmode (alpha between 0 and 255).

## Light parameters

#define | CS_LIGHTPARAM_ATTENUATION 3
| Attenuation of the light.
#define | CS_LIGHTPARAM_DIFFUSE 1
| Diffuse color of the light.
#define | CS_LIGHTPARAM_POSITION 0
| Position of the light.
#define | CS_LIGHTPARAM_SPECULAR 2
| Specular color of the light.

## Mix mode: Alpha test flags

Enabled alpha test (or binary alpha) means that a fragment is only drawn when its alpha component is above a certain threshold, and discarded otherwise.
#define | CS_MIXMODE_ALPHATEST_AUTO (0x00000000)
| Automatic alpha test.
#define | CS_MIXMODE_ALPHATEST_DISABLE (0x20000000)
| Unconditionally disable alpha test.
#define | CS_MIXMODE_ALPHATEST_ENABLE (0x10000000)
| Unconditionally enable alpha test.
#define | CS_MIXMODE_ALPHATEST_MASK (0x30000000)
| Bit mask to extract the alpha test flag from a mixmode specifier.

## Mix mode: Blending mode helpers

#define | CS_MIXMODE_BLEND(Src, Dst)
| Helper macro to construct a blending operation mixmode Src and Dst are blending op factors , however sans the CS_MIXMODE_FACT_ prefix.
#define | CS_MIXMODE_BLENDOP_DST(mode) ((mode >> 16) & CS_MIXMODE_FACT_MASK)
| Helper macro to extract the `dstFactor` from a blending op mixmode.
#define | CS_MIXMODE_BLENDOP_SRC(mode) ((mode >> 20) & CS_MIXMODE_FACT_MASK)
| Helper macro to extract the `srcFactor` from a blending op mixmode.

## Mix mode: Types

The mix mode specifies how a shaded fragment (denoted as `SRC`) is mixed (or blended) with the framebuffer fragment (`DST`).
#define | CS_MIXMODE_TYPE_AUTO (0x00000000)
| Automatic blending mode.
#define | CS_MIXMODE_TYPE_BLENDOP (0x40000000)
| Blend with a blending operation.
#define | CS_MIXMODE_TYPE_MASK (0xc0000000)
| Bit mask to extract the type from a mixmode specifier.
#define | CS_MIXMODE_TYPE_MESH (0x80000000)
| Use the mix mode of the mesh mix mode.

## Shadow states

#define | CS_SHADOW_VOLUME_BEGIN 1
| Clear stencil.
#define | CS_SHADOW_VOLUME_FAIL1 4
| Setup for carmack's reverse pass 1.
#define | CS_SHADOW_VOLUME_FAIL2 5
| Setup for carmack's reverse pass 2.
#define | CS_SHADOW_VOLUME_FINISH 7
| Restore states.
#define | CS_SHADOW_VOLUME_PASS1 2
| Setup for pass 1.
#define | CS_SHADOW_VOLUME_PASS2 3
| Setup for pass 2.
#define | CS_SHADOW_VOLUME_USE 6
| Setup for shadow masking.

## iGraphics3D::BeginDraw() flags

#define | CSDRAW_2DGRAPHICS 0x00000001
| We're going to draw 2D graphics.
#define | CSDRAW_3DGRAPHICS 0x00000002
| We're going to draw 3D graphics.
#define | CSDRAW_CLEARSCREEN 0x00000020
| Clear frame buffer ?
#define | CSDRAW_CLEARZBUFFER 0x00000010
| Clear Z-buffer ?

## Defines

#define | CS_VATTRIB_GENERIC_FIRST 100
#define | CS_VATTRIB_GENERIC_LAST (CS_VATTRIB_GENERIC_FIRST + 15)
#define | CS_VATTRIB_IS_GENERIC(va) ((va >= CS_VATTRIB_GENERIC_FIRST) && (va <=CS_VATTRIB_GENERIC_LAST))
#define | CS_VATTRIB_IS_SPECIFIC(va) ((va >= CS_VATTRIB_SPECIFIC_FIRST) && (va <=CS_VATTRIB_SPECIFIC_LAST))
#define | CS_VATTRIB_SPECIFIC_FIRST 0
#define | CS_VATTRIB_SPECIFIC_LAST 15

## Enumerations

enum | { CS_MIXMODE_FACT_ZERO = 0x0, CS_MIXMODE_FACT_ONE = 0x1, CS_MIXMODE_FACT_SRCCOLOR = 0x2, CS_MIXMODE_FACT_SRCCOLOR_INV = 0x3, CS_MIXMODE_FACT_DSTCOLOR = 0x4, CS_MIXMODE_FACT_DSTCOLOR_INV = 0x5, CS_MIXMODE_FACT_SRCALPHA = 0x6, CS_MIXMODE_FACT_SRCALPHA_INV = 0x7, CS_MIXMODE_FACT_DSTALPHA = 0x8, CS_MIXMODE_FACT_DSTALPHA_INV = 0x9, CS_MIXMODE_FACT_COUNT = 0xa, CS_MIXMODE_FACT_MASK = 0xf }
| Mix mode: Blending op factors. More...
enum | csRenderMeshType { CS_MESHTYPE_TRIANGLES, CS_MESHTYPE_QUADS, CS_MESHTYPE_TRIANGLESTRIP, CS_MESHTYPE_TRIANGLEFAN, CS_MESHTYPE_POINTS, CS_MESHTYPE_POINT_SPRITES, CS_MESHTYPE_LINES, CS_MESHTYPE_LINESTRIP }
| Primitive type of a mesh. More...
enum | csSimpleMeshFlags { csSimpleMeshScreenspace = 0x01 }
| Flags to influence the behaviour of DrawSimpleMesh(). More...

enum

csVertexAttrib {
CS_VATTRIB_INVALID = -1, CS_VATTRIB_POSITION = CS_VATTRIB_SPECIFIC_FIRST + 0, CS_VATTRIB_WEIGHT = CS_VATTRIB_SPECIFIC_FIRST + 1, CS_VATTRIB_NORMAL = CS_VATTRIB_SPECIFIC_FIRST + 2,
CS_VATTRIB_COLOR = CS_VATTRIB_SPECIFIC_FIRST + 3, CS_VATTRIB_PRIMARY_COLOR = CS_VATTRIB_SPECIFIC_FIRST + 3, CS_VATTRIB_SECONDARY_COLOR = CS_VATTRIB_SPECIFIC_FIRST + 4, CS_VATTRIB_FOGCOORD = CS_VATTRIB_SPECIFIC_FIRST + 5,
CS_VATTRIB_TEXCOORD = CS_VATTRIB_SPECIFIC_FIRST + 8, CS_VATTRIB_TEXCOORD0 = CS_VATTRIB_SPECIFIC_FIRST + 8, CS_VATTRIB_TEXCOORD1 = CS_VATTRIB_SPECIFIC_FIRST + 9, CS_VATTRIB_TEXCOORD2 = CS_VATTRIB_SPECIFIC_FIRST + 10,
CS_VATTRIB_TEXCOORD3 = CS_VATTRIB_SPECIFIC_FIRST + 11, CS_VATTRIB_TEXCOORD4 = CS_VATTRIB_SPECIFIC_FIRST + 12, CS_VATTRIB_TEXCOORD5 = CS_VATTRIB_SPECIFIC_FIRST + 13, CS_VATTRIB_TEXCOORD6 = CS_VATTRIB_SPECIFIC_FIRST + 14,
CS_VATTRIB_TEXCOORD7 = CS_VATTRIB_SPECIFIC_FIRST + 15, CS_VATTRIB_0 = CS_VATTRIB_GENERIC_FIRST + 0, CS_VATTRIB_1 = CS_VATTRIB_GENERIC_FIRST + 1, CS_VATTRIB_2 = CS_VATTRIB_GENERIC_FIRST + 2,
CS_VATTRIB_3 = CS_VATTRIB_GENERIC_FIRST + 3, CS_VATTRIB_4 = CS_VATTRIB_GENERIC_FIRST + 4, CS_VATTRIB_5 = CS_VATTRIB_GENERIC_FIRST + 5, CS_VATTRIB_6 = CS_VATTRIB_GENERIC_FIRST + 6,
CS_VATTRIB_7 = CS_VATTRIB_GENERIC_FIRST + 7, CS_VATTRIB_8 = CS_VATTRIB_GENERIC_FIRST + 8, CS_VATTRIB_9 = CS_VATTRIB_GENERIC_FIRST + 9, CS_VATTRIB_10 = CS_VATTRIB_GENERIC_FIRST + 10,
CS_VATTRIB_11 = CS_VATTRIB_GENERIC_FIRST + 11, CS_VATTRIB_12 = CS_VATTRIB_GENERIC_FIRST + 12, CS_VATTRIB_13 = CS_VATTRIB_GENERIC_FIRST + 13, CS_VATTRIB_14 = CS_VATTRIB_GENERIC_FIRST + 14
}

| Vertex attributes. More...
enum | csZBufMode { CS_ZBUF_NONE = 0x00000000, CS_ZBUF_FILL = 0x00000001, CS_ZBUF_TEST = 0x00000002, CS_ZBUF_USE = 0x00000003, CS_ZBUF_EQUAL = 0x00000004, CS_ZBUF_INVERT = 0x00000005, CS_ZBUF_MESH = 0x80000000, CS_ZBUF_MESH2 = 0x80000001 }
| Z-buffer modes. More...

enum

G3D_RENDERSTATEOPTION {
G3DRENDERSTATE_ZBUFFERMODE, G3DRENDERSTATE_DITHERENABLE, G3DRENDERSTATE_BILINEARMAPPINGENABLE, G3DRENDERSTATE_TRILINEARMAPPINGENABLE,
G3DRENDERSTATE_TRANSPARENCYENABLE, G3DRENDERSTATE_MIPMAPENABLE, G3DRENDERSTATE_TEXTUREMAPPINGENABLE, G3DRENDERSTATE_LIGHTINGENABLE,
G3DRENDERSTATE_INTERLACINGENABLE, G3DRENDERSTATE_MMXENABLE, G3DRENDERSTATE_INTERPOLATIONSTEP, G3DRENDERSTATE_MAXPOLYGONSTODRAW,
G3DRENDERSTATE_GOURAUDENABLE, G3DRENDERSTATE_EDGES
}

| Graphics3D render state options. More...

## Detailed Description

3D graphics interface

Definition in file graph3d.h.

## Define Documentation

#define CS_LIGHTPARAM_ATTENUATION 3

| Attenuation of the light. Definition at line 446 of file graph3d.h.

#define CS_LIGHTPARAM_DIFFUSE 1

| Diffuse color of the light. Definition at line 442 of file graph3d.h.

#define CS_LIGHTPARAM_POSITION 0

| Position of the light. Definition at line 440 of file graph3d.h.

#define CS_LIGHTPARAM_SPECULAR 2

| Specular color of the light. Definition at line 444 of file graph3d.h.

#define CS_SHADOW_VOLUME_BEGIN 1

| Clear stencil. Definition at line 452 of file graph3d.h.

#define CS_SHADOW_VOLUME_FAIL1 4

| Setup for carmack's reverse pass 1. Definition at line 458 of file graph3d.h.

#define CS_SHADOW_VOLUME_FAIL2 5

| Setup for carmack's reverse pass 2. Definition at line 460 of file graph3d.h.

#define CS_SHADOW_VOLUME_FINISH 7

| Restore states. Definition at line 464 of file graph3d.h.

#define CS_SHADOW_VOLUME_PASS1 2

| Setup for pass 1. Definition at line 454 of file graph3d.h.

#define CS_SHADOW_VOLUME_PASS2 3

| Setup for pass 2. Definition at line 456 of file graph3d.h.

#define CS_SHADOW_VOLUME_USE 6

| Setup for shadow masking. Definition at line 462 of file graph3d.h.

## Enumeration Type Documentation

enum csRenderMeshType

Primitive type of a mesh.

Enumerator:

  CS_MESHTYPE_TRIANGLES | Triangles.
  CS_MESHTYPE_QUADS | Quads.

  CS_MESHTYPE_TRIANGLESTRIP

  Triangle strip.

  The OpenGL spec describes it pretty well: "A triangle strip is a series of triangles connected along shared edges. A triangle strip is specified by giving a series of defining vertices [...]. In this case, the first three vertices define the first triangle [...]. Each subsequent vertex defines a new triangle using that point along with two vertices from the previous triangle."

  CS_MESHTYPE_TRIANGLEFAN | Triangle fan. Similar to a triangle strip, however, a triangle is always defined with the first, previously added and the recently added vertex.
  CS_MESHTYPE_POINTS | Points.
  CS_MESHTYPE_POINT_SPRITES | Point sprites. Note: only supported if the SupportsPointSprites member of the csGraphics3DCaps structure for this renderer is true.
  CS_MESHTYPE_LINES | Lines.
  CS_MESHTYPE_LINESTRIP | Line strip. A line is defined from the prebviously and recently added vertex.

Definition at line 527 of file graph3d.h.

enum csSimpleMeshFlags

Flags to influence the behaviour of DrawSimpleMesh().

Enumerator:

  csSimpleMeshScreenspace | Ignore the object2camera transform in the csSimpleRenderMesh struct and replace it with a transformation that effectively lets you specify the vertices in screen space. The Z components of the mesh vertices should be set to 0 when this flag is specified.

Definition at line 573 of file graph3d.h.

enum G3D_RENDERSTATEOPTION

Graphics3D render state options.

Enumerator:

  G3DRENDERSTATE_ZBUFFERMODE | Set Z-buffer fill/test/use mode (parameter is a csZBufMode).
  G3DRENDERSTATE_DITHERENABLE | Enable/disable dithering (parameter is a bool).
  G3DRENDERSTATE_BILINEARMAPPINGENABLE | Enable/disable bi-linear mapping (parameter is a bool).
  G3DRENDERSTATE_TRILINEARMAPPINGENABLE | Enable/disable tri-linear mapping (parameter is a bool).
  G3DRENDERSTATE_TRANSPARENCYENABLE | Enable/disable transparent textures (parameter is a bool).
  G3DRENDERSTATE_MIPMAPENABLE | Enable/disable mip-mapping (parameter is a bool).
  G3DRENDERSTATE_TEXTUREMAPPINGENABLE | Enable/disable textures (parameter is a bool).
  G3DRENDERSTATE_LIGHTINGENABLE | Enable/disable lighting (parameter is a bool).
  G3DRENDERSTATE_INTERLACINGENABLE | Enable/disable interlacing (parameter is a bool).
  G3DRENDERSTATE_MMXENABLE | Enable/disable MMX instructions usage (parameter is a bool).
  G3DRENDERSTATE_INTERPOLATIONSTEP | Set perspective-correction interpolation step (parameter is a int).
  G3DRENDERSTATE_MAXPOLYGONSTODRAW | Set maximal number of polygons per frame to draw (parameter is a int).
  G3DRENDERSTATE_GOURAUDENABLE | Enable/disable Gouraud shading (parameter is a bool).
  G3DRENDERSTATE_EDGES | Enable/disable edge drawing (debugging) (parameter is a bool).

Definition at line 468 of file graph3d.h.