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