From 3ea64a61d05ae7d2dec987d16e4a63119e399f93 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 11 Jun 2020 23:38:33 +1000 Subject: [PATCH] Generate a 64 bit mac icon file and fixup Window.m 64 mac build doesn't show icon quite yet, still WIP --- misc/CCicon_mac64 | Bin 0 -> 16852 bytes misc/Window.m | 110 ++++++++++++++++++++++--------------------- misc/buildbot.sh | 3 +- misc/mac_icon_gen.cs | 4 +- readme.md | 4 +- 5 files changed, 62 insertions(+), 59 deletions(-) create mode 100644 misc/CCicon_mac64 diff --git a/misc/CCicon_mac64 b/misc/CCicon_mac64 new file mode 100644 index 0000000000000000000000000000000000000000..df6b103ba94f6eb6daa8b9c75c51ba0f833575bc GIT binary patch literal 16852 zcmd^HId3FI6gJDshmarziGa|S2<*fb*`NgpvJF;(Y_x(Ey9prSU_&zh0}}oKksaBB z!0YjS$oGBU_kG`XQQvsqY|ZO>-P6-OK4x1gSH144SMPi8)vKf1({sLcotKmI!G}5e zk50&+qVR=I`ua?#)p*JNCqHs?|97;}7txw$4$>ps)K@fG{^E7{P5Fj?_U(_)-qE~7 z{EYj58fDGzr{8}4;~m3j)XtCO0l&v416GEdpX&7b>l+>Xqw_B{{gF;jbuusL2x~8Va79VcgA4GeXl$6BdxnDo$IK61WA2O|n zTeo+bdI)=5h`4Xd-f8L~s6U9fQ=P}WFE8)Cz)!e=*-Y7vU&2i~$X5J>oBW*c@;uw{6K;-E zqO%1*;r6mO*TX}{Pq+zJU0t0T9v)U38yo8Q_*fks9jW#8b=A|;lN9%;e%SagFE7>B z)|OgaTvRJ7D+=;uV$LJnro9IT2i3{RiM2n-)zHx3&_S5^fw!@-(a}dsON*MDn^TY> zs4fUM*$;Uv7E^0$Yp%S}zuAV$Vd00pO+5~tN8iu^;v~t;bMEIPFXdxn zV~)0neZ9TCNwPFGH6_v1p7Nmhx3{-N{_XAUao>agb#-+)>LFI1o}M~zKo=yREk_*T zu@pA9#a>%`^IlN=3kwTYS%H_!h#1X%Wnf^yH+~-L5#OK_6IZI`p!g>zCmsF5cMlE@ zthjb}cjIx3lgdqMF7 zE9X5kGvkS$!myHiGNW1Q&Uq8{8(#pIsMWkpP6G%WAefN#(bVmIVgTx z{KtG}%9&1?W5K$S$4Sfsyq;e=DE`gOO@|EdiF7cVZ8(m$wl)V(X-~u3y3s-LpPijK z@DB|QIb=1lrBdcH>qlx;C(dU`skU)}~Z=1kkU2h|P3{#eryKg#{=acz1bK9nQQ@_IOPpyyJK zI#`QJ`=BuJLoUQ8Q-;pYPKUf)emC0Wg|ZF5P48yAzP`SM3^=2(trfz;kNv#aH_Cjz zcEih`ab7n6$KD%jXkHgI_6dBxgg$uPu<%0`u3yN;W#Bj^n#(ycF_EyP*@pHKW__Fi z@P2LcG}?rPA2Pw-rW`0^9B^4o`K2=F158p~tb?$R#yJ#l@_OiB@)JM!Q+fZ5GiWY5 z=0}{9m~vt4^1Y1tob$lh27Jt{lWG}j2hNXZKkvWwd-C}As&3!A;4Fg2Lh1|mVJG+m z=E(W^c@Yn_F>|iNRPgh;nfO&yRH(wjLcII-djIYF`xop>r1^&WM-H1xK48|PvTY40 z=>WcBI~M`&qM{aG1F*t^<=<$1L-+FB^WGiF9{&C-GqR zCfs!zTLb`8yj=CbzvIT)CYQs+f-=@-w)n{F5sfo{eg;H3Kz~>hqYl*z3Od-(EPq zp1b;kxqcx055&*CaP#M`dcgi7OL3>H2VIe3Ir4|*=NzXOE%`%CH;i~S&Z6fOCu15@ zz_P`e)GKic@7ajy!yHPWrF(d M#j9Ul>YqgTA1t!+zyJUM literal 0 HcmV?d00001 diff --git a/misc/Window.m b/misc/Window.m index 136acf37b..7b64c5b1e 100644 --- a/misc/Window.m +++ b/misc/Window.m @@ -14,6 +14,7 @@ static NSApplication* appHandle; static NSWindow* winHandle; static int windowX, windowY; +struct GraphicsMode { int R, G, B, A, IsIndexed; }; extern void Window_CommonInit(void); extern int Window_MapKey(UInt32 key); @@ -21,6 +22,7 @@ extern int Window_MapKey(UInt32 key); @end @implementation ClassiCubeWindowDelegate +static void Window_RefreshBounds(void); - (void)windowDidResize:(NSNotification *)notification { @@ -36,13 +38,13 @@ extern int Window_MapKey(UInt32 key); - (void)windowDidBecomeKey:(NSNotification *)notification { - Window_Focused = true; + WindowInfo.Focused = true; Event_RaiseVoid(&WindowEvents.FocusChanged); } - (void)windowDidResignKey:(NSNotification *)notification { - Window_Focused = false; + WindowInfo.Focused = false; Event_RaiseVoid(&WindowEvents.FocusChanged); } @@ -73,8 +75,8 @@ static void Window_RefreshBounds(void) { windowX = (int)rect.origin.x; windowY = (int)rect.origin.y; - Window_Width = (int)rect.size.width; - Window_Height = (int)rect.size.height; + WindowInfo.Width = (int)rect.size.width; + WindowInfo.Height = (int)rect.size.height; Platform_Log2("WINPOS: %i, %i", &windowX, &windowY); } @@ -94,15 +96,15 @@ void Window_Init1(void) { Window_CommonInit(); } -#define Display_CentreX(width) (Display_Bounds.X + (Display_Bounds.Width - width) / 2) -#define Display_CentreY(height) (Display_Bounds.Y + (Display_Bounds.Height - height) / 2) +#define Display_CentreX(width) (DisplayInfo.X + (DisplayInfo.Width - width) / 2) +#define Display_CentreY(height) (DisplayInfo.Y + (DisplayInfo.Height - height) / 2) void Window_Create1(int width, int height) { NSRect rect; // TODO: don't set, RefreshBounds - Window_Width = width; - Window_Height = height; - Window_Exists = true; + WindowInfo.Width = width; + WindowInfo.Height = height; + WindowInfo.Exists = true; rect.origin.x = Display_CentreX(width); rect.origin.y = Display_CentreY(height); @@ -159,37 +161,37 @@ void Window_ProcessEvents1(void) { case NSOtherMouseUp: key = Window_MapMouse([ev buttonNumber]); if (key) Input_SetPressed(key, false); - break; - - case NSKeyDown: - key = Window_MapKey([ev keyCode]); + break; + + case NSKeyDown: + key = Window_MapKey([ev keyCode]); if (key) Input_SetPressed(key, true); - break; - - case NSKeyUp: - key = Window_MapKey([ev keyCode]); + break; + + case NSKeyUp: + key = Window_MapKey([ev keyCode]); if (key) Input_SetPressed(key, false); break; - case NSScrollWheel: - Mouse_SetWheel(Mouse_Wheel + [ev deltaY]); - break; - + case NSScrollWheel: + Mouse_ScrollWheel([ev deltaY]); + break; + case NSMouseMoved: case NSLeftMouseDragged: case NSRightMouseDragged: - case NSOtherMouseDragged: - loc = [NSEvent mouseLocation]; - dx = [ev deltaX]; - dy = [ev deltaY]; - - mouseX = (int)loc.x - windowX; - mouseY = (int)loc.y - windowY; - /* need to flip Y coordinates because cocoa has window origin at bottom left */ - mouseY = Window_Height - mouseY; - Pointer_SetPosition(0, mouseX, mouseY); - - if (Input_RawMode) Event_RaiseMove(&PointerEvents.RawMoved, 0, dx, dy); + case NSOtherMouseDragged: + loc = [NSEvent mouseLocation]; + dx = [ev deltaX]; + dy = [ev deltaY]; + + mouseX = (int)loc.x - windowX; + mouseY = (int)loc.y - windowY; + /* need to flip Y coordinates because cocoa has window origin at bottom left */ + mouseY = WindowInfo.Height - mouseY; + Pointer_SetPosition(0, mouseX, mouseY); + + if (Input_RawMode) Event_RaiseRawMove(&PointerEvents.RawMoved, dx, dy); break; } @@ -198,20 +200,20 @@ void Window_ProcessEvents1(void) { } } -static NSOpenGLContext* ctxHandle; -static NSOpenGLPixelFormat* SelectPixelFormat(struct GraphicsMode* mode, bool fullscreen) { - NSOpenGLPixelFormat* fmt; +static NSOpenGLContext* ctxHandle; +static NSOpenGLPixelFormat* SelectPixelFormat(struct GraphicsMode* mode, bool fullscreen) { + NSOpenGLPixelFormat* fmt; uint32_t attribs[7] = { NSOpenGLPFAColorSize, 0, NSOpenGLPFADepthSize, GLCONTEXT_DEFAULT_DEPTH, NSOpenGLPFADoubleBuffer, 0, 0 - }; - - attribs[1] = mode->R + mode->G + mode->B + mode->A; - attribs[5] = fullscreen ? NSOpenGLPFAFullScreen : 0; - - fmt = [NSOpenGLPixelFormat alloc]; - return [fmt initWithAttributes: attribs]; + }; + + attribs[1] = mode->R + mode->G + mode->B + mode->A; + attribs[5] = fullscreen ? NSOpenGLPFAFullScreen : 0; + + fmt = [NSOpenGLPixelFormat alloc]; + return [fmt initWithAttributes: attribs]; } void GLContext_Init1(struct GraphicsMode* mode) { @@ -227,15 +229,15 @@ void GLContext_Init1(struct GraphicsMode* mode) { if (!fmt) Logger_Abort("Choosing pixel format"); ctxHandle = [NSOpenGLContext alloc]; - ctxHandle = [ctxHandle initWithFormat:fmt shareContext:Nil]; - if (!ctxHandle) Logger_Abort("Failed to create OpenGL context"); + ctxHandle = [ctxHandle initWithFormat:fmt shareContext:Nil]; + if (!ctxHandle) Logger_Abort("Failed to create OpenGL context"); - view = [winHandle contentView]; - [ctxHandle setView:view]; - /* TODO: Support high DPI OSX */ - /* [ctxHandle setWantsBestResolutionOpenGLSurface:YES]; */ - - [fmt release]; + view = [winHandle contentView]; + [ctxHandle setView:view]; + /* TODO: Support high DPI OSX */ + /* [ctxHandle setWantsBestResolutionOpenGLSurface:YES]; */ + + [fmt release]; [ctxHandle makeCurrentContext]; [ctxHandle update]; } @@ -245,8 +247,8 @@ void GLContext_Update1(void) { } void GLContext_Free1(void) { - [NSOpenGLContext clearCurrentContext]; - [ctxHandle clearDrawable]; + [NSOpenGLContext clearCurrentContext]; + [ctxHandle clearDrawable]; [ctxHandle release]; } @@ -256,6 +258,6 @@ bool GLContext_SwapBuffers1(void) { } void GLContext_SetFpsLimit1(bool vsync, float minFrameMs) { - GLint value = vsync ? 1 : 0; + GLint value = vsync ? 1 : 0; [ctxHandle setValues: &value forParameter: NSOpenGLCPSwapInterval]; } diff --git a/misc/buildbot.sh b/misc/buildbot.sh index a79a605e0..999c5eed6 100644 --- a/misc/buildbot.sh +++ b/misc/buildbot.sh @@ -77,8 +77,9 @@ build_mac32() { build_mac64() { echo "Building mac64.." + cp $SOURCE_DIR/misc/CCicon_mac64 $SOURCE_DIR/src/CCicon_mac64.o rm cc-osx64 - $MAC64_CC *.c $ALL_FLAGS $MACOS_FLAGS -DCC_COMMIT_SHA=\"$LATEST\" -o cc-osx64 -framework Cocoa -framework OpenGL -lobjc + $MAC64_CC *.c $ALL_FLAGS $MACOS_FLAGS CCicon_mac64.o -DCC_COMMIT_SHA=\"$LATEST\" -o cc-osx64 -framework Cocoa -framework OpenGL -lobjc } build_web() { diff --git a/misc/mac_icon_gen.cs b/misc/mac_icon_gen.cs index f967fb2fa..583cf1409 100644 --- a/misc/mac_icon_gen.cs +++ b/misc/mac_icon_gen.cs @@ -5,8 +5,8 @@ using System.IO; namespace test { public static class Program { - const string src = @"H:\PortableApps\GitPortable\App\Git\ClassicalSharp\misc\CCIcon.ico"; - const string dst = @"H:\PortableApps\GitPortable\App\Git\ClassicalSharp\misc\CCIcon.c"; + const string src = "CCIcon.ico"; + const string dst = "CCIcon.c"; static void DumpIcon(StreamWriter sw, int width, int height) { using (Icon icon = new Icon(src, width, height)) { diff --git a/readme.md b/readme.md index 4bffb1535..3a3058962 100644 --- a/readme.md +++ b/readme.md @@ -69,11 +69,11 @@ Although the regular linux compiliation flags will work fine, to take full advan #### macOS (32 bit) -```gcc *.c -o ClassiCube -framework Carbon -framework AGL -framework OpenGL``` +```cc *.c -o ClassiCube -framework Carbon -framework AGL -framework OpenGL``` #### macOS (64 bit) -```gcc *.c -o ClassiCube -framework Cocoa -framework OpenGL -lobjc``` +```cc *.c -o ClassiCube -framework Cocoa -framework OpenGL -lobjc``` #### FreeBSD