/* Pixmaps */
-/* mode is a __GLcontextModes * */
+/* mode is a struct glx_config * */
/* Returns true if an error occurred. */
bool apple_glx_pixmap_create(Display * dpy, int screen, Pixmap pixmap,
const void *mode);
Window root;
int screen;
Pixmap xid;
- __GLcontextModes *modes = (__GLcontextModes *) config;
+ struct glx_config *modes = (__GLcontextModes *) config;
root = DefaultRootWindow(dpy);
screen = DefaultScreen(dpy);
bool double_buffered;
bool uses_stereo;
CGLError error;
- const __GLcontextModes *cmodes = mode;
+ const struct glx_config *cmodes = mode;
if (apple_glx_drawable_create(dpy, screen, pixmap, &d, &callbacks))
return true;
bool offscreen)
{
CGLPixelFormatAttribute attr[MAX_ATTR];
- const __GLcontextModes *c = mode;
+ const struct glx_config *c = mode;
int numattr = 0;
GLint vsref = 0;
CGLError error = 0;
#include <stdbool.h>
#include <OpenGL/CGLTypes.h>
-/* mode is expected to be of type __GLcontextModes. */
+/* mode is expected to be of type struct glx_config. */
void apple_visual_create_pfobj(CGLPixelFormatObj * pfobj, const void *mode,
bool * double_buffered, bool * uses_stereo,
bool offscreen);
static __GLXcontext *
dri2_create_context(__GLXscreenConfigs *base,
- const __GLcontextModes * mode,
+ struct glx_config *config_base,
GLXContext shareList, int renderType)
{
struct dri2_context *pcp, *pcp_shared;
struct dri2_screen *psc = (struct dri2_screen *) base;
- __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;
+ __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
__DRIcontext *shared = NULL;
if (shareList) {
return NULL;
memset(pcp, 0, sizeof *pcp);
- if (!glx_context_init(&pcp->base, &psc->base, mode)) {
+ if (!glx_context_init(&pcp->base, &psc->base, &config->base)) {
Xfree(pcp);
return NULL;
}
static __GLXDRIdrawable *
dri2CreateDrawable(__GLXscreenConfigs *base, XID xDrawable,
- GLXDrawable drawable, const __GLcontextModes * modes)
+ GLXDrawable drawable, struct glx_config *config_base)
{
struct dri2_drawable *pdraw;
struct dri2_screen *psc = (struct dri2_screen *) base;
- __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
+ __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
__GLXdisplayPrivate *dpyPriv;
struct dri2_display *pdp;
GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1;
};
#define __ATTRIB(attrib, field) \
- { attrib, offsetof(__GLcontextModes, field) }
+ { attrib, offsetof(struct glx_config, field) }
static const struct
{
bindToMipmapTexture),
__ATTRIB(__DRI_ATTRIB_YINVERTED, yInverted),};
-#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
-
static int
-scalarEqual(__GLcontextModes * mode, unsigned int attrib, unsigned int value)
+scalarEqual(struct glx_config *mode, unsigned int attrib, unsigned int value)
{
unsigned int glxValue;
int i;
}
static int
-driConfigEqual(const __DRIcoreExtension * core,
- __GLcontextModes * modes, const __DRIconfig * driConfig)
+driConfigEqual(const __DRIcoreExtension *core,
+ struct glx_config *config, const __DRIconfig *driConfig)
{
unsigned int attrib, value, glxValue;
int i;
else if (value & __DRI_ATTRIB_COLOR_INDEX_BIT) {
glxValue |= GLX_COLOR_INDEX_BIT;
}
- if (glxValue != modes->renderType)
+ if (glxValue != config->renderType)
return GL_FALSE;
break;
glxValue = GLX_SLOW_CONFIG;
else
glxValue = GLX_NONE;
- if (glxValue != modes->visualRating)
+ if (glxValue != config->visualRating)
return GL_FALSE;
break;
glxValue |= GLX_TEXTURE_2D_BIT_EXT;
if (value & __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT)
glxValue |= GLX_TEXTURE_RECTANGLE_BIT_EXT;
- if (modes->bindToTextureTargets != GLX_DONT_CARE &&
- glxValue != modes->bindToTextureTargets)
+ if (config->bindToTextureTargets != GLX_DONT_CARE &&
+ glxValue != config->bindToTextureTargets)
return GL_FALSE;
break;
default:
- if (!scalarEqual(modes, attrib, value))
+ if (!scalarEqual(config, attrib, value))
return GL_FALSE;
}
}
return GL_TRUE;
}
-static __GLcontextModes *
+static struct glx_config *
createDriMode(const __DRIcoreExtension * core,
- __GLcontextModes * modes, const __DRIconfig ** driConfigs)
+ struct glx_config *config, const __DRIconfig **driConfigs)
{
- __GLXDRIconfigPrivate *config;
+ __GLXDRIconfigPrivate *driConfig;
int i;
for (i = 0; driConfigs[i]; i++) {
- if (driConfigEqual(core, modes, driConfigs[i]))
+ if (driConfigEqual(core, config, driConfigs[i]))
break;
}
if (driConfigs[i] == NULL)
return NULL;
- config = Xmalloc(sizeof *config);
- if (config == NULL)
+ driConfig = Xmalloc(sizeof *driConfig);
+ if (driConfig == NULL)
return NULL;
- config->modes = *modes;
- config->driConfig = driConfigs[i];
+ driConfig->base = *config;
+ driConfig->driConfig = driConfigs[i];
- return &config->modes;
+ return &driConfig->base;
}
-_X_HIDDEN __GLcontextModes *
+_X_HIDDEN struct glx_config *
driConvertConfigs(const __DRIcoreExtension * core,
- __GLcontextModes * modes, const __DRIconfig ** configs)
+ struct glx_config *configs, const __DRIconfig **driConfigs)
{
- __GLcontextModes head, *tail, *m;
+ struct glx_config head, *tail, *m;
tail = &head;
head.next = NULL;
- for (m = modes; m; m = m->next) {
- tail->next = createDriMode(core, m, configs);
+ for (m = configs; m; m = m->next) {
+ tail->next = createDriMode(core, m, driConfigs);
if (tail->next == NULL) {
/* no matching dri config for m */
continue;
tail = tail->next;
}
- _gl_context_modes_destroy(modes);
+ glx_config_destroy_list(configs);
return head.next;
}
struct __GLXDRIconfigPrivateRec
{
- __GLcontextModes modes;
+ struct glx_config base;
const __DRIconfig *driConfig;
};
-extern __GLcontextModes *driConvertConfigs(const __DRIcoreExtension * core,
- __GLcontextModes * modes,
+extern struct glx_config *driConvertConfigs(const __DRIcoreExtension * core,
+ struct glx_config * modes,
const __DRIconfig ** configs);
extern void driDestroyConfigs(const __DRIconfig **configs);
drm_handle_t hFB;
int junk;
const __DRIconfig **driver_configs;
- __GLcontextModes *visual;
+ struct glx_config *visual;
/* DRI protocol version. */
dri_version.major = driDpy->driMajor;
static __GLXcontext *
dri_create_context(__GLXscreenConfigs *base,
- const __GLcontextModes *mode,
+ struct glx_config *config_base,
GLXContext shareList, int renderType)
{
struct dri_context *pcp, *pcp_shared;
struct dri_screen *psc = (struct dri_screen *) base;
drm_context_t hwContext;
__DRIcontext *shared = NULL;
- __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;
+ __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
if (!psc->base.driScreen)
return NULL;
return NULL;
memset(pcp, 0, sizeof *pcp);
- if (!glx_context_init(&pcp->base, &psc->base, mode)) {
+ if (!glx_context_init(&pcp->base, &psc->base, &config->base)) {
Xfree(pcp);
return NULL;
}
if (!XF86DRICreateContextWithConfig(psc->base.dpy, psc->base.scr,
- mode->visualID,
+ config->base.visualID,
&pcp->hwContextID, &hwContext)) {
Xfree(pcp);
return NULL;
static __GLXDRIdrawable *
driCreateDrawable(__GLXscreenConfigs *base,
XID xDrawable,
- GLXDrawable drawable, const __GLcontextModes * modes)
+ GLXDrawable drawable, struct glx_config *config_base)
{
drm_drawable_t hwDrawable;
void *empty_attribute_list = NULL;
- __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
+ __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
struct dri_screen *psc = (struct dri_screen *) base;
struct dri_drawable *pdp;
static __GLXcontext *
drisw_create_context(__GLXscreenConfigs *base,
- const __GLcontextModes *mode,
+ struct glx_config *config_base,
GLXContext shareList, int renderType)
{
struct drisw_context *pcp, *pcp_shared;
- __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;
+ __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) config_base;
struct drisw_screen *psc = (struct drisw_screen *) base;
__DRIcontext *shared = NULL;
return NULL;
memset(pcp, 0, sizeof *pcp);
- if (!glx_context_init(&pcp->base, &psc->base, mode)) {
+ if (!glx_context_init(&pcp->base, &psc->base, &config->base)) {
Xfree(pcp);
return NULL;
}
static __GLXDRIdrawable *
driCreateDrawable(__GLXscreenConfigs *base, XID xDrawable,
- GLXDrawable drawable, const __GLcontextModes * modes)
+ GLXDrawable drawable, struct glx_config *modes)
{
struct drisw_drawable *pdp;
__GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
/**
* \file glcontextmodes.c
- * Utility routines for working with \c __GLcontextModes structures. At
+ * Utility routines for working with \c struct glx_config structures. At
* some point most or all of these functions will be moved to the Mesa
* code base.
*
#define NUM_VISUAL_TYPES 6
/**
- * Convert an X visual type to a GLX visual type.
- *
- * \param visualType X visual type (i.e., \c TrueColor, \c StaticGray, etc.)
- * to be converted.
- * \return If \c visualType is a valid X visual type, a GLX visual type will
- * be returned. Otherwise \c GLX_NONE will be returned.
- */
-GLint
-_gl_convert_from_x_visual_type(int visualType)
-{
- static const int glx_visual_types[NUM_VISUAL_TYPES] = {
- GLX_STATIC_GRAY, GLX_GRAY_SCALE,
- GLX_STATIC_COLOR, GLX_PSEUDO_COLOR,
- GLX_TRUE_COLOR, GLX_DIRECT_COLOR
- };
-
- return ((unsigned) visualType < NUM_VISUAL_TYPES)
- ? glx_visual_types[visualType] : GLX_NONE;
-}
-
-/**
- * Get data from a GL context mode.
+ * Get data from a GLX config
*
* \param mode GL context mode whose data is to be returned.
* \param attribute Attribute of \c mode that is to be returned.
* \return If \c attribute is a valid attribute of \c mode, zero is
* returned. Otherwise \c GLX_BAD_ATTRIBUTE is returned.
*/
-int
-_gl_get_context_mode_data(const __GLcontextModes * mode, int attribute,
- int *value_return)
+_X_HIDDEN int
+glx_config_get(struct glx_config * mode, int attribute, int *value_return)
{
switch (attribute) {
case GLX_USE_GL:
/**
- * Allocate a linked list of \c __GLcontextModes structures. The fields of
+ * Allocate a linked list of \c struct glx_config structures. The fields of
* each structure will be initialized to "reasonable" default values. In
* most cases this is the default value defined by table 3.4 of the GLX
* 1.3 specification. This means that most values are either initialized to
* \param count Number of structures to allocate.
* \param minimum_size Minimum size of a structure to allocate. This allows
* for differences in the version of the
- * \c __GLcontextModes stucture used in libGL and in a
+ * \c struct glx_config stucture used in libGL and in a
* DRI-based driver.
* \returns A pointer to the first element in a linked list of \c count
* stuctures on success, or \c NULL on failure.
- *
- * \warning Use of \c minimum_size does \b not guarantee binary compatibility.
- * The fundamental assumption is that if the \c minimum_size
- * specified by the driver and the size of the \c __GLcontextModes
- * structure in libGL is the same, then the meaning of each byte in
- * the structure is the same in both places. \b Be \b careful!
- * Basically this means that fields have to be added in libGL and
- * then propagated to drivers. Drivers should \b never arbitrarilly
- * extend the \c __GLcontextModes data-structure.
*/
-__GLcontextModes *
-_gl_context_modes_create(unsigned count, size_t minimum_size)
+_X_HIDDEN struct glx_config *
+glx_config_create_list(unsigned count)
{
- const size_t size = (minimum_size > sizeof(__GLcontextModes))
- ? minimum_size : sizeof(__GLcontextModes);
- __GLcontextModes *base = NULL;
- __GLcontextModes **next;
+ const size_t size = sizeof(struct glx_config);
+ struct glx_config *base = NULL;
+ struct glx_config **next;
unsigned i;
next = &base;
for (i = 0; i < count; i++) {
- *next = (__GLcontextModes *) malloc(size);
+ *next = (struct glx_config *) malloc(size);
if (*next == NULL) {
- _gl_context_modes_destroy(base);
- base = NULL;
- break;
+ glx_config_destroy_list(base);
+ base = NULL;
+ break;
}
(void) memset(*next, 0, size);
return base;
}
-
-/**
- * Destroy a linked list of \c __GLcontextModes structures created by
- * \c _gl_context_modes_create.
- *
- * \param modes Linked list of structures to be destroyed. All structres
- * in the list will be freed.
- */
-void
-_gl_context_modes_destroy(__GLcontextModes * modes)
+_X_HIDDEN void
+glx_config_destroy_list(struct glx_config *configs)
{
- while (modes != NULL) {
- __GLcontextModes *const next = modes->next;
+ while (configs != NULL) {
+ struct glx_config *const next = configs->next;
- free(modes);
- modes = next;
+ free(configs);
+ configs = next;
}
}
* the list, or \c NULL if it was not.
*/
-__GLcontextModes *
-_gl_context_modes_find_visual(__GLcontextModes * modes, int vid)
+_X_HIDDEN struct glx_config *
+glx_config_find_visual(struct glx_config *configs, int vid)
{
- __GLcontextModes *m;
+ struct glx_config *c;
- for (m = modes; m != NULL; m = m->next)
- if (m->visualID == vid)
- return m;
+ for (c = configs; c != NULL; c = c->next)
+ if (c->visualID == vid)
+ return c;
return NULL;
}
-__GLcontextModes *
-_gl_context_modes_find_fbconfig(__GLcontextModes * modes, int fbid)
+_X_HIDDEN struct glx_config *
+glx_config_find_fbconfig(struct glx_config *configs, int fbid)
{
- __GLcontextModes *m;
+ struct glx_config *c;
- for (m = modes; m != NULL; m = m->next)
- if (m->fbconfigID == fbid)
- return m;
+ for (c = configs; c != NULL; c = c->next)
+ if (c->fbconfigID == fbid)
+ return c;
return NULL;
}
#ifndef GLCONTEXTMODES_H
#define GLCONTEXTMODES_H
-typedef struct __GLcontextModesRec {
- struct __GLcontextModesRec * next;
+struct glx_config {
+ struct glx_config * next;
GLboolean rgbMode;
GLboolean floatMode;
GLint bindToMipmapTexture;
GLint bindToTextureTargets;
GLint yInverted;
-} __GLcontextModes;
+};
#define __GLX_MIN_CONFIG_PROPS 18
#define __GLX_MAX_CONFIG_PROPS 500
(__GLX_MIN_CONFIG_PROPS + 2 * __GLX_EXT_CONFIG_PROPS)
extern GLint _gl_convert_from_x_visual_type(int visualType);
-extern int _gl_get_context_mode_data(const __GLcontextModes * mode,
- int attribute, int *value_return);
-extern __GLcontextModes *_gl_context_modes_create(unsigned count,
- size_t minimum_size);
-extern void _gl_context_modes_destroy(__GLcontextModes * modes);
-extern __GLcontextModes *_gl_context_modes_find_visual(__GLcontextModes *
- modes, int vid);
-extern __GLcontextModes *_gl_context_modes_find_fbconfig(__GLcontextModes *
- modes, int fbid);
+
+extern int
+glx_config_get(struct glx_config * mode, int attribute, int *value_return);
+extern struct glx_config *
+glx_config_create_list(unsigned count);
+extern void
+glx_config_destroy_list(struct glx_config *configs);
+extern struct glx_config *
+glx_config_find_visual(struct glx_config *configs, int vid);
+extern struct glx_config *
+glx_config_find_fbconfig(struct glx_config *configs, int fbid);
#endif /* GLCONTEXTMODES_H */
+
}
static void
-CreateDRIDrawable(Display *dpy, const __GLcontextModes *fbconfig,
+CreateDRIDrawable(Display *dpy, struct glx_config *config,
XID drawable, XID glxdrawable,
const int *attrib_list, size_t num_attribs)
{
__GLXDRIdrawable *pdraw;
__GLXscreenConfigs *psc;
- psc = priv->screenConfigs[fbconfig->screen];
+ psc = priv->screenConfigs[config->screen];
if (psc->driScreen == NULL)
return;
pdraw = psc->driScreen->createDrawable(psc, drawable,
- glxdrawable, fbconfig);
+ glxdrawable, config);
if (pdraw == NULL) {
fprintf(stderr, "failed to create drawable\n");
return;
#else
static void
-CreateDRIDrawable(Display *dpy, const __GLcontextModes * fbconfig,
+CreateDRIDrawable(Display *dpy, const struct glx_config * fbconfig,
XID drawable, XID glxdrawable,
const int *attrib_list, size_t num_attribs)
{
* This function needs to be modified to work with direct-rendering drivers.
*/
static GLXDrawable
-CreateDrawable(Display * dpy, const __GLcontextModes * fbconfig,
+CreateDrawable(Display *dpy, struct glx_config *config,
Drawable drawable, const int *attrib_list, CARD8 glxCode)
{
xGLXCreateWindowReq *req;
req->reqType = opcode;
req->glxCode = glxCode;
- req->screen = (CARD32) fbconfig->screen;
- req->fbconfig = fbconfig->fbconfigID;
- req->window = (CARD32) drawable;
- req->glxwindow = (GLXWindow) XAllocID(dpy);
- req->numAttribs = (CARD32) i;
+ req->screen = config->screen;
+ req->fbconfig = config->fbconfigID;
+ req->window = drawable;
+ req->glxwindow = XAllocID(dpy);
+ req->numAttribs = i;
if (attrib_list)
memcpy(data, attrib_list, 8 * i);
UnlockDisplay(dpy);
SyncHandle();
- CreateDRIDrawable(dpy, fbconfig, drawable, req->glxwindow, attrib_list, i);
+ CreateDRIDrawable(dpy, config, drawable, req->glxwindow, attrib_list, i);
- return (GLXDrawable) req->glxwindow;
+ return req->glxwindow;
}
* This function needs to be modified to work with direct-rendering drivers.
*/
static GLXDrawable
-CreatePbuffer(Display * dpy, const __GLcontextModes * fbconfig,
+CreatePbuffer(Display * dpy, struct glx_config *config,
unsigned int width, unsigned int height,
const int *attrib_list, GLboolean size_in_attribs)
{
req->reqType = opcode;
req->glxCode = X_GLXCreatePbuffer;
- req->screen = (CARD32) fbconfig->screen;
- req->fbconfig = fbconfig->fbconfigID;
- req->pbuffer = (GLXPbuffer) id;
- req->numAttribs = (CARD32) (i + extra);
+ req->screen = config->screen;
+ req->fbconfig = config->fbconfigID;
+ req->pbuffer = id;
+ req->numAttribs = i + extra;
if (!size_in_attribs) {
data[(2 * i) + 0] = GLX_PBUFFER_WIDTH;
vpreq->glxCode = X_GLXVendorPrivate;
vpreq->vendorCode = X_GLXvop_CreateGLXPbufferSGIX;
- data[0] = (CARD32) fbconfig->screen;
- data[1] = (CARD32) fbconfig->fbconfigID;
- data[2] = (CARD32) id;
- data[3] = (CARD32) width;
- data[4] = (CARD32) height;
+ data[0] = config->screen;
+ data[1] = config->fbconfigID;
+ data[2] = id;
+ data[3] = width;
+ data[4] = height;
data += 5;
}
UnlockDisplay(dpy);
SyncHandle();
- pixmap = XCreatePixmap(dpy, RootWindow(dpy, fbconfig->screen),
- width, height, fbconfig->rgbBits);
+ pixmap = XCreatePixmap(dpy, RootWindow(dpy, config->screen),
+ width, height, config->rgbBits);
- CreateDRIDrawable(dpy, fbconfig, pixmap, id, attrib_list, i);
+ CreateDRIDrawable(dpy, config, pixmap, id, attrib_list, i);
return id;
}
unsigned int width, unsigned int height,
int *attrib_list)
{
- return (GLXPbufferSGIX) CreatePbuffer(dpy, (__GLcontextModes *) config,
+ return (GLXPbufferSGIX) CreatePbuffer(dpy, (struct glx_config *) config,
width, height,
attrib_list, GL_FALSE);
}
}
}
- return (GLXPbuffer) CreatePbuffer(dpy, (__GLcontextModes *) config,
+ return (GLXPbuffer) CreatePbuffer(dpy, (struct glx_config *) config,
width, height, attrib_list, GL_TRUE);
#endif
}
WARN_ONCE_GLX_1_3(dpy, __func__);
#ifdef GLX_USE_APPLEGL
- const __GLcontextModes *modes = (const __GLcontextModes *) config;
+ const struct glx_config *modes = (const __GLcontextModes *) config;
if (apple_glx_pixmap_create(dpy, modes->screen, pixmap, modes))
return None;
return pixmap;
#else
- return CreateDrawable(dpy, (__GLcontextModes *) config,
+ return CreateDrawable(dpy, (struct glx_config *) config,
(Drawable) pixmap, attrib_list, X_GLXCreatePixmap);
#endif
}
return win;
#else
- return CreateDrawable(dpy, (__GLcontextModes *) config,
+ return CreateDrawable(dpy, (struct glx_config *) config,
(Drawable) win, attrib_list, X_GLXCreateWindow);
#endif
}
# define USED
#endif
-
+#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
#define GLX_MAJOR_VERSION 1 /* current version numbers */
#define GLX_MINOR_VERSION 4
void (*destroyScreen)(__GLXscreenConfigs *psc);
__GLXcontext *(*createContext)(__GLXscreenConfigs *psc,
- const __GLcontextModes *mode,
+ struct glx_config *config,
GLXContext shareList, int renderType);
__GLXDRIdrawable *(*createDrawable)(__GLXscreenConfigs *psc,
XID drawable,
GLXDrawable glxDrawable,
- const __GLcontextModes *modes);
+ struct glx_config *config);
int64_t (*swapBuffers)(__GLXDRIdrawable *pdraw, int64_t target_msc,
int64_t divisor, int64_t remainder);
GLint majorOpcode;
/**
- * Pointer to the mode used to create this context.
+ * Pointer to the config used to create this context.
*/
- const __GLcontextModes *mode;
+ struct glx_config *config;
#ifdef GLX_DIRECT_RENDERING
#ifdef GLX_USE_APPLEGL
extern Bool
glx_context_init(__GLXcontext *gc,
- __GLXscreenConfigs *psc, const __GLcontextModes *fbconfig);
+ __GLXscreenConfigs *psc, struct glx_config *fbconfig);
#define __glXSetError(gc,code) \
if (!(gc)->error) { \
*/
struct glx_screen_vtable {
__GLXcontext *(*create_context)(__GLXscreenConfigs *psc,
- const __GLcontextModes *mode,
+ struct glx_config *config,
GLXContext shareList, int renderType);
};
/**
* Linked list of glx visuals and fbconfigs for this screen.
*/
- __GLcontextModes *visuals, *configs;
+ struct glx_config *visuals, *configs;
/**
* Per-screen dynamic GLX extension tracking. The \c direct_support
#endif
-extern void __glXInitializeVisualConfigFromTags(__GLcontextModes * config,
+extern void __glXInitializeVisualConfigFromTags(struct glx_config * config,
int count, const INT32 * bp,
Bool tagged_only,
Bool fbconfig_style_tags);
* \param config Application supplied \c GLXFBConfig.
*
* \returns If the \c GLXFBConfig is valid, the a pointer to the matching
- * \c __GLcontextModes structure is returned. Otherwise, \c NULL
+ * \c struct glx_config structure is returned. Otherwise, \c NULL
* is returned.
*/
-static __GLcontextModes *
-ValidateGLXFBConfig(Display * dpy, GLXFBConfig config)
+static struct glx_config *
+ValidateGLXFBConfig(Display * dpy, GLXFBConfig fbconfig)
{
__GLXdisplayPrivate *const priv = __glXInitialize(dpy);
- const unsigned num_screens = ScreenCount(dpy);
+ int num_screens = ScreenCount(dpy);
unsigned i;
- const __GLcontextModes *modes;
-
+ struct glx_config *config;
if (priv != NULL) {
for (i = 0; i < num_screens; i++) {
- for (modes = priv->screenConfigs[i]->configs; modes != NULL;
- modes = modes->next) {
- if (modes == (__GLcontextModes *) config) {
- return (__GLcontextModes *) config;
- }
- }
+ for (config = priv->screenConfigs[i]->configs; config != NULL;
+ config = config->next) {
+ if (config == (struct glx_config *) fbconfig) {
+ return config;
+ }
+ }
}
}
static __GLcontext *
applegl_create_context(__GLXscreenConfigs *psc,
- const __GLcontextModes *mode,
- GLXContext shareList, int renderType)
+ struct glx_config *mode,
+ GLXContext shareList, int renderType)
{
__GLXcontext *gc;
int errorcode;
*/
static GLXContext
indirect_create_context(__GLXscreenConfigs *psc,
- const __GLcontextModes *mode,
+ struct glx_config *mode,
GLXContext shareList, int renderType)
{
GLXContext gc;
_X_HIDDEN Bool
glx_context_init(__GLXcontext *gc,
- __GLXscreenConfigs *psc, const __GLcontextModes *fbconfig)
+ __GLXscreenConfigs *psc, struct glx_config *config)
{
gc->majorOpcode = __glXSetupForCommand(psc->display->dpy);
if (!gc->majorOpcode)
gc->screen = psc->scr;
gc->psc = psc;
- gc->mode = fbconfig;
+ gc->config = config;
gc->isDirect = GL_TRUE;
return GL_TRUE;
static GLXContext
CreateContext(Display * dpy, int generic_id,
- const __GLcontextModes * const fbconfig,
+ struct glx_config *config,
GLXContext shareList,
Bool allowDirect,
unsigned code, int renderType, int screen)
gc = NULL;
if (allowDirect && psc->vtable->create_context)
- gc = psc->vtable->create_context(psc, fbconfig,
- shareList, renderType);
+ gc = psc->vtable->create_context(psc, config, shareList, renderType);
if (!gc)
- gc = indirect_create_context(psc, fbconfig, shareList, renderType);
+ gc = indirect_create_context(psc, config, shareList, renderType);
if (!gc)
return NULL;
glXCreateContext(Display * dpy, XVisualInfo * vis,
GLXContext shareList, Bool allowDirect)
{
- const __GLcontextModes *mode = NULL;
+ struct glx_config *config = NULL;
int renderType = 0;
#if defined(GLX_DIRECT_RENDERING) || defined(GLX_USE_APPLEGL)
__GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, vis->screen);
- mode = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
- if (mode == NULL) {
+ config = glx_config_find_visual(psc->visuals, vis->visualid);
+ if (config == NULL) {
xError error;
error.errorCode = BadValue;
return None;
}
- renderType = mode->rgbMode ? GLX_RGBA_TYPE : GLX_COLOR_INDEX_TYPE;
+ renderType = config->rgbMode ? GLX_RGBA_TYPE : GLX_COLOR_INDEX_TYPE;
#endif
- return CreateContext(dpy, vis->visualid, mode, shareList, allowDirect,
+ return CreateContext(dpy, vis->visualid, config, shareList, allowDirect,
X_GLXCreateContext, renderType, vis->screen);
}
#ifdef GLX_USE_APPLEGL
int screen = vis->screen;
__GLXscreenConfigs *const psc = GetGLXScreenConfigs(dpy, screen);
- const __GLcontextModes *modes;
+ const struct glx_config *config;
- modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
+ config = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
- if(apple_glx_pixmap_create(dpy, vis->screen, pixmap, modes))
+ if(apple_glx_pixmap_create(dpy, vis->screen, pixmap, config))
return None;
return pixmap;
__GLXdisplayPrivate *const priv = __glXInitialize(dpy);
__GLXDRIdrawable *pdraw;
__GLXscreenConfigs *psc;
- __GLcontextModes *modes;
+ struct glx_config *config;
psc = priv->screenConfigs[vis->screen];
if (psc->driScreen == NULL)
break;
- modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
- pdraw = psc->driScreen->createDrawable(psc, pixmap, req->glxpixmap, modes);
+ config = glx_config_find_visual(psc->visuals, vis->visualid);
+ pdraw = psc->driScreen->createDrawable(psc, pixmap, req->glxpixmap, config);
if (pdraw == NULL) {
fprintf(stderr, "failed to create pixmap\n");
break;
{
__GLXdisplayPrivate *priv;
__GLXscreenConfigs *psc;
- __GLcontextModes *modes;
+ struct glx_config *config;
int status;
status = GetGLXPrivScreenConfig(dpy, vis->screen, &priv, &psc);
if (status == Success) {
- modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
+ config = glx_config_find_visual(psc->visuals, vis->visualid);
/* Lookup attribute after first finding a match on the visual */
- if (modes != NULL) {
- return _gl_get_context_mode_data(modes, attribute, value_return);
+ if (config != NULL) {
+ return glx_config_get(config, attribute, value_return);
}
status = GLX_BAD_VISUAL;
/************************************************************************/
static void
-init_fbconfig_for_chooser(__GLcontextModes * config,
+init_fbconfig_for_chooser(struct glx_config * config,
GLboolean fbconfig_style_tags)
{
- memset(config, 0, sizeof(__GLcontextModes));
+ memset(config, 0, sizeof(struct glx_config));
config->visualID = (XID) GLX_DONT_CARE;
config->visualType = GLX_DONT_CARE;
* \param b Server specified config to test against \c a.
*/
static Bool
-fbconfigs_compatible(const __GLcontextModes * const a,
- const __GLcontextModes * const b)
+fbconfigs_compatible(const struct glx_config * const a,
+ const struct glx_config * const b)
{
MATCH_DONT_CARE(doubleBufferMode);
MATCH_DONT_CARE(visualType);
* \sa qsort, glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX
*/
static int
-fbconfig_compare(const __GLcontextModes * const *const a,
- const __GLcontextModes * const *const b)
+fbconfig_compare(struct glx_config **a, struct glx_config **b)
{
/* The order of these comparisons must NOT change. It is defined by
* the GLX 1.3 spec and ARB_multisample.
* \sa glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX
*/
static int
-choose_visual(__GLcontextModes ** configs, int num_configs,
+choose_visual(struct glx_config ** configs, int num_configs,
const int *attribList, GLboolean fbconfig_style_tags)
{
- __GLcontextModes test_config;
+ struct glx_config test_config;
int base;
int i;
* specifications.
*/
- qsort(configs, base, sizeof(__GLcontextModes *),
+ qsort(configs, base, sizeof(struct glx_config *),
(int (*)(const void *, const void *)) fbconfig_compare);
return base;
}
XVisualInfo *visualList = NULL;
__GLXdisplayPrivate *priv;
__GLXscreenConfigs *psc;
- __GLcontextModes test_config;
- __GLcontextModes *modes;
- const __GLcontextModes *best_config = NULL;
+ struct glx_config test_config;
+ struct glx_config *config;
+ struct glx_config *best_config = NULL;
/*
** Get a list of all visuals, return if list is empty
** Otherwise, create an XVisualInfo list with just the selected X visual
** and return this.
*/
- for (modes = psc->visuals; modes != NULL; modes = modes->next) {
- if (fbconfigs_compatible(&test_config, modes)
- && ((best_config == NULL)
- ||
- (fbconfig_compare
- ((const __GLcontextModes * const *const) &modes,
- &best_config) < 0))) {
+ for (config = psc->visuals; config != NULL; config = config->next) {
+ if (fbconfigs_compatible(&test_config, config)
+ && ((best_config == NULL) ||
+ (fbconfig_compare (&config, &best_config) < 0))) {
XVisualInfo visualTemplate;
XVisualInfo *newList;
int i;
visualTemplate.screen = screen;
- visualTemplate.visualid = modes->visualID;
+ visualTemplate.visualid = config->visualID;
newList = XGetVisualInfo(dpy, VisualScreenMask | VisualIDMask,
&visualTemplate, &i);
if (newList) {
Xfree(visualList);
visualList = newList;
- best_config = modes;
+ best_config = config;
}
}
}
int propList[__GLX_MAX_CONTEXT_PROPS * 2], *pProp, nPropListBytes;
int i, renderType;
XID share;
- __GLcontextModes *mode;
+ struct glx_config *mode;
if (contextID == None || __glXIsDirect(dpy, contextID))
return NULL;
share = pProp[1];
break;
case GLX_VISUAL_ID_EXT:
- mode = _gl_context_modes_find_visual(psc->visuals, pProp[1]);
+ mode = glx_config_find_visual(psc->visuals, pProp[1]);
break;
case GLX_FBCONFIG_ID:
- mode = _gl_context_modes_find_fbconfig(psc->configs, pProp[1]);
+ mode = glx_config_find_fbconfig(psc->configs, pProp[1]);
break;
case GLX_RENDER_TYPE:
renderType = pProp[1];
*value = ctx->share_xid;
break;
case GLX_VISUAL_ID_EXT:
- *value = ctx->mode ? ctx->mode->visualID : None;
+ *value = ctx->config ? ctx->config->visualID : None;
break;
case GLX_SCREEN:
*value = ctx->screen;
break;
case GLX_FBCONFIG_ID:
- *value = ctx->mode ? ctx->mode->fbconfigID : None;
+ *value = ctx->config ? ctx->config->fbconfigID : None;
break;
case GLX_RENDER_TYPE:
*value = ctx->renderType;
glXChooseFBConfig(Display * dpy, int screen,
const int *attribList, int *nitems)
{
- __GLcontextModes **config_list;
+ struct glx_config **config_list;
int list_size;
- config_list = (__GLcontextModes **)
+ config_list = (struct glx_config **)
glXGetFBConfigs(dpy, screen, &list_size);
if ((config_list != NULL) && (list_size > 0) && (attribList != NULL)) {
PUBLIC GLXContext
-glXCreateNewContext(Display * dpy, GLXFBConfig config,
+glXCreateNewContext(Display * dpy, GLXFBConfig fbconfig,
int renderType, GLXContext shareList, Bool allowDirect)
{
- const __GLcontextModes *const fbconfig =
- (const __GLcontextModes *const) config;
+ struct glx_config *config = (struct glx_config *) fbconfig;
- return CreateContext(dpy, fbconfig->fbconfigID, fbconfig, shareList,
- allowDirect, X_GLXCreateNewContext, renderType,
- fbconfig->screen);
+ return CreateContext(dpy, config->fbconfigID, config, shareList,
+ allowDirect, X_GLXCreateNewContext, renderType,
+ config->screen);
}
glXGetFBConfigs(Display * dpy, int screen, int *nelements)
{
__GLXdisplayPrivate *priv = __glXInitialize(dpy);
- __GLcontextModes **config = NULL;
+ struct glx_config **config_list = NULL;
+ struct glx_config *config;
+ unsigned num_configs = 0;
int i;
*nelements = 0;
&& (priv->screenConfigs[screen]->configs != NULL)
&& (priv->screenConfigs[screen]->configs->fbconfigID
!= (int) GLX_DONT_CARE)) {
- unsigned num_configs = 0;
- __GLcontextModes *modes;
-
- for (modes = priv->screenConfigs[screen]->configs; modes != NULL;
- modes = modes->next) {
- if (modes->fbconfigID != (int) GLX_DONT_CARE) {
+ for (config = priv->screenConfigs[screen]->configs; config != NULL;
+ config = config->next) {
+ if (config->fbconfigID != (int) GLX_DONT_CARE) {
num_configs++;
}
}
- config = (__GLcontextModes **) Xmalloc(sizeof(__GLcontextModes *)
- * num_configs);
- if (config != NULL) {
+ config_list = Xmalloc(num_configs * sizeof *config_list);
+ if (config_list != NULL) {
*nelements = num_configs;
i = 0;
- for (modes = priv->screenConfigs[screen]->configs; modes != NULL;
- modes = modes->next) {
- if (modes->fbconfigID != (int) GLX_DONT_CARE) {
- config[i] = modes;
+ for (config = priv->screenConfigs[screen]->configs; config != NULL;
+ config = config->next) {
+ if (config->fbconfigID != (int) GLX_DONT_CARE) {
+ config_list[i] = config;
i++;
}
}
}
}
- return (GLXFBConfig *) config;
+
+ return (GLXFBConfig *) config_list;
}
PUBLIC int
-glXGetFBConfigAttrib(Display * dpy, GLXFBConfig config,
+glXGetFBConfigAttrib(Display * dpy, GLXFBConfig fbconfig,
int attribute, int *value)
{
- __GLcontextModes *const modes = ValidateGLXFBConfig(dpy, config);
+ struct glx_config *config = ValidateGLXFBConfig(dpy, fbconfig);
+
+ if (config == NULL)
+ return GLXBadFBConfig;
- return (modes != NULL)
- ? _gl_get_context_mode_data(modes, attribute, value)
- : GLXBadFBConfig;
+ return glx_config_get(config, attribute, value);
}
PUBLIC XVisualInfo *
-glXGetVisualFromFBConfig(Display * dpy, GLXFBConfig config)
+glXGetVisualFromFBConfig(Display * dpy, GLXFBConfig fbconfig)
{
XVisualInfo visualTemplate;
- __GLcontextModes *fbconfig = (__GLcontextModes *) config;
+ struct glx_config *config = (struct glx_config *) fbconfig;
int count;
/*
** Get a list of all visuals, return if list is empty
*/
- visualTemplate.visualid = fbconfig->visualID;
+ visualTemplate.visualid = config->visualID;
return XGetVisualInfo(dpy, VisualIDMask, &visualTemplate, &count);
}
PUBLIC GLXPixmap
glXCreateGLXPixmapWithConfigSGIX(Display * dpy,
- GLXFBConfigSGIX config,
+ GLXFBConfigSGIX fbconfig,
Pixmap pixmap)
{
#ifndef GLX_USE_APPLEGL
CARD8 opcode;
__GLXscreenConfigs *psc;
#endif
- const __GLcontextModes *const fbconfig = (__GLcontextModes *) config;
+ struct glx_config *config = (struct glx_config *) fbconfig;
if ((dpy == NULL) || (config == NULL)) {
return None;
}
#ifdef GLX_USE_APPLEGL
- if(apple_glx_pixmap_create(dpy, fbconfig->screen, pixmap, fbconfig))
+ if(apple_glx_pixmap_create(dpy, config->screen, pixmap, config))
return None;
return pixmap;
#else
- psc = GetGLXScreenConfigs(dpy, fbconfig->screen);
+ psc = GetGLXScreenConfigs(dpy, config->screen);
if ((psc != NULL)
&& __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit)) {
opcode = __glXSetupForCommand(dpy);
req->reqType = opcode;
req->glxCode = X_GLXVendorPrivateWithReply;
req->vendorCode = X_GLXvop_CreateGLXPixmapWithConfigSGIX;
- req->screen = fbconfig->screen;
- req->fbconfig = fbconfig->fbconfigID;
+ req->screen = config->screen;
+ req->fbconfig = config->fbconfigID;
req->pixmap = pixmap;
req->glxpixmap = xid = XAllocID(dpy);
UnlockDisplay(dpy);
PUBLIC GLXContext
glXCreateContextWithConfigSGIX(Display * dpy,
- GLXFBConfigSGIX config, int renderType,
+ GLXFBConfigSGIX fbconfig, int renderType,
GLXContext shareList, Bool allowDirect)
{
GLXContext gc = NULL;
- const __GLcontextModes *const fbconfig = (__GLcontextModes *) config;
+ struct glx_config *config = (struct glx_config *) fbconfig;
__GLXscreenConfigs *psc;
return None;
}
- psc = GetGLXScreenConfigs(dpy, fbconfig->screen);
+ psc = GetGLXScreenConfigs(dpy, config->screen);
if ((psc != NULL)
&& __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit)) {
- gc = CreateContext(dpy, fbconfig->fbconfigID, fbconfig, shareList,
+ gc = CreateContext(dpy, config->fbconfigID, config, shareList,
allowDirect,
X_GLXvop_CreateContextWithConfigSGIX, renderType,
- fbconfig->screen);
+ config->screen);
}
return gc;
if ((GetGLXPrivScreenConfig(dpy, vis->screen, &priv, &psc) != Success)
&& __glXExtensionBitIsEnabled(psc, SGIX_fbconfig_bit)
&& (psc->configs->fbconfigID != (int) GLX_DONT_CARE)) {
- return (GLXFBConfigSGIX) _gl_context_modes_find_visual(psc->configs,
- vis->visualid);
+ return (GLXFBConfigSGIX) glx_config_find_visual(psc->configs,
+ vis->visualid);
}
return NULL;
return pdraw;
pdraw = psc->driScreen->createDrawable(psc, glxDrawable,
- glxDrawable, gc->mode);
+ glxDrawable, gc->config);
if (__glxHashInsert(priv->drawHash, glxDrawable, pdraw)) {
(*pdraw->destroyDrawable) (pdraw);
return NULL;
for (i = 0; i < screens; i++) {
psc = priv->screenConfigs[i];
if (psc->configs) {
- _gl_context_modes_destroy(psc->configs);
+ glx_config_destroy_list(psc->configs);
if (psc->effectiveGLXexts)
Xfree(psc->effectiveGLXexts);
psc->configs = NULL; /* NOTE: just for paranoia */
}
if (psc->visuals) {
- _gl_context_modes_destroy(psc->visuals);
- psc->visuals = NULL; /* NOTE: just for paranoia */
+ glx_config_destroy_list(psc->visuals);
+ psc->visuals = NULL; /* NOTE: just for paranoia */
}
Xfree((char *) psc->serverGLXexts);
};
+static GLint
+convert_from_x_visual_type(int visualType)
+{
+ static const int glx_visual_types[] = {
+ GLX_STATIC_GRAY, GLX_GRAY_SCALE,
+ GLX_STATIC_COLOR, GLX_PSEUDO_COLOR,
+ GLX_TRUE_COLOR, GLX_DIRECT_COLOR
+ };
+
+ if (visualType < ARRAY_SIZE(glx_visual_types))
+ return glx_visual_types[visualType];
+
+ return GLX_NONE;
+}
+
/*
* getVisualConfigs uses the !tagged_only path.
* getFBConfigs uses the tagged_only path.
*/
_X_HIDDEN void
-__glXInitializeVisualConfigFromTags(__GLcontextModes * config, int count,
+__glXInitializeVisualConfigFromTags(struct glx_config * config, int count,
const INT32 * bp, Bool tagged_only,
Bool fbconfig_style_tags)
{
/* Copy in the first set of properties */
config->visualID = *bp++;
- config->visualType = _gl_convert_from_x_visual_type(*bp++);
+ config->visualType = convert_from_x_visual_type(*bp++);
config->rgbMode = *bp++;
(config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
}
-static __GLcontextModes *
+static struct glx_config *
createConfigsFromProperties(Display * dpy, int nvisuals, int nprops,
int screen, GLboolean tagged_only)
{
INT32 buf[__GLX_TOTAL_CONFIG], *props;
unsigned prop_size;
- __GLcontextModes *modes, *m;
+ struct glx_config *modes, *m;
int i;
if (nprops == 0)
return NULL;
/* Allocate memory for our config structure */
- modes = _gl_context_modes_create(nvisuals, sizeof(__GLcontextModes));
+ modes = glx_config_create_list(nvisuals);
if (!modes)
return NULL;