Debian Codegraph @

lib/linux/lnxdraw.h

raw symbols SCIP
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 __LNXDRAW_H_
20 #define __LNXDRAW_H_
21
22 // #include "dyna_xwin.h"
23 // #include "dyna_xext.h"
24
25 #include <SDL.h>
26
27 struct LnxVideoDesc {
28 // Display *dDisplay; // Which X-Windows Display to use
29 int nScreen; // Which X-Windows screen to use
30 };
31
32 struct LnxWindowDesc {
33 uint32_t bpp; // bits per pixel.
34 uint32_t dwFlags; // flags for window
35 uint32_t dwWidth; // width of the created window
36 uint32_t dwHeight; // height of the created window
37 uint32_t dwXPos; // Top-Left X position
38 uint32_t dwYPos; // Top-Left Y position
39
40 char *lpszName; // Window name
41 // Window *pre_created_window; // Window already created
42 // XVisualInfo pre_created_visinfo;
43 };
44 // #define LNXDRAWF_USEPRECREATEDWIN 0x01
45
46 struct LnxWindow {
47 // XSizeHints *lpSizeHints;
48 // XWMHints *lpWmHints;
49 // XClassHint *lpClassHints;
50 // Visual *lpXvisual;
51 // Window wWindow;
52 SDL_Surface *surface;
53 // bool bHaveSharedMemory;
54 bool bLocked;
55 // bool WindowPreCreated;
56 // XVisualInfo viVisualInfo;
57 // Colormap cmColorMap;
58 uint8_t *lpBuffer;
59 // GC m_GC;
60 // XImage *lpImage;
61 // XShmSegmentInfo shmInfo;
62 uint32_t dwWidth; // width of the created window
63 uint32_t dwHeight; // height of the created window
64 bool fullScreen;
65
66 uint32_t lock_x, lock_y, lock_w, lock_h;
67 uint8_t *lock_ptr;
68 };
69
70 //////////////////////
71 // LnxDraw_InitVideo
72 //////////////////////
73 // Initializes the Linux video system (for X-Windows)
74 //
75 // Returns:
76 // 0 : no error
77 // -1 : invalid parameter
78 // -2 : already initialized
79 int LnxDraw_InitVideo(LnxVideoDesc *ldesc);
80
81 /////////////////////////
82 // LnxDraw_CreateWindow
83 /////////////////////////
84
85 // Creates and displays a window
86 //
87 // Returns:
88 // 0 : no error (handle in lphandle)
89 // -1 : invalid parameter
90 // -2 : Display not opened
91 // -3 : Out of memory
92 int LnxDraw_CreateWindow(LnxWindowDesc *ldesc, LnxWindow **lphandle);
93
94 //////////////////////////
95 // LnxDraw_DestroyWindow
96 //////////////////////////
97 // Closes and deletes a window
98 //
99 // Returns:
100 // 0 : no error
101 // -1 : invalid parameter
102 int LnxDraw_DestroyWindow(LnxWindow *handle);
103
104 ////////////////////////
105 // LnxDraw_LockSurface
106 ////////////////////////
107 // Locks the window surface, giving you a pointer to write data to
108 //
109 // Returns:
110 // true : success
111 // false : error
112 bool LnxDraw_LockSurface(LnxWindow *wnd, uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2,
113 uint8_t **ptr, int *pitch);
114
115 //////////////////////////
116 // LnxDraw_UnlockSurface
117 //////////////////////////
118 // Unlocks the window surface, blitting the buffer
119 //
120 void LnxDraw_UnlockSurface(LnxWindow *wnd, uint8_t *ptr);
121
122 ////////////////////////////
123 /// LnxDraw_Blit
124 ////////////////////////////
125 // Blits a buffer to the window
126 //
127 // Returns:
128 // 0 : no error
129 // -1 : invalid parameter
130 // -2 : unknown error
131 int LnxDraw_Blit(LnxWindow *wnd, uint8_t *ptr, uint32_t x, uint32_t y, uint32_t w, uint32_t h);
132
133 ////////////////////////
134 // LnxDraw_GetRGBMasks
135 ////////////////////////
136 // Returns the RGB masks for the display
137 //
138 // Returns:
139 // 0 : no error
140 // -1 : invalid parameters
141 int LnxDraw_GetRGBMasks(LnxWindow *wnd, uint32_t *r, uint32_t *g, uint32_t *b);
142
143 #endif