fix forceRender, at the cost of breaking the rotate example
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
75c9af91d1
commit
21d5625ec7
2 changed files with 23 additions and 30 deletions
|
|
@ -140,6 +140,7 @@ static NSPoint pointFlip(NSPoint point) {
|
||||||
c->rect.origin.y -= [p->window frame].origin.y - offset;
|
c->rect.origin.y -= [p->window frame].origin.y - offset;
|
||||||
c->rect.origin.y -= offset;
|
c->rect.origin.y -= offset;
|
||||||
} else {
|
} else {
|
||||||
|
[c->application setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||||
[c->application activateIgnoringOtherApps:true];
|
[c->application activateIgnoringOtherApps:true];
|
||||||
[c->window makeFirstResponder:c->view];
|
[c->window makeFirstResponder:c->view];
|
||||||
}
|
}
|
||||||
|
|
@ -279,7 +280,7 @@ static NSPoint pointFlip(NSPoint point) {
|
||||||
};
|
};
|
||||||
|
|
||||||
- (void)getNextEvent {
|
- (void)getNextEvent {
|
||||||
|
[self eventProcess:self->lastEvent];
|
||||||
while (true) {
|
while (true) {
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSEvent *ev = [self->window nextEventMatchingMask:NSAnyEventMask
|
NSEvent *ev = [self->window nextEventMatchingMask:NSAnyEventMask
|
||||||
|
|
@ -595,18 +596,19 @@ static NSPoint pointFlip(NSPoint point) {
|
||||||
(void)pixmap;
|
(void)pixmap;
|
||||||
};
|
};
|
||||||
- (void)forceRender {
|
- (void)forceRender {
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
self->_forceRender = MwTRUE;
|
||||||
NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined
|
// NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
location:NSMakePoint(0, 0)
|
// NSEvent *event = [NSEvent otherEventWithType:NSApplicationDefined
|
||||||
modifierFlags:0
|
// location:NSMakePoint(0, 0)
|
||||||
timestamp:0
|
// modifierFlags:0
|
||||||
windowNumber:0
|
// timestamp:0
|
||||||
context:nil
|
// windowNumber:0
|
||||||
subtype:0
|
// context:nil
|
||||||
data1:0
|
// subtype:0
|
||||||
data2:0];
|
// data1:0
|
||||||
[NSApp postEvent:event atStart:YES];
|
// data2:0];
|
||||||
[pool release];
|
// [NSApp postEvent:event atStart:YES];
|
||||||
|
// [pool release];
|
||||||
};
|
};
|
||||||
- (void)setCursor:(MwCursor *)image mask:(MwCursor *)mask {
|
- (void)setCursor:(MwCursor *)image mask:(MwCursor *)mask {
|
||||||
(void)image;
|
(void)image;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "Mw/BaseTypes.h"
|
#include "Mw/BaseTypes.h"
|
||||||
#include "Mw/Core.h"
|
#include "Mw/Core.h"
|
||||||
|
#include "Mw/LowLevel/Cocoa.h"
|
||||||
#include "Mw/StringDefs.h"
|
#include "Mw/StringDefs.h"
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
#include <Mw/Widget/OpenGL.h>
|
#include <Mw/Widget/OpenGL.h>
|
||||||
|
|
@ -8,9 +9,10 @@
|
||||||
@interface MacOpenGLWidget : NSObject {
|
@interface MacOpenGLWidget : NSObject {
|
||||||
NSOpenGLPixelFormat *pixelFormat;
|
NSOpenGLPixelFormat *pixelFormat;
|
||||||
NSOpenGLContext *glc;
|
NSOpenGLContext *glc;
|
||||||
|
MilskoCocoa * _win;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (MacOpenGLWidget *)initWithView:(NSView *)view;
|
- (MacOpenGLWidget *)initWithWindow:(MilskoCocoa *)w;
|
||||||
- (void)destroy;
|
- (void)destroy;
|
||||||
- (void)makeCurrent;
|
- (void)makeCurrent;
|
||||||
- (void)swapBuffer;
|
- (void)swapBuffer;
|
||||||
|
|
@ -30,7 +32,7 @@ static int create(MwWidget handle) {
|
||||||
printf("%d %d\n", width, height);
|
printf("%d %d\n", width, height);
|
||||||
|
|
||||||
handle->internal = [[MacOpenGLWidget alloc]
|
handle->internal = [[MacOpenGLWidget alloc]
|
||||||
initWithView:[handle->lowlevel->cocoa.real getView]];
|
initWithWindow:handle->lowlevel->cocoa.real];
|
||||||
handle->lowlevel->common.copy_buffer = 0;
|
handle->lowlevel->common.copy_buffer = 0;
|
||||||
|
|
||||||
MwSetDefault(handle);
|
MwSetDefault(handle);
|
||||||
|
|
@ -75,7 +77,7 @@ static void func_handler(MwWidget handle, const char *name, void *out,
|
||||||
|
|
||||||
@implementation MacOpenGLWidget
|
@implementation MacOpenGLWidget
|
||||||
|
|
||||||
- (MacOpenGLWidget *)initWithView:(NSView *)view {
|
- (MacOpenGLWidget *)initWithWindow:(MilskoCocoa *)w {
|
||||||
NSOpenGLPixelFormatAttribute pixelFormatAttributes[] = {
|
NSOpenGLPixelFormatAttribute pixelFormatAttributes[] = {
|
||||||
NSOpenGLPFAColorSize, 24,
|
NSOpenGLPFAColorSize, 24,
|
||||||
NSOpenGLPFAStencilSize, 8,
|
NSOpenGLPFAStencilSize, 8,
|
||||||
|
|
@ -86,7 +88,8 @@ static void func_handler(MwWidget handle, const char *name, void *out,
|
||||||
[[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes];
|
[[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes];
|
||||||
self->glc =
|
self->glc =
|
||||||
[[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
|
[[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
|
||||||
[self->glc setView:view];
|
[self->glc setView:[w getView]];
|
||||||
|
self->_win = w;
|
||||||
return self;
|
return self;
|
||||||
};
|
};
|
||||||
- (void)destroy {
|
- (void)destroy {
|
||||||
|
|
@ -95,19 +98,7 @@ static void func_handler(MwWidget handle, const char *name, void *out,
|
||||||
[self->glc makeCurrentContext];
|
[self->glc makeCurrentContext];
|
||||||
};
|
};
|
||||||
- (void)swapBuffer {
|
- (void)swapBuffer {
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
[self->_win forceRender];
|
||||||
NSEvent *event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined
|
|
||||||
location:NSMakePoint(0, 0)
|
|
||||||
modifierFlags:0
|
|
||||||
timestamp:0
|
|
||||||
windowNumber:0
|
|
||||||
context:nil
|
|
||||||
subtype:0
|
|
||||||
data1:0
|
|
||||||
data2:0];
|
|
||||||
[NSApp postEvent:event atStart:YES];
|
|
||||||
[pool release];
|
|
||||||
|
|
||||||
[self->glc flushBuffer];
|
[self->glc flushBuffer];
|
||||||
};
|
};
|
||||||
- (void *)getProcAddressWithName:(const char *)name {
|
- (void *)getProcAddressWithName:(const char *)name {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue