Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Joystick with View/Pro on win98

 [1/5] from: deadzaphod::flyingparty::com at: 4-Sep-2001 17:22


I just got /Pro and decided to try accessing the joystick under windows. It works great and I thought maybe I should share the code, so here's my joystick demo: REBOL [ title: "Joystick Demo 2" ] winmm: load/library %winmm.dll joyinfostruct: make struct! [ xpos [integer!] ypos [integer!] zpos [integer!] buttons [integer!] ] none joyGetPos: make routine! [ joyid [integer!] joyinfo [ struct! [ xpos [integer!] ypos [integer!] zpos [integer!] buttons [integer!] ] ] return: [integer!] ] winmm "joyGetPos" joystick: func [ number /local a ] [ joygetpos number joyinfostruct a: context [ x: y: z: b: none ] set bind [x y z b] in a 'self second joyinfostruct a ] old: j: context [ x: y: z: b: 0 ] view/new layout/size [ b: box 15x15 green ] 272x272 while [j/b <> 15] [ wait 0 j: joystick 0 b/offset: to-pair reduce [ (to-integer j/x / 256) (to-integer j/y / 256) ] either j/b = 0 [ b/color: green ] [ b/color: red ] show b old: j ] halt

 [2/5] from: greggirwin:starband at: 4-Sep-2001 22:54


Cal, Very cool! Man, I hate being a beginner again.<g> Now I can see I'll have to learn about interfacing with DLLs...along with everything else. --Gregg

 [3/5] from: deadzaphod:flyingparty at: 4-Sep-2001 22:21


> Very cool! Man, I hate being a beginner again.<g> Now I can see I'll have
to
> learn about interfacing with DLLs...along with everything else.
Hey, I've just been looking through various docs, and it looks like it would be possible to use OpenGL from rebol.. ;-) Cal

 [4/5] from: cyphre:volny:cz at: 5-Sep-2001 9:42


> Hey, I've just been looking through various docs, and it looks like it
would
> be possible to use OpenGL from rebol.. ;-) >
Hi Cal, Yes, I've had this idea long time ago but since I haven't bought /Pro yet I'm just thinking about it ;-) I believe it is possible to use OpenGL or DirectX dll calls to generate 3D scene (or better make Rebol dialect for generating 3D scene :) ) and then, using method of "sharing image memory"(PeKr has tried it and succeed ;-) ) to show it in /View's face. It would be simple...you just call dlls to create 3D scene while face is automatically refreshed by time events...what about VRML player in REBOL?(though it will currently run only at "limited" 20fps or so) ;-) regards Cyphre

 [5/5] from: allenk:powerup:au at: 5-Sep-2001 22:28


----- Original Message ----- From: "Cal Dixon" <[deadzaphod--flyingparty--com]> To: <[rebol-list--rebol--com]> Sent: Wednesday, September 05, 2001 3:21 PM Subject: [REBOL] Re: Joystick with View/Pro on win98
> > Very cool! Man, I hate being a beginner again.<g> Now I can see I'll
have
> to > > learn about interfacing with DLLs...along with everything else. > > Hey, I've just been looking through various docs, and it looks like it
would
> be possible to use OpenGL from rebol.. ;-) > > Cal
I recall Jeff posting some code to do that back in beta testing for Command 1.0, it was for linux though. Not sure if it is any use/interest for you or not, but reposting anyway ... ----- Original Message ----- From: <[whip--cs--unm--edu]> Sent: Wednesday, July 05, 2000 8:19 AM Subject: [COMMAND] REBOL/command and opengl Hi, folks. Today I got REBOL/command working with Mesa OpenGL on my linux box. Rather than post a bunch of C source code, I'll just describe the process I took: Basically, I turned the Mesa bouncing ball demo into a shared library (changing main() into a function named "go"). One other important detail was that I needed to do a minor hack to the glut library to overcome the endless glutMainLoop problem. Details on doing that are found at: http://web2.airmail.net/sjbaker1/software/glut_hack.html What I did was rebuild glut to include a single pass glutMainLoopUpdate function instead of the never returning glutMainLoop. The whole process was quite painless, really just cut and paste. With glut rebuilt and installed, I added a function to my bouncing ball library code which just does the call to glutMainLoopupdate and returns. The final REBOL/command script is this tiny little proof of concept: REBOL [ Title: "REBOL/command using Mesa OpenGL" ] glib: load/library %./bounce-lib.so go: make routine! [return: [int]] glib "go" bupdate: make routine! [] glib "bounce_update" go loop 2000 [ prin "." bupdate ] halt { Instead of printing a dot, the script could be calling other external library routines to modify the state of the 3d environment based on who knows what. What could REBOL/command use OpenGL for? I dunno, a 3d emailer, a distributed 3d data visualizer.. endless possibilities. Sorry if my description of how to make it work is too vague, but maybe I'll write up a more detailed doc on doing it some time soon. -jeff }