So, I'm trying to create an openGL view (in my window). Im making a Cocoa app. Ive managed to create one through Interface Builder, but for educational purposes I want to continue and make one without it. Only on papers.
And here is the point that tells you that I am struggling with this. So what ive has basically done is still: I created a new class, "MyOpenGLView.h / m", inheriting from NSOpenGLView. I did not add any private vars or methods for it just the class name. The only thing I did was override initWithFrame: (by adding self = [super initWithFrame: pixelFormat:] to it). I read about it on the Internet so that you first create an instance of this file before it can be used). here is the code:
- (id) initWithFrame:(NSRect)frameRect
{
NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc]
initWithAttributes:(NSOpenGLPixelFormatAttribute[])
{
NSOpenGLPFAWindow,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFADepthSize, 32,
nil
}];
self = [super initWithFrame:frameRect pixelFormat:pixelFormat];
[[self openGLContext] makeCurrentContext];
}
, "MyViewController.h/m", ?
MyOpenGLView * myView.
.m - :
myView = [[MyOpenGLView alloc] initWithFrame:CGRectMake(0,0,100.0,100.0)];
if (!myView) { NSLog(@"ERROR"); }
, , .
openGL-. , - , .. im not sure. ?