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