Moved most of my stuff from x11-wrunt into x11. Added a few things to

Edouardo's xlib.factor to make my stuff work. Removed all but xlib.factor from
x11-wrunt. I have left that there because there may still be things in it that
are not yet in the other xlib.factor.

I've also added load2.factor which will load the files when factor's cwd is its
root dir.
cvs
Alex Chapman 2005-12-19 02:02:43 +00:00
parent 4ff0569498
commit 04a27de131
10 changed files with 37 additions and 34 deletions

View File

@ -1,5 +1,5 @@
IN: nehe
USING: opengl x11 syntax kernel sequences alien namespaces math threads generic io prettyprint ;
USING: opengl x11 xlib syntax kernel sequences alien namespaces math threads generic io prettyprint ;
TUPLE: gl-window dpy screen win ctx x y width height depth ;
SYMBOL: current-window
@ -82,7 +82,7 @@ SYMBOL: height
title set depth set height set width set y set x set
make-display dup dup make-screen make-vi make-ctx
make-colormap normal-XSetWindowAttributes make-win
dpy get swap 2dup over "WM_DELETE_WINDOW" t XInternAtom <int> 1 XSetWMProtocols drop
dpy get swap 2dup over "WM_DELETE_WINDOW" 1 XInternAtom <int> 1 XSetWMProtocols drop
2dup title get dup None 0 <alien> 0 over XSetStandardProperties drop
2dup XMapRaised drop
2dup ctx get glXMakeCurrent 2drop

9
contrib/x11/load2.factor Normal file
View File

@ -0,0 +1,9 @@
USING: kernel alien parser sequences words compiler ;
"X11" "libX11.so" "cdecl" add-library
[ "x-constants.factor" "xlib.factor" "xutil.factor" "keysymdef.factor" "x-events.factor" "glx.factor" ] [ "contrib/x11/" swap append run-file ] each
"x11" words [ try-compile ] each
"xlib" words [ try-compile ] each
clear

View File

@ -1,20 +0,0 @@
Most of these files take their content from corresponding C files:
x.factor -- X.h
xlib.factor -- Xlib.h
xutil.factor -- Xutil.h
glx.factor -- glx.h and glxtokens.h
keysymdef.factor -- keysymdef.h
x-events.factor defines x-event predicates (see lesson2.factor for usage)
Not all of these are complete, but they are complete to run lesson 2 of the
nehe opengl tutorials (and the other tutorials with small changes). To see a
demo run from factor's root dir:
"contrib/x11/x11-wrunt/load.factor" run-file
( then wait for everything to compile... )
USE: nehe
main
Pressing 'q' or esc, or clicking the mouse will exit. If something goes wrong
you can kill off the window with:
current-window get kill-gl-window

View File

@ -1,9 +0,0 @@
USING: kernel alien parser sequences words compiler ;
"X11" "libX11.so" "cdecl" add-library
[ "x.factor" "xlib.factor" "xutil.factor" "keysymdef.factor" "x-events.factor"
"glx.factor" "lesson2.factor" ] [ "contrib/x11/x11-wrunt/" swap append run-file ] each
"x11" words [ try-compile ] each

View File

@ -9,7 +9,7 @@
! and are wondering what part of the file to modify, just find the
! function or data structure in the manual and note the section.
IN: xlib USING: kernel vectors alien math ;
IN: xlib USING: kernel arrays alien math ;
LIBRARY: xlib
@ -27,6 +27,7 @@ TYPEDEF: XID KeySym
TYPEDEF: ulong Atom
TYPEDEF: char* XPointer
TYPEDEF: void* Display*
TYPEDEF: void* Screen*
TYPEDEF: void* GC
@ -67,6 +68,9 @@ FUNCTION: int XQLength ( Display* display ) ;
FUNCTION: int XScreenCount ( Display* display ) ;
FUNCTION: int XConnectionNumber ( Display* display ) ;
! 2.5 Closing the Display
FUNCTION: int XCloseDisplay ( Display* display ) ;
!
! 3 - Window Functions
!
@ -123,6 +127,7 @@ END-STRUCT
! 3.3 - Creating Windows
FUNCTION: Window XCreateWindow ( Display* display, Window parent, int x, int y, uint width, uint height, uint border_width, int depth, uint class, Visual* visual, ulong valuemask, XSetWindowAttributes* attributes ) ;
FUNCTION: Window XCreateSimpleWindow ( Display* display, Window parent, int x, int y, uint width, uint height, uint border_width, ulong border, ulong background ) ;
FUNCTION: Status XDestroyWindow ( Display* display, Window w ) ;
FUNCTION: Status XMapWindow ( Display* display, Window window ) ;
@ -130,6 +135,10 @@ FUNCTION: Status XMapSubwindows ( Display* display, Window window ) ;
FUNCTION: Status XUnmapWindow ( Display* display, Window w ) ;
FUNCTION: Status XUnmapSubwindows ( Display* display, Window w ) ;
! 3.5 Mapping Windows
FUNCTION: int XMapRaised ( Display* display, Window w ) ;
! 3.7 - Configuring Windows
: CWX 1 0 shift ;
@ -265,6 +274,10 @@ FUNCTION: Status XLookupColor ( Display* display, Colormap colormap, char* color
FUNCTION: Status XAllocColor ( Display* display, Colormap colormap, XColor* screen_in_out ) ;
FUNCTION: Status XQueryColor ( Display* display, Colormap colormap, XColor* def_in_out ) ;
! 6.4 Creating, Copying, and Destroying Colormaps
FUNCTION: Colormap XCreateColormap ( Display* display, Window w, Visual* visual, int alloc ) ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! 7 - Graphics Context Functions
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@ -525,10 +538,10 @@ TYPEDEF: XButtonEvent XButtonPressedEvent
TYPEDEF: XButtonEvent XButtonReleasedEvent
: XButtonEvent-position ( event -- { x y } )
dup XButtonEvent-x swap XButtonEvent-y 2vector ;
dup XButtonEvent-x swap XButtonEvent-y 2array ;
: XButtonEvent-root-position ( event -- { x y } )
dup XButtonEvent-x swap XButtonEvent-y 2vector ;
dup XButtonEvent-x swap XButtonEvent-y 2array ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@ -1087,6 +1100,10 @@ FUNCTION: Status XWarpPointer ( Display* display, Window src_w, Window dest_w, i
! 14 - Inter-Client Communication Functions
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! 14.1 Client to Window Manager Communication
FUNCTION: Status XSetWMProtocols ( Display* display, Window w, Atom* protocols, int count ) ;
FUNCTION: Status XFetchName ( Display* display, Window w, char** window_name_return ) ;
FUNCTION: Status XGetTransientForHint ( Display* display, Window w, Window* prop_window_return ) ;
@ -1094,8 +1111,14 @@ FUNCTION: Status XGetTransientForHint ( Display* display, Window w, Window* prop
! 16 - Application Utility Functions
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! 16.1 Keyboard Utility Functions
FUNCTION: KeySym XLookupKeysym ( XKeyEvent* key_event, int index ) ;
FUNCTION: int XLookupString ( XKeyEvent* event_struct, char* buffer_return, int bytes_buffer, KeySym* keysym_return, XComposeStatus* status_in_out ) ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: CurrentTime 0 ;