factor/library/x11/ui.factor

60 lines
1.1 KiB
Factor
Raw Normal View History

2006-03-19 23:17:14 -05:00
USING: alien kernel math namespaces opengl threads x11 ;
2006-03-19 19:37:01 -05:00
2006-03-19 23:17:14 -05:00
f initialize-x
2006-03-19 19:37:01 -05:00
2006-03-19 23:17:14 -05:00
SYMBOL: window
2006-03-19 19:37:01 -05:00
2006-03-19 23:17:14 -05:00
choose-visual
2006-03-19 19:37:01 -05:00
2006-03-19 23:17:14 -05:00
500 500 pick create-window window set
2006-03-19 19:37:01 -05:00
2006-03-19 23:17:14 -05:00
window get map-window
create-context window get swap make-current
2006-03-19 19:37:01 -05:00
SYMBOL: pval
: p pval get ;
: -p pval get neg ;
: wire-cube ( size -- )
2.0 / pval set
GL_LINE_LOOP glBegin
-p -p -p glVertex3f
p -p -p glVertex3f
p p -p glVertex3f
-p p -p glVertex3f
glEnd
GL_LINE_LOOP glBegin
-p -p p glVertex3f
p -p p glVertex3f
p p p glVertex3f
-p p p glVertex3f
glEnd
GL_LINES glBegin
-p -p -p glVertex3f
-p -p p glVertex3f
p -p -p glVertex3f
p -p p glVertex3f
-p p -p glVertex3f
-p p p glVertex3f
p p -p glVertex3f
p p p glVertex3f
glEnd ;
: display ( -- )
2006-03-19 23:17:14 -05:00
0.0 0.0 0.0 0.0 glClearColor GL_FLAT glShadeModel
2006-03-19 19:37:01 -05:00
GL_COLOR_BUFFER_BIT glClear
1.0 1.0 1.0 glColor3f
glLoadIdentity
0.0 0.0 5.0 0.0 0.0 0.0 0.0 1.0 0.0 gluLookAt
1.0 2.0 1.0 glScalef
1.0 wire-cube
glFlush ;
2006-03-19 23:17:14 -05:00
display
2006-03-19 19:37:01 -05:00
2006-03-19 23:17:14 -05:00
window get swap-buffers
2006-03-19 19:37:01 -05:00
flush-dpy