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