mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-11 00:26:28 -04:00
Split Window_Create into Window_Create2D/3D
This commit is contained in:
parent
f595a5bca8
commit
50ee66a6f8
@ -663,7 +663,7 @@ static void Game_RunLoop(void) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Game_Run(int width, int height, const cc_string* title) {
|
void Game_Run(int width, int height, const cc_string* title) {
|
||||||
Window_Create(width, height);
|
Window_Create3D(width, height);
|
||||||
Window_SetTitle(title);
|
Window_SetTitle(title);
|
||||||
Window_Show();
|
Window_Show();
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ static void Launcher_Free(void) {
|
|||||||
|
|
||||||
void Launcher_Run(void) {
|
void Launcher_Run(void) {
|
||||||
static const cc_string title = String_FromConst(GAME_APP_TITLE);
|
static const cc_string title = String_FromConst(GAME_APP_TITLE);
|
||||||
Window_Create(640, 400);
|
Window_Create2D(640, 400);
|
||||||
#ifdef CC_BUILD_MOBILE
|
#ifdef CC_BUILD_MOBILE
|
||||||
Window_LockLandscapeOrientation(Options_GetBool(OPT_LANDSCAPE_MODE, false));
|
Window_LockLandscapeOrientation(Options_GetBool(OPT_LANDSCAPE_MODE, false));
|
||||||
#endif
|
#endif
|
||||||
|
@ -79,8 +79,12 @@ CC_VAR extern struct _WinData {
|
|||||||
|
|
||||||
/* Initialises state for window. Also sets Display_ members. */
|
/* Initialises state for window. Also sets Display_ members. */
|
||||||
void Window_Init(void);
|
void Window_Init(void);
|
||||||
/* Creates the window as the given size at centre of the screen. */
|
/* Creates a window of the given size at centre of the screen. */
|
||||||
void Window_Create(int width, int height);
|
/* NOTE: The created window is compatible with 2D drawing */
|
||||||
|
void Window_Create2D(int width, int height);
|
||||||
|
/* Creates a window of the given size at centre of the screen. */
|
||||||
|
/* NOTE: The created window is compatible with 3D rendering */
|
||||||
|
void Window_Create3D(int width, int height);
|
||||||
/* Sets the text of the titlebar above the window. */
|
/* Sets the text of the titlebar above the window. */
|
||||||
CC_API void Window_SetTitle(const cc_string* title);
|
CC_API void Window_SetTitle(const cc_string* title);
|
||||||
|
|
||||||
|
@ -254,13 +254,15 @@ static void Window_RemakeSurface(void) {
|
|||||||
Platform_LogConst("OK window created..");
|
Platform_LogConst("OK window created..");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_Create(int width, int height) {
|
static void DoCreateWindow(void) {
|
||||||
WindowInfo.Exists = true;
|
WindowInfo.Exists = true;
|
||||||
/* actual window creation is done when processSurfaceCreated is received */
|
/* actual window creation is done when processSurfaceCreated is received */
|
||||||
Window_RemakeSurface();
|
Window_RemakeSurface();
|
||||||
/* always start as fullscreen */
|
/* always start as fullscreen */
|
||||||
Window_EnterFullscrene();
|
Window_EnterFullscrene();
|
||||||
}
|
}
|
||||||
|
void Window_Create2D(int width, int height) { DoCreateWindow(); }
|
||||||
|
void Window_Create3D(int width, int height) { DoCreateWindow(); }
|
||||||
|
|
||||||
void Window_SetTitle(const cc_string* title) {
|
void Window_SetTitle(const cc_string* title) {
|
||||||
/* TODO: Implement this somehow */
|
/* TODO: Implement this somehow */
|
||||||
|
@ -479,7 +479,7 @@ static void ApplyIcon(void) {
|
|||||||
static void ApplyIcon(void) { }
|
static void ApplyIcon(void) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Window_Create(int width, int height) {
|
static void DoCreateWindow(int width, int height) {
|
||||||
Rect r;
|
Rect r;
|
||||||
OSStatus res;
|
OSStatus res;
|
||||||
ProcessSerialNumber psn;
|
ProcessSerialNumber psn;
|
||||||
@ -507,6 +507,8 @@ void Window_Create(int width, int height) {
|
|||||||
winId = GetNativeWindowFromWindowRef(win_handle);
|
winId = GetNativeWindowFromWindowRef(win_handle);
|
||||||
ApplyIcon();
|
ApplyIcon();
|
||||||
}
|
}
|
||||||
|
void Window_Create2D(int width, int height) { DoCreateWindow(width, height); }
|
||||||
|
void Window_Create3D(int width, int height) { DoCreateWindow(width, height); }
|
||||||
|
|
||||||
void Window_SetTitle(const cc_string* title) {
|
void Window_SetTitle(const cc_string* title) {
|
||||||
UInt8 str[NATIVE_STR_LEN];
|
UInt8 str[NATIVE_STR_LEN];
|
||||||
|
@ -35,18 +35,19 @@ void Window_Init(void) {
|
|||||||
DisplayInfo.ScaleY = 1;
|
DisplayInfo.ScaleY = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_Create(int width, int height) {
|
static void DoCreateWindow(int width, int height, int flags) {
|
||||||
int x = Display_CentreX(width);
|
int x = Display_CentreX(width);
|
||||||
int y = Display_CentreY(height);
|
int y = Display_CentreY(height);
|
||||||
|
|
||||||
/* TODO: Don't set this flag for launcher window */
|
win_handle = SDL_CreateWindow(NULL, x, y, width, height, flags);
|
||||||
win_handle = SDL_CreateWindow(NULL, x, y, width, height, SDL_WINDOW_OPENGL);
|
|
||||||
if (!win_handle) Window_SDLFail("creating window");
|
if (!win_handle) Window_SDLFail("creating window");
|
||||||
|
|
||||||
RefreshWindowBounds();
|
RefreshWindowBounds();
|
||||||
WindowInfo.Exists = true;
|
WindowInfo.Exists = true;
|
||||||
WindowInfo.Handle = win_handle;
|
WindowInfo.Handle = win_handle;
|
||||||
}
|
}
|
||||||
|
void Window_Create2D(int width, int height) { DoCreateWindow(width, height, 0); }
|
||||||
|
void Window_Create3D(int width, int height) { DoCreateWindow(width, height, SDL_WINDOW_OPENGL); }
|
||||||
|
|
||||||
void Window_SetTitle(const cc_string* title) {
|
void Window_SetTitle(const cc_string* title) {
|
||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
|
@ -376,7 +376,7 @@ void Window_Init(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern void interop_InitContainer(void);
|
extern void interop_InitContainer(void);
|
||||||
void Window_Create(int width, int height) {
|
static void DoCreateWindow(void) {
|
||||||
WindowInfo.Exists = true;
|
WindowInfo.Exists = true;
|
||||||
WindowInfo.Focused = true;
|
WindowInfo.Focused = true;
|
||||||
HookEvents();
|
HookEvents();
|
||||||
@ -385,6 +385,8 @@ void Window_Create(int width, int height) {
|
|||||||
WindowInfo.Height = interop_CanvasHeight();
|
WindowInfo.Height = interop_CanvasHeight();
|
||||||
interop_InitContainer();
|
interop_InitContainer();
|
||||||
}
|
}
|
||||||
|
void Window_Create2D(int width, int height) { DoCreateWindow(); }
|
||||||
|
void Window_Create3D(int width, int height) { DoCreateWindow(); }
|
||||||
|
|
||||||
extern void interop_SetPageTitle(const char* title);
|
extern void interop_SetPageTitle(const char* title);
|
||||||
void Window_SetTitle(const cc_string* title) {
|
void Window_SetTitle(const cc_string* title) {
|
||||||
|
@ -285,7 +285,7 @@ static ATOM DoRegisterClass(void) {
|
|||||||
return RegisterClassExA((const WNDCLASSEXA*)&wc);
|
return RegisterClassExA((const WNDCLASSEXA*)&wc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DoCreateWindow(ATOM atom, int width, int height) {
|
static void CreateWindowHandle(ATOM atom, int width, int height) {
|
||||||
cc_result res;
|
cc_result res;
|
||||||
RECT r;
|
RECT r;
|
||||||
/* Calculate final window rectangle after window decorations are added (titlebar, borders etc) */
|
/* Calculate final window rectangle after window decorations are added (titlebar, borders etc) */
|
||||||
@ -307,7 +307,7 @@ static void DoCreateWindow(ATOM atom, int width, int height) {
|
|||||||
Logger_Abort2(res, "Failed to create window");
|
Logger_Abort2(res, "Failed to create window");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_Create(int width, int height) {
|
static void DoCreateWindow(int width, int height) {
|
||||||
ATOM atom;
|
ATOM atom;
|
||||||
win_instance = GetModuleHandleA(NULL);
|
win_instance = GetModuleHandleA(NULL);
|
||||||
/* TODO: UngroupFromTaskbar(); */
|
/* TODO: UngroupFromTaskbar(); */
|
||||||
@ -315,7 +315,7 @@ void Window_Create(int width, int height) {
|
|||||||
height = Display_ScaleY(height);
|
height = Display_ScaleY(height);
|
||||||
|
|
||||||
atom = DoRegisterClass();
|
atom = DoRegisterClass();
|
||||||
DoCreateWindow(atom, width, height);
|
CreateWindowHandle(atom, width, height);
|
||||||
RefreshWindowBounds();
|
RefreshWindowBounds();
|
||||||
|
|
||||||
win_DC = GetDC(win_handle);
|
win_DC = GetDC(win_handle);
|
||||||
@ -323,6 +323,8 @@ void Window_Create(int width, int height) {
|
|||||||
WindowInfo.Exists = true;
|
WindowInfo.Exists = true;
|
||||||
WindowInfo.Handle = win_handle;
|
WindowInfo.Handle = win_handle;
|
||||||
}
|
}
|
||||||
|
void Window_Create2D(int width, int height) { DoCreateWindow(width, height); }
|
||||||
|
void Window_Create3D(int width, int height) { DoCreateWindow(width, height); }
|
||||||
|
|
||||||
void Window_SetTitle(const cc_string* title) {
|
void Window_SetTitle(const cc_string* title) {
|
||||||
WCHAR str[NATIVE_STR_LEN];
|
WCHAR str[NATIVE_STR_LEN];
|
||||||
|
@ -278,7 +278,7 @@ static void ApplyIcon(void) {
|
|||||||
static void ApplyIcon(void) { }
|
static void ApplyIcon(void) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Window_Create(int width, int height) {
|
static void DoCreateWindow(int width, int height) {
|
||||||
XSetWindowAttributes attributes = { 0 };
|
XSetWindowAttributes attributes = { 0 };
|
||||||
XSizeHints hints = { 0 };
|
XSizeHints hints = { 0 };
|
||||||
Atom protocols[2];
|
Atom protocols[2];
|
||||||
@ -340,6 +340,8 @@ void Window_Create(int width, int height) {
|
|||||||
XGetInputFocus(win_display, &focus, &focusRevert);
|
XGetInputFocus(win_display, &focus, &focusRevert);
|
||||||
if (focus == win_handle) WindowInfo.Focused = true;
|
if (focus == win_handle) WindowInfo.Focused = true;
|
||||||
}
|
}
|
||||||
|
void Window_Create2D(int width, int height) { DoCreateWindow(width, height); }
|
||||||
|
void Window_Create3D(int width, int height) { DoCreateWindow(width, height); }
|
||||||
|
|
||||||
void Window_SetTitle(const cc_string* title) {
|
void Window_SetTitle(const cc_string* title) {
|
||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
|
@ -262,7 +262,7 @@ static void ApplyIcon(void) { }
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define WIN_MASK (NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask | NSMiniaturizableWindowMask)
|
#define WIN_MASK (NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask | NSMiniaturizableWindowMask)
|
||||||
void Window_Create(int width, int height) {
|
static void DoCreateWindow(void) {
|
||||||
CCWindowDelegate* del;
|
CCWindowDelegate* del;
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
|
|
||||||
@ -287,6 +287,8 @@ void Window_Create(int width, int height) {
|
|||||||
MakeContentView();
|
MakeContentView();
|
||||||
ApplyIcon();
|
ApplyIcon();
|
||||||
}
|
}
|
||||||
|
void Window_Create2D(int width, int height) { DoCreateWindow(width, height); }
|
||||||
|
void Window_Create3D(int width, int height) { DoCreateWindow(width, height); }
|
||||||
|
|
||||||
void Window_SetTitle(const cc_string* title) {
|
void Window_SetTitle(const cc_string* title) {
|
||||||
char raw[NATIVE_STR_LEN];
|
char raw[NATIVE_STR_LEN];
|
||||||
|
@ -123,7 +123,7 @@ void Window_Init(void) {
|
|||||||
DisplayInfo.ScaleY = 1; // TODO dpi scale
|
DisplayInfo.ScaleY = 1; // TODO dpi scale
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_Create(int width, int height) {
|
static void DoCreateWindow(void) {
|
||||||
CGRect bounds = UIScreen.mainScreen.bounds;
|
CGRect bounds = UIScreen.mainScreen.bounds;
|
||||||
controller = [CCViewController alloc];
|
controller = [CCViewController alloc];
|
||||||
winHandle = [[CCWindow alloc] initWithFrame:bounds];
|
winHandle = [[CCWindow alloc] initWithFrame:bounds];
|
||||||
@ -134,6 +134,8 @@ void Window_Create(int width, int height) {
|
|||||||
WindowInfo.Width = bounds.size.width;
|
WindowInfo.Width = bounds.size.width;
|
||||||
WindowInfo.Height = bounds.size.height;
|
WindowInfo.Height = bounds.size.height;
|
||||||
}
|
}
|
||||||
|
void Window_Create2D(int width, int height) { DoCreateWindow(); }
|
||||||
|
void Window_Create3D(int width, int height) { DoCreateWindow(); }
|
||||||
void Window_SetSize(int width, int height) { }
|
void Window_SetSize(int width, int height) { }
|
||||||
|
|
||||||
void Window_Close(void) { }
|
void Window_Close(void) { }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user