Very Frustrated, any idea what's going on?
Very Frustrated, any idea what's going on?
- Subject: Very Frustrated, any idea what's going on?
- From: Graham Wihlidal <email@hidden>
- Date: Sun, 28 Apr 2002 00:19:40 -0600
It's been a while since I've used Obj-C, but since Apple's going this
route for the future, I better jump on the lackey wagon :)
I understand how IB and delegates work, etc...
This is my problem (which SHOULD work according to all the examples and
docs I've checked out)
I made a class called CEGL_Context which is going to handle an
NSOpenGLContext and its info. It is superclassed from NSObject because
as I hear, that's how I access all the dynamic mem functions and other
goodies.
Here is the class' header file (CEGL_Context.h)
#import <Cocoa/Cocoa.h>
#import <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/glext.h>
#include <OpenGL/CGLRenderers.h>
#define DEFAULT_TIME_INTERVAL 0.001
#define FRAME_TIME_INTERVAL 0.300
#define FRAMERATE_TIME_INTERVAL 0.200
@interface CEGL_Context : NSObject
{
@public
//@private
NSOpenGLContext *nsOpenGLContext;
NSOpenGLPixelFormat *pixelFormat;
NSOpenGLPixelFormatAttribute pixelFormatAttribs[64];
unsigned long bitsPerPixel;
unsigned long depthSize;
unsigned long start;
unsigned long totalFrames;
BOOL usePackedPixels;
BOOL useAcceleration;
BOOL useNoRecover;
BOOL useFullscreen;
NSTimer *renderTimer;
NSTimer *frameTimer;
NSTimer *frameRateTimer;
NSTimeInterval frameTimeInterval;
NSTimeInterval timeInterval;
NSTimeInterval frameRateTimeInterval;
double fps;
double bufferSwaps;
double frMin;
double frMax;
double frAvg;
double elapseTime;
double delta;
double time;
//@protected
}
- (id)init;
- (void)dealloc;
- (void)createPixelFormat;
- (void)switchMode:(BOOL)isFullscreen;
- (void)calcFrameRate;
- (void)resetFrameRateCounters;
@end
Here is the .m source file:
#import "CEGL_Context.h"
@implementation CEGL_Context
- (id)init
{
self = [super init];
return self;
}
- (void)dealloc
{
[super release];
}
- (void)createPixelFormat
{
int i = 0;
if (useNoRecover)
pixelFormatAttribs[i++] = NSOpenGLPFANoRecovery;
if (useAcceleration)
pixelFormatAttribs[i++] = NSOpenGLPFAAccelerated;
pixelFormatAttribs[i++] = NSOpenGLPFADoubleBuffer;
pixelFormatAttribs[i++] = NSOpenGLPFAColorSize;
pixelFormatAttribs[i++] = bitsPerPixel;
pixelFormatAttribs[i++] = NSOpenGLPFADepthSize;
pixelFormatAttribs[i++] = depthSize;
pixelFormat = [[NSOpenGLPixelFormat alloc]
initWithAttributes:pixelFormatAttribs];
if (!pixelFormat)
NSLog(@"[CEGL] OpenGL Pixel Format is NULL!]");
}
- (void)switchMode:(BOOL)isFullscreen
{
}
- (void)calcFrameRate
{
}
- (void)resetFrameRateCounters
{
}
@end
In another class (NSApplication delegate to handle IB GUI)
CEGL_AppShell, I instantiate (or attempt to) a CEGL_Context object and
call the createPixelFormat method.
I import the header using #import "CEGL_Context.h" and in the method
applicationDidFinishLaunching for the delegate I want to create the
context instance.
First I create the variable:
CEGL_Context* myContext;
Next I want to allocate memory for this pointer so I call:
myContext = [[CEGL_Context alloc] init];
When I compile I get "/usr/bin/ld: Undefined symbols:
.objc_class_name_CEGL_Context"
If I comment out the allocation, it compiles fine. Means one of two
things:
a) Perhaps Obj-C is different than C++ in the sense that it doesn't care
about the names of class variables until you actually try to allocate
memory for them (Dynamic binding) causing the undefined symbol
b) It finds my class header and create CEGL_Context* myContext fine
because it doesn't choke. I could be doing the allocation wrong itself
(missing something, etc..) and it can't setup an alloc definition for my
class or something
I've checked the code over and over and it doesn't want to compile.
I've also tried many things and same result
Any ideas? I'm really frustrated after spending my whole day (sorry,
wasted my whole day) trying to solve this simple yet elusive problem
Thanks in advance,
Graham Wihlidal
_______________________________________________
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.