Dreambox C/C++ SDK v1.0.0
C/C++ SDK for creating Dreambox games
Loading...
Searching...
No Matches
db_vdp.h File Reference
#include <stdint.h>
#include "db_math.h"

Go to the source code of this file.

Data Structures

struct  vdp_Rect
 An axis-aligned rectangle. More...
 
struct  vdp_Color32
 A 32-bit color. More...
 
struct  vdp_Vertex
 A vertex which can be passed to vdp_drawGeometry. More...
 

Macros

#define VDP_TEXFMT_RGB565   0
 
#define VDP_TEXFMT_RGBA4444   1
 
#define VDP_TEXFMT_RGBA8888   2
 
#define VDP_TEXFMT_DXT1   3
 
#define VDP_TEXFMT_DXT3   4
 
#define VDP_FILTER_NEAREST   0x2600
 
#define VDP_FILTER_LINEAR   0x2601
 
#define VDP_WRAP_REPEAT   0x2901
 
#define VDP_WRAP_CLAMP   0x812F
 
#define VDP_WRAP_MIRROR   0x8370
 
#define VDP_COMPARE_NEVER   0x0200
 
#define VDP_COMPARE_LESS   0x0201
 
#define VDP_COMPARE_EQUAL   0x0202
 
#define VDP_COMPARE_LEQUAL   0x0203
 
#define VDP_COMPARE_GREATER   0x0204
 
#define VDP_COMPARE_NOTEQUAL   0x0205
 
#define VDP_COMPARE_GEQUAL   0x0206
 
#define VDP_COMPARE_ALWAYS   0x0207
 
#define VDP_FUNC_ADD   0x8006
 
#define VDP_FUNC_SUBTRACT   0x800A
 
#define VDP_FUNC_REVERSE_SUBTRACT   0x800B
 
#define VDP_BLEND_ZERO   0
 
#define VDP_BLEND_ONE   1
 
#define VDP_BLEND_SRC_COLOR   0x0300
 
#define VDP_BLEND_ONE_MINUS_SRC_COLOR   0x0301
 
#define VDP_BLEND_SRC_ALPHA   0x0302
 
#define VDP_BLEND_ONE_MINUS_SRC_ALPHA   0x0303
 
#define VDP_BLEND_DST_ALPHA   0x0304
 
#define VDP_BLEND_ONE_MINUS_DST_ALPHA   0x0305
 
#define VDP_BLEND_DST_COLOR   0x0306
 
#define VDP_BLEND_ONE_MINUS_DST_COLOR   0x0307
 
#define VDP_WINDING_CW   0x0900
 
#define VDP_WINDING_CCW   0x0901
 
#define VDP_TOPOLOGY_LINES   0x0000
 
#define VDP_TOPOLOGY_LINE_STRIP   0x0001
 
#define VDP_TOPOLOGY_TRIANGLES   0x0002
 
#define VDP_TOPOLOGY_TRIANGLE_STRIP   0x0003
 

Typedefs

typedef void(* vsync_handler_t) ()
 Callback type for vsync. More...
 

Functions

void vdp_clearColor (const vdp_Color32 *color)
 Clear framebuffer to the given color value. More...
 
void vdp_clearDepth (float depth)
 Clear depth buffer to the given depth value. More...
 
void vdp_depthWrite (uint8_t enable)
 Set whether depth writes are enabled or disabled. More...
 
void vdp_depthFunc (uint32_t comparison)
 Set the depth test function. More...
 
void vdp_blendEquation (uint32_t mode)
 Set the blend equation mode. More...
 
void vdp_blendFunc (uint32_t srcFactor, uint32_t dstFactor)
 Set the blend equation factors. More...
 
void vdp_setWinding (uint32_t windingOrder)
 Set the winding order of vertices for backface culling. More...
 
void vdp_setCulling (uint8_t enabled)
 Set whether backface culling is enabled or disabled. More...
 
void vdp_drawGeometry (uint32_t topology, uint32_t first, uint32_t count, const vdp_Vertex *vertexData)
 Draw geometry to the screen. More...
 
