// Tell startup code that we have a client
int cl_available = true;
+qboolean vid_supportrefreshrate = false;
+
// AGL prototypes
AGLPixelFormat (*qaglChoosePixelFormat) (const AGLDevice *gdevs, GLint ndev, const GLint *attribList);
AGLContext (*qaglCreateContext) (AGLPixelFormat pix, AGLContext share);
{
if (context == NULL || window == NULL)
return;
-
+
IN_Activate(false);
VID_RestoreSystemGamma();
-
+
if (context != NULL)
{
qaglDestroyContext(context);
context = NULL;
}
-
+
if (window != NULL)
{
DisposeWindow(window);
static OSStatus MainWindowEventHandler (EventHandlerCallRef nextHandler, EventRef event, void *userData)
{
OSStatus err = noErr;
-
+
switch (GetEventKind (event))
{
case kEventWindowClosed:
vid_activewindow = false;
VID_RestoreSystemGamma();
}
-
+
// Closed
if (AsyncEvent_Quitting)
{
*attrib++ = AGL_NONE;
}
-int VID_InitMode(int fullscreen, int width, int height, int bpp)
+int VID_InitMode(int fullscreen, int width, int height, int bpp, int refreshrate)
{
const EventTypeSpec winEvents[] =
{
return false;
}
- if ((qaglChoosePixelFormat = GL_GetProcAddress("aglChoosePixelFormat")) == NULL
- || (qaglCreateContext = GL_GetProcAddress("aglCreateContext")) == NULL
- || (qaglDestroyContext = GL_GetProcAddress("aglDestroyContext")) == NULL
- || (qaglDestroyPixelFormat = GL_GetProcAddress("aglDestroyPixelFormat")) == NULL
- || (qaglSetCurrentContext = GL_GetProcAddress("aglSetCurrentContext")) == NULL
- || (qaglSetDrawable = GL_GetProcAddress("aglSetDrawable")) == NULL
- || (qaglSetFullScreen = GL_GetProcAddress("aglSetFullScreen")) == NULL
- || (qaglSwapBuffers = GL_GetProcAddress("aglSwapBuffers")) == NULL
+ if ((qaglChoosePixelFormat = (AGLPixelFormat (*) (const AGLDevice *gdevs, GLint ndev, const GLint *attribList))GL_GetProcAddress("aglChoosePixelFormat")) == NULL
+ || (qaglCreateContext = (AGLContext (*) (AGLPixelFormat pix, AGLContext share))GL_GetProcAddress("aglCreateContext")) == NULL
+ || (qaglDestroyContext = (GLboolean (*) (AGLContext ctx))GL_GetProcAddress("aglDestroyContext")) == NULL
+ || (qaglDestroyPixelFormat = (void (*) (AGLPixelFormat pix))GL_GetProcAddress("aglDestroyPixelFormat")) == NULL
+ || (qaglSetCurrentContext = (GLboolean (*) (AGLContext ctx))GL_GetProcAddress("aglSetCurrentContext")) == NULL
+ || (qaglSetDrawable = (GLboolean (*) (AGLContext ctx, AGLDrawable draw))GL_GetProcAddress("aglSetDrawable")) == NULL
+ || (qaglSetFullScreen = (GLboolean (*) (AGLContext ctx, GLsizei width, GLsizei height, GLsizei freq, GLint device))GL_GetProcAddress("aglSetFullScreen")) == NULL
+ || (qaglSwapBuffers = (void (*) (AGLContext ctx))GL_GetProcAddress("aglSwapBuffers")) == NULL
)
{
Con_Printf("AGL functions not found\n");
Con_Printf("Unable to create window (error %d)\n", carbonError);
return false;
}
-
+
// Set the window title
CFStringRef windowTitle = CFSTR("DarkPlaces AGL");
SetWindowTitleWithCFString(window, windowTitle);
// Install the callback function for the window events we can't get
// through ReceiveNextEvent (i.e. close, collapse, and expand)
InstallWindowEventHandler (window, NewEventHandlerUPP (MainWindowEventHandler),
- GetEventTypeCount(winEvents), winEvents, window, NULL);
+ GetEventTypeCount(winEvents), winEvents, window, NULL);
screen = GetGWorldDevice(GetWindowPort(window));
if (screen == NULL)
// Set context and show the window
context = qaglCreateContext(pixelFormat, NULL);
- qaglDestroyPixelFormat(pixelFormat);
if (context == NULL)
- Sys_Error ("aglCreateContext failed\n");
- if (!qaglSetDrawable(context, GetWindowPort(window)))
- Sys_Error ("aglSetDrawable failed\n");
- if (!qaglSetCurrentContext(context))
- Sys_Error ("aglSetCurrentContext failed\n");
-
- scr_width = width;
- scr_height = height;
-
- if ((qglGetString = GL_GetProcAddress("glGetString")) == NULL)
- Sys_Error("glGetString not found in %s", gl_driver);
-
+ Sys_Error ("aglCreateContext failed");
if (fullscreen)
{
if (!qaglSetFullScreen (context, width, height, 0, 0))
- Sys_Error("aglSetFullScreen failed\n");
+ Sys_Error("aglSetFullScreen failed");
vid_isfullscreen = true;
}
+ else
+ {
+ if (!qaglSetDrawable(context, GetWindowPort(window)))
+ Sys_Error ("aglSetDrawable failed");
+ }
+ if (!qaglSetCurrentContext(context))
+ Sys_Error ("aglSetCurrentContext failed");
+ qaglDestroyPixelFormat(pixelFormat);
- gl_renderer = qglGetString(GL_RENDERER);
- gl_vendor = qglGetString(GL_VENDOR);
- gl_version = qglGetString(GL_VERSION);
- gl_extensions = qglGetString(GL_EXTENSIONS);
+ scr_width = width;
+ scr_height = height;
+
+ if ((qglGetString = (const GLubyte* (GLAPIENTRY *)(GLenum name))GL_GetProcAddress("glGetString")) == NULL)
+ Sys_Error("glGetString not found in %s", gl_driver);
+
+ gl_renderer = (const char *)qglGetString(GL_RENDERER);
+ gl_vendor = (const char *)qglGetString(GL_VENDOR);
+ gl_version = (const char *)qglGetString(GL_VERSION);
+ gl_extensions = (const char *)qglGetString(GL_EXTENSIONS);
gl_platform = "AGL";
gl_videosyncavailable = false;
prev_keymod = keymod;
}
-static void Handle_Key(qbyte charcode, qboolean keypressed)
+static void Handle_Key(unsigned char charcode, qboolean keypressed)
{
unsigned int keycode = 0;
char ascii = '\0';
keycode = charcode + ('a' - 'A'); // lowercase it
ascii = charcode;
}
- else if (32 <= charcode && charcode <= 126)
+ else if (32 <= charcode)
{
keycode = charcode;
ascii = charcode;
{
EventRef theEvent;
EventTargetRef theTarget;
-
- // Start by processing the asynchronous events we received since the previous frame
+
+ // Start by processing the asynchronous events we received since the previous frame
VID_ProcessPendingAsyncEvents();
theTarget = GetEventDispatcherTarget();
case kEventMouseMoved:
{
HIPoint deltaPos;
-
+
GetEventParameter(theEvent, kEventParamMouseDelta, typeHIPoint, NULL, sizeof(deltaPos), NULL, &deltaPos);
//Con_Printf(">> kEventMouseMoved (%f, %f) <<\n", deltaPos.x, deltaPos.y);
Handle_Key(keycode, false);
//Con_Printf(">> kEventRawKeyUp (%d) <<\n", keycode);
break;
-
+
case kEventRawKeyModifiersChanged:
{
UInt32 keymod = 0;