1 ! Copyright (C) 2005, 2006 Eduardo Cavazos and Alex Chapman
2 ! See http://factorcode.org/license.txt for BSD license.
4 ! based on glx.h from xfree86, and some of glxtokens.h
5 USING: alien.c-types alien.syntax kernel namespaces
6 specialized-arrays x11 x11.X x11.syntax x11.xlib ;
12 ! Visual Config Attributes (glXGetConfig, glXGetFBConfigAttrib)
13 CONSTANT: GLX_USE_GL 1 ! support GLX rendering
14 CONSTANT: GLX_BUFFER_SIZE 2 ! depth of the color buffer
15 CONSTANT: GLX_LEVEL 3 ! level in plane stacking
16 CONSTANT: GLX_RGBA 4 ! true if RGBA mode
17 CONSTANT: GLX_DOUBLEBUFFER 5 ! double buffering supported
18 CONSTANT: GLX_STEREO 6 ! stereo buffering supported
19 CONSTANT: GLX_AUX_BUFFERS 7 ! number of aux buffers
20 CONSTANT: GLX_RED_SIZE 8 ! number of red component bits
21 CONSTANT: GLX_GREEN_SIZE 9 ! number of green component bits
22 CONSTANT: GLX_BLUE_SIZE 10 ! number of blue component bits
23 CONSTANT: GLX_ALPHA_SIZE 11 ! number of alpha component bits
24 CONSTANT: GLX_DEPTH_SIZE 12 ! number of depth bits
25 CONSTANT: GLX_STENCIL_SIZE 13 ! number of stencil bits
26 CONSTANT: GLX_ACCUM_RED_SIZE 14 ! number of red accum bits
27 CONSTANT: GLX_ACCUM_GREEN_SIZE 15 ! number of green accum bits
28 CONSTANT: GLX_ACCUM_BLUE_SIZE 16 ! number of blue accum bits
29 CONSTANT: GLX_ACCUM_ALPHA_SIZE 17 ! number of alpha accum bits
31 TYPEDEF: XID GLXContextID
32 TYPEDEF: XID GLXPixmap
33 TYPEDEF: XID GLXDrawable
34 TYPEDEF: XID GLXPbuffer
35 TYPEDEF: XID GLXWindow
36 TYPEDEF: XID GLXFBConfigID
37 TYPEDEF: void* GLXContext ! typedef struct __GLXcontextRec *GLXContext;
38 TYPEDEF: void* GLXFBConfig ! typedef struct __GLXFBConfigRec *GLXFBConfig;
40 X-FUNCTION: XVisualInfo* glXChooseVisual ( Display* dpy, int screen, int* attribList )
41 X-FUNCTION: void glXCopyContext ( Display* dpy, GLXContext src, GLXContext dst, ulong mask )
42 X-FUNCTION: GLXContext glXCreateContext ( Display* dpy, XVisualInfo* vis, GLXContext shareList, bool direct )
43 X-FUNCTION: GLXPixmap glXCreateGLXPixmap ( Display* dpy, XVisualInfo* vis, Pixmap pixmap )
44 X-FUNCTION: void glXDestroyContext ( Display* dpy, GLXContext ctx )
45 X-FUNCTION: void glXDestroyGLXPixmap ( Display* dpy, GLXPixmap pix )
46 X-FUNCTION: int glXGetConfig ( Display* dpy, XVisualInfo* vis, int attrib, int* value )
47 X-FUNCTION: GLXContext glXGetCurrentContext ( )
48 X-FUNCTION: GLXDrawable glXGetCurrentDrawable ( )
49 X-FUNCTION: bool glXIsDirect ( Display* dpy, GLXContext ctx )
50 X-FUNCTION: bool glXMakeCurrent ( Display* dpy, GLXDrawable drawable, GLXContext ctx )
51 X-FUNCTION: bool glXQueryExtension ( Display* dpy, int* errorBase, int* eventBase )
52 X-FUNCTION: bool glXQueryVersion ( Display* dpy, int* major, int* minor )
53 X-FUNCTION: void glXSwapBuffers ( Display* dpy, GLXDrawable drawable )
54 X-FUNCTION: void glXUseXFont ( Font font, int first, int count, int listBase )
55 X-FUNCTION: void glXWaitGL ( )
56 X-FUNCTION: void glXWaitX ( )
57 X-FUNCTION: c-string glXGetClientString ( Display* dpy, int name )
58 X-FUNCTION: c-string glXQueryServerString ( Display* dpy, int screen, int name )
59 X-FUNCTION: c-string glXQueryExtensionsString ( Display* dpy, int screen )
62 X-FUNCTION: GLXFBConfig* glXGetFBConfigs ( Display* dpy, int screen, int* nelements )
63 X-FUNCTION: GLXFBConfig* glXChooseFBConfig ( Display* dpy, int screen, int* attrib_list, int* nelements )
64 X-FUNCTION: int glXGetFBConfigAttrib ( Display* dpy, GLXFBConfig config, int attribute, int* value )
65 X-FUNCTION: XVisualInfo* glXGetVisualFromFBConfig ( Display* dpy, GLXFBConfig config )
66 X-FUNCTION: GLXWindow glXCreateWindow ( Display* dpy, GLXFBConfig config, Window win, int* attrib_list )
67 X-FUNCTION: void glXDestroyWindow ( Display* dpy, GLXWindow win )
68 X-FUNCTION: GLXPixmap glXCreatePixmap ( Display* dpy, GLXFBConfig config, Pixmap pixmap, int* attrib_list )
69 X-FUNCTION: void glXDestroyPixmap ( Display* dpy, GLXPixmap pixmap )
70 X-FUNCTION: GLXPbuffer glXCreatePbuffer ( Display* dpy, GLXFBConfig config, int* attrib_list )
71 X-FUNCTION: void glXDestroyPbuffer ( Display* dpy, GLXPbuffer pbuf )
72 X-FUNCTION: void glXQueryDrawable ( Display* dpy, GLXDrawable draw, int attribute, uint* value )
73 X-FUNCTION: GLXContext glXCreateNewContext ( Display* dpy, GLXFBConfig config, int render_type, GLXContext share_list, bool direct )
74 X-FUNCTION: bool glXMakeContextCurrent ( Display* display, GLXDrawable draw, GLXDrawable read, GLXContext ctx )
75 X-FUNCTION: GLXDrawable glXGetCurrentReadDrawable ( )
76 X-FUNCTION: Display* glXGetCurrentDisplay ( )
77 X-FUNCTION: int glXQueryContext ( Display* dpy, GLXContext ctx, int attribute, int* value )
78 X-FUNCTION: void glXSelectEvent ( Display* dpy, GLXDrawable draw, ulong event_mask )
79 X-FUNCTION: void glXGetSelectedEvent ( Display* dpy, GLXDrawable draw, ulong* event_mask )
82 X-FUNCTION: void* glXGetProcAddress ( c-string procname )
84 ! GLX_ARB_get_proc_address extension
85 X-FUNCTION: void* glXGetProcAddressARB ( c-string procname )
88 CONSTANT: GLX_SAMPLE_BUFFERS 100000
89 CONSTANT: GLX_SAMPLES 100001
91 ! GLX_ARB_fbconfig_float
92 CONSTANT: GLX_RGBA_FLOAT_TYPE 0x20B9
93 CONSTANT: GLX_RGBA_FLOAT_BIT 0x0004
96 ! (also skipped for now. only has GLXPbufferClobberEvent, the rest is handled by xlib methinks)
98 : create-glx ( XVisualInfo* -- GLXContext )
99 [ dpy get ] dip f 1 glXCreateContext
100 [ "Failed to create GLX context" throw ] unless* ;
102 : destroy-glx ( GLXContext -- )
103 dpy get swap glXDestroyContext ;