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
|
|
@ -7,124 +7,125 @@
|
|||
#import <mach-o/dyld.h>
|
||||
|
||||
@interface MacOpenGLWidget : NSObject {
|
||||
NSOpenGLPixelFormat *pixelFormat;
|
||||
NSOpenGLContext *glc;
|
||||
MilskoCocoa *_win;
|
||||
NSOpenGLPixelFormat* pixelFormat;
|
||||
NSOpenGLContext* glc;
|
||||
MilskoCocoa* _win;
|
||||
}
|
||||
|
||||
- (MacOpenGLWidget *)initWithWindow:(MilskoCocoa *)w;
|
||||
- (MacOpenGLWidget*)initWithWindow:(MilskoCocoa*)w;
|
||||
- (void)destroy;
|
||||
- (void)makeCurrent;
|
||||
- (void)swapBuffer;
|
||||
- (void *)getProcAddressWithName:(const char *)name;
|
||||
- (void*)getProcAddressWithName:(const char*)name;
|
||||
|
||||
@end
|
||||
|
||||
static int create(MwWidget handle) {
|
||||
void *r = NULL;
|
||||
MwWidget w = handle;
|
||||
void* r = NULL;
|
||||
MwWidget w = handle;
|
||||
|
||||
int x = MwGetInteger(w, MwNx);
|
||||
int y = MwGetInteger(w, MwNy);
|
||||
int width = MwGetInteger(w, MwNwidth);
|
||||
int height = MwGetInteger(w, MwNheight);
|
||||
int x = MwGetInteger(w, MwNx);
|
||||
int y = MwGetInteger(w, MwNy);
|
||||
int width = MwGetInteger(w, MwNwidth);
|
||||
int height = MwGetInteger(w, MwNheight);
|
||||
|
||||
printf("%d %d\n", width, height);
|
||||
printf("%d %d\n", width, height);
|
||||
|
||||
handle->internal =
|
||||
[[MacOpenGLWidget alloc] initWithWindow:handle->lowlevel->cocoa.real];
|
||||
handle->lowlevel->common.copy_buffer = 0;
|
||||
handle->internal =
|
||||
[[MacOpenGLWidget alloc] initWithWindow:handle->lowlevel->cocoa.real];
|
||||
handle->lowlevel->common.copy_buffer = 0;
|
||||
|
||||
MwSetDefault(handle);
|
||||
MwSetDefault(handle);
|
||||
|
||||
while (w->parent != NULL)
|
||||
w = w->parent;
|
||||
while(w->parent != NULL)
|
||||
w = w->parent;
|
||||
|
||||
w->berserk++;
|
||||
w->berserk++;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void destroy(MwWidget handle) {
|
||||
[(MacOpenGLWidget *)handle->internal destroy];
|
||||
[(MacOpenGLWidget*)handle->internal destroy];
|
||||
}
|
||||
|
||||
static void mwOpenGLMakeCurrentImpl(MwWidget handle) {
|
||||
[(MacOpenGLWidget *)handle->internal makeCurrent];
|
||||
[(MacOpenGLWidget*)handle->internal makeCurrent];
|
||||
}
|
||||
|
||||
static void mwOpenGLSwapBufferImpl(MwWidget handle) {
|
||||
[(MacOpenGLWidget *)handle->internal swapBuffer];
|
||||
[(MacOpenGLWidget*)handle->internal swapBuffer];
|
||||
}
|
||||
|
||||
static void *mwOpenGLGetProcAddressImpl(MwWidget handle, const char *name) {
|
||||
return [(MacOpenGLWidget *)handle->internal getProcAddressWithName:name];
|
||||
static void* mwOpenGLGetProcAddressImpl(MwWidget handle, const char* name) {
|
||||
return [(MacOpenGLWidget*)handle->internal getProcAddressWithName:name];
|
||||
}
|
||||
|
||||
static void func_handler(MwWidget handle, const char *name, void *out,
|
||||
va_list va) {
|
||||
if (strcmp(name, "mwOpenGLMakeCurrent") == 0) {
|
||||
mwOpenGLMakeCurrentImpl(handle);
|
||||
}
|
||||
if (strcmp(name, "mwOpenGLSwapBuffer") == 0) {
|
||||
mwOpenGLSwapBufferImpl(handle);
|
||||
}
|
||||
if (strcmp(name, "mwOpenGLGetProcAddress") == 0) {
|
||||
const char *_name = va_arg(va, const char *);
|
||||
*(void **)out = mwOpenGLGetProcAddressImpl(handle, _name);
|
||||
}
|
||||
static void func_handler(MwWidget handle, const char* name, void* out,
|
||||
va_list va) {
|
||||
if(strcmp(name, "mwOpenGLMakeCurrent") == 0) {
|
||||
mwOpenGLMakeCurrentImpl(handle);
|
||||
}
|
||||
if(strcmp(name, "mwOpenGLSwapBuffer") == 0) {
|
||||
mwOpenGLSwapBufferImpl(handle);
|
||||
}
|
||||
if(strcmp(name, "mwOpenGLGetProcAddress") == 0) {
|
||||
const char* _name = va_arg(va, const char*);
|
||||
*(void**)out = mwOpenGLGetProcAddressImpl(handle, _name);
|
||||
}
|
||||
}
|
||||
|
||||
@implementation MacOpenGLWidget
|
||||
|
||||
- (MacOpenGLWidget *)initWithWindow:(MilskoCocoa *)w {
|
||||
NSOpenGLPixelFormatAttribute pixelFormatAttributes[] = {
|
||||
NSOpenGLPFAColorSize, 24,
|
||||
NSOpenGLPFAStencilSize, 8,
|
||||
NSOpenGLPFAAlphaSize, 8,
|
||||
NSOpenGLPFADoubleBuffer, NSOpenGLPFAAccelerated,
|
||||
NSOpenGLPFANoRecovery, 0};
|
||||
self->pixelFormat =
|
||||
[[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes];
|
||||
self->glc =
|
||||
[[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
|
||||
[self->glc setView:[w getView]];
|
||||
self->_win = w;
|
||||
return self;
|
||||
- (MacOpenGLWidget*)initWithWindow:(MilskoCocoa*)w {
|
||||
NSOpenGLPixelFormatAttribute pixelFormatAttributes[] = {
|
||||
NSOpenGLPFAColorSize, 24,
|
||||
NSOpenGLPFAStencilSize, 8,
|
||||
NSOpenGLPFAAlphaSize, 8,
|
||||
NSOpenGLPFADoubleBuffer, NSOpenGLPFAAccelerated,
|
||||
NSOpenGLPFANoRecovery, 0};
|
||||
self->pixelFormat =
|
||||
[[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes];
|
||||
self->glc =
|
||||
[[NSOpenGLContext alloc] initWithFormat:pixelFormat
|
||||
shareContext:nil];
|
||||
[self->glc setView:[w getView]];
|
||||
self->_win = w;
|
||||
return self;
|
||||
};
|
||||
- (void)destroy {
|
||||
};
|
||||
- (void)makeCurrent {
|
||||
[self->glc makeCurrentContext];
|
||||
[self->glc makeCurrentContext];
|
||||
};
|
||||
- (void)swapBuffer {
|
||||
[self->glc flushBuffer];
|
||||
[self->glc flushBuffer];
|
||||
};
|
||||
- (void *)getProcAddressWithName:(const char *)name {
|
||||
if (NSIsSymbolNameDefined(name)) {
|
||||
return NSAddressOfSymbol(NSLookupAndBindSymbol(name));
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
- (void*)getProcAddressWithName:(const char*)name {
|
||||
if(NSIsSymbolNameDefined(name)) {
|
||||
return NSAddressOfSymbol(NSLookupAndBindSymbol(name));
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
||||
@end
|
||||
|
||||
MwClassRec MwOpenGLClassRec = {create, /* create */
|
||||
destroy, /* destroy */
|
||||
NULL, /* draw */
|
||||
NULL, /* click */
|
||||
NULL, /* parent_resize */
|
||||
NULL, /* prop_change */
|
||||
NULL, /* mouse_move */
|
||||
NULL, /* mouse_up */
|
||||
NULL, /* mouse_down */
|
||||
NULL, /* key */
|
||||
func_handler, /* execute */
|
||||
NULL, /* tick */
|
||||
NULL, /* resize */
|
||||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL, NULL, NULL, NULL};
|
||||
MwClass MwOpenGLClass = &MwOpenGLClassRec;
|
||||
MwClassRec MwOpenGLClassRec = {create, /* create */
|
||||
destroy, /* destroy */
|
||||
NULL, /* draw */
|
||||
NULL, /* click */
|
||||
NULL, /* parent_resize */
|
||||
NULL, /* prop_change */
|
||||
NULL, /* mouse_move */
|
||||
NULL, /* mouse_up */
|
||||
NULL, /* mouse_down */
|
||||
NULL, /* key */
|
||||
func_handler, /* execute */
|
||||
NULL, /* tick */
|
||||
NULL, /* resize */
|
||||
NULL, /* children_update */
|
||||
NULL, /* children_prop_change */
|
||||
NULL, /* clipboard */
|
||||
NULL, NULL, NULL, NULL};
|
||||
MwClass MwOpenGLClass = &MwOpenGLClassRec;
|
||||
Loading…
Add table
Add a link
Reference in a new issue