Hello.
I wish to use OpenGL on OS-X.
My code works fine on OS-9, but I get an access fault on OS-X on the second-to-the-last line of the listing below. Why?
(mnw.wind is type WindowPtr)
Rect R;
Str255 P_s;
C_to_P("Main",P_s);
SetRect(&R,0,0,mnw.xres,mnw.yres);
mnw.wind=NewCWindow(NULL,&R,P_s,Xtrue,plainDBox,(WindowPtr)-1L,Xfals,0L);
SetPortWindowPort(mnw.wind);
if(!OSX)HideMenuBar();
SizeWindow(mnw.wind,mnw.xres,mnw.yres,Xfals);
GLint wind_attribs[]={ // windowed hardware renderer
AGL_RGBA,
AGL_DOUBLEBUFFER ,
AGL_DEPTH_SIZE ,32, // 32-bit depth buffer better
AGL_NO_RECOVERY , // if hardware resources run out, do NOT switch to software.. it is slow!
AGL_ALL_RENDERERS, // work on all cards possible, even if not 100% compliant
AGL_NONE}; // end-list
GLint full_attribs[]={ // full-screen hardware renderer
AGL_RGBA,
AGL_DOUBLEBUFFER ,
AGL_DEPTH_SIZE ,32, // 32-bit depth buffer better
AGL_NO_RECOVERY , // if hardware resources run out, do NOT switch to software.. it is slow!
AGL_ALL_RENDERERS, // work on all cards possible, even if not 100% compliant
AGL_FULLSCREEN ,
AGL_NONE}; // end-list
GDHandle device=GetMainDevice(); // get main device, and choose a pixel format to run ONLY ON THAT DEVICE! This keeps part of screen from bleeding onto second monitor and slowing down the sim a LOT, if second monitor is not accelled!!
AGLPixelFormat aglpixformat; // pixel format
aglpixformat=aglChoosePixelFormat(&device,1,wind_attribs); // try for a windowed app first... (some 3dfx will provide a "windowed" context, but then NOT draw the cursor!!! do NOT select 3dfx based on this!)
if(aglpixformat==NULL)aglpixformat=aglChoosePixelFormat(&device,1,full_attribs); // ..then accept full-screen. (some 3dfx?)
if(aglpixformat==NULL)return Xfals;
xcon cont=aglCreateContext(aglpixformat,NULL);
if(cont==NULL)return Xfals;
if(!aglSetDrawable(cont,(AGLDrawable)GetWindowPort(mnw.wind)))return Xfals;
if(!aglSetCurrentContext(cont))return Xfals;