On Tue, 20 Mar 2007 11:38:26 -0500, bbrown wrote
> I was bothering doublec about this on irc yesterday.  It is more a 
> general question, not something too specific.  If I want to add 
> opengl inits like changing the background color and different types 
> of shading and I only want it to effect the newly opened window.   
> Where should I put those inits?  I thought about putting opengl-init 
> in the 'graft' definition, but it looks like the opengl parameters 
> effect the main window.
> 
> I could put it in draw-gadget, but draw-gadget gets update so it 
> might be slopppy to have some kind of sentinel-init-loaded? type of 
> code.  Is there some other gadget method I could use to place this code?
> 
> IN: mechbot
> USING: kernel gadgets opengl math arrays threads interpreter 
>               prettyprint io namespaces canvas timers generic inference ;
>                               
> TUPLE: mechbot-gadget loaded? mechbot ticks ;
> 
> : width 640 ; inline
> : height 480 ; inline
> 
> C: mechbot-gadget ( mechbot -- gadget )
>       [ set-mechbot-gadget-mechbot ] keep     
>       [ f swap set-mechbot-gadget-loaded? ] keep
>       [ 0 swap set-mechbot-gadget-ticks ] keep
>       [ delegate>gadget ] keep ;
>       
> ! ==== Method Declarations ================================
> 
> M: mechbot-gadget graft* 120 50 add-timer ;
> 
> M: mechbot-gadget ungraft* dup delegate ungraft* remove-timer ;
>       
> M: mechbot-gadget tick relayout-1 ;
> 
> M: mechbot-gadget pref-dim* drop width height 2array ;
> 
> ! ==== Method Declarations(end) ===========================
> 
> : game-tick ( gadget -- )
>       dup mechbot-gadget-ticks 1 + swap
>       set-mechbot-gadget-ticks ;      
> 
> M: mechbot-gadget draw-gadget* ( gadget -- )
>       "** in draw-gadget=" print flush 
>       [ game-tick ] keep
>       "** tick=" write mechbot-gadget-ticks pprint 
>       nl flush        
>       !  where should the init go again?
>       glinit ;
>               
> : run ( -- )  
>       <new-mechbot> <mechbot-gadget> "mechbot" open-window ;
> 
> : glinit ( -- )
>       "GL Init, loading opengl game properties..." print flush
>       ! Enable Smooth Shading
>       GL_SMOOTH glShadeModel
>       ! Black Background
>       0.0 0.0 0.0 0.0 glClearColor
>       ! Depth Buffer Setup
>       1.0 glClearDepth
> 
>       GL_NORMALIZE glEnable
>       GL_FRONT_AND_BACK GL_FILL glPolygonMode
>       GL_SMOOTH glShadeModel
> 
>       ! Enables Depth Testing
>       GL_DEPTH_TEST glEnable
>       ! The Type Of Depth Testing To Do
>       GL_LEQUAL glDepthFunc
>       ! Really Nice Perspective Calculations
>       GL_PERSPECTIVE_CORRECTION_HINT GL_NICEST glHint ;
> 
> --
> Berlin Brown
> 
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to 
> share your opinions on IT & business topics through brief surveys-
> and earn cash http://www.techsay.com/default.php?
page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk


Also, if you look at the C version of the opengl examples, for example; 
nehe4.cpp.  Is there a way to recreate that 'init' function in a factor way.  
For example, the factor version; it recalls the opengl setup routines like 
setting the background color, etc.  Here is the windows C version of nehe4:

int InitGL(GLvoid)                                                      
                        // All Setup For OpenGL Goes Here
{
        glShadeModel(GL_SMOOTH);                                        
                // Enable Smooth Shading
        glClearColor(0.0f, 0.0f, 0.0f, 0.5f);                           // 
Black Background
        glClearDepth(1.0f);                                             
                        // Depth Buffer Setup
        glEnable(GL_DEPTH_TEST);                                        
                // Enables Depth Testing
        glDepthFunc(GL_LEQUAL);                                         
                // The Type Of Depth Testing To Do
        glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);      // Really 
Nice Perspective Calculations
        return TRUE;                                                    
                        // Initialization Went OK
}


http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=04


--
Berlin Brown
berlin dot brown at gmail dot com or 
bbrown at botspiritcompany dot com


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to