cocoa for nibbies [OpenGL context creation/ Initializing a PixelFormat]
What is the correct way to initialize an OpenGl Context, set a pixelFormat using
Code:
-(id)initWithAttributes:(NSOpenGLPixelFormat*)attribs
here is my *cough* source code :-\
/* aGameGLView */
#import <Cocoa/Cocoa.h>
@interface aGameGLView : NSOpenGLView
{
BOOL readyToDraw;
NSRect* myRect;
NSOpenGLPixelFormat* myPixelFormat;
NSOpenGLContext* myContext;
NSOpenGLPixelFormatAttribute* attribs;
}
-(void)awakeFromNib;
-(void)drawRect:(NSRect)rect;
-(id)initWithAttributes:(NSOpenGLPixelFormatAttribute *)attribs;
#import "aGameGLView.h"
#define kWindowHeight 400
#define kWindowWidth 300
@implementation aGameGLView
-(void)awakeFromNib
{
readyToDraw = NO;
myPixelFormat = [[NSOpenGlPixelFormat alloc] init];
myContext =[[NSOpenGLContext alloc] init];
attribs = [NSOpenGLPFAAllRenderers,
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAStereo,
NSOpenGLPFAMinimumPolicy,
NSOpenGLPFAMaximumPolicy,
NSOpenGLPFAOffScreen,
NSOpenGLPFAFullScreen,
NSOpenGLPFASingleRenderer,
NSOpenGLPFANoRecovery,
NSOpenGLPFAAccelerated,
NSOpenGLPFAClosestPolicy,
NSOpenGLPFARobust,
NSOpenGLPFABackingStore,
NSOpenGLPFAWindow,
NSOpenGLPFAMultiScreen,
NSOpenGLPFACompliant,
NSOpenGLPFAPixelBuffer, 0];
}
-(void)drawRect:(NSRect)rect
{
// Check to see if we're initialized
if(!readyToDraw)
{
readyToDraw = YES;
}
}
@end
Thanks a lot for the help!!
oh, and kudos on the book!
oh, and kudos on the book!
I keep getting the build error : "too many filenames given. Type cc1obj --help for usage", what does this mean?
probably an xcode error—but then I'm usually wrong, so don't take my advice of doing it from the Terminal.
It's not magic, it's Ruby.
Definitely sounds like an Xcode problem
Is this in your own project, or one of my example projects?
Is this in your own project, or one of my example projects?
The error occurs in my project, I wasn't aware that you had sample projects with your book, I'm sure if I had those to compare to mine I could find the reason for the problem. Thanks again for the help guys!
If it was not clear OneSadCookie's mini book answered my question
thanks ^^
thanks ^^
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Opengl/Cocoa text rendering | tesil | 15 | 14,615 |
Mar 20, 2012 11:16 AM Last Post: OneSadCookie |
|
| OpenGL Text Rendering (in Cocoa) | daveh84 | 5 | 6,707 |
Feb 19, 2009 12:44 PM Last Post: TomorrowPlusX |
|
| OpenGL & Cocoa - Improving frame rate | daveh84 | 4 | 4,966 |
Feb 2, 2009 06:53 AM Last Post: backslash |
|
| bad depth sorting in Cocoa OpenGL | aldermoore | 2 | 4,134 |
Dec 30, 2008 03:07 PM Last Post: ThemsAllTook |
|
| Loading and using textures with alpha in OpenGL with Cocoa | corporatenewt | 4 | 5,113 |
Dec 8, 2007 02:06 PM Last Post: Malarkey |
|

