| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * $Logfile: /DescentIII/Main/lib/renderer.h $ |
| 21 | * $Revision: 80 $ |
| 22 | * $Date: 4/19/00 5:22p $ |
| 23 | * $Author: Matt $ |
| 24 | * |
| 25 | * Header for renderer library |
| 26 | * |
| 27 | * $Log: /DescentIII/Main/lib/renderer.h $ |
| 28 | * |
| 29 | * 80 4/19/00 5:22p Matt |
| 30 | * From Duane for 1.4 |
| 31 | * Added extern |
| 32 | * |
| 33 | * 79 10/21/99 1:43p Kevin |
| 34 | * Mac Merge |
| 35 | * |
| 36 | * 78 9/18/99 9:22p Jeff |
| 37 | * Get/Set Alpha factor functions |
| 38 | * |
| 39 | * 77 8/10/99 10:51p Duane |
| 40 | * Added UseMipmap global |
| 41 | * |
| 42 | * 76 7/22/99 8:37p Jeff |
| 43 | * added texture upload to renderstats |
| 44 | * |
| 45 | * 75 7/15/99 6:38p Jeff |
| 46 | * created function to get rendering stats |
| 47 | * |
| 48 | * 74 4/01/99 10:56a Jason |
| 49 | * added better support for movie rendering |
| 50 | * |
| 51 | * 73 3/31/99 3:48p Jason |
| 52 | * changes for cinematics |
| 53 | * |
| 54 | * 72 3/29/99 7:29p Jason |
| 55 | * made renderer handle default resolution more gracefully |
| 56 | * |
| 57 | * 71 3/24/99 11:55a Jason |
| 58 | * added S3 texture compression |
| 59 | * |
| 60 | * 70 3/22/99 5:51p Jason |
| 61 | * enhancements to mirrors |
| 62 | * |
| 63 | * 69 1/29/99 6:29p Jason |
| 64 | * first pass at adding bumpmaps |
| 65 | * |
| 66 | * 68 1/22/99 1:09a Jason |
| 67 | * added vid mem checking |
| 68 | * |
| 69 | * 67 1/18/99 10:45a Samir |
| 70 | * added function to get DirectDraw object from Win32 apps. |
| 71 | * |
| 72 | * 66 12/23/98 5:35p Jason |
| 73 | * added saturated lightmap blending |
| 74 | * |
| 75 | * 65 12/18/98 5:25p Jason |
| 76 | * added specularity to mine walls |
| 77 | * |
| 78 | * 64 12/09/98 5:28p Jason |
| 79 | * added more options |
| 80 | * |
| 81 | * 63 12/08/98 2:29p Jason |
| 82 | * fog rendering changes for patch |
| 83 | * |
| 84 | * 62 10/21/98 9:28p Jason |
| 85 | * Made no lightmaps work globally |
| 86 | * |
| 87 | * 61 10/21/98 12:05p Jason |
| 88 | * changes for data paging |
| 89 | * |
| 90 | * 60 10/17/98 3:10p Jason |
| 91 | * added Set/Get error message stuff |
| 92 | * |
| 93 | * 59 10/08/98 3:36p Jason |
| 94 | * fixes for the demo |
| 95 | * |
| 96 | * 58 9/25/98 1:17a Jason |
| 97 | * added rend_SetCoplanarPolygonOffset functions |
| 98 | * |
| 99 | * 57 9/18/98 1:28p Jason |
| 100 | * cleaned up renderer initting |
| 101 | * |
| 102 | * 56 9/11/98 4:03p Jason |
| 103 | * added better multitexture support |
| 104 | * |
| 105 | * 55 6/11/98 3:38p Jason |
| 106 | * added a general StateLimit render boolean for APIs that are state |
| 107 | * limited (like OpenGL or D3D) |
| 108 | * |
| 109 | * 54 6/09/98 4:47p Jason |
| 110 | * added windowed openGL mode |
| 111 | * |
| 112 | * 53 5/26/98 3:59p Jason |
| 113 | * added LIGHTMAP_BLEND_CONSTANT alpha type |
| 114 | * |
| 115 | * 52 5/20/98 5:44p Jason |
| 116 | * incremental checkin for bumpmapping |
| 117 | * |
| 118 | * 51 5/19/98 12:27p Jason |
| 119 | * cleaned up some 3d stuff |
| 120 | * |
| 121 | * 50 5/06/98 1:39p Jason |
| 122 | * added rend_SetResolution |
| 123 | * |
| 124 | * 49 5/06/98 10:51a Jeff |
| 125 | * put rend_DrawScaledChunkBitmap back in the header |
| 126 | * |
| 127 | * 48 5/05/98 3:02p Jason |
| 128 | * attempting to add different screen resolutions |
| 129 | * |
| 130 | * 46 4/23/98 6:38p Jason |
| 131 | * made bitmaps use 1555 format |
| 132 | * |
| 133 | * 45 4/17/98 4:27p Jason |
| 134 | * added alpha per vertex stuff to drawscaledbitmap |
| 135 | * |
| 136 | * 44 4/08/98 12:27p Jason |
| 137 | * added rend_drawsimplebitmap |
| 138 | * |
| 139 | * 43 4/01/98 12:02p Jason |
| 140 | * incremental checkin for rendering changes |
| 141 | * |
| 142 | * 42 3/13/98 1:22p Jason |
| 143 | * Moved UseHardware flag to the renderer lib where it belongs |
| 144 | * |
| 145 | * 41 3/03/98 6:50p Jason |
| 146 | * added gamma stuff in preferred state |
| 147 | * |
| 148 | * 40 3/02/98 5:53p Jason |
| 149 | * added gamma functionality |
| 150 | * |
| 151 | * 39 2/14/98 10:48p Jason |
| 152 | * got preferred rendering working |
| 153 | * |
| 154 | * 38 2/12/98 1:32p Jason |
| 155 | * got mipmapping working |
| 156 | * |
| 157 | * 37 2/05/98 6:53p Jason |
| 158 | * added new weapon slot |
| 159 | * |
| 160 | * 36 2/03/98 3:16p Jason |
| 161 | * added the ability to specify saturation textures for models |
| 162 | * |
| 163 | * 35 1/28/98 5:37p Jason |
| 164 | * added streamer weapons |
| 165 | * |
| 166 | * 34 1/19/98 2:32p Jason |
| 167 | * added the ability to set clear flags on rend_StartFrame |
| 168 | * |
| 169 | * 33 1/16/98 11:54a Samir |
| 170 | * Added support for rendering chunked bitmaps. |
| 171 | * |
| 172 | * 32 1/15/98 6:32p Jason |
| 173 | * added v wrapping for sky textures |
| 174 | * |
| 175 | * 31 12/22/97 7:23p Samir |
| 176 | * took out transparent colors again. |
| 177 | * |
| 178 | * 30 12/22/97 7:15p Samir |
| 179 | * removed references of ddgr and gr.h. replace with grdefs.h |
| 180 | * |
| 181 | * 29 12/19/97 5:22p Samir |
| 182 | * Added more drawing primatives for software. |
| 183 | * |
| 184 | * 28 12/19/97 2:18p Jason |
| 185 | * fixed some more 2d/3d integration |
| 186 | * |
| 187 | * 27 12/19/97 12:20p Jason |
| 188 | * changes for better 2d/3d system integration |
| 189 | * |
| 190 | * 26 11/25/97 12:33p Jason |
| 191 | * added antialiasing mode |
| 192 | * |
| 193 | * 25 11/19/97 5:25p Jason |
| 194 | * added new alpha mode - AT_FLAT_BLEND |
| 195 | * |
| 196 | * 24 11/13/97 4:06p Jason |
| 197 | * added rend_DrawLFBBitmap |
| 198 | * |
| 199 | * 23 11/13/97 3:52p Jason |
| 200 | * added lfb stuff for renderer |
| 201 | * |
| 202 | * 22 10/29/97 12:36p Jason |
| 203 | * remove byte/bool conflicts in the renderer lib |
| 204 | * |
| 205 | * 21 10/24/97 4:39p Jason |
| 206 | * added support to not write into the zbuffer |
| 207 | * |
| 208 | * 20 10/24/97 2:29p Jason |
| 209 | * added alpha saturation type |
| 210 | * |
| 211 | * 19 10/22/97 4:19p Jason |
| 212 | * added smoke trail effects |
| 213 | * |
| 214 | * 18 10/15/97 5:20p Jason |
| 215 | * did a HUGE overhaul of the bitmap system |
| 216 | * |
| 217 | * 17 10/13/97 3:56p Jason |
| 218 | * made a better 3d bitmap system |
| 219 | * |
| 220 | * 16 9/16/97 4:09p Jason |
| 221 | * implemented software zbuffer |
| 222 | * |
| 223 | * 15 9/09/97 12:09p Jason |
| 224 | * took transparency out of texture_types |
| 225 | * |
| 226 | * 14 9/09/97 11:44a Jason |
| 227 | * changed the way alpha works with the renderer |
| 228 | * |
| 229 | * 13 9/04/97 5:52p Matt |
| 230 | * Took out include of 3d.h |
| 231 | * |
| 232 | * 12 8/29/97 11:59a Jason |
| 233 | * implemented screenshot functions |
| 234 | * |
| 235 | * 11 8/24/97 2:45p Jason |
| 236 | * implemented texture wrapping |
| 237 | * |
| 238 | * 10 8/07/97 11:46a Jason |
| 239 | * implemented tmap overlay system |
| 240 | * |
| 241 | * 9 8/06/97 11:43a Jason |
| 242 | * made lightmaps work correctly in the terrain |
| 243 | * |
| 244 | * 8 8/04/97 6:46p Jason |
| 245 | * added code for a lightmap system |
| 246 | * |
| 247 | * 7 8/04/97 3:28p Jason |
| 248 | * added alpha blending per texture |
| 249 | * |
| 250 | * 6 7/20/97 7:36p Jason |
| 251 | * added support for colored fog |
| 252 | * |
| 253 | * 2 6/24/97 7:45p Matt |
| 254 | * Removed include of manage.h |
| 255 | * |
| 256 | * 1 6/23/97 9:25p Samir |
| 257 | * added because source safe sucks |
| 258 | * |
| 259 | * 11 6/16/97 5:02p Jason |
| 260 | * added flip function |
| 261 | * |
| 262 | * 10 6/16/97 3:44p Jason |
| 263 | * added line drawing |
| 264 | * |
| 265 | * 9 6/16/97 2:54p Jason |
| 266 | * added rend_DrawFontCharacter function for drawing fonts |
| 267 | * |
| 268 | * 8 6/16/97 2:34p Jason |
| 269 | * added 3dfx support |
| 270 | * |
| 271 | * 7 6/06/97 11:35a Jason |
| 272 | * added missing functions for pixel primitives |
| 273 | * |
| 274 | * 6 6/03/97 12:19p Jason |
| 275 | * more functions added for opengl |
| 276 | * |
| 277 | * 5 5/27/97 4:39p Jason |
| 278 | * changes to support OpenGL |
| 279 | * |
| 280 | * 4 5/22/97 11:59a Jason |
| 281 | * add a ScaleBitmap function to the abstracted render library |
| 282 | * |
| 283 | * 3 5/21/97 12:30p Jason |
| 284 | * calls rend_start and rend_end when frames begin/end |
| 285 | * |
| 286 | * 2 5/19/97 5:10p Jason |
| 287 | * changes for our new abstracted renderer code |
| 288 | * |
| 289 | * 1 5/19/97 3:23p Jason |
| 290 | * |
| 291 | * $NoKeywords: $ |
| 292 | */ |
| 293 | |
| 294 | #ifndef RENDERER_H |
| 295 | #define RENDERER_H |
| 296 | |
| 297 | #include <memory> |
| 298 | #include "pstypes.h" |
| 299 | #include "grdefs.h" |
| 300 | |
| 301 | // Declare this here so we don't need to include 3d.h |
| 302 | typedef struct g3Point g3Point; |
| 303 | typedef struct chunked_bitmap chunked_bitmap; |
| 304 | |
| 305 | // for rend_Init prototype |
| 306 | class oeApplication; |
| 307 | |
| 308 | #define TEXTURE_WIDTH 128 |
| 309 | #define TEXTURE_HEIGHT 128 |
| 310 | #define TEXTURE_BPP 2 |
| 311 | |
| 312 | #define FLAT_SHADE_COLOR 0x7C01 |
| 313 | // If an incoming texture has the above color in it, change that color to this color |
| 314 | #define REPLACEMENT_COLOR 0x07C0 |
| 315 | |
| 316 | extern int Triangles_drawn; |
| 317 | |
| 318 | // Is this hardware or software rendered? |
| 319 | enum renderer_type { |
| 320 | RENDERER_OPENGL = 2, |
| 321 | RENDERER_DIRECT3D = 3, |
| 322 | RENDERER_GLIDE = 4, // Unused |
| 323 | RENDERER_NONE = 5, |
| 324 | }; |
| 325 | |
| 326 | extern renderer_type Renderer_type; |
| 327 | |
| 328 | // renderer clear flags |
| 329 | #define RF_CLEAR_ZBUFFER 1 |
| 330 | #define RF_CLEAR_COLOR 2 |
| 331 | |
| 332 | // Overlay texture settings |
| 333 | #define OT_NONE 0 // No overlay |
| 334 | #define OT_BLEND 1 // Draw a lightmap texture afterwards |
| 335 | #define OT_REPLACE 2 // Draw a tmap2 style texture afterwards |
| 336 | #define OT_FLAT_BLEND 3 // Draw a gouraud shaded polygon afterwards |
| 337 | #define OT_BLEND_VERTEX 4 // Like OT_BLEND, but take constant alpha into account |
| 338 | #define OT_BUMPMAP 5 // Draw a saturated bumpmap afterwards |
| 339 | #define OT_BLEND_SATURATE 6 // Add a lightmap in |
| 340 | |
| 341 | extern uint8_t Overlay_type; |
| 342 | extern int Overlay_map; |
| 343 | extern int Bumpmap_ready, Bump_map; |
| 344 | extern float Z_bias; |
| 345 | extern bool UseHardware; |
| 346 | extern bool StateLimited; |
| 347 | extern bool NoLightmaps; |
| 348 | extern bool UseMultitexture; |
| 349 | extern bool UseWBuffer; |
| 350 | extern bool UseMipmap; // DAJ |
| 351 | extern bool ATIRagePro; // DAJ |
| 352 | extern bool Formac; // DAJ |
| 353 | |
| 354 | class NewBitmap; |
| 355 | |
| 356 | // various state setting functions |
| 357 | //------------------------------------ |
| 358 | |
| 359 | // Sets our renderer |
| 360 | void rend_SetRendererType(renderer_type state); |
| 361 | |
| 362 | #define MAP_TYPE_BITMAP 0 |
| 363 | #define MAP_TYPE_LIGHTMAP 1 |
| 364 | #define MAP_TYPE_BUMPMAP 2 |
| 365 | #define MAP_TYPE_UNKNOWN 3 |
| 366 | |
| 367 | // lighting state |
| 368 | enum light_state { |
| 369 | LS_NONE, // no lighting, fully lit rendering |
| 370 | LS_GOURAUD, // Gouraud shading |
| 371 | LS_PHONG, // Phong shading |
| 372 | LS_FLAT_GOURAUD // Take color from flat color |
| 373 | }; |
| 374 | |
| 375 | void rend_SetLighting(light_state); |
| 376 | |
| 377 | enum color_model { |
| 378 | CM_MONO, // monochromatic (intensity) model - default |
| 379 | CM_RGB, // RGB model |
| 380 | }; |
| 381 | |
| 382 | // color model |
| 383 | void rend_SetColorModel(color_model); |
| 384 | |
| 385 | enum texture_type { |
| 386 | TT_FLAT, // solid color |
| 387 | TT_LINEAR, // textured linearly |
| 388 | TT_PERSPECTIVE, // texture perspectively |
| 389 | TT_LINEAR_SPECIAL, // A textured polygon drawn as a flat color |
| 390 | TT_PERSPECTIVE_SPECIAL, // A textured polygon drawn as a flat color |
| 391 | }; |
| 392 | |
| 393 | // Alpha type flags - used to decide what type of alpha blending to use |
| 394 | #define ATF_CONSTANT 1 // Take constant alpha into account |
| 395 | #define ATF_TEXTURE 2 // Take texture alpha into account |
| 396 | #define ATF_VERTEX 4 // Take vertex alpha into account |
| 397 | |
| 398 | // Alpha types |
| 399 | #define AT_ALWAYS 0 // Alpha is always 255 (1.0) |
| 400 | #define AT_CONSTANT 1 // constant alpha across the whole image |
| 401 | #define AT_TEXTURE 2 // Only uses texture alpha |
| 402 | #define AT_CONSTANT_TEXTURE 3 // Use texture * constant alpha |
| 403 | #define AT_VERTEX 4 // Use vertex alpha only |
| 404 | #define AT_CONSTANT_VERTEX 5 // Use vertex * constant alpha |
| 405 | #define AT_TEXTURE_VERTEX 6 // Use texture * vertex alpha |
| 406 | #define AT_CONSTANT_TEXTURE_VERTEX 7 // Use all three (texture constant vertex) |
| 407 | #define AT_LIGHTMAP_BLEND 8 // dest*src colors |
| 408 | #define AT_SATURATE_TEXTURE 9 // Saturate up to white when blending |
| 409 | #define AT_FLAT_BLEND 10 // Like lightmap blend, but uses gouraud shaded flat polygon |
| 410 | #define AT_ANTIALIAS 11 // Draws an antialiased polygon |
| 411 | #define AT_SATURATE_VERTEX 12 // Saturation with vertices |
| 412 | #define AT_SATURATE_CONSTANT_VERTEX 13 // Constant*vertex saturation |
| 413 | #define AT_SATURATE_TEXTURE_VERTEX 14 // Texture * vertex saturation |
| 414 | #define AT_LIGHTMAP_BLEND_VERTEX 15 // Like AT_LIGHTMAP_BLEND, but take vertex alpha into account |
| 415 | #define AT_LIGHTMAP_BLEND_CONSTANT 16 // Like AT_LIGHTMAP_BLEND, but take constant alpha into account |
| 416 | #define AT_SPECULAR 32 |
| 417 | #define AT_LIGHTMAP_BLEND_SATURATE 33 // Light lightmap blend, but add instead of multiply |
| 418 | |
| 419 | #define LFB_LOCK_READ 0 |
| 420 | #define LFB_LOCK_WRITE 1 |
| 421 | |
| 422 | enum wrap_type { |
| 423 | WT_WRAP, // Texture repeats |
| 424 | WT_CLAMP, // Texture clamps |
| 425 | WT_WRAP_V // Texture wraps in v |
| 426 | }; |
| 427 | |
| 428 | struct rendering_state { |
| 429 | int8_t initted; |
| 430 | |
| 431 | int8_t cur_bilinear_state; |
| 432 | int8_t cur_zbuffer_state; |
| 433 | int8_t cur_fog_state; |
| 434 | int8_t cur_mip_state; |
| 435 | |
| 436 | texture_type cur_texture_type; |
| 437 | color_model cur_color_model; |
| 438 | light_state cur_light_state; |
| 439 | int8_t cur_alpha_type; |
| 440 | |
| 441 | wrap_type cur_wrap_type; |
| 442 | |
| 443 | float cur_fog_start, cur_fog_end; |
| 444 | float cur_near_z, cur_far_z; |
| 445 | float gamma_value; |
| 446 | |
| 447 | int cur_alpha; |
| 448 | ddgr_color cur_color; |
| 449 | ddgr_color cur_fog_color; |
| 450 | |
| 451 | int8_t cur_texture_quality; // 0-none, 1-linear, 2-perspective |
| 452 | |
| 453 | int clip_x1, clip_x2, clip_y1, clip_y2; |
| 454 | int screen_width, screen_height; |
| 455 | |
| 456 | }; |
| 457 | |
| 458 | struct renderer_preferred_state { |
| 459 | uint8_t mipping; |
| 460 | uint8_t filtering; |
| 461 | float gamma; |
| 462 | uint8_t bit_depth; |
| 463 | int width, height; |
| 464 | uint8_t vsync_on; |
| 465 | }; |
| 466 | |
| 467 | struct renderer_lfb { |
| 468 | int type; |
| 469 | uint16_t *data; |
| 470 | int bytes_per_row; |
| 471 | }; |
| 472 | |
| 473 | struct tRendererStats { |
| 474 | int poly_count; |
| 475 | int vert_count; |
| 476 | int texture_uploads; |
| 477 | }; |
| 478 | |
| 479 | // returns rendering statistics for the frame |
| 480 | void rend_GetStatistics(tRendererStats *stats); |
| 481 | |
| 482 | void rend_SetTextureType(texture_type); |
| 483 | |
| 484 | // Given a handle to a bitmap and nv point vertices, draws a 3D polygon |
| 485 | void rend_DrawPolygon3D(int handle, g3Point **p, int nv, int map_type = MAP_TYPE_BITMAP); |
| 486 | |
| 487 | // Given a handle to a bitmap and nv point vertices, draws a 2D polygon |
| 488 | void rend_DrawPolygon2D(int handle, g3Point **p, int nv); |
| 489 | |
| 490 | // Tells the software renderer whether or not to use mipping |
| 491 | void rend_SetMipState(int8_t); |
| 492 | |
| 493 | // Sets the fog state to TRUE or FALSE |
| 494 | void rend_SetFogState(int8_t on); |
| 495 | |
| 496 | // Sets the near and far plane of fog |
| 497 | void rend_SetFogBorders(float fog_near, float fog_far); |
| 498 | |
| 499 | // Sets the color for fill based primitives; |
| 500 | void rend_SetFlatColor(ddgr_color color); |
| 501 | |
| 502 | // Tells the renderer we're starting a frame. Clear flags tells the renderer |
| 503 | // what buffer (if any) to clear |
| 504 | void rend_StartFrame(int x1, int y1, int x2, int y2, int clear_flags = RF_CLEAR_ZBUFFER); |
| 505 | |
| 506 | // Tells the renderer the frame is over |
| 507 | void rend_EndFrame(); |
| 508 | |
| 509 | // Init our renderer, pass the application object also. |
| 510 | int rend_Init(renderer_type state, oeApplication *app, renderer_preferred_state *pref_state); |
| 511 | |
| 512 | // de-init the renderer |
| 513 | void rend_Close(); |
| 514 | |
| 515 | // Draws a scaled 2d bitmap to our buffer |
| 516 | // NOTE: scripts are expecting the old prototype that has a zvalue (which is ignored) before color |
| 517 | void rend_DrawScaledBitmap(int x1, int y1, int x2, int y2, int bm, float u0, float v0, float u1, float v1, |
| 518 | int color = -1, float *alphas = NULL); |
| 519 | |
| 520 | // Sets the state of bilinear filtering for our textures |
| 521 | void rend_SetFiltering(int8_t state); |
| 522 | |
| 523 | // Sets the state of zbuffering to on or off |
| 524 | void rend_SetZBufferState(int8_t state); |
| 525 | |
| 526 | // Sets the near and far planes for z buffer |
| 527 | void rend_SetZValues(float nearz, float farz); |
| 528 | |
| 529 | // Sets a bitmap as an overlay to rendered on top of the next texture map |
| 530 | void rend_SetOverlayMap(int handle); |
| 531 | |
| 532 | // Sets the type of overlay operation |
| 533 | void rend_SetOverlayType(uint8_t type); |
| 534 | |
| 535 | // Clears the display to a specified color |
| 536 | void rend_ClearScreen(ddgr_color color); |
| 537 | |
| 538 | // Fills a rectangle on the display |
| 539 | void rend_FillRect(ddgr_color color, int x1, int y1, int x2, int y2); |
| 540 | |
| 541 | // Sets a pixel on the display |
| 542 | void rend_SetPixel(ddgr_color color, int x, int y); |
| 543 | |
| 544 | // Sets a pixel on the display |
| 545 | ddgr_color rend_GetPixel(int x, int y); |
| 546 | |
| 547 | // Sets up a font character to draw. We draw our fonts as pieces of textures |
| 548 | void rend_DrawFontCharacter(int bm_handle, int x1, int y1, int x2, int y2, float u, float v, float w, float h); |
| 549 | |
| 550 | // Draws a line |
| 551 | void rend_DrawLine(int x1, int y1, int x2, int y2); |
| 552 | |
| 553 | // Draws spheres |
| 554 | void rend_FillCircle(ddgr_color col, int x, int y, int rad); |
| 555 | |
| 556 | // draws circles |
| 557 | void rend_DrawCircle(int x, int y, int rad); |
| 558 | |
| 559 | // Flips the surface |
| 560 | void rend_Flip(); |
| 561 | |
| 562 | // Sets the argb characteristics of the font characters. color1 is the upper left and proceeds clockwise |
| 563 | void rend_SetCharacterParameters(ddgr_color color1, ddgr_color color2, ddgr_color color3, ddgr_color color4); |
| 564 | |
| 565 | // Sets the color of fog |
| 566 | void rend_SetFogColor(ddgr_color fogcolor); |
| 567 | |
| 568 | // sets the alpha type |
| 569 | void rend_SetAlphaType(int8_t); |
| 570 | |
| 571 | // Sets the constant alpha value |
| 572 | void rend_SetAlphaValue(uint8_t val); |
| 573 | |
| 574 | // Sets the overall alpha scale factor (all alpha values are scaled by this value) |
| 575 | // usefull for motion blur effect |
| 576 | void rend_SetAlphaFactor(float val); |
| 577 | |
| 578 | // Returns the current Alpha factor |
| 579 | float rend_GetAlphaFactor(void); |
| 580 | |
| 581 | // Sets the wrap parameter |
| 582 | void rend_SetWrapType(wrap_type val); |
| 583 | |
| 584 | /// Takes a screenshot of the current frame and returns a NewBitmap |
| 585 | std::unique_ptr<NewBitmap> rend_Screenshot(); |
| 586 | |
| 587 | // Takes a screenshot of the current frame and puts it into the handle passed |
| 588 | void rend_Screenshot(int bm_handle); |
| 589 | |
| 590 | // Adds a bias to each coordinates z value. This is useful for making 2d bitmaps |
| 591 | // get drawn without being clipped by the zbuffer |
| 592 | void rend_SetZBias(float z_bias); |
| 593 | |
| 594 | // Enables/disables writes the depth buffer |
| 595 | void rend_SetZBufferWriteMask(int state); |
| 596 | |
| 597 | // Sets where the software renderer should write to |
| 598 | void rend_SetSoftwareParameters(float aspect, int width, int height, int pitch, uint8_t *framebuffer); |
| 599 | |
| 600 | // Fills in some variables so the 3d math routines know how to project |
| 601 | void rend_GetProjectionParameters(int *width, int *height); |
| 602 | void rend_GetProjectionScreenParameters(int &screenLX, int &screenTY, int &screenW, int &screenH); |
| 603 | |
| 604 | // Returns the aspect ratio of the physical screen |
| 605 | float rend_GetAspectRatio(); |
| 606 | |
| 607 | // Gets a pointer to a linear frame buffer |
| 608 | void rend_GetLFBLock(renderer_lfb *lfb); |
| 609 | |
| 610 | // Releases an lfb lock |
| 611 | void rend_ReleaseLFBLock(renderer_lfb *lfb); |
| 612 | |
| 613 | // Given a source x,y and width,height, draws any sized bitmap into the renderer lfb |
| 614 | void rend_DrawLFBBitmap(int sx, int sy, int w, int h, int dx, int dy, uint16_t *data, int rowsize); |
| 615 | |
| 616 | // given a chunked bitmap, renders it. |
| 617 | void rend_DrawChunkedBitmap(chunked_bitmap *chunk, int x, int y, uint8_t alpha); |
| 618 | |
| 619 | // given a chunked bitmap, renders it.scaled |
| 620 | void rend_DrawScaledChunkedBitmap(chunked_bitmap *chunk, int x, int y, int neww, int newh, uint8_t alpha); |
| 621 | |
| 622 | // Draws a line using the states of the renderer |
| 623 | void rend_DrawSpecialLine(g3Point *p0, g3Point *p1); |
| 624 | |
| 625 | // Sets some global preferences for the renderer |
| 626 | // Returns -1 if it had to use the default resolution/bitdepth |
| 627 | int rend_SetPreferredState(renderer_preferred_state *pref_state); |
| 628 | |
| 629 | // Sets the gamma value |
| 630 | void rend_SetGammaValue(float val); |
| 631 | |
| 632 | // Fills in the passed in pointer with the current rendering state |
| 633 | void rend_GetRenderState(rendering_state *rstate); |
| 634 | |
| 635 | // Draws a simple bitmap at the specified x,y location |
| 636 | void rend_DrawSimpleBitmap(int bm_handle, int x, int y); |
| 637 | |
| 638 | // Gets OpenGL ready to work in a window |
| 639 | int rend_InitOpenGLWindow(oeApplication *app, renderer_preferred_state *pref_state); |
| 640 | |
| 641 | // Shuts down OpenGL in a window |
| 642 | void rend_CloseOpenGLWindow(); |
| 643 | |
| 644 | // Sets the state of the OpenGLWindow to on or off |
| 645 | void rend_SetOpenGLWindowState(int state, oeApplication *app, renderer_preferred_state *pref_state); |
| 646 | |
| 647 | // Sets the hardware bias level for coplanar polygons |
| 648 | // This helps reduce z buffer artifaces |
| 649 | void rend_SetCoplanarPolygonOffset(float factor); |
| 650 | |
| 651 | // Gets the error message string |
| 652 | const char *rend_GetErrorMessage(); |
| 653 | |
| 654 | // Sets the error message string |
| 655 | void rend_SetErrorMessage(const char *str); |
| 656 | |
| 657 | // Preuploads a bitmap to the card |
| 658 | void rend_PreUploadTextureToCard(int, int); |
| 659 | void rend_FreePreUploadedTexture(int, int); |
| 660 | |
| 661 | // Returns 1 if there is mid video memory, 2 if there is low vid memory, or 0 if there is large vid memory |
| 662 | int rend_LowVidMem(); |
| 663 | |
| 664 | // Returns 1 if the renderer supports bumpmapping |
| 665 | int rend_SupportsBumpmapping(); |
| 666 | |
| 667 | // Gets a bumpmap ready for drawing, or turns off bumpmapping |
| 668 | void rend_SetBumpmapReadyState(int state, int map); |
| 669 | |
| 670 | // Clears the zbuffer |
| 671 | void rend_ClearZBuffer(); |
| 672 | |
| 673 | // Clears the texture cache |
| 674 | void rend_ResetCache(); |
| 675 | |
| 676 | // Takes a bitmap and blits it to the screen using linear frame buffer stuff |
| 677 | // X and Y are the destination X,Y. |
| 678 | void rend_CopyBitmapToFramebuffer(int bm_handle, int x, int y); |
| 679 | |
| 680 | // Gets a renderer ready for a framebuffer copy, or stops a framebuffer copy |
| 681 | void rend_SetFrameBufferCopyState(bool state); |
| 682 | |
| 683 | #if defined(WIN32) |
| 684 | // returns the direct draw object |
| 685 | void *rend_RetrieveDirectDrawObj(void **frontsurf, void **backsurf); |
| 686 | #endif |
| 687 | |
| 688 | #endif |