uint32_t vdp_allocTexture (uint8_t mipmap, uint32_t format, uint32_t width, uint32_t height)
 Allocate a texture. More...
 
void vdp_releaseTexture (uint32_t textureHandle)
 Release previously allocated texture. More...
 
void vdp_setTextureData (uint32_t textureHandle, uint32_t level, const void *data, uint32_t dataLen)
 Upload data to an allocated texture. More...
 
void vdp_copyFbToTexture (vdp_Rect *srcRect, vdp_Rect *dstRect, uint32_t textureHandle)
 Copy a portion of the framebuffer into a texture. More...
 
uint32_t vdp_getUsage ()
 Report total texture memory usage in bytes. More...
 
void vdp_setSampleParams (uint32_t filter, uint32_t wrapU, uint32_t wrapV)
 Set texture sampling params. More...
 
void vdp_bindTexture (uint32_t textureHandle)
 Set texture to use for rendering. More...
 
void vdp_viewport (uint32_t x, uint32_t y, uint32_t width, uint32_t height)
 Set the current viewport rect. More...
 
void vdp_submitDepthQuery (float refVal, uint32_t comparison, uint32_t x, uint32_t y, uint32_t w, uint32_t h)
 Submit a depth query of a portion of the framebuffer, comparing a region of it against a specified value. More...
 
uint32_t vdp_getDepthQueryResult ()
 Get the results of the previously submitted depth query. More...
 
void vdp_setVsyncHandler (const vsync_handler_t handler)
 Set a callback handler for vsync. More...
 

Macro Definition Documentation

◆ VDP_BLEND_DST_ALPHA

#define VDP_BLEND_DST_ALPHA   0x0304

Definition at line 43 of file db_vdp.h.

◆ VDP_BLEND_DST_COLOR

#define VDP_BLEND_DST_COLOR   0x0306

Definition at line 45 of file db_vdp.h.

◆ VDP_BLEND_ONE

#define VDP_BLEND_ONE   1

Definition at line 38 of file db_vdp.h.

◆ VDP_BLEND_ONE_MINUS_DST_ALPHA

#define VDP_BLEND_ONE_MINUS_DST_ALPHA   0x0305

Definition at line 44 of file db_vdp.h.

◆ VDP_BLEND_ONE_MINUS_DST_COLOR

#define VDP_BLEND_ONE_MINUS_DST_COLOR   0x0307

Definition at line 46 of file db_vdp.h.

◆ VDP_BLEND_ONE_MINUS_SRC_ALPHA

#define VDP_BLEND_ONE_MINUS_SRC_ALPHA   0x0303

Definition at line 42 of file db_vdp.h.

◆ VDP_BLEND_ONE_MINUS_SRC_COLOR

#define VDP_BLEND_ONE_MINUS_SRC_COLOR   0x0301

Definition at line 40 of file db_vdp.h.

◆ VDP_BLEND_SRC_ALPHA

#define VDP_BLEND_SRC_ALPHA   0x0302

Definition at line 41 of file db_vdp.h.

◆ VDP_BLEND_SRC_COLOR

#define VDP_BLEND_SRC_COLOR   0x0300

Definition at line 39 of file db_vdp.h.

◆ VDP_BLEND_ZERO

#define VDP_BLEND_ZERO   0

Definition at line 37 of file db_vdp.h.

◆ VDP_COMPARE_ALWAYS

#define VDP_COMPARE_ALWAYS   0x0207

Definition at line 31 of file db_vdp.h.

◆ VDP_COMPARE_EQUAL

#define VDP_COMPARE_EQUAL   0x0202

Definition at line 26 of file db_vdp.h.

◆ VDP_COMPARE_GEQUAL

#define VDP_COMPARE_GEQUAL   0x0206

Definition at line 30 of file db_vdp.h.

◆ VDP_COMPARE_GREATER

#define VDP_COMPARE_GREATER   0x0204

Definition at line 28 of file db_vdp.h.

