My program I am trying to use openGL routine to make 3D plots. For example:
Rect rect;
CGrafPtr win;
GLint attrib[] = { AGL_RGBA, AGL_DOUBLEBUFFER, AGL_NONE };
AGLPixelFormat fmt;
AGLContext ctx;
/* Initialize Macintosh system */
InitGraf(&qd.thePort);
InitFonts();
FlushEvents(everyEvent, 0);
InitWindows();
InitMenus();
TEInit();
InitDialogs(0L);
InitCursor();
/* Create a window */
SetRect(&rect,5,5,620,400); // Set default drawing rect.
win = (CGrafPtr) NewCWindow(NULL, &rect, "\p3D", false,
documentProc, (WindowPtr) -1L, true, 0L);
if(win == NULL) return 1;
ShowWindow((GrafPort *) win);
/* Never unload a code module */
aglConfigure(AGL_RETAIN_RENDERERS, GL_TRUE);
//win=(CGrafPtr) (gcPtr->gcFrame);
/* Choose pixel format */
fmt = aglChoosePixelFormat(NULL, 0, attrib);
if(fmt == NULL) return 1;
/* Create an AGL context */
ctx = aglCreateContext(fmt, NULL);
if(ctx == NULL) return 1;
/* Attach the context to the window */
if(!aglSetDrawable(ctx, win)) return 1;
/* Make this context current */
aglSetCurrentContext(ctx);
InitGL();
Idle();
//Dispose of the pixel format
aglDestroyPixelFormat(fmt);
/* Make the context not current, set it's drawable to NULL, and destroy it */
aglSetCurrentContext(NULL);
aglSetDrawable(ctx, NULL);
aglDestroyContext(ctx);
return 0;
The problem is that 3d image will appear but disappear when I click any on the screen. That the graph window close leaving by dial window in which I can click the button to redraw my 3D image but would quit when I click anywhere in the screen. I am trying to have my plot stay around that I could save it to the HD.
Thank you for taking the time to help me
[This message has been edited by hcrogma (edited 07-25-2003).]