| 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/ddgrWin32GDI.h $ |
| 21 | * $Revision: 2 $ |
| 22 | * $Date: 9/12/97 4:13p $ |
| 23 | * $Author: Samir $ |
| 24 | * |
| 25 | * DDGR v2.0 GDI(X) implementation,. |
| 26 | * |
| 27 | * $Log: /DescentIII/Main/ddgr_win32/ddgrWin32GDI.h $ |
| 28 | * |
| 29 | * 2 9/12/97 4:13p Samir |
| 30 | * Added some private data access functions and more DirectX |
| 31 | * functionality. |
| 32 | * |
| 33 | * 1 6/12/97 6:34p Samir |
| 34 | * initial revision |
| 35 | * |
| 36 | * $NoKeywords: $ |
| 37 | */ |
| 38 | |
| 39 | #ifndef DDGRWIN32GDI_H |
| 40 | #define DDGRWIN32GDI_H |
| 41 | |
| 42 | #include <windows.h> |
| 43 | |
| 44 | #include "ddgr.h" |
| 45 | #include "ddraw.h" |
| 46 | |
| 47 | class oeApplication; |
| 48 | |
| 49 | /* Data structures |
| 50 | */ |
| 51 | #define GDI_MAX_DEVMODES 30 |
| 52 | struct tDDGRGDIInternalData // Internal data for GDI subsystem |
| 53 | { |
| 54 | bool init; // is library initialized |
| 55 | bool ddraw; // do we use DirectDraw for display mode changing. |
| 56 | LPDIRECTDRAW lpDD; // DirectDraw Object for video manipulation |
| 57 | HWND hPrimaryWnd; // window owning display |
| 58 | HDC hOffscreenDC; // DC for our generic surfaces. |
| 59 | bool fullscreen; // Should we run in fullscreen? |
| 60 | int vidrefs; // Number of surface references to hPrimaryWnd. |
| 61 | int olddispmode; // old display mode for GDI subsystem only (not GDIX) |
| 62 | DEVMODE devmodes[GDI_MAX_DEVMODES]; // Device modes for GDI subsystem (not GDIX) |
| 63 | }; |
| 64 | |
| 65 | struct tGDISurface { |
| 66 | HBITMAP hbm; // windows DIB section bitmap handle |
| 67 | void *data; // pointer to bitmap bits |
| 68 | bool backbuffer; // is this a dual-page surface? (hbm is offscreen) |
| 69 | int rowsize; // rowsize of bitmap bits array |
| 70 | HWND hwnd; // window attached to surface |
| 71 | }; |
| 72 | |
| 73 | struct tDIBHeader // used to create and manipulate DIBs (a 16/32BPP surface only) |
| 74 | { |
| 75 | BITMAPINFOHEADER bmi; |
| 76 | DWORD red_mask; |
| 77 | DWORD green_mask; |
| 78 | DWORD blue_mask; |
| 79 | }; |
| 80 | |
| 81 | struct tDIBHeader8 // used to create and manipulate DIBs (a 16/32BPP surface only) |
| 82 | { |
| 83 | BITMAPINFOHEADER bmi; |
| 84 | RGBQUAD rgb[256]; |
| 85 | }; |
| 86 | |
| 87 | /* Externs */ |
| 88 | extern tDDGRGDIInternalData DDGR_GDI_lib_data; |
| 89 | |
| 90 | /* Macros */ |
| 91 | #define GDI_DATA(_c) DDGR_GDI_lib_data._c |
| 92 | |
| 93 | /* Functions |
| 94 | */ |
| 95 | |
| 96 | // Initializes GDI subsystem |
| 97 | bool ddgr_gdi_Init(oeApplication *app, bool fullscreen, bool ddraw); |
| 98 | |
| 99 | // Closes GDI subsystem |
| 100 | void ddgr_gdi_Close(); |
| 101 | |
| 102 | // Initializes the display for use with the GDI subsystem. |
| 103 | bool ddgr_gdi_surf_InitVideo(ddgr_surface *sf); |
| 104 | |
| 105 | // Deinitializes the video surface |
| 106 | void ddgr_gdi_surf_CloseVideo(ddgr_surface *sf); |
| 107 | |
| 108 | // flips the buffers in a surface. really only useful for video screens |
| 109 | bool ddgr_gdi_surf_FlipVideo(ddgr_surface *sf); |
| 110 | |
| 111 | /* input: |
| 112 | sf->name is optional. |
| 113 | sf->w, sf->h, sf->bpp are mandatory |
| 114 | sf->type and sf->flags are mandatory. |
| 115 | output: |
| 116 | sf->obj = surface object. |
| 117 | sf->locks = 0 |
| 118 | */ |
| 119 | bool ddgr_gdi_surf_Create(ddgr_surface *sf); |
| 120 | void ddgr_gdi_surf_Destroy(ddgr_surface *sf); |
| 121 | |
| 122 | /* retrieves a pointer to surface memory. allowed to lock one surface multiple times. |
| 123 | ptr is the returned pointer to surface memory. used to unlock surface also |
| 124 | rowsize is the size in bytes of one row of memory. |
| 125 | */ |
| 126 | bool ddgr_gdi_surf_Lock(ddgr_surface *sf, void **ptr, int *rowsize); |
| 127 | bool ddgr_gdi_surf_Unlock(ddgr_surface *sf, void *ptr); |
| 128 | |
| 129 | // attaches an OS handle to a surface |
| 130 | void ddgr_gdi_surf_AttachHandle(ddgr_surface *sf, unsigned handle); |
| 131 | |
| 132 | // The only graphic primatives |
| 133 | // clear |
| 134 | // blt. |
| 135 | void ddgr_gdi_surf_Clear(ddgr_surface *dsf, ddgr_color col, int l, int t, int w, int h); |
| 136 | bool ddgr_gdi_surf_Blt(ddgr_surface *dsf, int dx, int dy, ddgr_surface *ssf, int sx, int sy, int sw, int sh); |
| 137 | |
| 138 | #endif |