13464ebd5Sriastradh/*
23464ebd5Sriastradh Copyright (c) 2008, 2009 Apple Inc.
33464ebd5Sriastradh
43464ebd5Sriastradh Permission is hereby granted, free of charge, to any person
53464ebd5Sriastradh obtaining a copy of this software and associated documentation files
63464ebd5Sriastradh (the "Software"), to deal in the Software without restriction,
73464ebd5Sriastradh including without limitation the rights to use, copy, modify, merge,
83464ebd5Sriastradh publish, distribute, sublicense, and/or sell copies of the Software,
93464ebd5Sriastradh and to permit persons to whom the Software is furnished to do so,
103464ebd5Sriastradh subject to the following conditions:
113464ebd5Sriastradh
123464ebd5Sriastradh The above copyright notice and this permission notice shall be
133464ebd5Sriastradh included in all copies or substantial portions of the Software.
143464ebd5Sriastradh
153464ebd5Sriastradh THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
163464ebd5Sriastradh EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
173464ebd5Sriastradh MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
183464ebd5Sriastradh NONINFRINGEMENT.  IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
193464ebd5Sriastradh HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
203464ebd5Sriastradh WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
213464ebd5Sriastradh OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
223464ebd5Sriastradh DEALINGS IN THE SOFTWARE.
233464ebd5Sriastradh
243464ebd5Sriastradh Except as contained in this notice, the name(s) of the above
253464ebd5Sriastradh copyright holders shall not be used in advertising or otherwise to
263464ebd5Sriastradh promote the sale, use or other dealings in this Software without
273464ebd5Sriastradh prior written authorization.
283464ebd5Sriastradh*/
293464ebd5Sriastradh#ifndef APPLE_GLX_CONTEXT_H
303464ebd5Sriastradh#define APPLE_GLX_CONTEXT_H
313464ebd5Sriastradh
323464ebd5Sriastradh/* <rdar://problem/6953344> */
333464ebd5Sriastradh#define glTexImage1D glTexImage1D_OSX
343464ebd5Sriastradh#define glTexImage2D glTexImage2D_OSX
353464ebd5Sriastradh#define glTexImage3D glTexImage3D_OSX
363464ebd5Sriastradh#include <OpenGL/CGLTypes.h>
373464ebd5Sriastradh#include <OpenGL/CGLContext.h>
383464ebd5Sriastradh#undef glTexImage1D
393464ebd5Sriastradh#undef glTexImage2D
403464ebd5Sriastradh#undef glTexImage3D
413464ebd5Sriastradh
423464ebd5Sriastradh#include <stdbool.h>
433464ebd5Sriastradh#include <X11/Xlib.h>
443464ebd5Sriastradh#include <GL/glx.h>
453464ebd5Sriastradh#define XP_NO_X_HEADERS
463464ebd5Sriastradh#include <Xplugin.h>
473464ebd5Sriastradh#undef XP_NO_X_HEADERS
483464ebd5Sriastradh
493464ebd5Sriastradh#include "apple_glx_drawable.h"
503464ebd5Sriastradh
513464ebd5Sriastradhstruct apple_glx_context
523464ebd5Sriastradh{
533464ebd5Sriastradh   CGLContextObj context_obj;
543464ebd5Sriastradh   CGLPixelFormatObj pixel_format_obj;
553464ebd5Sriastradh   struct apple_glx_drawable *drawable;
563464ebd5Sriastradh   pthread_t thread_id;
573464ebd5Sriastradh   int screen;
583464ebd5Sriastradh   bool double_buffered;
593464ebd5Sriastradh   bool uses_stereo;
603464ebd5Sriastradh   bool need_update;
613464ebd5Sriastradh   bool is_current;             /* True if the context is current in some thread. */
623464ebd5Sriastradh   bool made_current;           /* True if the context has ever been made current. */
633464ebd5Sriastradh
643464ebd5Sriastradh   /*
653464ebd5Sriastradh    * last_surface is set by the pending_destroy code handler for a drawable.
663464ebd5Sriastradh    * Due to a CG difference, we have to recreate a surface if the window
673464ebd5Sriastradh    * is unmapped and mapped again.
683464ebd5Sriastradh    */
693464ebd5Sriastradh   Window last_surface_window;
703464ebd5Sriastradh   struct apple_glx_context *previous, *next;
713464ebd5Sriastradh};
723464ebd5Sriastradh
733464ebd5Sriastradhbool apple_glx_create_context(void **ptr, Display * dpy, int screen,
743464ebd5Sriastradh                              const void *mode, void *sharedContext,
753464ebd5Sriastradh                              int *errorptr, bool * x11errorptr);
763464ebd5Sriastradhvoid apple_glx_destroy_context(void **ptr, Display * dpy);
773464ebd5Sriastradh
783464ebd5Sriastradhbool apple_glx_make_current_context(Display * dpy, void *oldptr, void *ptr,
793464ebd5Sriastradh                                    GLXDrawable drawable);
803464ebd5Sriastradhbool apple_glx_is_current_drawable(Display * dpy, void *ptr,
813464ebd5Sriastradh                                   GLXDrawable drawable);
823464ebd5Sriastradh
833464ebd5Sriastradhbool apple_glx_copy_context(void *currentptr, void *srcptr, void *destptr,
843464ebd5Sriastradh                            unsigned long mask, int *errorptr,
853464ebd5Sriastradh                            bool * x11errorptr);
863464ebd5Sriastradh
873464ebd5Sriastradhint apple_glx_context_surface_changed(unsigned int uid, pthread_t caller);
883464ebd5Sriastradh
893464ebd5Sriastradhvoid apple_glx_context_update(Display * dpy, void *ptr);
903464ebd5Sriastradh
913464ebd5Sriastradhbool apple_glx_context_uses_stereo(void *ptr);
923464ebd5Sriastradh
933464ebd5Sriastradh#endif /*APPLE_GLX_CONTEXT_H */
94