Re: Beginning OpenGL programmer
Re: Beginning OpenGL programmer
- Subject: Re: Beginning OpenGL programmer
- From: "Halvor Kise jr." <email@hidden>
- Date: Thu, 4 Apr 2002 20:36:27 +0200 (CEST)
Hi,
On Thu, 4 Apr 2002, Erik M. Buck wrote:
>
initWithFrame:pixelFormat: is the designated initializer.
Thanks, but I have implemented both of them (Yes, I am desperate! :-)
The content of - (id)initWithFrame:(NSRect) frameRect
pixelFormat:(NSOpenGLPixelFormat*) format
is just a copy of the - (id)initWithFrame:(NSRect) frameRect that I
included in my first mail.
The debug string is a little different though...
None of the functions is called.
Just banging my head in the wall here...
- Halvor
>
>
You don't have to turn on double buffering if you are running not-full
>
screen. If you are full screen, see any of the many examples on Apple's
>
site.
>
>
>
----- Original Message -----
>
From: "Halvor Kise jr." <email@hidden>
>
To: <email@hidden>
>
Sent: Thursday, April 04, 2002 11:13 AM
>
Subject: Beginning OpenGL programmer
>
>
>
> Hi,
>
>
>
> I am trying to make a OpenGL enabled program for Mac OS X under Cocoa.
>
>
>
> I have subclassed NSOpenGLView and I am trying to turn on dubble buffering
>
> in my pixelformat.
>
> I have read that the right place to do that is to override
>
> initWithFrame:frameRect
>
>
>
> But my program doesnt seem to work.
>
> Being new to Cocoa, Obj-C _and_ OpenGL is not very promising...
>
>
>
> I have added a bunch of NSLog's and have found out that my initWithFrame
>
> function is not called at all. How come?
>
> I have now used 4 days on this problem! (Guess it turns out I have forgot
>
> a semicolon or something like it...argh!)
>
>
>
> Can someone please help me out here?
>
>
>
> Best,
>
> - Halvor.
>
>
>
> My .h file:
>
> #import <Cocoa/Cocoa.h>
>
> #import <OpenGL/OpenGL.h>
>
> #include <OpenGL/gl.h>
>
> #include <OpenGL/glu.h>
>
> #include <OpenGL/glext.h>
>
> #include <OpenGL/CGLRenderers.h>
>
>
>
> @interface MyOpenGLView : NSOpenGLView
>
> {
>
> // Pixel format & context stuff
>
> NSOpenGLPixelFormatAttribute pfAttribs[32];
>
> NSOpenGLPixelFormat *nsglFormat;
>
> NSOpenGLContext *glContext;
>
>
>
> unsigned long bitsPerPixel, depthSize,
>
> stencilSize, numAuxBuffs;
>
> BOOL enableDepth, packedPixels, pause;
>
> BOOL useDblBuffer, useAccel,
>
> useNoRecover, useAux, useStencil, useAllRender;
>
>
>
> }
>
> // Overrides
>
> - (void)drawRect:(NSRect)rect;
>
> - (id)initWithFrame:(NSRect) frameRect;
>
> - (id)initWithFrame:(NSRect) frameRect
>
pixelFormat:(NSOpenGLPixelFormat*)format;
>
>
>
> // Basic functions
>
> -(void) SetPerspective:(int) width height: (int) height;
>
> -(void) InitializeRContext;
>
>
>
> @end
>
>
>
> and initWithFrame from my MyOpenGLView.m :
>
>
>
////////////////////////////////////////////////////////////////////////////
>
//////
>
> // initWithFrame
>
>
>
////////////////////////////////////////////////////////////////////////////
>
//////
>
> - (id)initWithFrame:(NSRect) frameRect
>
> {
>
> // Basic pixel format with some default values
>
> NSOpenGLPixelFormatAttribute attr[] =
>
> {
>
> NSOpenGLPFANoRecovery,
>
> NSOpenGLPFADoubleBuffer,
>
> NSOpenGLPFAAccelerated,
>
> NSOpenGLPFAColorSize,
>
> 16, // bitsPerPixel,
>
> NSOpenGLPFADepthSize,
>
> 16, // depthSize,
>
> 0 };
>
>
>
> // Create our pixel format
>
> nsglFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
>
>
>
> NSLog(@"Tada!");
>
>
>
> // If the format isn't valid...
>
> if(!nsglFormat)
>
> NSLog(@"Pixel format is nil");
>
> else
>
> NSLog(@"Worked!");
>
> // Otherwise create the context...
>
> self = [super initWithFrame:frameRect pixelFormat:nsglFormat];
>
> // If we don't get a context...
>
> if(!self)
>
> NSLog(@"initWithFrame failed");
>
>
>
> // Otherwise, make the context current and continue
>
> [[self openGLContext] makeCurrentContext];
>
>
>
> return self;
>
> }
>
>
>
> --
>
> *** MEMENTO MORI ***
>
> _______________________________________________
>
> cocoa-dev mailing list | email@hidden
>
> Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
> Do not post admin requests to the list. They will be ignored.
>
>
>
>
>
>
--
*** MEMENTO MORI ***
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.