a toolkit for developing cross-platform user interfaces with openGL (gradually migrating from github)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

opening a window, gl context initialized

+105 -7
+1 -1
.vimrc
··· 7 7 \ "passive_filetypes": []} 8 8 9 9 let g:syntastic_c_checkers = ['gcc'] 10 - let g:syntastic_c_compiler_options = "-std=c99 -D_GNU_SOURCE -fms-extensions" 10 + let g:syntastic_c_compiler_options = "-std=c99 -D_GNU_SOURCE -fms-extensions -Wno-microsoft" 11 11 let g:syntastic_c_include_dirs = [ 12 12 \ "include", 13 13 \ "third-party",
+5 -1
src/platform/cocoa/event.m
··· 26 26 27 27 #include <uv.h> 28 28 29 + #include <glloadgen/gl_core.3.0.h> 30 + 31 + #import <Cocoa/Cocoa.h> 32 + 29 33 #include "rutabaga/rutabaga.h" 30 34 #include "rutabaga/window.h" 31 35 ··· 34 38 void 35 39 rtb_event_loop(struct rutabaga *r) 36 40 { 37 - return; 41 + [NSApp run]; 38 42 }
+99 -5
src/platform/cocoa/window.m
··· 44 44 backing: (NSBackingStoreType) bufferingType 45 45 defer: (BOOL) deferCreation; 46 46 47 - - (void) setRtbWindow: (struct rtb_window *) rtbWin; 47 + - (BOOL) windowShouldClose: (id) sender; 48 48 - (BOOL) canBecomeKeyWindow: (id) sender; 49 49 @end 50 50 ··· 67 67 return self; 68 68 } 69 69 70 - - (void) setRtbWindow: (struct rtb_window *) rtbWin 70 + - (BOOL) windowShouldClose: (id) sender 71 71 { 72 - rtb_win = rtbWin; 73 - [self setContentSize:NSMakeSize(rtbWin->w, rtbWin->h)]; 72 + return NO; 74 73 } 75 74 76 75 - (BOOL) canBecomeKeyWindow: (id) sender 77 76 { 78 77 return NO; 79 78 } 79 + @end 80 80 81 + @interface RutabagaOpenGLView : NSOpenGLView 82 + { 83 + @public 84 + struct rtb_window *rtb_win; 85 + } 86 + 87 + - (id) initWithFrame: (NSRect) frame 88 + colorBits: (int) numColorBits 89 + depthBits: (int) numDepthBits; 90 + @end 91 + 92 + @implementation RutabagaOpenGLView 93 + - (id) initWithFrame: (NSRect) frame 94 + colorBits: (int) colorBits 95 + depthBits: (int) depthBits 96 + { 97 + NSOpenGLPixelFormat *format; 98 + NSOpenGLPixelFormatAttribute attribs[] = { 99 + NSOpenGLPFAOpenGLProfile, 100 + NSOpenGLProfileVersion3_2Core, 101 + NSOpenGLPFADoubleBuffer, 102 + NSOpenGLPFAAccelerated, 103 + NSOpenGLPFAColorSize, 104 + colorBits, 105 + NSOpenGLPFADepthSize, 106 + depthBits, 107 + 0 108 + }; 109 + 110 + format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs]; 111 + if (!format) 112 + return nil; 113 + 114 + self = [super initWithFrame:frame pixelFormat:format]; 115 + [format release]; 116 + 117 + if (!self) 118 + return nil; 119 + 120 + [[self openGLContext] makeCurrentContext]; 121 + [self reshape]; 122 + 123 + return self; 124 + } 81 125 @end 82 126 127 + /** 128 + * rutabaga interface 129 + */ 130 + 131 + struct cocoartb_window { 132 + RTB_INHERIT(rtb_window); 133 + RutabagaWindow *cocoa_win; 134 + }; 135 + 83 136 struct rutabaga * 84 137 window_impl_rtb_alloc(void) 85 138 { 86 139 struct rutabaga *rtb = calloc(1, sizeof(*rtb)); 140 + 141 + if (!NSApp) { 142 + [NSApplication sharedApplication]; 143 + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; 144 + [NSApp finishLaunching]; 145 + } 146 + 87 147 return rtb; 88 148 } 89 149 ··· 97 157 window_impl_open(struct rutabaga *rtb, 98 158 int w, int h, const char *title, intptr_t parent) 99 159 { 100 - return NULL; 160 + struct rtb_window *self; 161 + 162 + RutabagaOpenGLView *glview; 163 + RutabagaWindow *cwin; 164 + NSString *nstitle; 165 + 166 + [NSAutoreleasePool new]; 167 + 168 + self = calloc(1, sizeof(*self)); 169 + if (!self) 170 + return NULL; 171 + 172 + nstitle = 173 + [[NSString alloc] 174 + initWithBytes:title 175 + length:strlen(title) 176 + encoding:NSUTF8StringEncoding]; 177 + 178 + cwin = [[RutabagaWindow new] retain]; 179 + [cwin setContentSize:NSMakeSize(w, h)]; 180 + [cwin setTitle:nstitle]; 181 + cwin->rtb_win = self; 182 + 183 + glview = 184 + [[RutabagaOpenGLView new] 185 + initWithFrame:NSMakeRect(0, 0, w, h) 186 + colorBits:24 187 + depthBits:24]; 188 + [cwin setContentView:glview]; 189 + [cwin makeFirstResponder:glview]; 190 + 191 + [NSApp activateIgnoringOtherApps:YES]; 192 + [cwin makeKeyAndOrderFront:cwin]; 193 + 194 + return self; 101 195 } 102 196 103 197 void