PageRenderTime 17ms CodeModel.GetById 9ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 1ms

/unmaintained/4DNav/window3D/window3D.factor

http://github.com/abeaumont/factor
Unknown | 82 lines | 71 code | 11 blank | 0 comment | 0 complexity | 830a03be2ae2d7e4e5f48987a3a38108 MD5 | raw file
 1! Copyright (C) 2008 Jeff Bigot
 2! See http://factorcode.org/license.txt for BSD license.
 3USING: kernel 
 4ui.gadgets
 5ui.render
 6opengl
 7opengl.gl
 8opengl.glu
 94DNav.camera
104DNav.turtle
11math
12values
13alien.c-types
14accessors
15namespaces
16adsoda 
17models
18prettyprint
19;
20
21IN: 4DNav.window3D
22
23! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
24! drawing functions 
25! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26
27TUPLE: window3D  < gadget observer ; 
28
29: <window3D>  ( model observer -- gadget )
30    window3D  new
31    swap 2dup 
32    projection-mode>> add-connection
33    2dup 
34    collision-mode>> add-connection
35    >>observer 
36    swap <model> >>model 
37    t >>root?
38;
39
40M: window3D pref-dim* ( gadget -- dim )  drop { 300 300 } ;
41
42M: window3D draw-gadget* ( gadget -- )
43
44    GL_PROJECTION glMatrixMode
45        glLoadIdentity
46        0.6 0.6 0.6 .9 glClearColor
47        dup observer>> projection-mode>> value>> 1 =    
48        [ 60.0 1.0 0.1 3000.0 gluPerspective ]
49        [ -400.0 400.0 -400.0 400.0 0.0 4000.0 glOrtho ] if
50        dup observer>> collision-mode>> value>> 
51        \ remove-hidden-solids?   
52        set-value
53        dup  observer>> do-look-at
54        GL_MODELVIEW glMatrixMode
55            glLoadIdentity  
56            0.9 0.9 0.9 1.0 glClearColor
57            1.0 glClearDepth
58            GL_LINE_SMOOTH glEnable
59            GL_BLEND glEnable
60            GL_DEPTH_TEST glEnable       
61            GL_LEQUAL glDepthFunc
62            GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA glBlendFunc
63            GL_LINE_SMOOTH_HINT GL_NICEST glHint
64            1.25 glLineWidth
65            GL_COLOR_BUFFER_BIT GL_DEPTH_BUFFER_BIT bitor 
66                glClear
67            glLoadIdentity
68            GL_LIGHTING glEnable
69            GL_LIGHT0 glEnable
70            GL_COLOR_MATERIAL glEnable
71            GL_FRONT GL_AMBIENT_AND_DIFFUSE glColorMaterial
72            ! *************************
73            
74            model>> value>> 
75            [ space->GL ] when*
76
77            ! *************************
78;
79
80M: window3D graft* drop ;
81
82M: window3D model-changed nip relayout ;