| 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/ddgr_win32/ddgrWin32.h $ |
| 21 | * $Revision: 3 $ |
| 22 | * $Date: 4/23/98 6:38p $ |
| 23 | * $Author: Jason $ |
| 24 | * |
| 25 | * DDGR v2.0 Win32 Implementation |
| 26 | * |
| 27 | * $Log: /DescentIII/Main/ddgr_win32/ddgrWin32.h $ |
| 28 | * |
| 29 | * 3 4/23/98 6:38p Jason |
| 30 | * made bitmaps use 1555 format |
| 31 | * |
| 32 | * 2 9/12/97 4:13p Samir |
| 33 | * Added some private data access functions and more DirectX |
| 34 | * functionality. |
| 35 | * |
| 36 | * 1 6/12/97 6:33p Samir |
| 37 | * Initial revision |
| 38 | * |
| 39 | * $NoKeywords: $ |
| 40 | */ |
| 41 | |
| 42 | #ifndef DDGRWIN32_H |
| 43 | #define DDGRWIN32_H |
| 44 | |
| 45 | #include "ddgr.h" |
| 46 | #include "pstypes.h" |
| 47 | |
| 48 | /* Subsystem constants |
| 49 | |
| 50 | as of v2.0 |
| 51 | */ |
| 52 | const int DDGR_GDI_SUBSYSTEM = 1, // GDI subsystem |
| 53 | DDGR_GDIX_SUBSYSTEM = 2, // GDIX subsystem (GDI+DirectX) |
| 54 | DDGR_DX_SUBSYSTEM = 3; // DIRECTX subsystem |
| 55 | |
| 56 | /* Internal Library Data |
| 57 | |
| 58 | */ |
| 59 | struct tDDGRInternalData { |
| 60 | bool init; // Is library currently initialized |
| 61 | int subsystem; // Current active subsystem |
| 62 | }; |
| 63 | |
| 64 | /* Global externs |
| 65 | */ |
| 66 | extern tDDGRInternalData DDGR_lib_data; |
| 67 | extern char *DDGR_subsystem_names[]; |
| 68 | extern int DDGR_subsystems[]; |
| 69 | |
| 70 | /* Macros |
| 71 | */ |
| 72 | #define LIB_DATA(_c) DDGR_lib_data._c |
| 73 | |
| 74 | inline unsigned DDGR_MAKERGB16(ddgr_color c) { |
| 75 | uint8_t r, g, b; |
| 76 | r = (uint8_t)((c & 0x00ff0000) >> 16); |
| 77 | g = (uint8_t)((c & 0x0000ff00) >> 8); |
| 78 | b = (uint8_t)(c & 0x000000ff); |
| 79 | |
| 80 | return (((r >> 3) << 10) + ((g >> 3) << 5) + (b >> 3)); |
| 81 | } |
| 82 | |
| 83 | inline int DDGR_COLOR_RED(ddgr_color c) { |
| 84 | unsigned r = (uint8_t)((c & 0x00ff0000) >> 16); |
| 85 | return (int)r; |
| 86 | } |
| 87 | |
| 88 | inline int DDGR_COLOR_GREEN(ddgr_color c) { |
| 89 | unsigned g = (uint8_t)((c & 0x0000ff00) >> 8); |
| 90 | return (int)g; |
| 91 | } |
| 92 | |
| 93 | inline int DDGR_COLOR_BLUE(ddgr_color c) { |
| 94 | unsigned b = (uint8_t)(c & 0x000000ff); |
| 95 | return (int)b; |
| 96 | } |
| 97 | |
| 98 | /* Functions Internal |
| 99 | */ |
| 100 | |
| 101 | void ddgr_FatalError(const char *fmt, ...); |
| 102 | void ddgr_PushError(const char *fmt, ...); |
| 103 | |
| 104 | #endif |