| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Descent Developers |
| 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 | |
| 19 | // TODO: This is missing a good way of overriding base behavior (like, you know, method overrides...) |
| 20 | |
| 21 | #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/ |
| 22 | #include "mono.h"cxx . . $ `<file>/ddebug/mono.h`/ |
| 23 | #include "3d.h"cxx . . $ `<file>/lib/3d.h`/ |
| 24 | #include "renderer.h"cxx . . $ `<file>/lib/renderer.h`/ |
| 25 | #include "bitmap.h"cxx . . $ `<file>/lib/bitmap.h`/ |
| 26 | #include "grdefs.h"cxx . . $ `<file>/lib/grdefs.h`/ |
| 27 | #include <cstring> |
| 28 | |
| 29 | #include "HardwareInternal.h"cxx . . $ `<file>/renderer/HardwareInternal.h`/ |
| 30 | #include "lightmap.h"cxx . . $ `<file>/lib/lightmap.h`/ |
| 31 | |
| 32 | // FIXME: Unused |
| 33 | // The font characteristics |
| 34 | static float rend_FontRedcxx . . $ rend_FontRed.[4], rend_FontBluecxx . . $ rend_FontBlue.[4], rend_FontGreencxx . . $ rend_FontGreen.[4], rend_FontAlphacxx . . $ rend_FontAlpha.[4]; |
| 35 | char Renderer_error_messagecxx . . $ Renderer_error_message.[256] = "Generic renderer error"; |
| 36 | |
| 37 | // The following values are referenced by the game code, but only |
| 38 | // UseMultitexture is actually referenced and used in this code - and |
| 39 | // even that can probably go away and we just assume there is more than |
| 40 | // one texture unit (which, since I believe OpenGL 1.2 is a requirement) |
| 41 | bool UseHardwarecxx . . $ UseHardware. = true; |
| 42 | bool NoLightmapscxx . . $ NoLightmaps. = false; |
| 43 | bool StateLimitedcxx . . $ StateLimited. = false; |
| 44 | bool UseMultitexturecxx . . $ UseMultitexture. = false; |
| 45 | bool UseWBuffercxx . . $ UseWBuffer. = false; |
| 46 | |
| 47 | // General renderer states |
| 48 | int gpu_Overlay_mapcxx . . $ gpu_Overlay_map. = -1; |
| 49 | uint8_tcxx . . $ uint8_t# gpu_Overlay_typecxx . . $ gpu_Overlay_type. = OT_NONEcxx . . $ `lib/renderer.h:333:9`!; |
| 50 | uint8_tcxx . . $ uint8_t# Renderer_inittedcxx . . $ Renderer_initted. = 0; |
| 51 | |
| 52 | // Generic GPU data |
| 53 | rendering_statecxx . . $ rendering_state# gpu_statecxx . . $ gpu_state.; |
| 54 | renderer_preferred_statecxx . . $ renderer_preferred_state# gpu_preferred_statecxx . . $ gpu_preferred_state. = {0, 1, 1.5}; |
| 55 | |
| 56 | int gpu_last_frame_polys_drawncxx . . $ gpu_last_frame_polys_drawn. = 0; |
| 57 | int gpu_last_frame_verts_processedcxx . . $ gpu_last_frame_verts_processed. = 0; |
| 58 | int gpu_last_uploadedcxx . . $ gpu_last_uploaded. = 0; |
| 59 | |
| 60 | float gpu_Alpha_factorcxx . . $ gpu_Alpha_factor. = 1.0f; |
| 61 | float gpu_Alpha_multipliercxx . . $ gpu_Alpha_multiplier. = 1.0f; |
| 62 | |
| 63 | PosColorUVVertexcxx . . $ PosColorUVVertex# vArraycxx . . $ vArray.[100]; |
| 64 | PosColorUV2Vertexcxx . . $ PosColorUV2Vertex# vArray2cxx . . $ vArray2.[100]; |
| 65 | |
| 66 | // returns the alpha that we should use |
| 67 | float rend_GetAlphaMultipliercxx . . $ rend_GetAlphaMultiplier(9b8c9e39889c762c).() { |
| 68 | switch (gpu_statecxx . . $ gpu_state..cur_alpha_typecxx . . $ rendering_state#cur_alpha_type.) { |
| 69 | case AT_ALWAYScxx . . $ `lib/renderer.h:399:9`!: |
| 70 | case AT_TEXTUREcxx . . $ `lib/renderer.h:401:9`!: |
| 71 | case AT_VERTEXcxx . . $ `lib/renderer.h:403:9`!: |
| 72 | case AT_TEXTURE_VERTEXcxx . . $ `lib/renderer.h:405:9`!: |
| 73 | case AT_SATURATE_VERTEXcxx . . $ `lib/renderer.h:411:9`!: |
| 74 | case AT_SATURATE_TEXTURE_VERTEXcxx . . $ `lib/renderer.h:413:9`!: |
| 75 | case AT_SPECULARcxx . . $ `lib/renderer.h:416:9`!: |
| 76 | return 1.0; |
| 77 | case AT_CONSTANTcxx . . $ `lib/renderer.h:400:9`!: |
| 78 | case AT_CONSTANT_TEXTUREcxx . . $ `lib/renderer.h:402:9`!: |
| 79 | case AT_CONSTANT_TEXTURE_VERTEXcxx . . $ `lib/renderer.h:406:9`!: |
| 80 | case AT_CONSTANT_VERTEXcxx . . $ `lib/renderer.h:404:9`!: |
| 81 | case AT_LIGHTMAP_BLENDcxx . . $ `lib/renderer.h:407:9`!: |
| 82 | case AT_LIGHTMAP_BLEND_SATURATEcxx . . $ `lib/renderer.h:417:9`!: |
| 83 | case AT_SATURATE_TEXTUREcxx . . $ `lib/renderer.h:408:9`!: |
| 84 | case AT_SATURATE_CONSTANT_VERTEXcxx . . $ `lib/renderer.h:412:9`!: |
| 85 | return gpu_statecxx . . $ gpu_state..cur_alphacxx . . $ rendering_state#cur_alpha. / 255.0; |
| 86 | default: |
| 87 | // Int3(); // no type defined,get jason |
| 88 | return 0; |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | // Retrieves an error message |
| 93 | const char *rend_GetErrorMessagecxx . . $ rend_GetErrorMessage(33a1f659e94feb42).() { return Renderer_error_messagecxx . . $ Renderer_error_message.; } |
| 94 | |
| 95 | // Sets an error message |
| 96 | void rend_SetErrorMessagecxx . . $ rend_SetErrorMessage(85c52e162fed56f9).(const char *str) { |
| 97 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(strlen(str) < 256); |
| 98 | strcpy(Renderer_error_messagecxx . . $ Renderer_error_message., str); |
| 99 | } |
| 100 | |
| 101 | // FIXME: Unused |
| 102 | // Sets the argb characteristics of the font characters. color1 is the upper left and proceeds clockwise |
| 103 | void rend_SetCharacterParameterscxx . . $ rend_SetCharacterParameters(eda338842932bf2b).(ddgr_colorcxx . . $ ddgr_color# color1, ddgr_colorcxx . . $ ddgr_color# color2, ddgr_colorcxx . . $ ddgr_color# color3, ddgr_colorcxx . . $ ddgr_color# color4) { |
| 104 | rend_FontRedcxx . . $ rend_FontRed.[0] = (float)(GR_COLOR_REDcxx . . $ GR_COLOR_RED(4c679297bf94b9eb).(color1) / 255.0f); |
| 105 | rend_FontRedcxx . . $ rend_FontRed.[1] = (float)(GR_COLOR_REDcxx . . $ GR_COLOR_RED(4c679297bf94b9eb).(color2) / 255.0f); |
| 106 | rend_FontRedcxx . . $ rend_FontRed.[2] = (float)(GR_COLOR_REDcxx . . $ GR_COLOR_RED(4c679297bf94b9eb).(color3) / 255.0f); |
| 107 | rend_FontRedcxx . . $ rend_FontRed.[3] = (float)(GR_COLOR_REDcxx . . $ GR_COLOR_RED(4c679297bf94b9eb).(color4) / 255.0f); |
| 108 | rend_FontGreencxx . . $ rend_FontGreen.[0] = (float)(GR_COLOR_GREENcxx . . $ GR_COLOR_GREEN(4c679297bf94b9eb).(color1) / 255.0f); |
| 109 | rend_FontGreencxx . . $ rend_FontGreen.[1] = (float)(GR_COLOR_GREENcxx . . $ GR_COLOR_GREEN(4c679297bf94b9eb).(color2) / 255.0f); |
| 110 | rend_FontGreencxx . . $ rend_FontGreen.[2] = (float)(GR_COLOR_GREENcxx . . $ GR_COLOR_GREEN(4c679297bf94b9eb).(color3) / 255.0f); |
| 111 | rend_FontGreencxx . . $ rend_FontGreen.[3] = (float)(GR_COLOR_GREENcxx . . $ GR_COLOR_GREEN(4c679297bf94b9eb).(color4) / 255.0f); |
| 112 | rend_FontBluecxx . . $ rend_FontBlue.[0] = (float)(GR_COLOR_BLUEcxx . . $ GR_COLOR_BLUE(4c679297bf94b9eb).(color1) / 255.0f); |
| 113 | rend_FontBluecxx . . $ rend_FontBlue.[1] = (float)(GR_COLOR_BLUEcxx . . $ GR_COLOR_BLUE(4c679297bf94b9eb).(color2) / 255.0f); |
| 114 | rend_FontBluecxx . . $ rend_FontBlue.[2] = (float)(GR_COLOR_BLUEcxx . . $ GR_COLOR_BLUE(4c679297bf94b9eb).(color3) / 255.0f); |
| 115 | rend_FontBluecxx . . $ rend_FontBlue.[3] = (float)(GR_COLOR_BLUEcxx . . $ GR_COLOR_BLUE(4c679297bf94b9eb).(color4) / 255.0f); |
| 116 | rend_FontAlphacxx . . $ rend_FontAlpha.[0] = (color1 >> 24) / 255.0f; |
| 117 | rend_FontAlphacxx . . $ rend_FontAlpha.[1] = (color2 >> 24) / 255.0f; |
| 118 | rend_FontAlphacxx . . $ rend_FontAlpha.[2] = (color3 >> 24) / 255.0f; |
| 119 | rend_FontAlphacxx . . $ rend_FontAlpha.[3] = (color4 >> 24) / 255.0f; |
| 120 | } |
| 121 | |
| 122 | // Sets where the software renderer should write to |
| 123 | void rend_SetSoftwareParameterscxx . . $ rend_SetSoftwareParameters(d26b1bbbc1a6742).(float aspect, int width, int height, int pitch, uint8_tcxx . . $ uint8_t# *framebuffer) {} |
| 124 | |
| 125 | // Sets the state of bilinear filtering for our textures |
| 126 | void rend_SetFilteringcxx . . $ rend_SetFiltering(4af4fd0e2b26c4ac).(int8_t state) { |
| 127 | gpu_statecxx . . $ gpu_state..cur_bilinear_statecxx . . $ rendering_state#cur_bilinear_state. = state; |
| 128 | } |
| 129 | |
| 130 | // Sets the near and far planes for z buffer |
| 131 | void rend_SetZValuescxx . . $ rend_SetZValues(5102ef758adc0ae7).(float nearz, float farz) { |
| 132 | gpu_statecxx . . $ gpu_state..cur_near_zcxx . . $ rendering_state#cur_near_z. = nearz; |
| 133 | gpu_statecxx . . $ gpu_state..cur_far_zcxx . . $ rendering_state#cur_far_z. = farz; |
| 134 | // mprintf(0,"OPENGL:Setting depth range to %f - %f\n",nearz,farz); |
| 135 | |
| 136 | // JEFF: glDepthRange must take parameters [0,1] |
| 137 | // It is set in init |
| 138 | //@@dglDepthRange (0,farz); |
| 139 | } |
| 140 | |
| 141 | // Sets a bitmap as a overlay map to rendered on top of the next texture map |
| 142 | // a -1 value indicates no overlay map |
| 143 | void rend_SetOverlayMapcxx . . $ rend_SetOverlayMap(d4f767463ce0a6b3).(int handle) { gpu_Overlay_mapcxx . . $ gpu_Overlay_map. = handle; } |
| 144 | |
| 145 | void rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(uint8_tcxx . . $ uint8_t# type) { gpu_Overlay_typecxx . . $ gpu_Overlay_type. = type; } |
| 146 | |
| 147 | |
| 148 | void rend_FillCirclecxx . . $ rend_FillCircle(10de3014ec658f6e).(ddgr_colorcxx . . $ ddgr_color# col, int x, int y, int rad) {} |
| 149 | |
| 150 | void rend_DrawCirclecxx . . $ rend_DrawCircle(b1146eedae1e1d0b).(int x, int y, int rad) {} |
| 151 | |
| 152 | // Sets up a font character to draw. We draw our fonts as pieces of textures |
| 153 | void rend_DrawFontCharactercxx . . $ rend_DrawFontCharacter(d3f982e0313c7b8c).(int bm_handle, int x1, int y1, int x2, int y2, float u, float v, float w, float h) { |
| 154 | g3Pointcxx . . $ g3Point# *ptr_pnts[4]; |
| 155 | g3Pointcxx . . $ g3Point# pnts[4]; |
| 156 | for (int i = 0; i < 4; i++) { |
| 157 | pnts[i].p3_zcxx . . $ `lib/3d.h:247:9`! = 1; // Make REALLY close! |
| 158 | pnts[i].p3_flagscxx . . $ g3Point#p3_flags. = PF_PROJECTEDcxx . . $ `lib/3d.h:214:9`!; |
| 159 | ptr_pnts[i] = &pnts[i]; |
| 160 | } |
| 161 | pnts[0].p3_sxcxx . . $ g3Point#p3_sx. = x1; |
| 162 | pnts[0].p3_sycxx . . $ g3Point#p3_sy. = y1; |
| 163 | pnts[0].p3_ucxx . . $ `lib/3d.h:250:9`! = u; |
| 164 | pnts[0].p3_vcxx . . $ `lib/3d.h:251:9`! = v; |
| 165 | pnts[1].p3_sxcxx . . $ g3Point#p3_sx. = x2; |
| 166 | pnts[1].p3_sycxx . . $ g3Point#p3_sy. = y1; |
| 167 | pnts[1].p3_ucxx . . $ `lib/3d.h:250:9`! = u + w; |
| 168 | pnts[1].p3_vcxx . . $ `lib/3d.h:251:9`! = v; |
| 169 | pnts[2].p3_sxcxx . . $ g3Point#p3_sx. = x2; |
| 170 | pnts[2].p3_sycxx . . $ g3Point#p3_sy. = y2; |
| 171 | pnts[2].p3_ucxx . . $ `lib/3d.h:250:9`! = u + w; |
| 172 | pnts[2].p3_vcxx . . $ `lib/3d.h:251:9`! = v + h; |
| 173 | pnts[3].p3_sxcxx . . $ g3Point#p3_sx. = x1; |
| 174 | pnts[3].p3_sycxx . . $ g3Point#p3_sy. = y2; |
| 175 | pnts[3].p3_ucxx . . $ `lib/3d.h:250:9`! = u; |
| 176 | pnts[3].p3_vcxx . . $ `lib/3d.h:251:9`! = v + h; |
| 177 | rend_DrawPolygon2Dcxx . . $ rend_DrawPolygon2D(1464bdba6025a51).(bm_handle, ptr_pnts, 4); |
| 178 | } |
| 179 | |
| 180 | // Sets the alpha value for constant alpha |
| 181 | void rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(uint8_tcxx . . $ uint8_t# val) { |
| 182 | gpu_statecxx . . $ gpu_state..cur_alphacxx . . $ rendering_state#cur_alpha. = val; |
| 183 | gpu_Alpha_multipliercxx . . $ gpu_Alpha_multiplier. = rend_GetAlphaMultipliercxx . . $ rend_GetAlphaMultiplier(9b8c9e39889c762c).(); |
| 184 | } |
| 185 | |
| 186 | // Sets the texture wrapping type |
| 187 | void rend_SetWrapTypecxx . . $ rend_SetWrapType(da524b148887c0e7).(wrap_typecxx . . $ wrap_type# val) { gpu_statecxx . . $ gpu_state..cur_wrap_typecxx . . $ rendering_state#cur_wrap_type. = val; } |
| 188 | |
| 189 | void rend_SetZBiascxx . . $ rend_SetZBias(9364e6e7bff7660).(float z_bias) { |
| 190 | if (Z_biascxx . . $ Z_bias. != z_bias) { |
| 191 | Z_biascxx . . $ Z_bias. = z_bias; |
| 192 | |
| 193 | // Force refresh our transforms to take the Zbias into account |
| 194 | g3_GetModelViewMatrixcxx . . $ g3_GetModelViewMatrix(f698744c99c0df38).(&View_positioncxx . . $ View_position., &Unscaled_matrixcxx . . $ Unscaled_matrix., (float *)gTransformModelViewcxx . . $ gTransformModelView.); |
| 195 | g3_UpdateFullTransformcxx . . $ g3_UpdateFullTransform(49f6e7a06ebc5aa8).(); |
| 196 | g3_ForceTransformRefreshcxx . . $ g3_ForceTransformRefresh(49f6e7a06ebc5aa8).(); |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | // Sets the overall alpha scale factor (all alpha values are scaled by this value) |
| 201 | // usefull for motion blur effect |
| 202 | void rend_SetAlphaFactorcxx . . $ rend_SetAlphaFactor(9364e6e7bff7660).(float val) { |
| 203 | if (val < 0.0f) |
| 204 | val = 0.0f; |
| 205 | if (val > 1.0f) |
| 206 | val = 1.0f; |
| 207 | gpu_Alpha_factorcxx . . $ gpu_Alpha_factor. = val; |
| 208 | } |
| 209 | |
| 210 | // Returns the current Alpha factor |
| 211 | float rend_GetAlphaFactorcxx . . $ rend_GetAlphaFactor(9b8c9e39889c762c).(void) { return gpu_Alpha_factorcxx . . $ gpu_Alpha_factor.; } |
| 212 | |
| 213 | // Gets a pointer to a linear frame buffer |
| 214 | void rend_GetLFBLockcxx . . $ rend_GetLFBLock(419d9eae029ed3ee).(renderer_lfbcxx . . $ renderer_lfb# *lfb) {} |
| 215 | |
| 216 | // Releases an lfb lock |
| 217 | void rend_ReleaseLFBLockcxx . . $ rend_ReleaseLFBLock(419d9eae029ed3ee).(renderer_lfbcxx . . $ renderer_lfb# *lfb) {} |
| 218 | |
| 219 | // Returns the aspect ratio of the physical screen |
| 220 | void rend_GetProjectionParameterscxx . . $ rend_GetProjectionParameters(ce8f7825f8908cfa).(int *width, int *height) { |
| 221 | *width = gpu_statecxx . . $ gpu_state..clip_x2cxx . . $ rendering_state#clip_x2. - gpu_statecxx . . $ gpu_state..clip_x1cxx . . $ rendering_state#clip_x1.; |
| 222 | *height = gpu_statecxx . . $ gpu_state..clip_y2cxx . . $ rendering_state#clip_y2. - gpu_statecxx . . $ gpu_state..clip_y1cxx . . $ rendering_state#clip_y1.; |
| 223 | } |
| 224 | |
| 225 | void rend_GetProjectionScreenParameterscxx . . $ rend_GetProjectionScreenParameters(a90a5d8ba88c22b1).(int &screenLX, int &screenTY, int &screenW, int &screenH) { |
| 226 | screenLX = gpu_statecxx . . $ gpu_state..clip_x1cxx . . $ rendering_state#clip_x1.; |
| 227 | screenTY = gpu_statecxx . . $ gpu_state..clip_y1cxx . . $ rendering_state#clip_y1.; |
| 228 | screenW = gpu_statecxx . . $ gpu_state..clip_x2cxx . . $ rendering_state#clip_x2. - gpu_statecxx . . $ gpu_state..clip_x1cxx . . $ rendering_state#clip_x1. + 1; |
| 229 | screenH = gpu_statecxx . . $ gpu_state..clip_y2cxx . . $ rendering_state#clip_y2. - gpu_statecxx . . $ gpu_state..clip_y1cxx . . $ rendering_state#clip_y1. + 1; |
| 230 | } |
| 231 | |
| 232 | // Returns the aspect ratio of the physical screen |
| 233 | float rend_GetAspectRatiocxx . . $ rend_GetAspectRatio(9b8c9e39889c762c).(void) { |
| 234 | float aspect_ratio = (float)((3.0f * gpu_statecxx . . $ gpu_state..screen_widthcxx . . $ rendering_state#screen_width.) / (4.0f * gpu_statecxx . . $ gpu_state..screen_heightcxx . . $ rendering_state#screen_height.)); |
| 235 | return aspect_ratio; |
| 236 | } |
| 237 | |
| 238 | // Given a source x,y and width,height, draws any sized bitmap into the renderer lfb |
| 239 | void rend_DrawLFBBitmapcxx . . $ rend_DrawLFBBitmap(5d6120966b2638b4).(int sx, int sy, int w, int h, int dx, int dy, uint16_tcxx . . $ uint16_t# *data, int rowsize) {} |
| 240 | |
| 241 | // draws a scaled 2d bitmap to our buffer |
| 242 | void rend_DrawScaledBitmapcxx . . $ rend_DrawScaledBitmap(bffd21ce5f93b71b).(int x1, int y1, int x2, int y2, int bm, float u0, float v0, float u1, float v1, int color, |
| 243 | float *alphas) { |
| 244 | g3Pointcxx . . $ g3Point# *ptr_pnts[4]; |
| 245 | g3Pointcxx . . $ g3Point# pnts[4]; |
| 246 | float r, g, b; |
| 247 | if (color != -1) { |
| 248 | r = GR_COLOR_REDcxx . . $ GR_COLOR_RED(4c679297bf94b9eb).(color) / 255.0; |
| 249 | g = GR_COLOR_GREENcxx . . $ GR_COLOR_GREEN(4c679297bf94b9eb).(color) / 255.0; |
| 250 | b = GR_COLOR_BLUEcxx . . $ GR_COLOR_BLUE(4c679297bf94b9eb).(color) / 255.0; |
| 251 | } |
| 252 | for (int i = 0; i < 4; i++) { |
| 253 | if (color == -1) |
| 254 | pnts[i].p3_lcxx . . $ `lib/3d.h:252:9`! = 1.0; |
| 255 | else { |
| 256 | pnts[i].p3_rcxx . . $ `lib/3d.h:253:9`! = r; |
| 257 | pnts[i].p3_gcxx . . $ `lib/3d.h:254:9`! = g; |
| 258 | pnts[i].p3_bcxx . . $ `lib/3d.h:255:9`! = b; |
| 259 | } |
| 260 | if (alphas) { |
| 261 | pnts[i].p3_acxx . . $ `lib/3d.h:256:9`! = alphas[i]; |
| 262 | } |
| 263 | |
| 264 | pnts[i].p3_zcxx . . $ `lib/3d.h:247:9`! = 1.0f; |
| 265 | pnts[i].p3_flagscxx . . $ g3Point#p3_flags. = PF_PROJECTEDcxx . . $ `lib/3d.h:214:9`!; |
| 266 | } |
| 267 | |
| 268 | pnts[0].p3_sxcxx . . $ g3Point#p3_sx. = x1; |
| 269 | pnts[0].p3_sycxx . . $ g3Point#p3_sy. = y1; |
| 270 | pnts[0].p3_ucxx . . $ `lib/3d.h:250:9`! = u0; |
| 271 | pnts[0].p3_vcxx . . $ `lib/3d.h:251:9`! = v0; |
| 272 | pnts[1].p3_sxcxx . . $ g3Point#p3_sx. = x2; |
| 273 | pnts[1].p3_sycxx . . $ g3Point#p3_sy. = y1; |
| 274 | pnts[1].p3_ucxx . . $ `lib/3d.h:250:9`! = u1; |
| 275 | pnts[1].p3_vcxx . . $ `lib/3d.h:251:9`! = v0; |
| 276 | pnts[2].p3_sxcxx . . $ g3Point#p3_sx. = x2; |
| 277 | pnts[2].p3_sycxx . . $ g3Point#p3_sy. = y2; |
| 278 | pnts[2].p3_ucxx . . $ `lib/3d.h:250:9`! = u1; |
| 279 | pnts[2].p3_vcxx . . $ `lib/3d.h:251:9`! = v1; |
| 280 | pnts[3].p3_sxcxx . . $ g3Point#p3_sx. = x1; |
| 281 | pnts[3].p3_sycxx . . $ g3Point#p3_sy. = y2; |
| 282 | pnts[3].p3_ucxx . . $ `lib/3d.h:250:9`! = u0; |
| 283 | pnts[3].p3_vcxx . . $ `lib/3d.h:251:9`! = v1; |
| 284 | ptr_pnts[0] = &pnts[0]; |
| 285 | ptr_pnts[1] = &pnts[1]; |
| 286 | ptr_pnts[2] = &pnts[2]; |
| 287 | ptr_pnts[3] = &pnts[3]; |
| 288 | rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_LINEARcxx . . $ TT_LINEAR.); |
| 289 | rend_DrawPolygon2Dcxx . . $ rend_DrawPolygon2D(1464bdba6025a51).(bm, ptr_pnts, 4); |
| 290 | } |
| 291 | |
| 292 | // given a chunked bitmap, renders it. |
| 293 | void rend_DrawChunkedBitmapcxx . . $ rend_DrawChunkedBitmap(529c7906ea1e7bf7).(chunked_bitmapcxx . . $ chunked_bitmap# *chunk, int x, int y, uint8_tcxx . . $ uint8_t# alpha) { |
| 294 | int *bm_array = chunk->bm_arraycxx . . $ chunked_bitmap#bm_array.; |
| 295 | int w = chunk->wcxx . . $ chunked_bitmap#w.; |
| 296 | int h = chunk->hcxx . . $ chunked_bitmap#h.; |
| 297 | int piece_w = bm_wcxx . . $ bm_w(9b79fb6aee4c0440).(bm_array[0], 0); |
| 298 | int piece_h = bm_hcxx . . $ bm_h(9b79fb6aee4c0440).(bm_array[0], 0); |
| 299 | int screen_w, screen_h; |
| 300 | int i, t; |
| 301 | rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(0); |
| 302 | rend_GetProjectionParameterscxx . . $ rend_GetProjectionParameters(ce8f7825f8908cfa).(&screen_w, &screen_h); |
| 303 | for (i = 0; i < h; i++) { |
| 304 | for (t = 0; t < w; t++) { |
| 305 | int dx = x + (piece_w * t); |
| 306 | int dy = y + (piece_h * i); |
| 307 | int dw, dh; |
| 308 | if ((dx + piece_w) > screen_w) |
| 309 | dw = piece_w - ((dx + piece_w) - screen_w); |
| 310 | else |
| 311 | dw = piece_w; |
| 312 | if ((dy + piece_h) > screen_h) |
| 313 | dh = piece_h - ((dy + piece_h) - screen_h); |
| 314 | else |
| 315 | dh = piece_h; |
| 316 | |
| 317 | float u2 = (float)dw / (float)piece_w; |
| 318 | float v2 = (float)dh / (float)piece_h; |
| 319 | rend_DrawSimpleBitmapcxx . . $ rend_DrawSimpleBitmap(b1146eedae1e1d0b).(bm_array[i * w + t], dx, dy); |
| 320 | } |
| 321 | } |
| 322 | rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(1); |
| 323 | } |
| 324 | |
| 325 | // given a chunked bitmap, renders it.scaled |
| 326 | void rend_DrawScaledChunkedBitmapcxx . . $ rend_DrawScaledChunkedBitmap(a8bf607edbcedb63).(chunked_bitmapcxx . . $ chunked_bitmap# *chunk, int x, int y, int neww, int newh, uint8_tcxx . . $ uint8_t# alpha) { |
| 327 | int *bm_array = chunk->bm_arraycxx . . $ chunked_bitmap#bm_array.; |
| 328 | int w = chunk->wcxx . . $ chunked_bitmap#w.; |
| 329 | int h = chunk->hcxx . . $ chunked_bitmap#h.; |
| 330 | int piece_w; |
| 331 | int piece_h; |
| 332 | int screen_w, screen_h; |
| 333 | int i, t; |
| 334 | |
| 335 | float scalew, scaleh; |
| 336 | |
| 337 | scalew = ((float)neww) / ((float)chunk->pwcxx . . $ chunked_bitmap#pw.); |
| 338 | scaleh = ((float)newh) / ((float)chunk->phcxx . . $ chunked_bitmap#ph.); |
| 339 | piece_w = scalew * ((float)bm_wcxx . . $ bm_w(9b79fb6aee4c0440).(bm_array[0], 0)); |
| 340 | piece_h = scaleh * ((float)bm_hcxx . . $ bm_h(9b79fb6aee4c0440).(bm_array[0], 0)); |
| 341 | rend_GetProjectionParameterscxx . . $ rend_GetProjectionParameters(ce8f7825f8908cfa).(&screen_w, &screen_h); |
| 342 | rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!); |
| 343 | rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.); |
| 344 | rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_MONOcxx . . $ CM_MONO.); |
| 345 | rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(0); |
| 346 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_CONSTANT_TEXTUREcxx . . $ `lib/renderer.h:402:9`!); |
| 347 | rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(alpha); |
| 348 | rend_SetWrapTypecxx . . $ rend_SetWrapType(da524b148887c0e7).(WT_WRAPcxx . . $ WT_WRAP.); |
| 349 | for (i = 0; i < h; i++) { |
| 350 | for (t = 0; t < w; t++) { |
| 351 | int dx = x + (piece_w * t); |
| 352 | int dy = y + (piece_h * i); |
| 353 | int dw, dh; |
| 354 | if ((dx + piece_w) > screen_w) |
| 355 | dw = piece_w - ((dx + piece_w) - screen_w); |
| 356 | else |
| 357 | dw = piece_w; |
| 358 | if ((dy + piece_h) > screen_h) |
| 359 | dh = piece_h - ((dy + piece_h) - screen_h); |
| 360 | else |
| 361 | dh = piece_h; |
| 362 | |
| 363 | float u2 = (float)dw / (float)piece_w; |
| 364 | float v2 = (float)dh / (float)piece_h; |
| 365 | rend_DrawScaledBitmapcxx . . $ rend_DrawScaledBitmap(bffd21ce5f93b71b).(dx, dy, dx + dw, dy + dh, bm_array[i * w + t], 0, 0, u2, v2); |
| 366 | } |
| 367 | } |
| 368 | rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(1); |
| 369 | } |
| 370 | |
| 371 | // Sets some global preferences for the renderer |
| 372 | int rend_SetPreferredStatecxx . . $ rend_SetPreferredState(9d6d139eb250c11d).(renderer_preferred_statecxx . . $ renderer_preferred_state# *pref_state) { |
| 373 | int retval = 1; |
| 374 | renderer_preferred_statecxx . . $ renderer_preferred_state# old_state = gpu_preferred_statecxx . . $ gpu_preferred_state.; |
| 375 | |
| 376 | gpu_preferred_statecxx . . $ gpu_preferred_state. =cxx . . $ renderer_preferred_state#`operator=`(50e6b83d03d7b456). *pref_state; |
| 377 | if (gpu_statecxx . . $ gpu_state..inittedcxx . . $ rendering_state#initted.) { |
| 378 | int reinit = 0; |
| 379 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Inside pref state!\n"); |
| 380 | |
| 381 | // Change gamma if needed |
| 382 | if (pref_state->widthcxx . . $ renderer_preferred_state#width. != gpu_statecxx . . $ gpu_state..screen_widthcxx . . $ rendering_state#screen_width. || pref_state->heightcxx . . $ renderer_preferred_state#height. != gpu_statecxx . . $ gpu_state..screen_heightcxx . . $ rendering_state#screen_height. || |
| 383 | old_state.bit_depthcxx . . $ renderer_preferred_state#bit_depth. != pref_state->bit_depthcxx . . $ renderer_preferred_state#bit_depth.) { |
| 384 | reinit = 1; |
| 385 | } |
| 386 | |
| 387 | if (reinit) { |
| 388 | retval = rend_ReInitcxx . . $ rend_ReInit(b126dc7c1de90089).(); |
| 389 | } else { |
| 390 | if (old_state.gammacxx . . $ renderer_preferred_state#gamma. != pref_state->gammacxx . . $ renderer_preferred_state#gamma.) { |
| 391 | rend_SetGammaValuecxx . . $ rend_SetGammaValue(9364e6e7bff7660).(pref_state->gammacxx . . $ renderer_preferred_state#gamma.); |
| 392 | } |
| 393 | } |
| 394 | } else { |
| 395 | gpu_preferred_statecxx . . $ gpu_preferred_state. =cxx . . $ renderer_preferred_state#`operator=`(50e6b83d03d7b456). *pref_state; |
| 396 | } |
| 397 | |
| 398 | return retval; |
| 399 | } |
| 400 | |
| 401 | // Draws a simple bitmap at the specified x,y location |
| 402 | void rend_DrawSimpleBitmapcxx . . $ rend_DrawSimpleBitmap(b1146eedae1e1d0b).(int bm_handle, int x, int y) { |
| 403 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_CONSTANT_TEXTUREcxx . . $ `lib/renderer.h:402:9`!); |
| 404 | rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(255); |
| 405 | rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.); |
| 406 | rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_MONOcxx . . $ CM_MONO.); |
| 407 | rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!); |
| 408 | rend_SetFilteringcxx . . $ rend_SetFiltering(4af4fd0e2b26c4ac).(0); |
| 409 | rend_DrawScaledBitmapcxx . . $ rend_DrawScaledBitmap(bffd21ce5f93b71b).(x, y, x + bm_wcxx . . $ bm_w(9b79fb6aee4c0440).(bm_handle, 0), y + bm_hcxx . . $ bm_h(9b79fb6aee4c0440).(bm_handle, 0), bm_handle, 0, 0, 1, 1); |
| 410 | rend_SetFilteringcxx . . $ rend_SetFiltering(4af4fd0e2b26c4ac).(1); |
| 411 | } |
| 412 | |
| 413 | // Fills in the passed in pointer with the current rendering state |
| 414 | void rend_GetRenderStatecxx . . $ rend_GetRenderState(2ca0d60fb0cb1bea).(rendering_statecxx . . $ rendering_state# *rstate) { memcpy(rstate, &gpu_statecxx . . $ gpu_state., sizeof(rendering_statecxx . . $ rendering_state#)); } |
| 415 | |
| 416 | // Preuploads a texture to the video card |
| 417 | void rend_PreUploadTextureToCardcxx . . $ rend_PreUploadTextureToCard(3e454b8ccf442868).(int handle, int map_type) {} |
| 418 | |
| 419 | // Frees an uploaded texture from the video card |
| 420 | void rend_FreePreUploadedTexturecxx . . $ rend_FreePreUploadedTexture(3e454b8ccf442868).(int handle, int map_type) {} |
| 421 | |
| 422 | // Returns 1 if there is mid video memory, 2 if there is low vid memory, or 0 if there is large vid memory |
| 423 | int rend_LowVidMemcxx . . $ rend_LowVidMem(b126dc7c1de90089).(void) { return 0; } |
| 424 | |
| 425 | // Returns 1 if the renderer supports bumpmapping |
| 426 | int rend_SupportsBumpmappingcxx . . $ rend_SupportsBumpmapping(b126dc7c1de90089).(void) { return 0; } |
| 427 | |
| 428 | // Sets a bumpmap to be rendered, or turns off bumpmapping altogether |
| 429 | void rend_SetBumpmapReadyStatecxx . . $ rend_SetBumpmapReadyState(3e454b8ccf442868).(int state, int map) {} |
| 430 | |
| 431 | // returns rendering statistics for the frame |
| 432 | void rend_GetStatisticscxx . . $ rend_GetStatistics(65752c52ae58fada).(tRendererStatscxx . . $ tRendererStats# *stats) { |
| 433 | if (Renderer_inittedcxx . . $ Renderer_initted.) { |
| 434 | stats->poly_countcxx . . $ tRendererStats#poly_count. = gpu_last_frame_polys_drawncxx . . $ gpu_last_frame_polys_drawn.; |
| 435 | stats->vert_countcxx . . $ tRendererStats#vert_count. = gpu_last_frame_verts_processedcxx . . $ gpu_last_frame_verts_processed.; |
| 436 | stats->texture_uploadscxx . . $ tRendererStats#texture_uploads. = gpu_last_uploadedcxx . . $ gpu_last_uploaded.; |
| 437 | } else { |
| 438 | memset(stats, 0, sizeof(tRendererStatscxx . . $ tRendererStats#)); |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | #ifdef DEDICATED_ONLY |
| 443 | |
| 444 | void rend_DrawPolygon2D(int, g3Point **, int, int) {} |
| 445 | void rend_DrawPolygon3D(int, g3Point **, int, int) {} |
| 446 | |
| 447 | #else |
| 448 | |
| 449 | // Takes nv vertices and draws the 2D polygon defined by those vertices. |
| 450 | // Uses bitmap "handle" as a texture |
| 451 | void rend_DrawPolygon2Dcxx . . $ rend_DrawPolygon2D(1464bdba6025a51).(int handle, g3Pointcxx . . $ g3Point# **p, int nv) { |
| 452 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(nv < 100); |
| 453 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(gpu_Overlay_type == OT_NONEcxx . . $ `lib/renderer.h:333:9`!); |
| 454 | |
| 455 | g3_RefreshTransformscxx . . $ g3_RefreshTransforms(b45ddcbc8423892c).(true); |
| 456 | |
| 457 | if (UseMultitexturecxx . . $ UseMultitexture.) { |
| 458 | gpu_SetMultitextureBlendModecxx . . $ gpu_SetMultitextureBlendMode(b45ddcbc8423892c).(false); |
| 459 | } |
| 460 | |
| 461 | int xAdd = gpu_statecxx . . $ gpu_state..clip_x1cxx . . $ rendering_state#clip_x1.; |
| 462 | int yAdd = gpu_statecxx . . $ gpu_state..clip_y1cxx . . $ rendering_state#clip_y1.; |
| 463 | |
| 464 | float fr, fg, fb; |
| 465 | if (gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state. == LS_FLAT_GOURAUDcxx . . $ LS_FLAT_GOURAUD. || gpu_statecxx . . $ gpu_state..cur_texture_qualitycxx . . $ rendering_state#cur_texture_quality. == 0) { |
| 466 | float scale = 1.0f / 255.0f; |
| 467 | fr = GR_COLOR_REDcxx . . $ GR_COLOR_RED(4c679297bf94b9eb).(gpu_statecxx . . $ gpu_state..cur_colorcxx . . $ rendering_state#cur_color.) * scale; |
| 468 | fg = GR_COLOR_GREENcxx . . $ GR_COLOR_GREEN(4c679297bf94b9eb).(gpu_statecxx . . $ gpu_state..cur_colorcxx . . $ rendering_state#cur_color.) * scale; |
| 469 | fb = GR_COLOR_BLUEcxx . . $ GR_COLOR_BLUE(4c679297bf94b9eb).(gpu_statecxx . . $ gpu_state..cur_colorcxx . . $ rendering_state#cur_color.) * scale; |
| 470 | } |
| 471 | |
| 472 | // make sure our bitmap is ready to be drawn |
| 473 | gpu_BindTexturecxx . . $ gpu_BindTexture(b1146eedae1e1d0b).(handle, MAP_TYPE_BITMAPcxx . . $ `lib/renderer.h:362:9`!, 0); |
| 474 | |
| 475 | float alpha = gpu_Alpha_multipliercxx . . $ gpu_Alpha_multiplier. * gpu_Alpha_factorcxx . . $ gpu_Alpha_factor.; |
| 476 | |
| 477 | PosColorUVVertexcxx . . $ PosColorUVVertex# *vData = &vArraycxx . . $ vArray.[0]; |
| 478 | |
| 479 | // Specify our coordinates |
| 480 | int i; |
| 481 | for (i = 0; i < nv; ++i, ++vData) { |
| 482 | g3Pointcxx . . $ g3Point# *pnt = p[i]; |
| 483 | |
| 484 | if (gpu_statecxx . . $ gpu_state..cur_alpha_typecxx . . $ rendering_state#cur_alpha_type. & ATF_VERTEXcxx . . $ `lib/renderer.h:396:9`!) { |
| 485 | // the alpha should come from the vertex |
| 486 | alpha = pnt->p3_acxx . . $ `lib/3d.h:256:9`! * gpu_Alpha_multipliercxx . . $ gpu_Alpha_multiplier. * gpu_Alpha_factorcxx . . $ gpu_Alpha_factor.; |
| 487 | } |
| 488 | |
| 489 | // If we have a lighting model, apply the correct lighting! |
| 490 | if (gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state. == LS_FLAT_GOURAUDcxx . . $ LS_FLAT_GOURAUD. || gpu_statecxx . . $ gpu_state..cur_texture_qualitycxx . . $ rendering_state#cur_texture_quality. == 0) { |
| 491 | // pull the color from the constant color data |
| 492 | vData->colorcxx . . $ PosColorUVVertex#color..rcxx . . $ color_array#r. = fr; |
| 493 | vData->colorcxx . . $ PosColorUVVertex#color..gcxx . . $ color_array#g. = fg; |
| 494 | vData->colorcxx . . $ PosColorUVVertex#color..bcxx . . $ color_array#b. = fb; |
| 495 | vData->colorcxx . . $ PosColorUVVertex#color..acxx . . $ color_array#a. = alpha; |
| 496 | } else if (gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state. != LS_NONEcxx . . $ LS_NONE.) { |
| 497 | // Do lighting based on intensity (MONO) or colored (RGB) |
| 498 | if (gpu_statecxx . . $ gpu_state..cur_color_modelcxx . . $ rendering_state#cur_color_model. == CM_MONOcxx . . $ CM_MONO.) { |
| 499 | vData->colorcxx . . $ PosColorUVVertex#color..rcxx . . $ color_array#r. = pnt->p3_lcxx . . $ `lib/3d.h:252:9`!; |
| 500 | vData->colorcxx . . $ PosColorUVVertex#color..gcxx . . $ color_array#g. = pnt->p3_lcxx . . $ `lib/3d.h:252:9`!; |
| 501 | vData->colorcxx . . $ PosColorUVVertex#color..bcxx . . $ color_array#b. = pnt->p3_lcxx . . $ `lib/3d.h:252:9`!; |
| 502 | vData->colorcxx . . $ PosColorUVVertex#color..acxx . . $ color_array#a. = alpha; |
| 503 | } else { |
| 504 | vData->colorcxx . . $ PosColorUVVertex#color..rcxx . . $ color_array#r. = pnt->p3_rcxx . . $ `lib/3d.h:253:9`!; |
| 505 | vData->colorcxx . . $ PosColorUVVertex#color..gcxx . . $ color_array#g. = pnt->p3_gcxx . . $ `lib/3d.h:254:9`!; |
| 506 | vData->colorcxx . . $ PosColorUVVertex#color..bcxx . . $ color_array#b. = pnt->p3_bcxx . . $ `lib/3d.h:255:9`!; |
| 507 | vData->colorcxx . . $ PosColorUVVertex#color..acxx . . $ color_array#a. = alpha; |
| 508 | } |
| 509 | } else { |
| 510 | // force white |
| 511 | vData->colorcxx . . $ PosColorUVVertex#color..rcxx . . $ color_array#r. = 1.0f; |
| 512 | vData->colorcxx . . $ PosColorUVVertex#color..gcxx . . $ color_array#g. = 1.0f; |
| 513 | vData->colorcxx . . $ PosColorUVVertex#color..bcxx . . $ color_array#b. = 1.0f; |
| 514 | vData->colorcxx . . $ PosColorUVVertex#color..acxx . . $ color_array#a. = alpha; |
| 515 | } |
| 516 | |
| 517 | vData->uvcxx . . $ PosColorUVVertex#uv..scxx . . $ tex_array#s. = pnt->p3_ucxx . . $ `lib/3d.h:250:9`!; |
| 518 | vData->uvcxx . . $ PosColorUVVertex#uv..tcxx . . $ tex_array#t. = pnt->p3_vcxx . . $ `lib/3d.h:251:9`!; |
| 519 | vData->uvcxx . . $ PosColorUVVertex#uv..rcxx . . $ tex_array#r. = 0.0f; |
| 520 | vData->uvcxx . . $ PosColorUVVertex#uv..wcxx . . $ tex_array#w. = 1.0f; |
| 521 | |
| 522 | // Finally, specify a vertex |
| 523 | vData->poscxx . . $ PosColorUVVertex#pos..xcxx . . $ vector#x. = pnt->p3_sxcxx . . $ g3Point#p3_sx. + xAdd; |
| 524 | vData->poscxx . . $ PosColorUVVertex#pos..ycxx . . $ vector#y. = pnt->p3_sycxx . . $ g3Point#p3_sy. + yAdd; |
| 525 | vData->poscxx . . $ PosColorUVVertex#pos..zcxx . . $ vector#z. = 0.0f; |
| 526 | } |
| 527 | |
| 528 | gpu_RenderPolygoncxx . . $ gpu_RenderPolygon(1c3023f92cf1bc74).(&vArraycxx . . $ vArray.[0], nv); |
| 529 | } |
| 530 | |
| 531 | |
| 532 | // Takes nv vertices and draws the 3D polygon defined by those vertices. |
| 533 | // Uses bitmap "handle" as a texture |
| 534 | void rend_DrawPolygon3Dcxx . . $ rend_DrawPolygon3D(3928f75259b907be).(int handle, g3Pointcxx . . $ g3Point# **p, int nv, int map_type) { |
| 535 | g3Pointcxx . . $ g3Point# *pnt; |
| 536 | int i; |
| 537 | float fr, fg, fb; |
| 538 | float alpha; |
| 539 | |
| 540 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(nv < 100); |
| 541 | |
| 542 | g3_RefreshTransformscxx . . $ g3_RefreshTransforms(b45ddcbc8423892c).(false); |
| 543 | |
| 544 | if (gpu_statecxx . . $ gpu_state..cur_texture_qualitycxx . . $ rendering_state#cur_texture_quality. == 0) { |
| 545 | gpu_DrawFlatPolygon3Dcxx . . $ gpu_DrawFlatPolygon3D(3ae387dc3696f211).(p, nv); |
| 546 | return; |
| 547 | } |
| 548 | |
| 549 | if (gpu_Overlay_typecxx . . $ gpu_Overlay_type. != OT_NONEcxx . . $ `lib/renderer.h:333:9`! && UseMultitexturecxx . . $ UseMultitexture.) { |
| 550 | rend_DrawMultitexturePolygon3Dcxx . . $ rend_DrawMultitexturePolygon3D(3928f75259b907be).(handle, p, nv, map_type); |
| 551 | return; |
| 552 | } |
| 553 | |
| 554 | if (gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state. == LS_FLAT_GOURAUDcxx . . $ LS_FLAT_GOURAUD.) { |
| 555 | fr = GR_COLOR_REDcxx . . $ GR_COLOR_RED(4c679297bf94b9eb).(gpu_statecxx . . $ gpu_state..cur_colorcxx . . $ rendering_state#cur_color.) / 255.0; |
| 556 | fg = GR_COLOR_GREENcxx . . $ GR_COLOR_GREEN(4c679297bf94b9eb).(gpu_statecxx . . $ gpu_state..cur_colorcxx . . $ rendering_state#cur_color.) / 255.0; |
| 557 | fb = GR_COLOR_BLUEcxx . . $ GR_COLOR_BLUE(4c679297bf94b9eb).(gpu_statecxx . . $ gpu_state..cur_colorcxx . . $ rendering_state#cur_color.) / 255.0; |
| 558 | } |
| 559 | |
| 560 | if (UseMultitexturecxx . . $ UseMultitexture.) { |
| 561 | gpu_SetMultitextureBlendModecxx . . $ gpu_SetMultitextureBlendMode(b45ddcbc8423892c).(false); |
| 562 | } |
| 563 | |
| 564 | gpu_BindTexturecxx . . $ gpu_BindTexture(b1146eedae1e1d0b).(handle, map_type, 0); |
| 565 | |
| 566 | alpha = gpu_Alpha_multipliercxx . . $ gpu_Alpha_multiplier. * gpu_Alpha_factorcxx . . $ gpu_Alpha_factor.; |
| 567 | |
| 568 | PosColorUVVertexcxx . . $ PosColorUVVertex# *vData = &vArraycxx . . $ vArray.[0]; |
| 569 | |
| 570 | // Specify our coordinates |
| 571 | for (i = 0; i < nv; i++, vData++) { |
| 572 | pnt = p[i]; |
| 573 | |
| 574 | // all points should be original |
| 575 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(pnt->p3_flags & PF_ORIGPOINTcxx . . $ `lib/3d.h:221:9`!); |
| 576 | |
| 577 | //////////////////////////////////////////// |
| 578 | if (pnt->p3_flagscxx . . $ g3Point#p3_flags. & PF_ORIGPOINTcxx . . $ `lib/3d.h:221:9`!) { |
| 579 | if (!(pnt->p3_flagscxx . . $ g3Point#p3_flags. & PF_PROJECTEDcxx . . $ `lib/3d.h:214:9`!)) { |
| 580 | g3_ProjectPointcxx . . $ g3_ProjectPoint(4c7ad40c64d4fb9c).(pnt); |
| 581 | } |
| 582 | |
| 583 | // get the original point |
| 584 | float origPoint[4]; |
| 585 | origPoint[0] = pnt->p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot..xcxx . . $ vector#x.; |
| 586 | origPoint[1] = pnt->p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot..ycxx . . $ vector#y.; |
| 587 | origPoint[2] = pnt->p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot..zcxx . . $ vector#z.; |
| 588 | origPoint[3] = 1.0f; |
| 589 | |
| 590 | // transform by the full transform |
| 591 | float view[4]; |
| 592 | g3_TransformVertcxx . . $ g3_TransformVert(f8d5765aeee8bc35).(view, origPoint, gTransformFullcxx . . $ gTransformFull.); |
| 593 | |
| 594 | vectorcxx . . $ vector# tempv = pnt->p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. -cxx . . $ operator-(b77b703cd1e43e33). View_positioncxx . . $ View_position.; |
| 595 | vectorcxx . . $ vector# testPt = tempv *cxx . . $ `operator*`(14b8f9ac5c1e7b85). Unscaled_matrixcxx . . $ Unscaled_matrix.; |
| 596 | |
| 597 | float screenX = pnt->p3_sxcxx . . $ g3Point#p3_sx. + gpu_statecxx . . $ gpu_state..clip_x1cxx . . $ rendering_state#clip_x1.; |
| 598 | float screenY = pnt->p3_sycxx . . $ g3Point#p3_sy. + gpu_statecxx . . $ gpu_state..clip_y1cxx . . $ rendering_state#clip_y1.; |
| 599 | |
| 600 | // normalize |
| 601 | float oOW = 1.0f / view[3]; |
| 602 | view[0] *= oOW; |
| 603 | view[1] *= oOW; |
| 604 | view[2] *= oOW; |
| 605 | |
| 606 | oOW *= 1.0f; |
| 607 | } |
| 608 | //////////////////////////////////////////// |
| 609 | |
| 610 | if (gpu_statecxx . . $ gpu_state..cur_alpha_typecxx . . $ rendering_state#cur_alpha_type. & ATF_VERTEXcxx . . $ `lib/renderer.h:396:9`!) { |
| 611 | alpha = pnt->p3_acxx . . $ `lib/3d.h:256:9`! * gpu_Alpha_multipliercxx . . $ gpu_Alpha_multiplier. * gpu_Alpha_factorcxx . . $ gpu_Alpha_factor.; |
| 612 | } |
| 613 | |
| 614 | // If we have a lighting model, apply the correct lighting! |
| 615 | if (gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state. != LS_NONEcxx . . $ LS_NONE.) { |
| 616 | if (gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state. == LS_FLAT_GOURAUDcxx . . $ LS_FLAT_GOURAUD.) { |
| 617 | vData->colorcxx . . $ PosColorUVVertex#color..rcxx . . $ color_array#r. = fr; |
| 618 | vData->colorcxx . . $ PosColorUVVertex#color..gcxx . . $ color_array#g. = fg; |
| 619 | vData->colorcxx . . $ PosColorUVVertex#color..bcxx . . $ color_array#b. = fb; |
| 620 | vData->colorcxx . . $ PosColorUVVertex#color..acxx . . $ color_array#a. = alpha; |
| 621 | } else { |
| 622 | // Do lighting based on intesity (MONO) or colored (RGB) |
| 623 | if (gpu_statecxx . . $ gpu_state..cur_color_modelcxx . . $ rendering_state#cur_color_model. == CM_MONOcxx . . $ CM_MONO.) { |
| 624 | vData->colorcxx . . $ PosColorUVVertex#color..rcxx . . $ color_array#r. = pnt->p3_lcxx . . $ `lib/3d.h:252:9`!; |
| 625 | vData->colorcxx . . $ PosColorUVVertex#color..gcxx . . $ color_array#g. = pnt->p3_lcxx . . $ `lib/3d.h:252:9`!; |
| 626 | vData->colorcxx . . $ PosColorUVVertex#color..bcxx . . $ color_array#b. = pnt->p3_lcxx . . $ `lib/3d.h:252:9`!; |
| 627 | vData->colorcxx . . $ PosColorUVVertex#color..acxx . . $ color_array#a. = alpha; |
| 628 | } else { |
| 629 | vData->colorcxx . . $ PosColorUVVertex#color..rcxx . . $ color_array#r. = pnt->p3_rcxx . . $ `lib/3d.h:253:9`!; |
| 630 | vData->colorcxx . . $ PosColorUVVertex#color..gcxx . . $ color_array#g. = pnt->p3_gcxx . . $ `lib/3d.h:254:9`!; |
| 631 | vData->colorcxx . . $ PosColorUVVertex#color..bcxx . . $ color_array#b. = pnt->p3_bcxx . . $ `lib/3d.h:255:9`!; |
| 632 | vData->colorcxx . . $ PosColorUVVertex#color..acxx . . $ color_array#a. = alpha; |
| 633 | } |
| 634 | } |
| 635 | } else { |
| 636 | vData->colorcxx . . $ PosColorUVVertex#color..rcxx . . $ color_array#r. = 1; |
| 637 | vData->colorcxx . . $ PosColorUVVertex#color..gcxx . . $ color_array#g. = 1; |
| 638 | vData->colorcxx . . $ PosColorUVVertex#color..bcxx . . $ color_array#b. = 1; |
| 639 | vData->colorcxx . . $ PosColorUVVertex#color..acxx . . $ color_array#a. = alpha; |
| 640 | } |
| 641 | |
| 642 | vData->uvcxx . . $ PosColorUVVertex#uv..scxx . . $ tex_array#s. = pnt->p3_ucxx . . $ `lib/3d.h:250:9`!; |
| 643 | vData->uvcxx . . $ PosColorUVVertex#uv..tcxx . . $ tex_array#t. = pnt->p3_vcxx . . $ `lib/3d.h:251:9`!; |
| 644 | vData->uvcxx . . $ PosColorUVVertex#uv..rcxx . . $ tex_array#r. = 0.0f; |
| 645 | vData->uvcxx . . $ PosColorUVVertex#uv..wcxx . . $ tex_array#w. = 1.0f; |
| 646 | |
| 647 | // Finally, specify a vertex |
| 648 | vData->poscxx . . $ PosColorUVVertex#pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). pnt->p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot.; |
| 649 | } |
| 650 | |
| 651 | // And draw! |
| 652 | gpu_RenderPolygoncxx . . $ gpu_RenderPolygon(1c3023f92cf1bc74).(&vArraycxx . . $ vArray.[0], nv); |
| 653 | |
| 654 | // If there is a lightmap to draw, draw it as well |
| 655 | if (gpu_Overlay_typecxx . . $ gpu_Overlay_type. != OT_NONEcxx . . $ `lib/renderer.h:333:9`!) { |
| 656 | return; // Temp fix until I figure out whats going on |
| 657 | Int3cxx . . $ `misc/pserror.h:247:9`!(); // Shouldn't reach here |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | #endif // DEDICATED_ONLY |
| 662 | |
| 663 | // Takes nv vertices and draws the polygon defined by those vertices. Uses bitmap "handle" |
| 664 | // as a texture |
| 665 | void rend_DrawMultitexturePolygon3Dcxx . . $ rend_DrawMultitexturePolygon3D(3928f75259b907be).(int handle, g3Pointcxx . . $ g3Point# **p, int nv, int map_type) { |
| 666 | g3Pointcxx . . $ g3Point# *pnt; |
| 667 | int i, fr, fg, fb; |
| 668 | float alpha; |
| 669 | |
| 670 | float one_over_square_res = 1.0 / GameLightmapscxx . . $ GameLightmaps.[gpu_Overlay_mapcxx . . $ gpu_Overlay_map.].square_rescxx . . $ bms_lightmap#square_res.; |
| 671 | float xscalar = (float)GameLightmapscxx . . $ GameLightmaps.[gpu_Overlay_mapcxx . . $ gpu_Overlay_map.].widthcxx . . $ bms_lightmap#width. * one_over_square_res; |
| 672 | float yscalar = (float)GameLightmapscxx . . $ GameLightmaps.[gpu_Overlay_mapcxx . . $ gpu_Overlay_map.].heightcxx . . $ bms_lightmap#height. * one_over_square_res; |
| 673 | |
| 674 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(nv < 100); |
| 675 | |
| 676 | if (gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state. == LS_NONEcxx . . $ LS_NONE.) { |
| 677 | fr = GR_COLOR_REDcxx . . $ GR_COLOR_RED(4c679297bf94b9eb).(gpu_statecxx . . $ gpu_state..cur_colorcxx . . $ rendering_state#cur_color.); |
| 678 | fg = GR_COLOR_GREENcxx . . $ GR_COLOR_GREEN(4c679297bf94b9eb).(gpu_statecxx . . $ gpu_state..cur_colorcxx . . $ rendering_state#cur_color.); |
| 679 | fb = GR_COLOR_BLUEcxx . . $ GR_COLOR_BLUE(4c679297bf94b9eb).(gpu_statecxx . . $ gpu_state..cur_colorcxx . . $ rendering_state#cur_color.); |
| 680 | } |
| 681 | |
| 682 | alpha = gpu_Alpha_multipliercxx . . $ gpu_Alpha_multiplier. * gpu_Alpha_factorcxx . . $ gpu_Alpha_factor.; |
| 683 | |
| 684 | PosColorUV2Vertexcxx . . $ PosColorUV2Vertex# *vData = &vArray2cxx . . $ vArray2.[0]; |
| 685 | |
| 686 | // Specify our coordinates |
| 687 | for (i = 0; i < nv; i++, vData++) { |
| 688 | pnt = p[i]; |
| 689 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(pnt->p3_flags & PF_ORIGPOINTcxx . . $ `lib/3d.h:221:9`!); |
| 690 | |
| 691 | if (gpu_statecxx . . $ gpu_state..cur_alpha_typecxx . . $ rendering_state#cur_alpha_type. & ATF_VERTEXcxx . . $ `lib/renderer.h:396:9`!) |
| 692 | alpha = pnt->p3_acxx . . $ `lib/3d.h:256:9`! * gpu_Alpha_multipliercxx . . $ gpu_Alpha_multiplier. * gpu_Alpha_factorcxx . . $ gpu_Alpha_factor.; |
| 693 | |
| 694 | // If we have a lighting model, apply the correct lighting! |
| 695 | if (gpu_statecxx . . $ gpu_state..cur_light_statecxx . . $ rendering_state#cur_light_state. != LS_NONEcxx . . $ LS_NONE.) { |
| 696 | // Do lighting based on intesity (MONO) or colored (RGB) |
| 697 | if (gpu_statecxx . . $ gpu_state..cur_color_modelcxx . . $ rendering_state#cur_color_model. == CM_MONOcxx . . $ CM_MONO.) { |
| 698 | vData->colorcxx . . $ PosColorUV2Vertex#color..rcxx . . $ color_array#r. = pnt->p3_lcxx . . $ `lib/3d.h:252:9`!; |
| 699 | vData->colorcxx . . $ PosColorUV2Vertex#color..gcxx . . $ color_array#g. = pnt->p3_lcxx . . $ `lib/3d.h:252:9`!; |
| 700 | vData->colorcxx . . $ PosColorUV2Vertex#color..bcxx . . $ color_array#b. = pnt->p3_lcxx . . $ `lib/3d.h:252:9`!; |
| 701 | vData->colorcxx . . $ PosColorUV2Vertex#color..acxx . . $ color_array#a. = alpha; |
| 702 | } else { |
| 703 | vData->colorcxx . . $ PosColorUV2Vertex#color..rcxx . . $ color_array#r. = pnt->p3_rcxx . . $ `lib/3d.h:253:9`!; |
| 704 | vData->colorcxx . . $ PosColorUV2Vertex#color..gcxx . . $ color_array#g. = pnt->p3_gcxx . . $ `lib/3d.h:254:9`!; |
| 705 | vData->colorcxx . . $ PosColorUV2Vertex#color..bcxx . . $ color_array#b. = pnt->p3_bcxx . . $ `lib/3d.h:255:9`!; |
| 706 | vData->colorcxx . . $ PosColorUV2Vertex#color..acxx . . $ color_array#a. = alpha; |
| 707 | } |
| 708 | } else { |
| 709 | vData->colorcxx . . $ PosColorUV2Vertex#color..rcxx . . $ color_array#r. = 1; |
| 710 | vData->colorcxx . . $ PosColorUV2Vertex#color..gcxx . . $ color_array#g. = 1; |
| 711 | vData->colorcxx . . $ PosColorUV2Vertex#color..bcxx . . $ color_array#b. = 1; |
| 712 | vData->colorcxx . . $ PosColorUV2Vertex#color..acxx . . $ color_array#a. = alpha; |
| 713 | } |
| 714 | |
| 715 | /* |
| 716 | // Texture this polygon! |
| 717 | float texw=1.0/(pnt->p3_z+Z_bias); |
| 718 | vData->uv0.s=pnt->p3_u*texw; |
| 719 | vData->uv0.t=pnt->p3_v*texw; |
| 720 | vData->uv0.r=0; |
| 721 | vData->uv0.w=texw; |
| 722 | |
| 723 | vData->uv1.s=pnt->p3_u2*xscalar*texw; |
| 724 | vData->uv1.t=pnt->p3_v2*yscalar*texw; |
| 725 | vData->uv1.r=0; |
| 726 | vData->uv1.w=texw; |
| 727 | */ |
| 728 | vData->uv0cxx . . $ PosColorUV2Vertex#uv0..scxx . . $ tex_array#s. = pnt->p3_ucxx . . $ `lib/3d.h:250:9`!; |
| 729 | vData->uv0cxx . . $ PosColorUV2Vertex#uv0..tcxx . . $ tex_array#t. = pnt->p3_vcxx . . $ `lib/3d.h:251:9`!; |
| 730 | vData->uv0cxx . . $ PosColorUV2Vertex#uv0..rcxx . . $ tex_array#r. = 0.0f; |
| 731 | vData->uv0cxx . . $ PosColorUV2Vertex#uv0..wcxx . . $ tex_array#w. = 1.0f; |
| 732 | |
| 733 | vData->uv1cxx . . $ PosColorUV2Vertex#uv1..scxx . . $ tex_array#s. = pnt->p3_u2cxx . . $ `lib/3d.h:257:9`! * xscalar; |
| 734 | vData->uv1cxx . . $ PosColorUV2Vertex#uv1..tcxx . . $ tex_array#t. = pnt->p3_v2cxx . . $ `lib/3d.h:258:9`! * yscalar; |
| 735 | vData->uv1cxx . . $ PosColorUV2Vertex#uv1..rcxx . . $ tex_array#r. = 0.0f; |
| 736 | vData->uv1cxx . . $ PosColorUV2Vertex#uv1..wcxx . . $ tex_array#w. = 1.0f; |
| 737 | |
| 738 | // Finally, specify a vertex |
| 739 | /* |
| 740 | vData->pos.x=pnt->p3_sx+x_add; |
| 741 | vData->pos.y=pnt->p3_sy+y_add; |
| 742 | vData->pos.z = -std::max(0,std::min(1.0,1.0-(1.0/(pnt->p3_z+Z_bias)))); |
| 743 | */ |
| 744 | vData->poscxx . . $ PosColorUV2Vertex#pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). pnt->p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot.; |
| 745 | } |
| 746 | |
| 747 | // make sure our bitmap is ready to be drawn |
| 748 | gpu_BindTexturecxx . . $ gpu_BindTexture(b1146eedae1e1d0b).(handle, map_type, 0); |
| 749 | |
| 750 | // make sure our bitmap is ready to be drawn |
| 751 | gpu_BindTexturecxx . . $ gpu_BindTexture(b1146eedae1e1d0b).(gpu_Overlay_mapcxx . . $ gpu_Overlay_map., MAP_TYPE_LIGHTMAPcxx . . $ `lib/renderer.h:363:9`!, 1); |
| 752 | |
| 753 | gpu_SetMultitextureBlendModecxx . . $ gpu_SetMultitextureBlendMode(b45ddcbc8423892c).(true); |
| 754 | |
| 755 | gpu_RenderPolygonUV2cxx . . $ gpu_RenderPolygonUV2(e7931de23695a417).(&vArray2cxx . . $ vArray2.[0], nv); |
| 756 | } |