Dreambox C/C++ SDK v1.0.0
C/C++ SDK for creating Dreambox games
Loading...
Searching...
No Matches
db_vdp.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4#include "db_math.h"
5
6#ifdef __cplusplus
7extern "C"
8{
9#endif
10
11#define VDP_TEXFMT_RGB565 0
12#define VDP_TEXFMT_RGBA4444 1
13#define VDP_TEXFMT_RGBA8888 2
14#define VDP_TEXFMT_DXT1 3
15#define VDP_TEXFMT_DXT3 4
16
17#define VDP_FILTER_NEAREST 0x2600
18#define VDP_FILTER_LINEAR 0x2601
19
20#define VDP_WRAP_REPEAT 0x2901
21#define VDP_WRAP_CLAMP 0x812F
22#define VDP_WRAP_MIRROR 0x8370
23
24#define VDP_COMPARE_NEVER 0x0200
25#define VDP_COMPARE_LESS 0x0201
26#define VDP_COMPARE_EQUAL 0x0202
27#define VDP_COMPARE_LEQUAL 0x0203
28#define VDP_COMPARE_GREATER 0x0204
29#define VDP_COMPARE_NOTEQUAL 0x0205
30#define VDP_COMPARE_GEQUAL 0x0206
31#define VDP_COMPARE_ALWAYS 0x0207
32
33#define VDP_FUNC_ADD 0x8006
34#define VDP_FUNC_SUBTRACT 0x800A
35#define VDP_FUNC_REVERSE_SUBTRACT 0x800B
36
37#define VDP_BLEND_ZERO 0
38#define VDP_BLEND_ONE 1
39#define VDP_BLEND_SRC_COLOR 0x0300
40#define VDP_BLEND_ONE_MINUS_SRC_COLOR 0x0301
41#define VDP_BLEND_SRC_ALPHA 0x0302
42#define VDP_BLEND_ONE_MINUS_SRC_ALPHA 0x0303
43#define VDP_BLEND_DST_ALPHA 0x0304
44#define VDP_BLEND_ONE_MINUS_DST_ALPHA 0x0305
45#define VDP_BLEND_DST_COLOR 0x0306
46#define VDP_BLEND_ONE_MINUS_DST_COLOR 0x0307
47
48#define VDP_WINDING_CW 0x0900
49#define VDP_WINDING_CCW 0x0901
50
51#define VDP_TOPOLOGY_LINES 0x0000
52#define VDP_TOPOLOGY_LINE_STRIP 0x0001
53#define VDP_TOPOLOGY_TRIANGLES 0x0002
54#define VDP_TOPOLOGY_TRIANGLE_STRIP 0x0003
55
57typedef struct
58{
59 uint32_t x;
60 uint32_t y;
61 uint32_t w;
62 uint32_t h;
63} vdp_Rect;
64
66typedef struct
67{
68 uint8_t r;
69 uint8_t g;
70 uint8_t b;
71 uint8_t a;
73
75typedef struct
76{
79
82
85
89
91typedef void (*vsync_handler_t)();
92
95extern void vdp_clearColor(const vdp_Color32 *color);
96
99extern void vdp_clearDepth(float depth);
100
103extern void vdp_depthWrite(uint8_t enable);
104
107extern void vdp_depthFunc(uint32_t comparison);
108
111extern void vdp_blendEquation(uint32_t mode);
112
116extern void vdp_blendFunc(uint32_t srcFactor, uint32_t dstFactor);
117
120extern void vdp_setWinding(uint32_t windingOrder);
121
124extern void vdp_setCulling(uint8_t enabled);
125
131extern void vdp_drawGeometry(uint32_t topology, uint32_t first, uint32_t count, const vdp_Vertex *vertexData);
132
139extern uint32_t vdp_allocTexture(uint8_t mipmap, uint32_t format, uint32_t width, uint32_t height);
140
143extern void vdp_releaseTexture(uint32_t textureHandle);
144
150extern void vdp_setTextureData(uint32_t textureHandle, uint32_t level, const void *data, uint32_t dataLen);
151
156extern void vdp_copyFbToTexture(vdp_Rect *srcRect, vdp_Rect *dstRect, uint32_t textureHandle);
157
160extern uint32_t vdp_getUsage();
161
166extern void vdp_setSampleParams(uint32_t filter, uint32_t wrapU, uint32_t wrapV);
167
170extern void vdp_bindTexture(uint32_t textureHandle);
171
177extern void vdp_viewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height);
178
186extern void vdp_submitDepthQuery(float refVal, uint32_t comparison, uint32_t x, uint32_t y, uint32_t w, uint32_t h);
187
190extern uint32_t vdp_getDepthQueryResult();
191
194extern void vdp_setVsyncHandler(const vsync_handler_t handler);
195
196#ifdef __cplusplus
197}
198#endif
void vdp_viewport(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
Set the current viewport rect.
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 va...
void vdp_copyFbToTexture(vdp_Rect *srcRect, vdp_Rect *dstRect, uint32_t textureHandle)
Copy a portion of the framebuffer into a texture.
void vdp_depthWrite(uint8_t enable)
Set whether depth writes are enabled or disabled.
void vdp_depthFunc(uint32_t comparison)
Set the depth test function.
void vdp_clearDepth(float depth)
Clear depth buffer to the given depth value.
uint32_t vdp_getDepthQueryResult()
Get the results of the previously submitted depth query.
void vdp_blendFunc(uint32_t srcFactor, uint32_t dstFactor)
Set the blend equation factors.
void vdp_setWinding(uint32_t windingOrder)
Set the winding order of vertices for backface culling.
void vdp_setVsyncHandler(const vsync_handler_t handler)
Set a callback handler for vsync.
void vdp_releaseTexture(uint32_t textureHandle)
Release previously allocated texture.
void vdp_clearColor(const vdp_Color32 *color)
Clear framebuffer to the given color value.
uint32_t vdp_getUsage()
Report total texture memory usage in bytes.
void vdp_setSampleParams(uint32_t filter, uint32_t wrapU, uint32_t wrapV)
Set texture sampling params.
void vdp_blendEquation(uint32_t mode)
Set the blend equation mode.
void vdp_setTextureData(uint32_t textureHandle, uint32_t level, const void *data, uint32_t dataLen)
Upload data to an allocated texture.
void vdp_drawGeometry(uint32_t topology, uint32_t first, uint32_t count, const vdp_Vertex *vertexData)
Draw geometry to the screen.
void vdp_bindTexture(uint32_t textureHandle)
Set texture to use for rendering.
uint32_t vdp_allocTexture(uint8_t mipmap, uint32_t format, uint32_t width, uint32_t height)
Allocate a texture.
void(* vsync_handler_t)()
Callback type for vsync.
Definition: db_vdp.h:91
void vdp_setCulling(uint8_t enabled)
Set whether backface culling is enabled or disabled.
A four-component vector.
Definition: db_math.h:43
A 32-bit color.
Definition: db_vdp.h:67
uint8_t g
Definition: db_vdp.h:69
uint8_t b
Definition: db_vdp.h:70
uint8_t r
Definition: db_vdp.h:68
uint8_t a
Definition: db_vdp.h:71
An axis-aligned rectangle.
Definition: db_vdp.h:58
uint32_t h
Definition: db_vdp.h:62
uint32_t y
Definition: db_vdp.h:60
uint32_t x
Definition: db_vdp.h:59
uint32_t w
Definition: db_vdp.h:61
A vertex which can be passed to vdp_drawGeometry.
Definition: db_vdp.h:76
Vec4 texcoord
The texture coordinate used to sample the currently bound texture.
Definition: db_vdp.h:87
Vec4 ocolor
The vertex offset color (added to color * texture)
Definition: db_vdp.h:84
Vec4 color
The vertex color (multiplied with currently bound texture)
Definition: db_vdp.h:81
Vec4 position
The position of the vertex.
Definition: db_vdp.h:78