◆ VDP_COMPARE_LEQUAL

#define VDP_COMPARE_LEQUAL   0x0203

Definition at line 27 of file db_vdp.h.

◆ VDP_COMPARE_LESS

#define VDP_COMPARE_LESS   0x0201

Definition at line 25 of file db_vdp.h.

◆ VDP_COMPARE_NEVER

#define VDP_COMPARE_NEVER   0x0200

Definition at line 24 of file db_vdp.h.

◆ VDP_COMPARE_NOTEQUAL

#define VDP_COMPARE_NOTEQUAL   0x0205

Definition at line 29 of file db_vdp.h.

◆ VDP_FILTER_LINEAR

#define VDP_FILTER_LINEAR   0x2601

Definition at line 18 of file db_vdp.h.

◆ VDP_FILTER_NEAREST

#define VDP_FILTER_NEAREST   0x2600

Definition at line 17 of file db_vdp.h.

◆ VDP_FUNC_ADD

#define VDP_FUNC_ADD   0x8006

Definition at line 33 of file db_vdp.h.

◆ VDP_FUNC_REVERSE_SUBTRACT

#define VDP_FUNC_REVERSE_SUBTRACT   0x800B

Definition at line 35 of file db_vdp.h.

◆ VDP_FUNC_SUBTRACT

#define VDP_FUNC_SUBTRACT   0x800A

Definition at line 34 of file db_vdp.h.

◆ VDP_TEXFMT_DXT1

#define VDP_TEXFMT_DXT1   3

Definition at line 14 of file db_vdp.h.

◆ VDP_TEXFMT_DXT3

#define VDP_TEXFMT_DXT3   4

Definition at line 15 of file db_vdp.h.

◆ VDP_TEXFMT_RGB565

#define VDP_TEXFMT_RGB565   0

Definition at line 11 of file db_vdp.h.

◆ VDP_TEXFMT_RGBA4444

#define VDP_TEXFMT_RGBA4444   1

Definition at line 12 of file db_vdp.h.

◆ VDP_TEXFMT_RGBA8888

#define VDP_TEXFMT_RGBA8888   2

Definition at line 13 of file db_vdp.h.

◆ VDP_TOPOLOGY_LINE_STRIP

#define VDP_TOPOLOGY_LINE_STRIP   0x0001

Definition at line 52 of file db_vdp.h.

◆ VDP_TOPOLOGY_LINES

#define VDP_TOPOLOGY_LINES   0x0000

Definition at line 51 of file db_vdp.h.

◆ VDP_TOPOLOGY_TRIANGLE_STRIP

#define VDP_TOPOLOGY_TRIANGLE_STRIP   0x0003

Definition at line 54 of file db_vdp.h.

◆ VDP_TOPOLOGY_TRIANGLES

#define VDP_TOPOLOGY_TRIANGLES   0x0002

Definition at line 53 of file db_vdp.h.

◆ VDP_WINDING_CCW

#define VDP_WINDING_CCW   0x0901

Definition at line 49 of file db_vdp.h.

◆ VDP_WINDING_CW

#define VDP_WINDING_CW   0x0900

Definition at line 48 of file db_vdp.h.

◆ VDP_WRAP_CLAMP

#define VDP_WRAP_CLAMP   0x812F

Definition at line 21 of file db_vdp.h.

◆ VDP_WRAP_MIRROR

#define VDP_WRAP_MIRROR   0x8370

Definition at line 22 of file db_vdp.h.

◆ VDP_WRAP_REPEAT

#define VDP_WRAP_REPEAT   0x2901

Definition at line 20 of file db_vdp.h.

Typedef Documentation

◆ vsync_handler_t

typedef void(* vsync_handler_t) ()

Callback type for vsync.

Definition at line 91 of file db_vdp.h.

Function Documentation

◆ vdp_allocTexture()

uint32_t vdp_allocTexture ( uint8_t  mipmap,
uint32_t  format,
uint32_t  width,
uint32_t  height 
)

Allocate a texture.

