FossilOrigin-Name: bf625526315ec71308288cbf7e91dc425ca1dd9e4e762a4c264cf2235c06558e
73 lines
1.7 KiB
Objective-C
73 lines
1.7 KiB
Objective-C
/*
|
|
* Copyright (c) 2022 Jonathan Schleifer <js@nil.im>
|
|
*
|
|
* All rights reserved.
|
|
*
|
|
* This file is part of Obj3DEngine. It may be distributed under the terms of
|
|
* the Q Public License 1.0, which can be found in the file LICENSE.QPL
|
|
* included in the packaging of this file.
|
|
*
|
|
* Alternatively, it may be distributed under the terms of the GNU General
|
|
* Public License, either version 2 or 3, which can be found in the file
|
|
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of
|
|
* this file.
|
|
*/
|
|
|
|
#import "O3DWinAPIWindow.h"
|
|
|
|
#ifdef OF_WINDOWS
|
|
# include <winuser.h>
|
|
|
|
@implementation O3DWinAPIWindow
|
|
@synthesize hWnd = _hWnd;
|
|
|
|
- (instancetype)initWithSize: (OFSize)size
|
|
{
|
|
self = [super init];
|
|
|
|
@try {
|
|
_wndClass = (WNDCLASS){
|
|
.lpfnWndProc = (WNDPROC)DefWindowProc,
|
|
.hInstance = GetModuleHandle(NULL),
|
|
.lpszClassName = "O3DMainWindowClass"
|
|
};
|
|
|
|
if (!RegisterClass(&_wndClass))
|
|
@throw [OFInitializationFailedException
|
|
exceptionWithClass: self.class];
|
|
|
|
if ((_hWnd = CreateWindowEx(WS_EX_APPWINDOW,
|
|
_wndClass.lpszClassName, "O3DMainWindow", WS_OVERLAPPED,
|
|
CW_USEDEFAULT, CW_USEDEFAULT, size.width, size.height,
|
|
NULL, NULL, _wndClass.hInstance, NULL)) == NULL)
|
|
@throw [OFInitializationFailedException
|
|
exceptionWithClass: self.class];
|
|
|
|
ShowWindow(_hWnd, SW_NORMAL);
|
|
UpdateWindow(_hWnd);
|
|
} @catch (id e) {
|
|
[self release];
|
|
@throw e;
|
|
}
|
|
|
|
return self;
|
|
}
|
|
|
|
- (instancetype)init
|
|
{
|
|
OF_INVALID_INIT_METHOD
|
|
}
|
|
|
|
- (void)dealloc
|
|
{
|
|
if (_hWnd != NULL)
|
|
OFEnsure(DestroyWindow(_hWnd));
|
|
|
|
if (_wndClass.lpszClassName != NULL)
|
|
OFEnsure(UnregisterClass(
|
|
_wndClass.lpszClassName, _wndClass.hInstance));
|
|
|
|
[super dealloc];
|
|
}
|
|
@end
|
|
#endif
|