apple_glx_drawable.h [plain text]
#ifndef APPLE_GLX_DRAWABLE_H
#define APPLE_GLX_DRAWABLE_H
#include <pthread.h>
#include <stdbool.h>
#include <limits.h>
#include <GL/glx.h>
#define XP_NO_X_HEADERS
#include <Xplugin.h>
#undef XP_NO_X_HEADERS
#include "apple_glx_context.h"
enum {
APPLE_GLX_DRAWABLE_SURFACE = 1,
APPLE_GLX_DRAWABLE_PBUFFER,
APPLE_GLX_DRAWABLE_PIXMAP
};
enum {
APPLE_GLX_DRAWABLE_LOCK = 2,
APPLE_GLX_DRAWABLE_REFERENCE = 4
};
struct apple_glx_context;
struct apple_glx_drawable;
struct apple_glx_surface {
xp_surface_id surface_id;
unsigned int uid;
bool pending_destroy;
};
struct apple_glx_pbuffer {
GLXPbuffer xid;
int width, height;
GLint fbconfigID;
CGLPBufferObj buffer_obj;
unsigned long event_mask;
};
struct apple_glx_pixmap {
GLXPixmap xpixmap;
void *buffer;
int width, height, pitch, bpp;
size_t size;
char path[PATH_MAX];
int fd;
CGLPixelFormatObj pixel_format_obj;
CGLContextObj context_obj;
GLint fbconfigID;
};
struct apple_glx_drawable_callbacks {
int type;
bool (*make_current)(struct apple_glx_context *ac,
struct apple_glx_drawable *d);
void (*destroy)(Display *dpy, struct apple_glx_drawable *d);
};
struct apple_glx_drawable {
Display *display;
int reference_count;
GLXDrawable drawable;
int type;
union {
struct apple_glx_pixmap pixmap;
struct apple_glx_pbuffer pbuffer;
struct apple_glx_surface surface;
} types;
struct apple_glx_drawable_callbacks callbacks;
pthread_mutex_t mutex;
void (*lock)(struct apple_glx_drawable *agd);
void (*unlock)(struct apple_glx_drawable *agd);
void (*reference)(struct apple_glx_drawable *agd);
void (*release)(struct apple_glx_drawable *agd);
bool (*destroy)(struct apple_glx_drawable *agd);
bool (*is_pbuffer)(struct apple_glx_drawable *agd);
bool (*is_pixmap)(struct apple_glx_drawable *agd);
int width, height;
int row_bytes;
char path[PATH_MAX];
int fd;
void *buffer;
size_t buffer_length;
struct apple_glx_drawable *previous, *next;
};
struct apple_glx_context;
struct apple_glx_drawable *apple_glx_find_drawable(Display *dpy,
GLXDrawable drawable);
bool apple_glx_drawable_create(Display *dpy,
int screen,
GLXDrawable drawable,
struct apple_glx_drawable **agd,
struct apple_glx_drawable_callbacks *callbacks);
bool apple_glx_create_drawable(Display *dpy,
struct apple_glx_context *ac,
GLXDrawable drawable,
struct apple_glx_drawable **agd);
void apple_glx_garbage_collect_drawables(Display *dpy);
unsigned int apple_glx_get_drawable_count(void);
struct apple_glx_drawable *apple_glx_drawable_find_by_type(GLXDrawable drawable,
int type, int flags);
struct apple_glx_drawable *
apple_glx_drawable_find(GLXDrawable drawable, int flags);
bool apple_glx_drawable_destroy_by_type(Display *dpy, GLXDrawable drawable,
int type);
struct apple_glx_drawable *
apple_glx_drawable_find_by_uid(unsigned int uid, int flags);
bool apple_glx_surface_create(Display *dpy, int screen, GLXDrawable drawable,
struct apple_glx_drawable **resultptr);
void apple_glx_surface_destroy(unsigned int uid);
bool apple_glx_pbuffer_create(Display *dpy, GLXFBConfig config,
int width, int height, int *errorcode,
GLXPbuffer *pbuf);
bool apple_glx_pbuffer_destroy(Display *dpy, GLXPbuffer pbuf);
bool apple_glx_pbuffer_query(GLXDrawable d, int attribute,
unsigned int *value);
bool apple_glx_pbuffer_set_event_mask(GLXDrawable d, unsigned long mask);
bool apple_glx_pbuffer_get_event_mask(GLXDrawable d, unsigned long *mask);
bool apple_glx_pixmap_create(Display *dpy, int screen, Pixmap pixmap,
const void *mode);
bool apple_glx_pixmap_destroy(Display *dpy, Pixmap pixmap);
bool apple_glx_pixmap_query(GLXPixmap pixmap, int attribute,
unsigned int *value);
#endif