Author Topic: Terry Ritchie's GLInput Library  (Read 3541 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Terry Ritchie's GLInput Library
« on: November 01, 2019, 11:12:17 am »
A lot of our newer members have asked about how to get input from a graphical position here recently, so I wanted to bring Terry's GLInput library back to folks attention.

Inside the attached ZIP folder is all the necessary components to add Terry's library to your work, as well as several demos which he wrote to showcase how things perform.  Heck, there's even a PDF file documenting everything, to make it easy to learn and use...   

Normally, I'd post some example code to showcase how everything works when sharing a library like this, but Terry has did such a good job writing and documenting his, that I don't feel like doing such is necessary.  Just download the library, run the demos, read the PDF, and follow the instructions to add GLINPUT to your own projects.  :)
* QB64GLINPUTLibaryV2.1.zip (Filesize: 676.97 KB, Downloads: 181)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Terry Ritchie's GLInput Library
« Reply #1 on: November 01, 2019, 11:34:41 am »
Thanks to share Steve, I don't know if I have in one of the folders named QB64Store that are in different notebooks!
Programming isn't difficult, only it's  consuming time and coffee

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Terry Ritchie's GLInput Library
« Reply #2 on: November 02, 2019, 01:36:07 pm »
Hi
very fine this library, just follow the PDF and you manage it easily!
here a code example adding something to the last example in the PDF
Code: QB64: [Select]
  1. '$INCLUDE:'glinputtop.bi'
  2. CONST FALSE = 0, TRUE = NOT FALSE
  3. DIM helloworld%
  4. DIM helloworld$
  5. DIM wallpaper&
  6. DIM x%, y%
  7. wallpaper& = _NEWIMAGE(640, 528, 32) ' create image to use as background
  8. _DEST wallpaper&
  9. LINE (0, 0)-(639, 527), _RGB32(0, 0, 127), BF
  10. FOR y% = 1 TO 11
  11.     FOR x% = 1 TO 13
  12.         CIRCLE (x% * 48 - 17, y% * 48 - 24), 24, _RGB32(0, 0, 0)
  13.         PAINT (x% * 48 - 17, y% * 48 - 24), _RGB32(0, 0, 96), _RGB32(0, 0, 0)
  14.     NEXT x%
  15. NEXT y%
  16. SCREEN _NEWIMAGE(640, 480, 32)
  17. _PUTIMAGE (0, 0), wallpaper&
  18. ' show background image
  19. helloworld% = GLIINPUT(100, 100, GLIALPHA, "Hello World: ", TRUE)
  20.     GLICLEAR
  21.     ' must be first line in any loop
  22.  
  23.     _LIMIT 32
  24.     y% = y% - 1
  25.     IF y% = -48 THEN y% = 0
  26.     _PUTIMAGE (0, y%), wallpaper&
  27.     LOCATE 1, 1: PRINT "Real time: "; GLIOUTPUT$(helloworld%); " "
  28.  
  29.     GLIUPDATE ' must be the second to last command in any loop
  30.     LOCATE 1, 50: PRINT "Focus on GLinput "; GLICURRENT
  31.     _DISPLAY ' must be the last command in any loop to display results
  32. LOOP UNTIL GLIENTERED(helloworld%)
  33. helloworld$ = GLIOUTPUT$(helloworld%)
  34. LOCATE 2, 1: PRINT "Final : "; helloworld$
  35. GLICLOSE helloworld%, TRUE
  36. '$INCLUDE:'glinput.bi'

this my input function that manage
1. input range of character
2. graphic cohordinates
3. number max of character to take from input
4. waiting Enter to end the input
5. using key arrow to navigate into the string input
6. using key Backspace and Delete to change string input
7. using _LIMIT to no stuck the program in polling for input keys
https://www.qb64.org/forum/index.php?topic=1822.msg110648#msg110648
is just an one piece version without
 1. manager of multiple istances of Input field
 2. and manager of background restoring
 3. and CONST for identify the set of character to get as input
 4. auto-managing more input fields by using dedicated functions and subs
Programming isn't difficult, only it's  consuming time and coffee