fork download
  1. class Window {
  2. NSWindow* window;
  3. NSOpenGLView* view;
  4. public:
  5. Window() {
  6. window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0.0, 0.0, 640.0, 480.0)
  7. styleMask:NSTitledWindowMask | NSClosableWindowMask
  8. bufferingType:NSBackingStoreBuffered
  9. deferCreation:YES];
  10. if (!window) throw std::runtime_error("could not create window.");
  11. NSOpenGLPixelFormat format = [[NSOpenGLPixelFormat alloc] initWithAttributes:];
  12. view = [[NSOpenGLView alloc] initWithFrame:window.contentView.bounds pixelFormat:format];
  13. [format release];
  14. view.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
  15. [window.contentView addSubview:view];
  16. view.frame = window.contentView.bounds;
  17. }
  18.  
  19. Window(Window const&) = delete;
  20.  
  21. ~Window() {
  22. [view release];
  23. [window release];
  24. }
  25.  
  26. void make_front_window() {
  27. [window makeKeyAndOrderFront:nil];
  28. }
  29.  
  30. void make_current() {
  31. [view.openGLContext makeCurrentContext];
  32. }
  33. };
  34.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty