| 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 | |
| 19 | #ifndef __HARDWARE_INTERNAL_H__ |
| 20 | #define __HARDWARE_INTERNAL_H__ |
| 21 | |
| 22 | #include "pserror.h" |
| 23 | |
| 24 | #define MAX_POINTS_IN_POLY 100 |
| 25 | |
| 26 | // These structs are for drawing with vertex arrays |
| 27 | // Useful for fast indexing |
| 28 | struct color_array { |
| 29 | float r, g, b, a; |
| 30 | }; |
| 31 | |
| 32 | struct tex_array { |
| 33 | float s, t, r, w; |
| 34 | }; |
| 35 | |
| 36 | struct PosColorUVVertex { |
| 37 | vector pos; |
| 38 | color_array color; |
| 39 | tex_array uv; |
| 40 | }; |
| 41 | |
| 42 | struct PosColorUV2Vertex { |
| 43 | vector pos; |
| 44 | color_array color; |
| 45 | tex_array uv0; |
| 46 | tex_array uv1; |
| 47 | }; |
| 48 | |
| 49 | void FreeTempPoint(g3Point *p); |
| 50 | void InitFreePoints(void); |
| 51 | void ClipLine(g3Point **p0, g3Point **p1, uint8_t codes_or); |
| 52 | |
| 53 | // Verify that all the temp points are free, and free them it they are not. |
| 54 | #ifdef _DEBUG |
| 55 | void CheckTempPoints(); |
| 56 | #else |
| 57 | #define CheckTempPoints() |
| 58 | #endif |
| 59 | |
| 60 | extern int Window_width, Window_height; // the actual integer width & height |
| 61 | extern float Window_w2, Window_h2; // width,height/2 |
| 62 | extern float View_zoom; |
| 63 | extern vector View_position, Matrix_scale; |
| 64 | extern matrix View_matrix, Unscaled_matrix; |
| 65 | extern float Far_clip_z; |
| 66 | |
| 67 | // For custom clipping plane |
| 68 | extern uint8_t Clip_custom; |
| 69 | extern float Clip_plane_distance; |
| 70 | extern vector Clip_plane; |
| 71 | |
| 72 | extern float gTransformViewPort[4][4]; |
| 73 | extern float gTransformProjection[4][4]; |
| 74 | extern float gTransformModelView[4][4]; |
| 75 | extern float gTransformFull[4][4]; |
| 76 | void g3_UpdateFullTransform(); |
| 77 | void g3_ForceTransformRefresh(void); |
| 78 | |
| 79 | void rend_TransformSetToPassthru(void); |
| 80 | void rend_TransformSetViewport(int lx, int ty, int width, int height); |
| 81 | void rend_TransformSetProjection(float trans[4][4]); |
| 82 | void rend_TransformSetModelView(float trans[4][4]); |
| 83 | |
| 84 | int rend_ReInit(); |
| 85 | float rend_GetAlphaMultiplier(); |
| 86 | |
| 87 | void gpu_SetMultitextureBlendMode(bool state); |
| 88 | void gpu_BindTexture(int handle, int map_type, int slot); |
| 89 | void gpu_RenderPolygon(PosColorUVVertex *vData, uint32_t nv); |
| 90 | void gpu_RenderPolygonUV2(PosColorUV2Vertex *vData, uint32_t nv); |
| 91 | void gpu_DrawFlatPolygon3D(g3Point **p, int nv); |
| 92 | void rend_DrawMultitexturePolygon3D(int handle, g3Point **p, int nv, int map_type); |
| 93 | |
| 94 | #endif |