Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / libs / mesa / src / egl / main / eglcontext.h
blob0ac846219a7b2e41a1fc9b1c2e092baaa3dca610
1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * Copyright 2009-2010 Chia-I Wu <olvaffe@gmail.com>
5 * Copyright 2010-2011 LunarG, Inc.
6 * All Rights Reserved.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sub license, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
16 * The above copyright notice and this permission notice (including the
17 * next paragraph) shall be included in all copies or substantial portions
18 * of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
28 **************************************************************************/
31 #ifndef EGLCONTEXT_INCLUDED
32 #define EGLCONTEXT_INCLUDED
35 #include "egltypedefs.h"
36 #include "egldisplay.h"
39 /**
40 * "Base" class for device driver contexts.
42 struct _egl_context
44 /* A context is a display resource */
45 _EGLResource Resource;
47 /* The bound status of the context */
48 _EGLThreadInfo *Binding;
49 _EGLSurface *DrawSurface;
50 _EGLSurface *ReadSurface;
52 _EGLConfig *Config;
54 EGLint ClientAPI; /**< EGL_OPENGL_ES_API, EGL_OPENGL_API, EGL_OPENVG_API */
55 EGLint ClientVersion; /**< 1 = OpenGLES 1.x, 2 = OpenGLES 2.x */
57 /* The real render buffer when a window surface is bound */
58 EGLint WindowRenderBuffer;
62 PUBLIC EGLBoolean
63 _eglInitContext(_EGLContext *ctx, _EGLDisplay *dpy,
64 _EGLConfig *config, const EGLint *attrib_list);
67 extern EGLBoolean
68 _eglQueryContext(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLint attribute, EGLint *value);
71 PUBLIC EGLBoolean
72 _eglBindContext(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read,
73 _EGLContext **old_ctx,
74 _EGLSurface **old_draw, _EGLSurface **old_read);
77 /**
78 * Increment reference count for the context.
80 static INLINE _EGLContext *
81 _eglGetContext(_EGLContext *ctx)
83 if (ctx)
84 _eglGetResource(&ctx->Resource);
85 return ctx;
89 /**
90 * Decrement reference count for the context.
92 static INLINE EGLBoolean
93 _eglPutContext(_EGLContext *ctx)
95 return (ctx) ? _eglPutResource(&ctx->Resource) : EGL_FALSE;
99 /**
100 * Link a context to its display and return the handle of the link.
101 * The handle can be passed to client directly.
103 static INLINE EGLContext
104 _eglLinkContext(_EGLContext *ctx)
106 _eglLinkResource(&ctx->Resource, _EGL_RESOURCE_CONTEXT);
107 return (EGLContext) ctx;
112 * Unlink a linked context from its display.
113 * Accessing an unlinked context should generate EGL_BAD_CONTEXT error.
115 static INLINE void
116 _eglUnlinkContext(_EGLContext *ctx)
118 _eglUnlinkResource(&ctx->Resource, _EGL_RESOURCE_CONTEXT);
123 * Lookup a handle to find the linked context.
124 * Return NULL if the handle has no corresponding linked context.
126 static INLINE _EGLContext *
127 _eglLookupContext(EGLContext context, _EGLDisplay *dpy)
129 _EGLContext *ctx = (_EGLContext *) context;
130 if (!dpy || !_eglCheckResource((void *) ctx, _EGL_RESOURCE_CONTEXT, dpy))
131 ctx = NULL;
132 return ctx;
137 * Return the handle of a linked context, or EGL_NO_CONTEXT.
139 static INLINE EGLContext
140 _eglGetContextHandle(_EGLContext *ctx)
142 _EGLResource *res = (_EGLResource *) ctx;
143 return (res && _eglIsResourceLinked(res)) ?
144 (EGLContext) ctx : EGL_NO_CONTEXT;
148 #endif /* EGLCONTEXT_INCLUDED */