Merged opengl.lib into opengl and update Ed's demos (don\'t tase me bro\!)
parent
e4eb181ab0
commit
94a8ce2237
|
@ -57,10 +57,7 @@ IN: bunny
|
|||
] unless ;
|
||||
|
||||
: draw-triangle ( ns vs triple -- )
|
||||
[
|
||||
dup roll nth first3 glNormal3d
|
||||
swap nth first3 glVertex3d
|
||||
] each-with2 ;
|
||||
[ dup roll nth gl-normal swap nth gl-vertex ] each-with2 ;
|
||||
|
||||
: draw-bunny ( ns vs is -- )
|
||||
GL_TRIANGLES [ [ draw-triangle ] each-with2 ] do-state ;
|
||||
|
|
|
@ -14,7 +14,7 @@ IN: jamshred.gl
|
|||
|
||||
: draw-segment-vertex ( segment theta -- )
|
||||
over segment-color gl-color segment-vertex-and-normal
|
||||
first3 glNormal3d first3 glVertex3d ;
|
||||
gl-normal gl-vertex ;
|
||||
|
||||
: draw-vertex-pair ( theta next-segment segment -- )
|
||||
rot tuck draw-segment-vertex draw-segment-vertex ;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
USING: kernel math vectors sequences opengl.gl math.vectors math.matrices
|
||||
vars opengl.lib self pos ori turtle lsys.tortoise lsys.strings ;
|
||||
USING: kernel math vectors sequences opengl.gl math.vectors
|
||||
math.matrices vars opengl self pos ori turtle lsys.tortoise
|
||||
lsys.strings ;
|
||||
|
||||
IN: lsys.tortoise.graphics
|
||||
|
||||
|
@ -12,7 +13,7 @@ IN: lsys.tortoise.graphics
|
|||
|
||||
: (polygon) ( vertices -- )
|
||||
GL_POLYGON glBegin
|
||||
dup polygon-normal gl-normal-3f [ gl-vertex-3f ] each
|
||||
dup polygon-normal gl-normal [ gl-vertex ] each
|
||||
glEnd ;
|
||||
|
||||
: polygon ( vertices -- ) dup length 3 >= [ (polygon) ] [ drop ] if ;
|
||||
|
@ -31,7 +32,7 @@ VAR: vertices
|
|||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
: record-vertex ( -- ) pos> gl-vertex-3f ;
|
||||
: record-vertex ( -- ) pos> gl-vertex ;
|
||||
|
||||
: draw-forward ( length -- )
|
||||
GL_LINES glBegin record-vertex step-turtle record-vertex glEnd ;
|
||||
|
@ -78,10 +79,10 @@ VAR: color-table
|
|||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
: material-color ( color -- )
|
||||
GL_FRONT_AND_BACK GL_AMBIENT_AND_DIFFUSE rot gl-material-fv ;
|
||||
GL_FRONT_AND_BACK GL_AMBIENT_AND_DIFFUSE rot gl-material ;
|
||||
|
||||
: set-color ( i -- )
|
||||
dup >color color-table> nth dup gl-color-4f material-color ;
|
||||
dup >color color-table> nth dup gl-color material-color ;
|
||||
|
||||
: inc-color ( -- ) color> 1+ set-color ;
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
USING: tools.deploy ;
|
||||
V{
|
||||
{ strip-word-props? t }
|
||||
{ strip-word-names? t }
|
||||
{ strip-dictionary? t }
|
||||
{ strip-debugger? t }
|
||||
{ strip-c-types? t }
|
||||
{ deploy-math? t }
|
||||
{ deploy-compiled? t }
|
||||
{ deploy-io? f }
|
||||
{ deploy-ui? t }
|
||||
{ "bundle-name" "Lindenmayer Systems.app" }
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
USING: kernel namespaces threads math math.vectors quotations sequences
|
||||
opengl
|
||||
opengl.gl
|
||||
colors
|
||||
ui
|
||||
|
@ -11,7 +12,7 @@ USING: kernel namespaces threads math math.vectors quotations sequences
|
|||
ui.gadgets.lib
|
||||
ui.gadgets.slate
|
||||
ui.gadgets.theme
|
||||
vars rewrite-closures opengl.lib
|
||||
vars rewrite-closures
|
||||
self pos ori turtle opengl.camera
|
||||
lsys.tortoise lsys.tortoise.graphics lsys.strings
|
||||
;
|
||||
|
@ -34,7 +35,7 @@ VAR: model
|
|||
|
||||
: display ( -- )
|
||||
|
||||
black gl-clear-color
|
||||
black gl-clear
|
||||
|
||||
GL_FLAT glShadeModel
|
||||
|
||||
|
@ -48,13 +49,11 @@ glLoadIdentity
|
|||
|
||||
camera> do-look-at
|
||||
|
||||
GL_COLOR_BUFFER_BIT glClear
|
||||
|
||||
GL_FRONT_AND_BACK GL_LINE glPolygonMode
|
||||
|
||||
white gl-color-4f
|
||||
white gl-color
|
||||
|
||||
GL_LINES glBegin { 0 0 0 } gl-vertex-3f { 0 0 1 } gl-vertex-3f glEnd
|
||||
GL_LINES glBegin { 0 0 0 } gl-vertex { 0 0 1 } gl-vertex glEnd
|
||||
|
||||
color> set-color
|
||||
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
Slava Pestov
|
||||
Eduardo Cavazos
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
USING: kernel namespaces math.vectors opengl.lib pos ori turtle self ;
|
||||
USING: kernel namespaces math.vectors opengl pos ori turtle self ;
|
||||
|
||||
IN: opengl.camera
|
||||
|
||||
|
@ -13,4 +13,4 @@ IN: opengl.camera
|
|||
[ 90 pitch-up pos> 1 step-turtle pos> swap v- ] save-self ;
|
||||
|
||||
: do-look-at ( camera -- )
|
||||
[ >self camera-eye camera-focus camera-up glu-look-at ] with-scope ;
|
||||
[ >self camera-eye camera-focus camera-up gl-look-at ] with-scope ;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
! Copyright (C) 2005, 2006 Slava Pestov.
|
||||
! Copyright (C) 2005, 2007 Slava Pestov.
|
||||
! Portions copyright (C) 2007 Eduardo Cavazos.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien alien.c-types io kernel math namespaces
|
||||
sequences math.vectors opengl.gl opengl.glu ;
|
||||
sequences math.vectors opengl.gl opengl.glu combinators ;
|
||||
IN: opengl
|
||||
|
||||
: coordinates [ first2 ] 2apply ;
|
||||
|
@ -10,8 +11,11 @@ IN: opengl
|
|||
|
||||
: gl-color ( color -- ) first4 glColor4d ; inline
|
||||
|
||||
: gl-clear-color ( color -- )
|
||||
first4 glClearColor ;
|
||||
|
||||
: gl-clear ( color -- )
|
||||
first4 glClearColor GL_COLOR_BUFFER_BIT glClear ;
|
||||
gl-clear-color GL_COLOR_BUFFER_BIT glClear ;
|
||||
|
||||
: gl-error ( -- )
|
||||
glGetError dup zero? [
|
||||
|
@ -28,7 +32,17 @@ IN: opengl
|
|||
swap [ glMatrixMode glPushMatrix call ] keep
|
||||
glMatrixMode glPopMatrix ; inline
|
||||
|
||||
: gl-vertex ( point -- ) first2 glVertex2d ; inline
|
||||
: gl-vertex ( point -- )
|
||||
dup length {
|
||||
{ 2 [ first2 glVertex2d ] }
|
||||
{ 3 [ first3 glVertex3d ] }
|
||||
{ 4 [ first4 glVertex4d ] }
|
||||
} case ;
|
||||
|
||||
: gl-normal ( normal -- ) first3 glNormal3d ;
|
||||
|
||||
: gl-material ( face pname params -- )
|
||||
>c-float-array glMaterialfv ;
|
||||
|
||||
: gl-line ( a b -- )
|
||||
GL_LINES [ gl-vertex gl-vertex ] do-state ;
|
||||
|
@ -67,6 +81,9 @@ IN: opengl
|
|||
: do-attribs ( bits quot -- )
|
||||
swap glPushAttrib call glPopAttrib ; inline
|
||||
|
||||
: gl-look-at ( eye focus up -- )
|
||||
>r >r first3 r> first3 r> first3 gluLookAt ;
|
||||
|
||||
TUPLE: sprite loc dim dim2 dlist texture ;
|
||||
|
||||
: <sprite> ( loc dim dim2 -- sprite )
|
||||
|
|
Loading…
Reference in New Issue