fix cursor thing for x11/gdi, also format
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
This commit is contained in:
parent
9d65e9c6bf
commit
6d7fe3271f
8 changed files with 231 additions and 228 deletions
|
|
@ -12,78 +12,82 @@
|
||||||
static double deg = 0;
|
static double deg = 0;
|
||||||
|
|
||||||
static void draw(void) {
|
static void draw(void) {
|
||||||
int i;
|
int i;
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glRotatef(deg, 1, 0, 0);
|
glRotatef(deg, 1, 0, 0);
|
||||||
glRotatef(deg, 0, 1, 0);
|
glRotatef(deg, 0, 1, 0);
|
||||||
glRotatef(deg, 0, 0, 1);
|
glRotatef(deg, 0, 0, 1);
|
||||||
|
|
||||||
for (i = 0; i < 6; i++) {
|
for(i = 0; i < 6; i++) {
|
||||||
if (i == 0)
|
if(i == 0)
|
||||||
glColor3f(1, 0, 0);
|
glColor3f(1, 0, 0);
|
||||||
if (i == 1)
|
if(i == 1)
|
||||||
glColor3f(0, 1, 0);
|
glColor3f(0, 1, 0);
|
||||||
if (i == 2)
|
if(i == 2)
|
||||||
glColor3f(1, 1, 0);
|
glColor3f(1, 1, 0);
|
||||||
if (i == 3)
|
if(i == 3)
|
||||||
glColor3f(0, 0, 1);
|
glColor3f(0, 0, 1);
|
||||||
if (i == 4)
|
if(i == 4)
|
||||||
glColor3f(1, 0, 1);
|
glColor3f(1, 0, 1);
|
||||||
if (i == 5)
|
if(i == 5)
|
||||||
glColor3f(0, 1, 1);
|
glColor3f(0, 1, 1);
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glNormal3f(0, 1, 0);
|
glNormal3f(0, 1, 0);
|
||||||
glVertex3f(-1, 1, -1);
|
glVertex3f(-1, 1, -1);
|
||||||
glVertex3f(-1, 1, 1);
|
glVertex3f(-1, 1, 1);
|
||||||
glVertex3f(1, 1, 1);
|
glVertex3f(1, 1, 1);
|
||||||
glVertex3f(1, 1, -1);
|
glVertex3f(1, 1, -1);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
if (i < 3)
|
if(i < 3)
|
||||||
glRotatef(90, 0, 0, 1);
|
glRotatef(90, 0, 0, 1);
|
||||||
if (i == 3)
|
if(i == 3)
|
||||||
glRotatef(90, 1, 0, 0);
|
glRotatef(90, 1, 0, 0);
|
||||||
if (i == 4)
|
if(i == 4)
|
||||||
glRotatef(180, 0, 0, 1);
|
glRotatef(180, 0, 0, 1);
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void idle(void) { deg += 1.0; }
|
static void idle(void) {
|
||||||
|
deg += 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
static void reshape(int width, int height) {
|
static void reshape(int width, int height) {
|
||||||
GLfloat lpos[4];
|
GLfloat lpos[4];
|
||||||
|
|
||||||
lpos[0] = 1;
|
lpos[0] = 1;
|
||||||
lpos[1] = 1;
|
lpos[1] = 1;
|
||||||
lpos[2] = 1;
|
lpos[2] = 1;
|
||||||
lpos[3] = 0;
|
lpos[3] = 0;
|
||||||
|
|
||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluPerspective(60, (double)width / height, 1, 100);
|
gluPerspective(60, (double)width / height, 1, 100);
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
gluLookAt(2, 2, 2, 0, 0, 0, 0, 1, 0);
|
gluLookAt(2, 2, 2, 0, 0, 0, 0, 1, 0);
|
||||||
|
|
||||||
glLightfv(GL_LIGHT0, GL_POSITION, lpos);
|
glLightfv(GL_LIGHT0, GL_POSITION, lpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init(void) {
|
static void init(void) {
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
glEnable(GL_LIGHT0);
|
glEnable(GL_LIGHT0);
|
||||||
glEnable(GL_COLOR_MATERIAL);
|
glEnable(GL_COLOR_MATERIAL);
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
glEnable(GL_NORMALIZE);
|
glEnable(GL_NORMALIZE);
|
||||||
|
|
||||||
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
|
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void key(int k) { (void)k; }
|
static void key(int k) {
|
||||||
|
(void)k;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,9 @@
|
||||||
|
|
||||||
// Note: implements NSApplicationDelegate
|
// Note: implements NSApplicationDelegate
|
||||||
@interface MilskoCocoaApplicationDelegate : NSObject {
|
@interface MilskoCocoaApplicationDelegate : NSObject {
|
||||||
NSApplication *appl;
|
NSApplication* appl;
|
||||||
}
|
}
|
||||||
- (MilskoCocoaApplicationDelegate *)initWithAppl:(NSApplication *)appl;
|
- (MilskoCocoaApplicationDelegate*)initWithAppl:(NSApplication*)appl;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface MilskoCocoaWindow : NSWindow {
|
@interface MilskoCocoaWindow : NSWindow {
|
||||||
|
|
@ -34,9 +34,9 @@
|
||||||
|
|
||||||
// Note: implements NSWindowDelegate
|
// Note: implements NSWindowDelegate
|
||||||
@interface MilskoCocoaWindowDelegate : NSObject {
|
@interface MilskoCocoaWindowDelegate : NSObject {
|
||||||
MilskoCocoaWindow *w;
|
MilskoCocoaWindow* w;
|
||||||
}
|
}
|
||||||
- (MilskoCocoaWindowDelegate *)initWithWin:(MilskoCocoaWindow *)win;
|
- (MilskoCocoaWindowDelegate*)initWithWin:(MilskoCocoaWindow*)win;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -52,139 +52,138 @@
|
||||||
retrieved appropriately.
|
retrieved appropriately.
|
||||||
*/
|
*/
|
||||||
@interface MilskoFakePointer : NSView {
|
@interface MilskoFakePointer : NSView {
|
||||||
void *ptr;
|
void* ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setPointer:(void *)ptr;
|
- (void)setPointer:(void*)ptr;
|
||||||
- (void *)pointer;
|
- (void*)pointer;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface MilskoCocoaPixmap : NSObject {
|
@interface MilskoCocoaPixmap : NSObject {
|
||||||
MwBool valid;
|
MwBool valid;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
unsigned char *buf;
|
unsigned char* buf;
|
||||||
NSImage *image;
|
NSImage* image;
|
||||||
NSBitmapImageRep *rep;
|
NSBitmapImageRep* rep;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (MilskoCocoaPixmap *)newWithWidth:(int)width height:(int)height;
|
+ (MilskoCocoaPixmap*)newWithWidth:(int)width height:(int)height;
|
||||||
- (void)updateWithData:(unsigned char *)data;
|
- (void)updateWithData:(unsigned char*)data;
|
||||||
- (void)destroy;
|
- (void)destroy;
|
||||||
|
|
||||||
/* using @property to create instance variables fucks up 10.4 gcc for some
|
/* using @property to create instance variables fucks up 10.4 gcc for some
|
||||||
* reason? */
|
* reason? */
|
||||||
- (NSImage *)image;
|
- (NSImage*)image;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface MilskoCocoaView : NSView {
|
@interface MilskoCocoaView : NSView {
|
||||||
NSBitmapImageRep *rep;
|
NSBitmapImageRep* rep;
|
||||||
NSGraphicsContext *context;
|
NSGraphicsContext* context;
|
||||||
MwBool valid;
|
MwBool valid;
|
||||||
CGColorSpaceRef space;
|
CGColorSpaceRef space;
|
||||||
CGDataProviderRef provider;
|
CGDataProviderRef provider;
|
||||||
float width;
|
float width;
|
||||||
float height;
|
float height;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)initRepAndContextWithWidth:(float)w Height:(float)h;
|
- (void)initRepAndContextWithWidth:(float)w Height:(float)h;
|
||||||
- (NSGraphicsContext *)context;
|
- (NSGraphicsContext*)context;
|
||||||
- (void)destroy;
|
- (void)destroy;
|
||||||
- (NSBitmapImageRep *)getRep;
|
- (NSBitmapImageRep*)getRep;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface MilskoCocoa : NSObject {
|
@interface MilskoCocoa : NSObject {
|
||||||
NSApplication *application;
|
NSApplication* application;
|
||||||
MwBool _forceRender;
|
MwBool _forceRender;
|
||||||
MilskoCocoaWindow *window;
|
MilskoCocoaWindow* window;
|
||||||
NSRect rect;
|
NSRect rect;
|
||||||
MilskoCocoaView *view;
|
MilskoCocoaView* view;
|
||||||
MwLL parent;
|
MwLL parent;
|
||||||
MilskoFakePointer *handle;
|
MilskoFakePointer* handle;
|
||||||
unsigned int strHash;
|
unsigned int strHash;
|
||||||
NSEvent *lastEvent;
|
NSEvent* lastEvent;
|
||||||
|
|
||||||
MilskoCocoaPixmap *cursorPixmap;
|
MilskoCocoaPixmap* cursorPixmap;
|
||||||
NSCursor *cursor;
|
NSCursor* cursor;
|
||||||
NSModalSession modalSession;
|
NSModalSession modalSession;
|
||||||
|
|
||||||
MwBool pointerLocked;
|
|
||||||
MwBool mouseMoved;
|
|
||||||
|
|
||||||
|
MwBool pointerLocked;
|
||||||
|
MwBool mouseMoved;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (MilskoCocoa *)newWithParent:(MwLL)parent
|
+ (MilskoCocoa*)newWithParent:(MwLL)parent
|
||||||
x:(int)x
|
x:(int)x
|
||||||
y:(int)y
|
y:(int)y
|
||||||
width:(int)width
|
width:(int)width
|
||||||
height:(int)height
|
height:(int)height
|
||||||
handle:(MwLL)handle;
|
handle:(MwLL)handle;
|
||||||
- (void)polygonWithPoints:(MwPoint *)points
|
- (void)polygonWithPoints:(MwPoint*)points
|
||||||
points_count:(int)points_count
|
points_count:(int)points_count
|
||||||
color:(MwLLColor)color;
|
color:(MwLLColor)color;
|
||||||
- (void)lineWithPoints:(MwPoint *)points color:(MwLLColor)color;
|
- (void)lineWithPoints:(MwPoint*)points color:(MwLLColor)color;
|
||||||
- (void)getX:(int *)x Y:(int *)y W:(unsigned int *)w H:(unsigned int *)h;
|
- (void)getX:(int*)x Y:(int*)y W:(unsigned int*)w H:(unsigned int*)h;
|
||||||
- (void)setX:(int)x Y:(int)y;
|
- (void)setX:(int)x Y:(int)y;
|
||||||
- (void)setW:(int)w H:(int)h;
|
- (void)setW:(int)w H:(int)h;
|
||||||
- (int)pending;
|
- (int)pending;
|
||||||
- (void)eventProcess:(NSEvent *)ev;
|
- (void)eventProcess:(NSEvent*)ev;
|
||||||
- (void)handleKeyEvent:(NSEvent *)ev ll:(MwLL)ll;
|
- (void)handleKeyEvent:(NSEvent*)ev ll:(MwLL)ll;
|
||||||
- (void)handleMouseEvent:(NSEvent *)ev ll:(MwLL)ll;
|
- (void)handleMouseEvent:(NSEvent*)ev ll:(MwLL)ll;
|
||||||
- (void)getNextEvent;
|
- (void)getNextEvent;
|
||||||
- (void)setTitle:(const char *)title;
|
- (void)setTitle:(const char*)title;
|
||||||
- (void)drawPixmap:(MwLLPixmap)pixmap rect:(MwRect *)rect;
|
- (void)drawPixmap:(MwLLPixmap)pixmap rect:(MwRect*)rect;
|
||||||
- (void)setIcon:(MwLLPixmap)pixmap;
|
- (void)setIcon:(MwLLPixmap)pixmap;
|
||||||
- (void)forceRender;
|
- (void)forceRender;
|
||||||
- (void)setCursor:(MwCursor *)image mask:(MwCursor *)mask;
|
- (void)setCursor:(MwCursor*)image mask:(MwCursor*)mask;
|
||||||
- (void)detachWithPoint:(MwPoint *)point;
|
- (void)detachWithPoint:(MwPoint*)point;
|
||||||
- (void)show:(int)show;
|
- (void)show:(int)show;
|
||||||
- (void)makePopupWithParent:(MwLL)parent;
|
- (void)makePopupWithParent:(MwLL)parent;
|
||||||
- (void)setSizeHintsWithMinX:(int)minx
|
- (void)setSizeHintsWithMinX:(int)minx
|
||||||
MinY:(int)miny
|
MinY:(int)miny
|
||||||
MaxX:(int)maxx
|
MaxX:(int)maxx
|
||||||
MaxY:(int)maxy;
|
MaxY:(int)maxy;
|
||||||
- (void)makeBorderless:(int)toggle;
|
- (void)makeBorderless:(int)toggle;
|
||||||
- (void)focus;
|
- (void)focus;
|
||||||
- (void)grabPointer:(int)toggle;
|
- (void)grabPointer:(int)toggle;
|
||||||
- (void)setClipboard:(const char *)text;
|
- (void)setClipboard:(const char*)text;
|
||||||
- (void)makeToolWindow;
|
- (void)makeToolWindow;
|
||||||
- (void)getCursorCoord:(MwPoint *)point;
|
- (void)getCursorCoord:(MwPoint*)point;
|
||||||
- (void)getScreenSize:(MwRect *)rect;
|
- (void)getScreenSize:(MwRect*)rect;
|
||||||
- (void)destroy;
|
- (void)destroy;
|
||||||
- (void)sendClipboardEvent;
|
- (void)sendClipboardEvent;
|
||||||
|
|
||||||
- (MwLL)getParent;
|
- (MwLL)getParent;
|
||||||
- (NSView *)getView;
|
- (NSView*)getView;
|
||||||
- (MilskoCocoaWindow *)getWindow;
|
- (MilskoCocoaWindow*)getWindow;
|
||||||
|
|
||||||
- (MilskoFakePointer *)getHandle;
|
- (MilskoFakePointer*)getHandle;
|
||||||
+ (void)eventCanceller:(MilskoCocoa *)this;
|
+ (void)eventCanceller:(MilskoCocoa*)this;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
#define OBJC(x) x
|
#define OBJC(x) x
|
||||||
#else
|
#else
|
||||||
#define OBJC(x) void *
|
#define OBJC(x) void*
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MWDECL int MwLLCocoaCallInit(void);
|
MWDECL int MwLLCocoaCallInit(void);
|
||||||
|
|
||||||
struct _MwLLCocoa {
|
struct _MwLLCocoa {
|
||||||
struct _MwLLCommon common;
|
struct _MwLLCommon common;
|
||||||
OBJC(MilskoCocoa *)
|
OBJC(MilskoCocoa*)
|
||||||
real;
|
real;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MwLLCocoaColor {
|
struct _MwLLCocoaColor {
|
||||||
struct _MwLLCommonColor common;
|
struct _MwLLCommonColor common;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MwLLCocoaPixmap {
|
struct _MwLLCocoaPixmap {
|
||||||
struct _MwLLCommonPixmap common;
|
struct _MwLLCommonPixmap common;
|
||||||
OBJC(MilskoCocoaPixmap *)
|
OBJC(MilskoCocoaPixmap*)
|
||||||
real;
|
real;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ MWDECL MwClass MwOpenGLClass;
|
||||||
* @param handle Widget
|
* @param handle Widget
|
||||||
*/
|
*/
|
||||||
MwInline void MwOpenGLMakeCurrent(MwWidget handle) {
|
MwInline void MwOpenGLMakeCurrent(MwWidget handle) {
|
||||||
MwVaWidgetExecute(handle, "mwOpenGLMakeCurrent", NULL);
|
MwVaWidgetExecute(handle, "mwOpenGLMakeCurrent", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -52,10 +52,10 @@ MwInline void MwOpenGLMakeCurrent(MwWidget handle) {
|
||||||
* @param name Name
|
* @param name Name
|
||||||
* @return Procedure
|
* @return Procedure
|
||||||
*/
|
*/
|
||||||
MwInline void *MwOpenGLGetProcAddress(MwWidget handle, const char *name) {
|
MwInline void* MwOpenGLGetProcAddress(MwWidget handle, const char* name) {
|
||||||
void *out;
|
void* out;
|
||||||
MwVaWidgetExecute(handle, "mwOpenGLGetProcAddress", &out, name);
|
MwVaWidgetExecute(handle, "mwOpenGLGetProcAddress", &out, name);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -63,7 +63,7 @@ MwInline void *MwOpenGLGetProcAddress(MwWidget handle, const char *name) {
|
||||||
* @param handle Widget
|
* @param handle Widget
|
||||||
*/
|
*/
|
||||||
MwInline void MwOpenGLSwapBuffer(MwWidget handle) {
|
MwInline void MwOpenGLSwapBuffer(MwWidget handle) {
|
||||||
MwVaWidgetExecute(handle, "mwOpenGLSwapBuffer", NULL);
|
MwVaWidgetExecute(handle, "mwOpenGLSwapBuffer", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ if (grep(/^wayland$/, @backends)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
scan_wayland_protocol("stable", "xdg-shell", "");
|
scan_wayland_protocol("stable", "xdg-shell", "");
|
||||||
scan_wayland_protocol("stable", "viewporter", "");
|
scan_wayland_protocol("stable", "viewporter", "");
|
||||||
scan_wayland_protocol("stable", "tablet", "-v2");
|
scan_wayland_protocol("stable", "tablet", "-v2");
|
||||||
scan_wayland_protocol("staging", "xdg-toplevel-icon", "-v1");
|
scan_wayland_protocol("staging", "xdg-toplevel-icon", "-v1");
|
||||||
scan_wayland_protocol("staging", "cursor-shape", "-v1");
|
scan_wayland_protocol("staging", "cursor-shape", "-v1");
|
||||||
|
|
@ -55,7 +55,7 @@ if (grep(/^cocoa$/, @backends)) {
|
||||||
new_object("src/widget/opengl_cocoa.m");
|
new_object("src/widget/opengl_cocoa.m");
|
||||||
}
|
}
|
||||||
|
|
||||||
# tim cook my man literally everybody and their mother who knows what opengl is knows its deprecated on macos and i'm not having you spam the console with this
|
# tim cook my man literally everybody and their mother who knows what opengl is knows its deprecated on macos and i'm not having you spam the console with this
|
||||||
add_cflags("-DGL_SILENCE_DEPRECATION");
|
add_cflags("-DGL_SILENCE_DEPRECATION");
|
||||||
|
|
||||||
$gl_libs = "-framework OpenGL";
|
$gl_libs = "-framework OpenGL";
|
||||||
|
|
|
||||||
|
|
@ -621,7 +621,7 @@ HCURSOR MwLLGDICreateCursor(MwCursor* image, MwCursor* mask) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor = CreateCursor(GetModuleHandle(NULL), xs, ys, MwCursorDataHeight, MwCursorDataHeight, dmask, dimage);
|
cursor = CreateCursor(GetModuleHandle(NULL), xs - image->x, ys + (MwCursorDataHeight + image->y), MwCursorDataHeight, MwCursorDataHeight, dmask, dimage);
|
||||||
|
|
||||||
free(dimage);
|
free(dimage);
|
||||||
free(dmask);
|
free(dmask);
|
||||||
|
|
|
||||||
|
|
@ -849,7 +849,7 @@ Cursor MwLLX11CreateCursor(Display* display, MwCursor* image, MwCursor* mask) {
|
||||||
XPutImage(display, pimage, imagegc, cimage, 0, 0, 0, 0, MwCursorDataHeight, MwCursorDataHeight);
|
XPutImage(display, pimage, imagegc, cimage, 0, 0, 0, 0, MwCursorDataHeight, MwCursorDataHeight);
|
||||||
XPutImage(display, pmask, maskgc, cmask, 0, 0, 0, 0, MwCursorDataHeight, MwCursorDataHeight);
|
XPutImage(display, pmask, maskgc, cmask, 0, 0, 0, 0, MwCursorDataHeight, MwCursorDataHeight);
|
||||||
|
|
||||||
cur = XCreatePixmapCursor(display, pimage, pmask, &cfg, &cbg, xs, ys);
|
cur = XCreatePixmapCursor(display, pimage, pmask, &cfg, &cbg, xs - image->x, ys + (MwCursorDataHeight + image->y));
|
||||||
|
|
||||||
XFreePixmap(display, pimage);
|
XFreePixmap(display, pimage);
|
||||||
XFreePixmap(display, pmask);
|
XFreePixmap(display, pmask);
|
||||||
|
|
|
||||||
|
|
@ -7,124 +7,125 @@
|
||||||
#import <mach-o/dyld.h>
|
#import <mach-o/dyld.h>
|
||||||
|
|
||||||
@interface MacOpenGLWidget : NSObject {
|
@interface MacOpenGLWidget : NSObject {
|
||||||
NSOpenGLPixelFormat *pixelFormat;
|
NSOpenGLPixelFormat* pixelFormat;
|
||||||
NSOpenGLContext *glc;
|
NSOpenGLContext* glc;
|
||||||
MilskoCocoa *_win;
|
MilskoCocoa* _win;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (MacOpenGLWidget *)initWithWindow:(MilskoCocoa *)w;
|
- (MacOpenGLWidget*)initWithWindow:(MilskoCocoa*)w;
|
||||||
- (void)destroy;
|
- (void)destroy;
|
||||||
- (void)makeCurrent;
|
- (void)makeCurrent;
|
||||||
- (void)swapBuffer;
|
- (void)swapBuffer;
|
||||||
- (void *)getProcAddressWithName:(const char *)name;
|
- (void*)getProcAddressWithName:(const char*)name;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
static int create(MwWidget handle) {
|
static int create(MwWidget handle) {
|
||||||
void *r = NULL;
|
void* r = NULL;
|
||||||
MwWidget w = handle;
|
MwWidget w = handle;
|
||||||
|
|
||||||
int x = MwGetInteger(w, MwNx);
|
int x = MwGetInteger(w, MwNx);
|
||||||
int y = MwGetInteger(w, MwNy);
|
int y = MwGetInteger(w, MwNy);
|
||||||
int width = MwGetInteger(w, MwNwidth);
|
int width = MwGetInteger(w, MwNwidth);
|
||||||
int height = MwGetInteger(w, MwNheight);
|
int height = MwGetInteger(w, MwNheight);
|
||||||
|
|
||||||
printf("%d %d\n", width, height);
|
printf("%d %d\n", width, height);
|
||||||
|
|
||||||
handle->internal =
|
handle->internal =
|
||||||
[[MacOpenGLWidget alloc] initWithWindow:handle->lowlevel->cocoa.real];
|
[[MacOpenGLWidget alloc] initWithWindow:handle->lowlevel->cocoa.real];
|
||||||
handle->lowlevel->common.copy_buffer = 0;
|
handle->lowlevel->common.copy_buffer = 0;
|
||||||
|
|
||||||
MwSetDefault(handle);
|
MwSetDefault(handle);
|
||||||
|
|
||||||
while (w->parent != NULL)
|
while(w->parent != NULL)
|
||||||
w = w->parent;
|
w = w->parent;
|
||||||
|
|
||||||
w->berserk++;
|
w->berserk++;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroy(MwWidget handle) {
|
static void destroy(MwWidget handle) {
|
||||||
[(MacOpenGLWidget *)handle->internal destroy];
|
[(MacOpenGLWidget*)handle->internal destroy];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mwOpenGLMakeCurrentImpl(MwWidget handle) {
|
static void mwOpenGLMakeCurrentImpl(MwWidget handle) {
|
||||||
[(MacOpenGLWidget *)handle->internal makeCurrent];
|
[(MacOpenGLWidget*)handle->internal makeCurrent];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mwOpenGLSwapBufferImpl(MwWidget handle) {
|
static void mwOpenGLSwapBufferImpl(MwWidget handle) {
|
||||||
[(MacOpenGLWidget *)handle->internal swapBuffer];
|
[(MacOpenGLWidget*)handle->internal swapBuffer];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *mwOpenGLGetProcAddressImpl(MwWidget handle, const char *name) {
|
static void* mwOpenGLGetProcAddressImpl(MwWidget handle, const char* name) {
|
||||||
return [(MacOpenGLWidget *)handle->internal getProcAddressWithName:name];
|
return [(MacOpenGLWidget*)handle->internal getProcAddressWithName:name];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void func_handler(MwWidget handle, const char *name, void *out,
|
static void func_handler(MwWidget handle, const char* name, void* out,
|
||||||
va_list va) {
|
va_list va) {
|
||||||
if (strcmp(name, "mwOpenGLMakeCurrent") == 0) {
|
if(strcmp(name, "mwOpenGLMakeCurrent") == 0) {
|
||||||
mwOpenGLMakeCurrentImpl(handle);
|
mwOpenGLMakeCurrentImpl(handle);
|
||||||
}
|
}
|
||||||
if (strcmp(name, "mwOpenGLSwapBuffer") == 0) {
|
if(strcmp(name, "mwOpenGLSwapBuffer") == 0) {
|
||||||
mwOpenGLSwapBufferImpl(handle);
|
mwOpenGLSwapBufferImpl(handle);
|
||||||
}
|
}
|
||||||
if (strcmp(name, "mwOpenGLGetProcAddress") == 0) {
|
if(strcmp(name, "mwOpenGLGetProcAddress") == 0) {
|
||||||
const char *_name = va_arg(va, const char *);
|
const char* _name = va_arg(va, const char*);
|
||||||
*(void **)out = mwOpenGLGetProcAddressImpl(handle, _name);
|
*(void**)out = mwOpenGLGetProcAddressImpl(handle, _name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@implementation MacOpenGLWidget
|
@implementation MacOpenGLWidget
|
||||||
|
|
||||||
- (MacOpenGLWidget *)initWithWindow:(MilskoCocoa *)w {
|
- (MacOpenGLWidget*)initWithWindow:(MilskoCocoa*)w {
|
||||||
NSOpenGLPixelFormatAttribute pixelFormatAttributes[] = {
|
NSOpenGLPixelFormatAttribute pixelFormatAttributes[] = {
|
||||||
NSOpenGLPFAColorSize, 24,
|
NSOpenGLPFAColorSize, 24,
|
||||||
NSOpenGLPFAStencilSize, 8,
|
NSOpenGLPFAStencilSize, 8,
|
||||||
NSOpenGLPFAAlphaSize, 8,
|
NSOpenGLPFAAlphaSize, 8,
|
||||||
NSOpenGLPFADoubleBuffer, NSOpenGLPFAAccelerated,
|
NSOpenGLPFADoubleBuffer, NSOpenGLPFAAccelerated,
|
||||||
NSOpenGLPFANoRecovery, 0};
|
NSOpenGLPFANoRecovery, 0};
|
||||||
self->pixelFormat =
|
self->pixelFormat =
|
||||||
[[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes];
|
[[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes];
|
||||||
self->glc =
|
self->glc =
|
||||||
[[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
|
[[NSOpenGLContext alloc] initWithFormat:pixelFormat
|
||||||
[self->glc setView:[w getView]];
|
shareContext:nil];
|
||||||
self->_win = w;
|
[self->glc setView:[w getView]];
|
||||||
return self;
|
self->_win = w;
|
||||||
|
return self;
|
||||||
};
|
};
|
||||||
- (void)destroy {
|
- (void)destroy {
|
||||||
};
|
};
|
||||||
- (void)makeCurrent {
|
- (void)makeCurrent {
|
||||||
[self->glc makeCurrentContext];
|
[self->glc makeCurrentContext];
|
||||||
};
|
};
|
||||||
- (void)swapBuffer {
|
- (void)swapBuffer {
|
||||||
[self->glc flushBuffer];
|
[self->glc flushBuffer];
|
||||||
};
|
};
|
||||||
- (void *)getProcAddressWithName:(const char *)name {
|
- (void*)getProcAddressWithName:(const char*)name {
|
||||||
if (NSIsSymbolNameDefined(name)) {
|
if(NSIsSymbolNameDefined(name)) {
|
||||||
return NSAddressOfSymbol(NSLookupAndBindSymbol(name));
|
return NSAddressOfSymbol(NSLookupAndBindSymbol(name));
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
MwClassRec MwOpenGLClassRec = {create, /* create */
|
MwClassRec MwOpenGLClassRec = {create, /* create */
|
||||||
destroy, /* destroy */
|
destroy, /* destroy */
|
||||||
NULL, /* draw */
|
NULL, /* draw */
|
||||||
NULL, /* click */
|
NULL, /* click */
|
||||||
NULL, /* parent_resize */
|
NULL, /* parent_resize */
|
||||||
NULL, /* prop_change */
|
NULL, /* prop_change */
|
||||||
NULL, /* mouse_move */
|
NULL, /* mouse_move */
|
||||||
NULL, /* mouse_up */
|
NULL, /* mouse_up */
|
||||||
NULL, /* mouse_down */
|
NULL, /* mouse_down */
|
||||||
NULL, /* key */
|
NULL, /* key */
|
||||||
func_handler, /* execute */
|
func_handler, /* execute */
|
||||||
NULL, /* tick */
|
NULL, /* tick */
|
||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL, /* clipboard */
|
NULL, /* clipboard */
|
||||||
NULL, NULL, NULL, NULL};
|
NULL, NULL, NULL, NULL};
|
||||||
MwClass MwOpenGLClass = &MwOpenGLClassRec;
|
MwClass MwOpenGLClass = &MwOpenGLClassRec;
|
||||||
|
|
@ -58,8 +58,7 @@ l(
|
||||||
l("");
|
l("");
|
||||||
c("Requirements");
|
c("Requirements");
|
||||||
l("");
|
l("");
|
||||||
l(
|
l(" Milsko requires either");
|
||||||
" Milsko requires either");
|
|
||||||
l(" * A Windows environment with GDI (so anything NT or 9x)");
|
l(" * A Windows environment with GDI (so anything NT or 9x)");
|
||||||
l(" * A MacOS environment with Cocoa (10.4 or above supported)");
|
l(" * A MacOS environment with Cocoa (10.4 or above supported)");
|
||||||
l(" * A Unix-like environment with X11 for runtime.");
|
l(" * A Unix-like environment with X11 for runtime.");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue