mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-09 15:28:21 -04:00
Generate a 64 bit mac icon file and fixup Window.m
64 mac build doesn't show icon quite yet, still WIP
This commit is contained in:
parent
18fce97418
commit
3ea64a61d0
BIN
misc/CCicon_mac64
Normal file
BIN
misc/CCicon_mac64
Normal file
Binary file not shown.
110
misc/Window.m
110
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];
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -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)) {
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user