Parameters
mipmap
format
width
height
Returns
A handle to the allocated texture (or -1 if allocation failed)

◆ vdp_bindTexture()

void vdp_bindTexture ( uint32_t  textureHandle)

Set texture to use for rendering.

Parameters
textureHandle

◆ vdp_blendEquation()

void vdp_blendEquation ( uint32_t  mode)

Set the blend equation mode.

Parameters
mode

◆ vdp_blendFunc()

void vdp_blendFunc ( uint32_t  srcFactor,
uint32_t  dstFactor 
)

Set the blend equation factors.

Parameters
srcFactor
dstFactor

◆ vdp_clearColor()

void vdp_clearColor ( const vdp_Color32 color)

Clear framebuffer to the given color value.

Parameters
color

◆ vdp_clearDepth()

void vdp_clearDepth ( float  depth)

Clear depth buffer to the given depth value.

Parameters
depth

◆ vdp_copyFbToTexture()

void vdp_copyFbToTexture ( vdp_Rect srcRect,
vdp_Rect dstRect,
uint32_t  textureHandle 
)

Copy a portion of the framebuffer into a texture.

Parameters
srcRectSource rectangle of the framebuffer to copy
dstRectDestination rectangle of the texture to copy into
textureHandleThe destination texture to copy into

◆ vdp_depthFunc()

void vdp_depthFunc ( uint32_t  comparison)

Set the depth test function.

Parameters
comparison

◆ vdp_depthWrite()

void vdp_depthWrite ( uint8_t  enable)

Set whether depth writes are enabled or disabled.

Parameters
enable

◆ vdp_drawGeometry()

void vdp_drawGeometry ( uint32_t  topology,
uint32_t  first,
uint32_t  count,
const vdp_Vertex vertexData 
)

Draw geometry to the screen.

Parameters
topology
first
count
vertexData

◆ vdp_getDepthQueryResult()

uint32_t vdp_getDepthQueryResult ( )

Get the results of the previously submitted depth query.

Returns
The number of pixels which passed the depth comparison within the region specified

◆ vdp_getUsage()

uint32_t vdp_getUsage ( )

Report total texture memory usage in bytes.

Returns

◆ vdp_releaseTexture()

void vdp_releaseTexture ( uint32_t  textureHandle)

Release previously allocated texture.

Parameters
textureHandle

◆ vdp_setCulling()

void vdp_setCulling ( uint8_t  enabled)

Set whether backface culling is enabled or disabled.

Parameters
enabled

◆ vdp_setSampleParams()

void vdp_setSampleParams ( uint32_t  filter,
uint32_t  wrapU,
uint32_t  wrapV 
)

Set texture sampling params.

Parameters
filter
wrapU
wrapV

◆ vdp_setTextureData()

void vdp_setTextureData ( uint32_t  textureHandle,
uint32_t  level,
const void *  data,
uint32_t  dataLen 
)

Upload data to an allocated texture.

Parameters
textureHandle
level
data
dataLen

◆ vdp_setVsyncHandler()

void vdp_setVsyncHandler ( const vsync_handler_t  handler)

Set a callback handler for vsync.

Parameters
handler

◆ vdp_setWinding()

void vdp_setWinding ( uint32_t  windingOrder)

Set the winding order of vertices for backface culling.

Parameters
windingOrder

◆ vdp_submitDepthQuery()

void vdp_submitDepthQuery ( float  refVal,
uint32_t  comparison,
uint32_t  x,
uint32_t  y,
uint32_t  w,
uint32_t  h 
)

Submit a depth query of a portion of the framebuffer, comparing a region of it against a specified value.

Parameters
refValThe reference value to compare against
comparisonThe comparison to use
xThe x coordinate of the region's top left corner
yThe y coordinate of the region's top left corner
wThe width of the region
hThe height of the region

◆ vdp_viewport()

void vdp_viewport ( uint32_t  x,
uint32_t  y,
uint32_t  width,
uint32_t  height 
)

Set the current viewport rect.

Parameters
x
y
width
height