MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / Window_Init

Function Window_Init

src/Window_OS2.c:248–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246*#########################################################################################################################*/
247void Window_PreInit(void) { }
248void Window_Init(void) {
249 ULONG rc;
250 PPIB pib;
251 DIVE_CAPS caps = {0};
252 FOURCC fccFormats[100] = {0};
253 HDC hdc;
254 HPS hps;
255 LONG screencaps[CAPS_DEVICE_POLYSET_POINTS];
256
257 /* Change process type code for use Win* API from VIO session */
258 DosGetInfoBlocks(NULL, &pib);
259 if (pib->pib_ultype == 2 || pib->pib_ultype == 0) {
260 /* VIO windowable or fullscreen protect-mode session */
261 pib->pib_ultype = 3; /* Presentation Manager protect-mode session */
262 }
263
264 habAnchor = WinInitialize(0);
265 if (habAnchor == NULLHANDLE) {
266 Process_Abort2(LOUSHORT(WinGetLastError(0)), "Initialization failed");
267 }
268 msgQueue = WinCreateMsgQueue(habAnchor, 0);
269 if (msgQueue == NULLHANDLE) {
270 Process_Abort2(LOUSHORT(WinGetLastError(habAnchor)), "Window queue creation failed");
271 }
272
273 // Init Dive
274 caps.pFormatData = fccFormats; //TODO do something with it.
275 caps.ulFormatLength = 100;
276 caps.ulStructLen = sizeof(DIVE_CAPS);
277 if (rc = DiveQueryCaps(&caps, DIVE_BUFFER_SCREEN)) {
278 Process_Abort2(rc, "DIVE: Could not get capabilities.");
279 }
280 if (caps.ulDepth < 24) {
281 Process_Abort2(rc, "DIVE: Too few colours");
282 }
283
284 rc = DiveOpen(&hDive, FALSE, NULL);
285 if (rc != DIVE_SUCCESS) {
286 Process_Abort2(rc, "DIVE: Display engine instance open failed");
287 }
288 // Everything is fine, so we set infos.
289 hps = WinGetScreenPS(HWND_DESKTOP);
290 hdc = GpiQueryDevice(hps);
291 DevQueryCaps(hdc, CAPS_FAMILY, CAPS_DEVICE_POLYSET_POINTS, screencaps);
292 WinReleasePS(hps);
293 DisplayInfo.Width = screencaps[CAPS_WIDTH];
294 DisplayInfo.Height = screencaps[CAPS_HEIGHT];
295 DisplayInfo.Depth = screencaps[CAPS_COLOR_BITCOUNT];
296 DisplayInfo.ScaleX = 1.0;
297 DisplayInfo.ScaleY = 1.0;
298 DisplayInfo.DPIScaling = Options_GetBool(OPT_DPI_SCALING, false);
299 Input.Sources = INPUT_SOURCE_NORMAL;
300}
301
302void Window_Create(int width, int height) {
303 ULONG ulFlags = FCF_SHELLPOSITION | FCF_TASKLIST

Callers 1

SetupProgramFunction · 0.70

Calls 2

Options_GetBoolFunction · 0.85
Process_Abort2Function · 0.70

Tested by

no test coverage detected