7 #define DPSOFTRAST_MAXMIPMAPS 16
8 #define DPSOFTRAST_TEXTURE_MAXSIZE (1<<(DPSOFTRAST_MAXMIPMAPS - 1))
9 #define DPSOFTRAST_MAXTEXTUREUNITS 16
10 #define DPSOFTRAST_MAXTEXCOORDARRAYS 8
12 // type of pixels in texture (some of these are converted to BGRA8 on update)
13 #define DPSOFTRAST_TEXTURE_FORMAT_BGRA8 0
14 #define DPSOFTRAST_TEXTURE_FORMAT_DEPTH 1
15 #define DPSOFTRAST_TEXTURE_FORMAT_RGBA8 2
16 #define DPSOFTRAST_TEXTURE_FORMAT_ALPHA8 3
17 #define DPSOFTRAST_TEXTURE_FORMAT_COMPAREMASK 3
19 // modifier flags for texture (can not be changed after creation)
20 #define DPSOFTRAST_TEXTURE_FLAG_MIPMAP 4
21 #define DPSOFTRAST_TEXTURE_FLAG_CUBEMAP 8
22 #define DPSOFTRAST_TEXTURE_FLAG_USEALPHA 16
23 #define DPSOFTRAST_TEXTURE_FLAG_CLAMPTOEDGE 32
25 typedef enum DPSOFTRAST_TEXTURE_FILTER_e
27 DPSOFTRAST_TEXTURE_FILTER_NEAREST = 0,
28 DPSOFTRAST_TEXTURE_FILTER_LINEAR = 1,
29 DPSOFTRAST_TEXTURE_FILTER_NEAREST_MIPMAP_TRIANGLE = 2,
30 DPSOFTRAST_TEXTURE_FILTER_LINEAR_MIPMAP_TRIANGLE = 3,
32 DPSOFTRAST_TEXTURE_FILTER;
34 void DPSOFTRAST_Init(int width, int height, int numthreads, int interlace, unsigned int *colorpixels, unsigned int *depthpixels);
35 void DPSOFTRAST_Shutdown(void);
36 void DPSOFTRAST_Flush(void);
37 void DPSOFTRAST_Finish(void);
39 int DPSOFTRAST_Texture_New(int flags, int width, int height, int depth);
40 void DPSOFTRAST_Texture_Free(int index);
41 void DPSOFTRAST_Texture_UpdatePartial(int index, int mip, const unsigned char *pixels, int blockx, int blocky, int blockwidth, int blockheight);
42 void DPSOFTRAST_Texture_UpdateFull(int index, const unsigned char *pixels);
43 int DPSOFTRAST_Texture_GetWidth(int index, int mip);
44 int DPSOFTRAST_Texture_GetHeight(int index, int mip);
45 int DPSOFTRAST_Texture_GetDepth(int index, int mip);
46 unsigned char *DPSOFTRAST_Texture_GetPixelPointer(int index, int mip);
47 void DPSOFTRAST_Texture_Filter(int index, DPSOFTRAST_TEXTURE_FILTER filter);
49 void DPSOFTRAST_SetRenderTargets(int width, int height, unsigned int *depthpixels, unsigned int *colorpixels0, unsigned int *colorpixels1, unsigned int *colorpixels2, unsigned int *colorpixels3);
50 void DPSOFTRAST_Viewport(int x, int y, int width, int height);
51 void DPSOFTRAST_ClearColor(float r, float g, float b, float a);
52 void DPSOFTRAST_ClearDepth(float d);
53 void DPSOFTRAST_ColorMask(int r, int g, int b, int a);
54 void DPSOFTRAST_DepthTest(int enable);
55 void DPSOFTRAST_ScissorTest(int enable);
56 void DPSOFTRAST_Scissor(float x, float y, float width, float height);
58 void DPSOFTRAST_BlendFunc(int smodulate, int dmodulate);
59 void DPSOFTRAST_BlendSubtract(int enable);
60 void DPSOFTRAST_DepthMask(int enable);
61 void DPSOFTRAST_DepthFunc(int comparemode);
62 void DPSOFTRAST_DepthRange(float range0, float range1);
63 void DPSOFTRAST_PolygonOffset(float alongnormal, float intoview);
64 void DPSOFTRAST_CullFace(int mode);
65 void DPSOFTRAST_AlphaTest(int enable);
66 void DPSOFTRAST_AlphaFunc(int alphafunc, float alphavalue);
67 void DPSOFTRAST_Color4f(float r, float g, float b, float a);
68 void DPSOFTRAST_GetPixelsBGRA(int blockx, int blocky, int blockwidth, int blockheight, unsigned char *outpixels);
69 void DPSOFTRAST_CopyRectangleToTexture(int index, int mip, int tx, int ty, int sx, int sy, int width, int height);
70 void DPSOFTRAST_SetTexture(int unitnum, int index);
72 void DPSOFTRAST_SetVertexPointer(const float *vertex3f, size_t stride);
73 void DPSOFTRAST_SetColorPointer(const float *color4f, size_t stride);
74 void DPSOFTRAST_SetColorPointer4ub(const unsigned char *color4ub, size_t stride);
75 void DPSOFTRAST_SetTexCoordPointer(int unitnum, int numcomponents, size_t stride, const float *texcoordf);
77 typedef enum gl20_texunit_e
79 // postprocess shaders, and generic shaders:
82 GL20TU_GAMMARAMPS = 2,
83 // standard material properties
88 // material properties for a second material
89 GL20TU_SECONDARY_NORMAL = 4,
90 GL20TU_SECONDARY_COLOR = 5,
91 GL20TU_SECONDARY_GLOSS = 6,
92 GL20TU_SECONDARY_GLOW = 7,
93 // material properties for a colormapped material
94 // conflicts with secondary material
97 // fog fade in the distance
99 // compiled ambient lightmap and deluxemap
101 GL20TU_DELUXEMAP = 10,
102 // refraction, used by water shaders
103 GL20TU_REFRACTION = 3,
104 // reflection, used by water shaders, also with normal material rendering
105 // conflicts with secondary material
106 GL20TU_REFLECTION = 7,
107 // rtlight attenuation (distance fade) and cubemap filter (projection texturing)
108 // conflicts with lightmap/deluxemap
109 GL20TU_ATTENUATION = 9,
111 GL20TU_SHADOWMAP2D = 15,
112 GL20TU_CUBEPROJECTION = 12,
113 // rtlight prepass data (screenspace depth and normalmap)
114 GL20TU_SCREENDEPTH = 13,
115 GL20TU_SCREENNORMALMAP = 14,
116 // lightmap prepass data (screenspace diffuse and specular from lights)
117 GL20TU_SCREENDIFFUSE = 11,
118 GL20TU_SCREENSPECULAR = 12,
120 GL20TU_REFLECTMASK = 5,
121 GL20TU_REFLECTCUBE = 6,
122 GL20TU_FOGHEIGHTTEXTURE = 14
126 // this enum selects which of the glslshadermodeinfo entries should be used
127 typedef enum shadermode_e
129 SHADERMODE_GENERIC, ///< (particles/HUD/etc) vertex color, optionally multiplied by one texture
130 SHADERMODE_POSTPROCESS, ///< postprocessing shader (r_glsl_postprocess)
131 SHADERMODE_DEPTH_OR_SHADOW, ///< (depthfirst/shadows) vertex shader only
132 SHADERMODE_FLATCOLOR, ///< (lightmap) modulate texture by uniform color (q1bsp, q3bsp)
133 SHADERMODE_VERTEXCOLOR, ///< (lightmap) modulate texture by vertex colors (q3bsp)
134 SHADERMODE_LIGHTMAP, ///< (lightmap) modulate texture by lightmap texture (q1bsp, q3bsp)
135 SHADERMODE_FAKELIGHT, ///< (fakelight) modulate texture by "fake" lighting (no lightmaps, no nothing)
136 SHADERMODE_LIGHTDIRECTIONMAP_MODELSPACE, ///< (lightmap) use directional pixel shading from texture containing modelspace light directions (q3bsp deluxemap)
137 SHADERMODE_LIGHTDIRECTIONMAP_TANGENTSPACE, ///< (lightmap) use directional pixel shading from texture containing tangentspace light directions (q1bsp deluxemap)
138 SHADERMODE_LIGHTDIRECTION, ///< (lightmap) use directional pixel shading from fixed light direction (q3bsp)
139 SHADERMODE_LIGHTSOURCE, ///< (lightsource) use directional pixel shading from light source (rtlight)
140 SHADERMODE_REFRACTION, ///< refract background (the material is rendered normally after this pass)
141 SHADERMODE_WATER, ///< refract background and reflection (the material is rendered normally after this pass)
142 SHADERMODE_SHOWDEPTH, ///< (debugging) renders depth as color
143 SHADERMODE_DEFERREDGEOMETRY, ///< (deferred) render material properties to screenspace geometry buffers
144 SHADERMODE_DEFERREDLIGHTSOURCE, ///< (deferred) use directional pixel shading from light source (rtlight) on screenspace geometry buffers
149 typedef enum shaderpermutation_e
151 SHADERPERMUTATION_DIFFUSE = 1<<0, ///< (lightsource) whether to use directional shading
152 SHADERPERMUTATION_VERTEXTEXTUREBLEND = 1<<1, ///< indicates this is a two-layer material blend based on vertex alpha (q3bsp)
153 SHADERPERMUTATION_VIEWTINT = 1<<2, ///< view tint (postprocessing only), use vertex colors (generic only)
154 SHADERPERMUTATION_COLORMAPPING = 1<<3, ///< indicates this is a colormapped skin
155 SHADERPERMUTATION_SATURATION = 1<<4, ///< saturation (postprocessing only)
156 SHADERPERMUTATION_FOGINSIDE = 1<<5, ///< tint the color by fog color or black if using additive blend mode
157 SHADERPERMUTATION_FOGOUTSIDE = 1<<6, ///< tint the color by fog color or black if using additive blend mode
158 SHADERPERMUTATION_FOGHEIGHTTEXTURE = 1<<7, ///< fog color and density determined by texture mapped on vertical axis
159 SHADERPERMUTATION_GAMMARAMPS = 1<<8, ///< gamma (postprocessing only)
160 SHADERPERMUTATION_CUBEFILTER = 1<<9, ///< (lightsource) use cubemap light filter
161 SHADERPERMUTATION_GLOW = 1<<10, ///< (lightmap) blend in an additive glow texture
162 SHADERPERMUTATION_BLOOM = 1<<11, ///< bloom (postprocessing only)
163 SHADERPERMUTATION_SPECULAR = 1<<12, ///< (lightsource or deluxemapping) render specular effects
164 SHADERPERMUTATION_POSTPROCESSING = 1<<13, ///< user defined postprocessing (postprocessing only)
165 SHADERPERMUTATION_REFLECTION = 1<<14, ///< normalmap-perturbed reflection of the scene infront of the surface, preformed as an overlay on the surface
166 SHADERPERMUTATION_OFFSETMAPPING = 1<<15, ///< adjust texcoords to roughly simulate a displacement mapped surface
167 SHADERPERMUTATION_OFFSETMAPPING_RELIEFMAPPING = 1<<16, ///< adjust texcoords to accurately simulate a displacement mapped surface (requires OFFSETMAPPING to also be set!)
168 SHADERPERMUTATION_SHADOWMAP2D = 1<<17, ///< (lightsource) use shadowmap texture as light filter
169 SHADERPERMUTATION_SHADOWMAPPCF = 1<<18, ///< (lightsource) use percentage closer filtering on shadowmap test results
170 SHADERPERMUTATION_SHADOWMAPPCF2 = 1<<19, ///< (lightsource) use higher quality percentage closer filtering on shadowmap test results
171 SHADERPERMUTATION_SHADOWSAMPLER = 1<<20, ///< (lightsource) use hardware shadowmap test
172 SHADERPERMUTATION_SHADOWMAPVSDCT = 1<<21, ///< (lightsource) use virtual shadow depth cube texture for shadowmap indexing
173 SHADERPERMUTATION_SHADOWMAPORTHO = 1<<22, //< (lightsource) use orthographic shadowmap projection
174 SHADERPERMUTATION_DEFERREDLIGHTMAP = 1<<23, ///< (lightmap) read Texture_ScreenDiffuse/Specular textures and add them on top of lightmapping
175 SHADERPERMUTATION_ALPHAKILL = 1<<24, ///< (deferredgeometry) discard pixel if diffuse texture alpha below 0.5
176 SHADERPERMUTATION_REFLECTCUBE = 1<<25, ///< fake reflections using global cubemap (not HDRI light probe)
177 SHADERPERMUTATION_NORMALMAPSCROLLBLEND = 1<<26, // (water) counter-direction normalmaps scrolling
178 SHADERPERMUTATION_LIMIT = 1<<27, ///< size of permutations array
179 SHADERPERMUTATION_COUNT = 27 ///< size of shaderpermutationinfo array
183 typedef enum DPSOFTRAST_UNIFORM_e
185 DPSOFTRAST_UNIFORM_Texture_First,
186 DPSOFTRAST_UNIFORM_Texture_Second,
187 DPSOFTRAST_UNIFORM_Texture_GammaRamps,
188 DPSOFTRAST_UNIFORM_Texture_Normal,
189 DPSOFTRAST_UNIFORM_Texture_Color,
190 DPSOFTRAST_UNIFORM_Texture_Gloss,
191 DPSOFTRAST_UNIFORM_Texture_Glow,
192 DPSOFTRAST_UNIFORM_Texture_SecondaryNormal,
193 DPSOFTRAST_UNIFORM_Texture_SecondaryColor,
194 DPSOFTRAST_UNIFORM_Texture_SecondaryGloss,
195 DPSOFTRAST_UNIFORM_Texture_SecondaryGlow,
196 DPSOFTRAST_UNIFORM_Texture_Pants,
197 DPSOFTRAST_UNIFORM_Texture_Shirt,
198 DPSOFTRAST_UNIFORM_Texture_FogHeightTexture,
199 DPSOFTRAST_UNIFORM_Texture_FogMask,
200 DPSOFTRAST_UNIFORM_Texture_Lightmap,
201 DPSOFTRAST_UNIFORM_Texture_Deluxemap,
202 DPSOFTRAST_UNIFORM_Texture_Attenuation,
203 DPSOFTRAST_UNIFORM_Texture_Cube,
204 DPSOFTRAST_UNIFORM_Texture_Refraction,
205 DPSOFTRAST_UNIFORM_Texture_Reflection,
206 DPSOFTRAST_UNIFORM_Texture_ShadowMap2D,
207 DPSOFTRAST_UNIFORM_Texture_CubeProjection,
208 DPSOFTRAST_UNIFORM_Texture_ScreenDepth,
209 DPSOFTRAST_UNIFORM_Texture_ScreenNormalMap,
210 DPSOFTRAST_UNIFORM_Texture_ScreenDiffuse,
211 DPSOFTRAST_UNIFORM_Texture_ScreenSpecular,
212 DPSOFTRAST_UNIFORM_Texture_ReflectMask,
213 DPSOFTRAST_UNIFORM_Texture_ReflectCube,
214 DPSOFTRAST_UNIFORM_Alpha,
215 DPSOFTRAST_UNIFORM_BloomBlur_Parameters,
216 DPSOFTRAST_UNIFORM_ClientTime,
217 DPSOFTRAST_UNIFORM_Color_Ambient,
218 DPSOFTRAST_UNIFORM_Color_Diffuse,
219 DPSOFTRAST_UNIFORM_Color_Specular,
220 DPSOFTRAST_UNIFORM_Color_Glow,
221 DPSOFTRAST_UNIFORM_Color_Pants,
222 DPSOFTRAST_UNIFORM_Color_Shirt,
223 DPSOFTRAST_UNIFORM_DeferredColor_Ambient,
224 DPSOFTRAST_UNIFORM_DeferredColor_Diffuse,
225 DPSOFTRAST_UNIFORM_DeferredColor_Specular,
226 DPSOFTRAST_UNIFORM_DeferredMod_Diffuse,
227 DPSOFTRAST_UNIFORM_DeferredMod_Specular,
228 DPSOFTRAST_UNIFORM_DistortScaleRefractReflect,
229 DPSOFTRAST_UNIFORM_EyePosition,
230 DPSOFTRAST_UNIFORM_FogColor,
231 DPSOFTRAST_UNIFORM_FogHeightFade,
232 DPSOFTRAST_UNIFORM_FogPlane,
233 DPSOFTRAST_UNIFORM_FogPlaneViewDist,
234 DPSOFTRAST_UNIFORM_FogRangeRecip,
235 DPSOFTRAST_UNIFORM_LightColor,
236 DPSOFTRAST_UNIFORM_LightDir,
237 DPSOFTRAST_UNIFORM_LightPosition,
238 DPSOFTRAST_UNIFORM_OffsetMapping_Scale,
239 DPSOFTRAST_UNIFORM_PixelSize,
240 DPSOFTRAST_UNIFORM_ReflectColor,
241 DPSOFTRAST_UNIFORM_ReflectFactor,
242 DPSOFTRAST_UNIFORM_ReflectOffset,
243 DPSOFTRAST_UNIFORM_RefractColor,
244 DPSOFTRAST_UNIFORM_Saturation,
245 DPSOFTRAST_UNIFORM_ScreenCenterRefractReflect,
246 DPSOFTRAST_UNIFORM_ScreenScaleRefractReflect,
247 DPSOFTRAST_UNIFORM_ScreenToDepth,
248 DPSOFTRAST_UNIFORM_ShadowMap_Parameters,
249 DPSOFTRAST_UNIFORM_ShadowMap_TextureScale,
250 DPSOFTRAST_UNIFORM_SpecularPower,
251 DPSOFTRAST_UNIFORM_UserVec1,
252 DPSOFTRAST_UNIFORM_UserVec2,
253 DPSOFTRAST_UNIFORM_UserVec3,
254 DPSOFTRAST_UNIFORM_UserVec4,
255 DPSOFTRAST_UNIFORM_ViewTintColor,
256 DPSOFTRAST_UNIFORM_ViewToLightM1,
257 DPSOFTRAST_UNIFORM_ViewToLightM2,
258 DPSOFTRAST_UNIFORM_ViewToLightM3,
259 DPSOFTRAST_UNIFORM_ViewToLightM4,
260 DPSOFTRAST_UNIFORM_ModelToLightM1,
261 DPSOFTRAST_UNIFORM_ModelToLightM2,
262 DPSOFTRAST_UNIFORM_ModelToLightM3,
263 DPSOFTRAST_UNIFORM_ModelToLightM4,
264 DPSOFTRAST_UNIFORM_TexMatrixM1,
265 DPSOFTRAST_UNIFORM_TexMatrixM2,
266 DPSOFTRAST_UNIFORM_TexMatrixM3,
267 DPSOFTRAST_UNIFORM_TexMatrixM4,
268 DPSOFTRAST_UNIFORM_BackgroundTexMatrixM1,
269 DPSOFTRAST_UNIFORM_BackgroundTexMatrixM2,
270 DPSOFTRAST_UNIFORM_BackgroundTexMatrixM3,
271 DPSOFTRAST_UNIFORM_BackgroundTexMatrixM4,
272 DPSOFTRAST_UNIFORM_ModelViewProjectionMatrixM1,
273 DPSOFTRAST_UNIFORM_ModelViewProjectionMatrixM2,
274 DPSOFTRAST_UNIFORM_ModelViewProjectionMatrixM3,
275 DPSOFTRAST_UNIFORM_ModelViewProjectionMatrixM4,
276 DPSOFTRAST_UNIFORM_ModelViewMatrixM1,
277 DPSOFTRAST_UNIFORM_ModelViewMatrixM2,
278 DPSOFTRAST_UNIFORM_ModelViewMatrixM3,
279 DPSOFTRAST_UNIFORM_ModelViewMatrixM4,
280 DPSOFTRAST_UNIFORM_PixelToScreenTexCoord,
281 DPSOFTRAST_UNIFORM_ModelToReflectCubeM1,
282 DPSOFTRAST_UNIFORM_ModelToReflectCubeM2,
283 DPSOFTRAST_UNIFORM_ModelToReflectCubeM3,
284 DPSOFTRAST_UNIFORM_ModelToReflectCubeM4,
285 DPSOFTRAST_UNIFORM_ShadowMapMatrixM1,
286 DPSOFTRAST_UNIFORM_ShadowMapMatrixM2,
287 DPSOFTRAST_UNIFORM_ShadowMapMatrixM3,
288 DPSOFTRAST_UNIFORM_ShadowMapMatrixM4,
289 DPSOFTRAST_UNIFORM_BloomColorSubtract,
290 DPSOFTRAST_UNIFORM_NormalmapScrollBlend,
291 DPSOFTRAST_UNIFORM_TOTAL
295 void DPSOFTRAST_SetShader(int mode, int permutation);
296 #define DPSOFTRAST_Uniform1f(index, v0) DPSOFTRAST_Uniform4f(index, v0, 0, 0, 0)
297 #define DPSOFTRAST_Uniform2f(index, v0, v1) DPSOFTRAST_Uniform4f(index, v0, v1, 0, 0)
298 #define DPSOFTRAST_Uniform3f(index, v0, v1, v2) DPSOFTRAST_Uniform4f(index, v0, v1, v2, 0)
299 void DPSOFTRAST_Uniform4f(DPSOFTRAST_UNIFORM index, float v0, float v1, float v2, float v3);
300 void DPSOFTRAST_Uniform4fv(DPSOFTRAST_UNIFORM index, const float *v);
301 void DPSOFTRAST_UniformMatrix4fv(DPSOFTRAST_UNIFORM index, int arraysize, int transpose, const float *v);
302 void DPSOFTRAST_Uniform1i(DPSOFTRAST_UNIFORM index, int i0);
304 void DPSOFTRAST_DrawTriangles(int firstvertex, int numvertices, int numtriangles, const int *element3i, const unsigned short *element3s);
306 #endif // DPSOFTRAST_H