QB64.org Forum

Active Forums => Programs => Topic started by: Ashish on November 19, 2020, 09:53:19 am

Title: NEON PEN
Post by: Ashish on November 19, 2020, 09:53:19 am
INSTRUCTION : Drag with mouse on screen to draw stuff. :)

Code: QB64: [Select]
  1. _TITLE "NEON PEN"
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3.  
  4. TYPE vec2
  5.     x AS SINGLE
  6.     y AS SINGLE
  7.  
  8. REDIM SHARED vert(1024) AS vec2, max_v_index
  9. DIM SHARED rFactor!, gFactor!, bFactor!
  10. rFactor! = 0.5: gFactor! = 1: bFactor! = 0.5
  11.     CLS
  12.     PRINT "VRAM Usage : "; vram; "KB"
  13.     PRINT "Vertices Used : "; max_v_index; "/"; UBOUND(vert)
  14.     vram = (UBOUND(vert) * 4) / 1024
  15.         mx = _MOUSEX: my = _MOUSEY
  16.         px = mx: py = my
  17.         WHILE _MOUSEBUTTON(1) AND max_v_index < UBOUND(vert)
  18.             WHILE _MOUSEINPUT: WEND
  19.             mx = _MOUSEX: my = _MOUSEY
  20.             IF ABS(px - mx) >= ABS(py - my) THEN
  21.                 IF mx >= px THEN s = 1 ELSE s = -1
  22.                 FOR i = px TO mx STEP s
  23.                     vert(max_v_index).x = i
  24.                     vert(max_v_index).y = map(i, px, mx, py, my)
  25.                     max_v_index = max_v_index + 1
  26.                     IF max_v_index > INT(UBOUND(vert) * 0.8) THEN REDIM _PRESERVE vert(max_v_index * 2) AS vec2
  27.                 NEXT
  28.             ELSE
  29.                 IF my >= py THEN s = 1 ELSE s = -1
  30.                 FOR i = py TO my STEP s
  31.                     vert(max_v_index).x = map(i, py, my, px, mx)
  32.                     vert(max_v_index).y = i
  33.                     max_v_index = max_v_index + 1
  34.                     IF max_v_index > INT(UBOUND(vert) * 0.8) THEN REDIM _PRESERVE vert(max_v_index * 2) AS vec2
  35.                 NEXT
  36.  
  37.             END IF
  38.             px = mx: py = my
  39.             _LIMIT 30
  40.         WEND
  41.     END IF
  42.  
  43.     _LIMIT 60
  44.  
  45. SUB _GL ()
  46.     STATIC glInit
  47.     IF glInit = 0 THEN
  48.         glInit = 1
  49.  
  50.     END IF
  51.     'set the gl screen so that it can work normal screen coordinates
  52.     _glTranslatef -1, 1, 0
  53.     _glScalef 1 / 400, -1 / 300, 1
  54.  
  55.     _glEnable _GL_BLEND
  56.  
  57.     _glBlendFunc _GL_SRC_ALPHA, _GL_ONE
  58.     _glEnableClientState _GL_VERTEX_ARRAY
  59.     _glVertexPointer 2, _GL_FLOAT, 0, _OFFSET(vert())
  60.     FOR j = 1 TO 15
  61.         _glColor4f rFactor!, gFactor!, bFactor!, 0.015
  62.         _glPointSize j
  63.         _glDrawArrays _GL_POINTS, 10, max_v_index
  64.     NEXT
  65.     _glFlush
  66.  
  67. FUNCTION map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!)
  68.     map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
  69.  
  70.  

Thank you for running it. :)

EDIT : CODE UPDATED. Thanks to @Dav for finding a glitch in which it stopped drawing sometimes (when both max_v_index equal to Ubound(vert) )
Title: Re: NEON PEN
Post by: bplus on November 19, 2020, 12:15:56 pm
@Ashish  welcome back, did they let you out of school?

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(1024, 600, 32)
  2. _DELAY .25
  3.  
  4.     mx = _MOUSEX: my = _MOUSEY
  5.         IF lastx <> mx OR lasty <> my THEN
  6.             FOR r = 0 TO 25
  7.                 fcirc mx, my, r, _RGBA32(200, 200, 255, 3)
  8.             NEXT
  9.         END IF
  10.         lastx = mx: lasty = my
  11.     END IF
  12.  
  13. 'from Steve Gold standard
  14. SUB fcirc (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  15.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  16.     DIM X AS INTEGER, Y AS INTEGER
  17.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  18.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  19.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  20.     WHILE X > Y
  21.         RadiusError = RadiusError + Y * 2 + 1
  22.         IF RadiusError >= 0 THEN
  23.             IF X <> Y + 1 THEN
  24.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  25.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  26.             END IF
  27.             X = X - 1
  28.             RadiusError = RadiusError - X * 2
  29.         END IF
  30.         Y = Y + 1
  31.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  32.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  33.     WEND
  34.  
  35.  

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: NEON PEN
Post by: Dav on November 19, 2020, 04:34:22 pm
I like it!  Cool effect.

- Dav
Title: Re: NEON PEN
Post by: Ashish on November 20, 2020, 12:27:04 am
@bplus
No... I just had an idea and I thought it might be easy to code something like this within 0.5-1 hour so I coded it.. The final exam of my school is in mid of next year.

@Dav
Thank You. :)
Title: Re: NEON PEN
Post by: TempodiBasic on November 20, 2020, 10:12:07 am
@Ashish
Cool! fine work of GPU


@bplus
Cool! fine work of CPU

Title: Re: NEON PEN
Post by: SierraKen on November 20, 2020, 10:51:39 am
Awesome effect Ashish! I'll have to use this effect later on! Thank you!

Title: Re: NEON PEN
Post by: Dav on November 20, 2020, 02:30:34 pm
Playing around with it for a while.  For some reason, the original neon program (GL one) sometimes stops writing for me.  Sometime it will write normally, other times running the same EXE, the drawing will stop after a couple seconds and the mouse no longer draws. When the freeze happens, the Vertices values are always the same, like it will say: Vertices used: 2500 / 2500.

- Dav
Title: Re: NEON PEN
Post by: TempodiBasic on November 20, 2020, 05:44:21 pm
Hi Dav
I think that the program stops writing because the bucket is full to the edge
as you can see here
Code: QB64: [Select]
  1. REDIM SHARED vert(1024) AS vec2, max_v_index
  2. ...
  3. ...
  4.  PRINT "Vertices Used : "; max_v_index; "/"; UBOUND(vert)
  5.  

if you pull up the Ubound of vert you can draw for more time, never for infinite!
More vert(index) is high more slow can be the program... it seems that in Opengl you must redraw all the screen as saying  all the points drawn at each refresh.
Title: Re: NEON PEN
Post by: Ashish on November 20, 2020, 10:27:55 pm
Awesome effect Ashish! I'll have to use this effect later on! Thank you!
Thanks Ken.

Playing around with it for a while.  For some reason, the original neon program (GL one) sometimes stops writing for me.  Sometime it will write normally, other times running the same EXE, the drawing will stop after a couple seconds and the mouse no longer draws. When the freeze happens, the Vertices values are always the same, like it will say: Vertices used: 2500 / 2500.

- Dav
Thank You, I updated the code in my first post of this topic. Please let me know if the program still stops sometimes drawing for you.

And yes, As @TempodiBasic pointed out.. The more vertices you used... The more GPU power will be utilize.
But it can render 16000+ vertices normally without slowing down on new computers.
Title: Re: NEON PEN
Post by: Dav on November 20, 2020, 10:59:13 pm
That did it!  It's working fine for me now.  Good example of GL use in QB64. 

 Nice little thing to put in a drawing program.   

Thanks for sharing.

- Dav

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: NEON PEN
Post by: TempodiBasic on November 21, 2020, 07:38:25 am
Hi
some times it seems hard to understand why on compiling a code you get a unresponding window that just after a bit it crashes!

I have tried to port the Fcircl of Steve into OpenGl  translating the Bplus code to Opengl....
but at the end I've got only stucked windows crashing after a bit! Today a voice from the deep of my head has suggested : you must put a LIMIT to your code!... so as soon as I can have a minute I add _LIMIT 30 to the code et voilà les jeux sont fait!

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(1024, 600, 32)
  2. _TITLE "Pen Neon Ashis + Bplus ideas"
  3.  
  4. CONST True = -1, False = 0
  5. DIM SHARED GlInit AS INTEGER, GlActive AS INTEGER, glGc AS INTEGER, glRc AS INTEGER, glBc AS INTEGER, glAc AS INTEGER
  6. DIM Color32 AS _UNSIGNED LONG, GlMouse AS INTEGER, GlPointList(1 TO 2, 1 TO 32767) AS INTEGER
  7. DIM mx AS SINGLE, my AS SINGLE, lastx AS SINGLE, lasty AS SINGLE, r AS SINGLE, GlInput AS INTEGER
  8.  
  9. GlInit = True
  10. Color32 = _RGBA32(200, 200, 255, 3)
  11. glGc = _GREEN32(Color32)
  12. glBc = _BLUE32(Color32)
  13. glRc = _RED32(Color32)
  14. GlActive = False
  15. GlMouse = 0
  16.  
  17.     GlInput = False
  18.     mx = _MOUSEX: my = _MOUSEY
  19.         IF GlActive THEN GlInput = True
  20.  
  21.         IF lastx <> mx OR lasty <> my THEN
  22.             IF GlInput THEN
  23.                 GlMouse = GlMouse + 1
  24.                 GlPointList(1, GlMouse) = mx
  25.                 GlPointList(2, GlMouse) = my
  26.             END IF
  27.             IF GlActive = True THEN
  28.                 ' here GL works
  29.             ELSE
  30.                 FOR r = 0 TO 25 ' graphic output engine :-)
  31.                     fcirc mx, my, r, Color32
  32.                 NEXT
  33.             END IF
  34.         END IF
  35.         lastx = mx: lasty = my
  36.     END IF
  37.         GlActive = NOT GlActive 'switch between stardard and Opengl graphic
  38.     END IF
  39.     _LIMIT 40
  40.  
  41. 'from Steve Gold standard
  42. SUB fcirc (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  43.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  44.     DIM X AS INTEGER, Y AS INTEGER
  45.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  46.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  47.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  48.     WHILE X > Y
  49.         RadiusError = RadiusError + Y * 2 + 1
  50.         IF RadiusError >= 0 THEN
  51.             IF X <> Y + 1 THEN
  52.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  53.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  54.             END IF
  55.             X = X - 1
  56.             RadiusError = RadiusError - X * 2
  57.         END IF
  58.         Y = Y + 1
  59.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  60.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  61.     WEND
  62.  
  63.  
  64. SUB _GL ()
  65.     SHARED mx AS SINGLE, my AS SINGLE, GlMouse AS INTEGER, GlPointList() AS INTEGER, GlInput AS INTEGER
  66.     DIM r AS SINGLE, n AS INTEGER, x1 AS SINGLE, y1 AS SINGLE
  67.     IF GlActive = False THEN EXIT SUB ' No gl session
  68.     IF GlInit THEN InitGl
  69.  
  70.     _glClear _GL_COLOR_BUFFER_BIT
  71.     ' graphic output engine :-)
  72.     IF GlInput THEN
  73.         ' actual point
  74.         FOR r = 0 TO 10
  75.             Gl_fcirc mx, my, r
  76.         NEXT
  77.     END IF
  78.     ' previous points
  79.     FOR n = 1 TO GlMouse
  80.         x1 = GlPointList(1, n)
  81.         y1 = GlPointList(2, n)
  82.         FOR r = 0 TO 10
  83.             Gl_fcirc x1, y1, r
  84.         NEXT
  85.     NEXT n
  86.     _glFlush
  87.  
  88. SUB InitGl
  89.     _glClearColor 1, 0.5, 0.5, 1
  90.     GlInit = False
  91.  
  92. 'from Steve Gold standard ported to OpenGl
  93. SUB Gl_fcirc (CX AS SINGLE, CY AS SINGLE, R AS SINGLE)
  94.     DIM Radius AS SINGLE, RadiusError AS SINGLE
  95.     DIM X AS SINGLE, Y AS SINGLE
  96.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  97.     _glColor4f glRc, glGc, glBc, glAc
  98.     IF Radius = 0 THEN
  99.         _glBegin _GL_POINTS
  100.         _glVertex2f Proportion(0, 1024, -1, 1, CX), Proportion(0, 600, 1, -1, CY)
  101.         _glEnd
  102.         EXIT SUB
  103.     END IF
  104.     _glBegin _GL_QUADS
  105.     _glVertex2f Proportion(0, 1024, -1, 1, CX - X), Proportion(0, 600, 1, -1, CY)
  106.     _glVertex2f Proportion(0, 1024, -1, 1, CX + X), Proportion(0, 600, 1, -1, CY)
  107.     _glEnd
  108.     WHILE X > Y
  109.         RadiusError = RadiusError + Y * 2 + 1
  110.         IF RadiusError >= 0 THEN
  111.             IF X <> Y + 1 THEN
  112.                 _glBegin _GL_QUADS
  113.                 _glVertex2f Proportion(0, 1024, -1, 1, CX - Y), Proportion(0, 600, 1, -1, CY - X)
  114.                 _glVertex2f Proportion(0, 1024, -1, 1, CX + Y), Proportion(0, 600, 1, -1, CY - X)
  115.                 _glVertex2f Proportion(0, 1024, -1, 1, CX - Y), Proportion(0, 600, 1, -1, CY + X)
  116.                 _glVertex2f Proportion(0, 1024, -1, 1, CX + Y), Proportion(0, 600, 1, -1, CY + X)
  117.                 _glEnd
  118.             END IF
  119.             X = X - 1
  120.             RadiusError = RadiusError - X * 2
  121.         END IF
  122.         Y = Y + 1
  123.         _glBegin _GL_QUADS
  124.         _glVertex2f Proportion(0, 1024, -1, 1, CX - X), Proportion(0, 600, 1, -1, CY - Y)
  125.         _glVertex2f Proportion(0, 1024, -1, 1, CX + X), Proportion(0, 600, 1, -1, CY - Y)
  126.         _glVertex2f Proportion(0, 1024, -1, 1, CX - X), Proportion(0, 600, 1, -1, CY + Y)
  127.         _glVertex2f Proportion(0, 1024, -1, 1, CX + X), Proportion(0, 600, 1, -1, CY + Y)
  128.         _glEnd
  129.     WEND
  130.  
  131. FUNCTION Proportion (min1, max1, min2, max2, value)
  132.     'delta1: value = Delta2: x
  133.     Proportion = ((value * (max2 - min2)) / (max1 - min1)) + min2
  134.  

Notes:
1 the Opengl panel redraws itself each time with no memory of previous graphic made (so you must have a track of these and you must redraw all these)
2 the Opengl panel uses its dimensions and its value for color ( so you must use a translator between the 2 system )
3 the graphic effect on standard panel screen is loosen in Opengl mode panel screen also using low alpha channel value!
4 my translation of Fcirc to GL_Fcirc can be wrong because I cannot interpretate the many BF used in Fcircle. So I decided to treat theme like simple LINE instruction. That is only my interpretation of it
Title: Re: NEON PEN
Post by: TempodiBasic on November 21, 2020, 07:41:38 am
Here a version of it in which you have on the same screen the standard and the Opengl graphics...
see screenshot
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
and here the code
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(1024, 600, 32)
  2. _TITLE "Pen Neon Ashis + Bplus ideas"
  3.  
  4. CONST True = -1, False = 0
  5. DIM SHARED GlInit AS INTEGER, GlActive AS INTEGER, glGc AS INTEGER, glRc AS INTEGER, glBc AS INTEGER, glAc AS INTEGER
  6. DIM Color32 AS _UNSIGNED LONG, GlMouse AS INTEGER, GlPointList(1 TO 2, 1 TO 32767) AS INTEGER
  7. DIM mx AS SINGLE, my AS SINGLE, lastx AS SINGLE, lasty AS SINGLE, r AS SINGLE, GlInput AS INTEGER
  8.  
  9. GlInit = True
  10. Color32 = _RGBA32(39, 161, 183, 3)
  11. glGc = _GREEN32(Color32)
  12. glBc = _BLUE32(Color32)
  13. glRc = _RED32(Color32)
  14. glAc = 0.02
  15. Color32 = _RGBA32(166, 233, 105, 3)
  16. GlActive = False
  17. GlMouse = 0
  18.  
  19.     GlInput = False
  20.     mx = _MOUSEX: my = _MOUSEY
  21.         IF GlActive THEN GlInput = True
  22.  
  23.         IF lastx <> mx OR lasty <> my THEN
  24.             IF GlInput THEN
  25.                 GlMouse = GlMouse + 1
  26.                 GlPointList(1, GlMouse) = mx
  27.                 GlPointList(2, GlMouse) = my
  28.             END IF
  29.             IF GlActive = True THEN
  30.                 ' here GL works
  31.             ELSE
  32.                 FOR r = 0 TO 25 ' graphic output engine :-)
  33.                     fcirc mx, my, r, Color32
  34.                 NEXT
  35.             END IF
  36.         END IF
  37.         lastx = mx: lasty = my
  38.     END IF
  39.         GlActive = NOT GlActive 'switch between stardard and Opengl graphic
  40.     END IF
  41.     _LIMIT 30
  42.  
  43. 'from Steve Gold standard
  44. SUB fcirc (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  45.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  46.     DIM X AS INTEGER, Y AS INTEGER
  47.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  48.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  49.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  50.     WHILE X > Y
  51.         RadiusError = RadiusError + Y * 2 + 1
  52.         IF RadiusError >= 0 THEN
  53.             IF X <> Y + 1 THEN
  54.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  55.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  56.             END IF
  57.             X = X - 1
  58.             RadiusError = RadiusError - X * 2
  59.         END IF
  60.         Y = Y + 1
  61.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  62.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  63.     WEND
  64.  
  65.  
  66. SUB _GL ()
  67.     SHARED mx AS SINGLE, my AS SINGLE, GlMouse AS INTEGER, GlPointList() AS INTEGER, GlInput AS INTEGER
  68.     DIM r AS SINGLE, n AS INTEGER, x1 AS SINGLE, y1 AS SINGLE
  69.     IF GlActive = False THEN EXIT SUB ' No gl session
  70.     IF GlInit THEN InitGl
  71.  
  72.     ' _glClear _GL_COLOR_BUFFER_BIT
  73.     ' graphic output engine :-)
  74.     IF GlInput THEN
  75.         ' actual point
  76.         FOR r = 0 TO 10
  77.             Gl_fcirc mx, my, r
  78.         NEXT
  79.     END IF
  80.     ' previous points
  81.     FOR n = 1 TO GlMouse
  82.         x1 = GlPointList(1, n)
  83.         y1 = GlPointList(2, n)
  84.         FOR r = 0 TO 10
  85.             Gl_fcirc x1, y1, r
  86.         NEXT
  87.     NEXT n
  88.     _glFlush
  89.  
  90. SUB InitGl
  91.     '    _glClearColor 0.6, 0.6, 0.8, 1
  92.     GlInit = False
  93.  
  94. 'from Steve Gold standard ported to OpenGl
  95. SUB Gl_fcirc (CX AS SINGLE, CY AS SINGLE, R AS SINGLE)
  96.     DIM Radius AS SINGLE, RadiusError AS SINGLE
  97.     DIM X AS SINGLE, Y AS SINGLE
  98.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  99.     _glColor4f glRc, glGc, glBc, glAc
  100.     IF Radius = 0 THEN
  101.         _glBegin _GL_POINTS
  102.         _glVertex2f Proportion(0, 1024, -1, 1, CX), Proportion(0, 600, 1, -1, CY)
  103.         _glEnd
  104.         EXIT SUB
  105.     END IF
  106.     _glBegin _GL_QUADS
  107.     _glVertex2f Proportion(0, 1024, -1, 1, CX - X), Proportion(0, 600, 1, -1, CY)
  108.     _glVertex2f Proportion(0, 1024, -1, 1, CX + X), Proportion(0, 600, 1, -1, CY)
  109.     _glEnd
  110.     WHILE X > Y
  111.         RadiusError = RadiusError + Y * 2 + 1
  112.         IF RadiusError >= 0 THEN
  113.             IF X <> Y + 1 THEN
  114.                 _glBegin _GL_QUADS
  115.                 _glVertex2f Proportion(0, 1024, -1, 1, CX - Y), Proportion(0, 600, 1, -1, CY - X)
  116.                 _glVertex2f Proportion(0, 1024, -1, 1, CX + Y), Proportion(0, 600, 1, -1, CY - X)
  117.                 _glVertex2f Proportion(0, 1024, -1, 1, CX - Y), Proportion(0, 600, 1, -1, CY + X)
  118.                 _glVertex2f Proportion(0, 1024, -1, 1, CX + Y), Proportion(0, 600, 1, -1, CY + X)
  119.                 _glEnd
  120.             END IF
  121.             X = X - 1
  122.             RadiusError = RadiusError - X * 2
  123.         END IF
  124.         Y = Y + 1
  125.         _glBegin _GL_QUADS
  126.         _glVertex2f Proportion(0, 1024, -1, 1, CX - X), Proportion(0, 600, 1, -1, CY - Y)
  127.         _glVertex2f Proportion(0, 1024, -1, 1, CX + X), Proportion(0, 600, 1, -1, CY - Y)
  128.         _glVertex2f Proportion(0, 1024, -1, 1, CX - X), Proportion(0, 600, 1, -1, CY + Y)
  129.         _glVertex2f Proportion(0, 1024, -1, 1, CX + X), Proportion(0, 600, 1, -1, CY + Y)
  130.         _glEnd
  131.     WEND
  132.  
  133. FUNCTION Proportion (min1, max1, min2, max2, value)
  134.     'delta1: value = Delta2: x
  135.     Proportion = ((value * (max2 - min2)) / (max1 - min1)) + min2
  136.  

I think that I must copy Ashish tecnique t get that graphic effect into Opengl!
Title: Re: NEON PEN
Post by: TempodiBasic on November 21, 2020, 03:21:58 pm
Hi
just another step forward...
I have missed the Blending and the transformation of color value.
now it works OK

I have added a function to emulate Ashish code if you like that other version of make circle

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(1024, 600, 32)
  2. _TITLE "Pen Neon Ashis + Bplus ideas"
  3.  
  4. CONST True = -1, False = 0
  5. DIM SHARED GlInit AS INTEGER, GlActive AS INTEGER, glGc AS INTEGER, glRc AS INTEGER, glBc AS INTEGER, glAc AS INTEGER
  6. DIM Color32 AS _UNSIGNED LONG, GlMouse AS INTEGER, GlPointList(1 TO 2, 1 TO 32767) AS INTEGER
  7. DIM mx AS SINGLE, my AS SINGLE, lastx AS SINGLE, lasty AS SINGLE, r AS SINGLE, GlInput AS INTEGER
  8.  
  9. GlInit = True
  10. Color32 = _RGB32(220, 150, 10, 3)
  11. glGc = _GREEN32(Color32)
  12. glBc = _BLUE32(Color32)
  13. glRc = _RED32(Color32)
  14. glAc = 10
  15. Color32 = _RGB32(166, 233, 105, 3)
  16. GlActive = False
  17. GlMouse = 0
  18.  
  19.     GlInput = False
  20.     mx = _MOUSEX: my = _MOUSEY
  21.         IF GlActive THEN GlInput = True
  22.  
  23.         IF lastx <> mx OR lasty <> my THEN
  24.             IF GlInput THEN
  25.                 GlMouse = GlMouse + 1
  26.                 GlPointList(1, GlMouse) = mx
  27.                 GlPointList(2, GlMouse) = my
  28.             END IF
  29.             IF GlActive = True THEN
  30.                 ' here GL works
  31.             ELSE
  32.                 FOR r = 0 TO 25 ' graphic output engine :-)
  33.                     fcirc mx, my, r, Color32
  34.                 NEXT
  35.             END IF
  36.         END IF
  37.         lastx = mx: lasty = my
  38.     END IF
  39.         GlActive = NOT GlActive 'switch between stardard and Opengl graphic
  40.     END IF
  41.     _LIMIT 30
  42.  
  43. 'from Steve Gold standard
  44. SUB fcirc (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  45.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  46.     DIM X AS INTEGER, Y AS INTEGER
  47.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  48.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  49.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  50.     WHILE X > Y
  51.         RadiusError = RadiusError + Y * 2 + 1
  52.         IF RadiusError >= 0 THEN
  53.             IF X <> Y + 1 THEN
  54.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  55.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  56.             END IF
  57.             X = X - 1
  58.             RadiusError = RadiusError - X * 2
  59.         END IF
  60.         Y = Y + 1
  61.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  62.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  63.     WEND
  64.  
  65.  
  66. SUB _GL ()
  67.     SHARED mx AS SINGLE, my AS SINGLE, GlMouse AS INTEGER, GlPointList() AS INTEGER, GlInput AS INTEGER
  68.     DIM r AS SINGLE, n AS INTEGER, x1 AS SINGLE, y1 AS SINGLE
  69.     IF GlActive = False THEN EXIT SUB ' No gl session
  70.     IF GlInit THEN InitGl
  71.  
  72.     ' _glClear _GL_COLOR_BUFFER_BIT
  73.  
  74.     ' graphic output engine :-)
  75.     _glEnable _GL_BLEND
  76.     _glBlendFunc _GL_SRC_ALPHA, _GL_ONE
  77.  
  78.     _glColor4f Proportion(0, 255, 0, 1, glRc), Proportion(0, 255, 0, 1, glGc), Proportion(0, 255, 0, 1, glBc), Proportion(0, 255, 0, 1, glAc)
  79.  
  80.     IF GlInput THEN
  81.         ' actual point
  82.         FOR r = 1 TO 15
  83.             'Gl_PointAshish mx, my, r
  84.             Gl_fcirc mx, my, r
  85.         NEXT
  86.     END IF
  87.     ' previous points
  88.     FOR n = 1 TO GlMouse
  89.         x1 = GlPointList(1, n)
  90.         y1 = GlPointList(2, n)
  91.         FOR r = 1 TO 15
  92.             'Gl_PointAshish x1, y1, r
  93.             Gl_fcirc x1, y1, r
  94.         NEXT
  95.     NEXT n
  96.     _glFlush
  97.  
  98. SUB InitGl
  99.     '    _glClearColor 0.6, 0.6, 0.8, 1
  100.     GlInit = False
  101.  
  102. SUB Gl_PointAshish (CX AS SINGLE, CY AS SINGLE, R AS SINGLE)
  103.     _glPointSize R
  104.     _glBegin _GL_POINTS
  105.     _glVertex2f Proportion(0, 1024, -1, 1, CX), Proportion(0, 600, 1, -1, CY)
  106.     _glEnd
  107.  
  108. 'from Steve Gold standard ported to OpenGl
  109. SUB Gl_fcirc (CX AS SINGLE, CY AS SINGLE, R AS SINGLE)
  110.     DIM Radius AS SINGLE, RadiusError AS SINGLE
  111.     DIM X AS SINGLE, Y AS SINGLE
  112.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  113.     IF Radius = 0 THEN
  114.         _glBegin _GL_POINTS
  115.         _glVertex2f Proportion(0, 1024, -1, 1, CX), Proportion(0, 600, 1, -1, CY)
  116.         _glEnd
  117.         EXIT SUB
  118.     END IF
  119.     _glBegin _GL_QUADS
  120.     _glVertex2f Proportion(0, 1024, -1, 1, CX - X), Proportion(0, 600, 1, -1, CY)
  121.     _glVertex2f Proportion(0, 1024, -1, 1, CX + X), Proportion(0, 600, 1, -1, CY)
  122.     _glEnd
  123.     WHILE X > Y
  124.         RadiusError = RadiusError + Y * 2 + 1
  125.         IF RadiusError >= 0 THEN
  126.             IF X <> Y + 1 THEN
  127.                 _glBegin _GL_QUADS
  128.                 _glVertex2f Proportion(0, 1024, -1, 1, CX - Y), Proportion(0, 600, 1, -1, CY - X)
  129.                 _glVertex2f Proportion(0, 1024, -1, 1, CX + Y), Proportion(0, 600, 1, -1, CY - X)
  130.                 _glVertex2f Proportion(0, 1024, -1, 1, CX - Y), Proportion(0, 600, 1, -1, CY + X)
  131.                 _glVertex2f Proportion(0, 1024, -1, 1, CX + Y), Proportion(0, 600, 1, -1, CY + X)
  132.                 _glEnd
  133.             END IF
  134.             X = X - 1
  135.             RadiusError = RadiusError - X * 2
  136.         END IF
  137.         Y = Y + 1
  138.         _glBegin _GL_QUADS
  139.         _glVertex2f Proportion(0, 1024, -1, 1, CX - X), Proportion(0, 600, 1, -1, CY - Y)
  140.         _glVertex2f Proportion(0, 1024, -1, 1, CX + X), Proportion(0, 600, 1, -1, CY - Y)
  141.         _glVertex2f Proportion(0, 1024, -1, 1, CX - X), Proportion(0, 600, 1, -1, CY + Y)
  142.         _glVertex2f Proportion(0, 1024, -1, 1, CX + X), Proportion(0, 600, 1, -1, CY + Y)
  143.         _glEnd
  144.     WEND
  145.  
  146. FUNCTION Proportion (min1, max1, min2, max2, value)
  147.     'delta1: value = Delta2: x
  148.     Proportion = ((value * (max2 - min2)) / (max1 - min1)) + min2
  149.  
  150.  

here the screenshot

  [ This attachment cannot be displayed inline in 'Print Page' view ]  

Thanks so I can learn!
Title: Re: NEON PEN
Post by: SierraKen on November 21, 2020, 08:51:44 pm
Took me a little while but I figured out some simple things with the neon. Here are 2 boxes I made just using commands.

Code: QB64: [Select]
  1. _TITLE "Ken's Neon"
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3.  
  4. TYPE vec2
  5.     x AS SINGLE
  6.     y AS SINGLE
  7.  
  8. REDIM SHARED vert(4024) AS vec2, max_v_index
  9. DIM SHARED rFactor!, gFactor!, bFactor!
  10. rFactor! = 0.5: gFactor! = 1: bFactor! = 0.5
  11.  
  12.  
  13.  
  14. 'First Box
  15. FOR xx = 195 TO 500
  16.     max_v_index = max_v_index + 1
  17.     vert(max_v_index).x = xx
  18.     vert(max_v_index).y = 200
  19. NEXT xx
  20.  
  21. FOR xx = 195 TO 500
  22.     max_v_index = max_v_index + 1
  23.     vert(max_v_index).x = xx
  24.     vert(max_v_index).y = 500
  25. NEXT xx
  26.  
  27. FOR yy = 200 TO 499
  28.     max_v_index = max_v_index + 1
  29.     vert(max_v_index).x = 200
  30.     vert(max_v_index).y = yy
  31. NEXT yy
  32.  
  33. FOR yy = 200 TO 500
  34.     max_v_index = max_v_index + 1
  35.     vert(max_v_index).x = 499
  36.     vert(max_v_index).y = yy
  37. NEXT yy
  38.  
  39. 'Second Box
  40. FOR xx = 395 TO 700
  41.     max_v_index = max_v_index + 1
  42.     vert(max_v_index).x = xx
  43.     vert(max_v_index).y = 50
  44. NEXT xx
  45.  
  46. FOR xx = 395 TO 700
  47.     max_v_index = max_v_index + 1
  48.     vert(max_v_index).x = xx
  49.     vert(max_v_index).y = 350
  50. NEXT xx
  51.  
  52. FOR yy = 50 TO 350
  53.     max_v_index = max_v_index + 1
  54.     vert(max_v_index).x = 700
  55.     vert(max_v_index).y = yy
  56. NEXT yy
  57.  
  58. FOR yy = 50 TO 350
  59.     max_v_index = max_v_index + 1
  60.     vert(max_v_index).x = 395
  61.     vert(max_v_index).y = yy
  62. NEXT yy
  63.  
  64.  
  65.  
  66.  
  67. SUB _GL ()
  68.     STATIC glInit
  69.     IF glInit = 0 THEN
  70.         glInit = 1
  71.  
  72.     END IF
  73.     'set the gl screen so that it can work normal screen coordinates
  74.     _glTranslatef -1, 1, 0
  75.     _glScalef 1 / 400, -1 / 300, 1
  76.  
  77.     _glEnable _GL_BLEND
  78.  
  79.     _glBlendFunc _GL_SRC_ALPHA, _GL_ONE
  80.     _glEnableClientState _GL_VERTEX_ARRAY
  81.     _glVertexPointer 2, _GL_FLOAT, 0, _OFFSET(vert())
  82.     FOR j = 1 TO 15
  83.         _glColor4f rFactor!, gFactor!, bFactor!, 0.015
  84.         _glPointSize j
  85.         _glDrawArrays _GL_POINTS, 10, max_v_index
  86.     NEXT
  87.     _glFlush
  88.  
Title: Re: NEON PEN
Post by: bplus on November 21, 2020, 10:51:09 pm
Ken gave me an idea

Code: QB64: [Select]
  1. _TITLE "b+ dimmer switch raise and lower mouse"
  2. SCREEN _NEWIMAGE(1024, 700, 32)
  3. _DELAY .25
  4.  
  5. TYPE vec2
  6.     x AS SINGLE
  7.     y AS SINGLE
  8.  
  9. REDIM vert(1 TO 4024) AS vec2
  10.  
  11. 'First Box
  12. FOR i = 50 TO 350 STEP 25
  13.     vi = vi + 1
  14.     vert(vi).x = 50
  15.     vert(vi).y = i
  16.     vi = vi + 1
  17.     vert(vi).x = 350
  18.     vert(vi).y = i
  19.     IF i <> 50 AND i <> 350 THEN
  20.         vi = vi + 1
  21.         vert(vi).x = i
  22.         vert(vi).y = 50
  23.         vi = vi + 1
  24.         vert(vi).x = i
  25.         vert(vi).y = 350
  26.     END IF
  27. 'Second Box
  28. FOR i = 250 TO 650 STEP 25
  29.     vi = vi + 1
  30.     vert(vi).x = 250
  31.     vert(vi).y = i
  32.     vi = vi + 1
  33.     vert(vi).x = 650
  34.     vert(vi).y = i
  35.     IF i <> 250 AND i <> 650 THEN
  36.         vi = vi + 1
  37.         vert(vi).x = i
  38.         vert(vi).y = 250
  39.         vi = vi + 1
  40.         vert(vi).x = i
  41.         vert(vi).y = 650
  42.     END IF
  43. FOR a = 0 TO _PI(2) - .01 STEP _PI(1 / 30)
  44.     vi = vi + 1
  45.     vert(vi).x = 750 + 200 * COS(a)
  46.     vert(vi).y = 350 + 200 * SIN(a)
  47.  
  48.  
  49.     CLS
  50.     my = _MOUSEY / _HEIGHT * 12
  51.     FOR power = 1 TO my
  52.         FOR i = 1 TO vi
  53.             FOR r = 1 TO 25
  54.                 IF vert(i).x = 0 AND vert(i).y = 0 THEN 'where is that coming from?
  55.                     LOCATE 1, 1: PRINT i
  56.                 ELSE
  57.                     fcirc vert(i).x, vert(i).y, r, _RGBA32(240, 230, 255, 3)
  58.                 END IF
  59.             NEXT
  60.         NEXT
  61.     NEXT
  62.     _DISPLAY
  63.     _LIMIT 60
  64.  
  65.  
  66. 'from Steve Gold standard
  67. SUB fcirc (CX AS INTEGER, CY AS INTEGER, R AS INTEGER, C AS _UNSIGNED LONG)
  68.     DIM Radius AS INTEGER, RadiusError AS INTEGER
  69.     DIM X AS INTEGER, Y AS INTEGER
  70.     Radius = ABS(R): RadiusError = -Radius: X = Radius: Y = 0
  71.     IF Radius = 0 THEN PSET (CX, CY), C: EXIT SUB
  72.     LINE (CX - X, CY)-(CX + X, CY), C, BF
  73.     WHILE X > Y
  74.         RadiusError = RadiusError + Y * 2 + 1
  75.         IF RadiusError >= 0 THEN
  76.             IF X <> Y + 1 THEN
  77.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  78.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  79.             END IF
  80.             X = X - 1
  81.             RadiusError = RadiusError - X * 2
  82.         END IF
  83.         Y = Y + 1
  84.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  85.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  86.     WEND
  87.  
  88.  

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: NEON PEN
Post by: SierraKen on November 21, 2020, 11:24:52 pm
LOL that's awesome B+! I love the dimming effect, it can be used on neon signs. :)
Title: Re: NEON PEN
Post by: Ashish on November 22, 2020, 03:03:52 am
@TempodiBasic
There is a simpler way to draw circle in OpenGL

Code: QB64: [Select]
  1. _TITLE "Learning OpenGL" 'giving title to your window
  2. SCREEN _NEWIMAGE(600, 600, 32) 'creating a window of 600x600
  3.  
  4. 'This is our main loop
  5.     _LIMIT 40 'Adding this will prevent high cpu usage.
  6.  
  7. SUB _GL ()
  8.     'Here we'll put our OpenGL commands!
  9.  
  10.     _glViewport 0, 0, _WIDTH, _HEIGHT 'here _WIDTH() and _HEIGHT() gives the width and height of our window.
  11.     '_glClearColor 1, .5, 0, 1
  12.     _glClear _GL_COLOR_BUFFER_BIT
  13.  
  14.  
  15.     _glColor3f 1, 1, 1
  16.  
  17.     r = .5
  18.     _glBegin _GL_TRIANGLE_FAN
  19.     FOR i = 0 TO _PI(2) STEP .05
  20.         _glVertex2f COS(i) * r, SIN(i) * r
  21.     NEXT
  22.     _glEnd
  23.  
  24.     _glFlush
  25.  


For explanation, see GL_TRIANGLE_FAN section here - https://ashishkingdom.github.io/OpenGL-Tutorials/2d-shapes/
Title: Re: NEON PEN
Post by: Ashish on November 22, 2020, 03:11:56 am
@bplus gives us new IDEA! :D

Here is the dimming effect in GL
Code: QB64: [Select]
  1. _TITLE "NEON PEN"
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3.  
  4. TYPE vec2
  5.     x AS SINGLE
  6.     y AS SINGLE
  7.  
  8. REDIM SHARED vert(1024) AS vec2, max_v_index
  9. DIM SHARED rFactor!, gFactor!, bFactor!
  10. rFactor! = 0.5: gFactor! = 1: bFactor! = 0.5
  11.     CLS
  12.     PRINT "VRAM Usage : "; vram; "KB"
  13.     PRINT "Vertices Used : "; max_v_index; "/"; UBOUND(vert)
  14.     vram = (UBOUND(vert) * 4) / 1024
  15.         mx = _MOUSEX: my = _MOUSEY
  16.         px = mx: py = my
  17.         WHILE _MOUSEBUTTON(1) AND max_v_index < UBOUND(vert)
  18.             WHILE _MOUSEINPUT: WEND
  19.             mx = _MOUSEX: my = _MOUSEY
  20.             IF ABS(px - mx) >= ABS(py - my) THEN
  21.                 IF mx >= px THEN s = 1 ELSE s = -1
  22.                 FOR i = px TO mx STEP s
  23.                     vert(max_v_index).x = i
  24.                     vert(max_v_index).y = map(i, px, mx, py, my)
  25.                     max_v_index = max_v_index + 1
  26.                     IF max_v_index > INT(UBOUND(vert) * 0.8) THEN REDIM _PRESERVE vert(max_v_index * 2) AS vec2
  27.                 NEXT
  28.             ELSE
  29.                 IF my >= py THEN s = 1 ELSE s = -1
  30.                 FOR i = py TO my STEP s
  31.                     vert(max_v_index).x = map(i, py, my, px, mx)
  32.                     vert(max_v_index).y = i
  33.                     max_v_index = max_v_index + 1
  34.                     IF max_v_index > INT(UBOUND(vert) * 0.8) THEN REDIM _PRESERVE vert(max_v_index * 2) AS vec2
  35.                 NEXT
  36.  
  37.             END IF
  38.             px = mx: py = my
  39.             _LIMIT 30
  40.         WEND
  41.     END IF
  42.  
  43.     _LIMIT 60
  44.  
  45. SUB _GL ()
  46.     STATIC glInit, clock
  47.     clock = clock + 0.03
  48.     IF glInit = 0 THEN
  49.         glInit = 1
  50.  
  51.     END IF
  52.     'set the gl screen so that it can work normal screen coordinates
  53.     _glTranslatef -1, 1, 0
  54.     _glScalef 1 / 400, -1 / 300, 1
  55.  
  56.     _glEnable _GL_BLEND
  57.  
  58.     _glBlendFunc _GL_SRC_ALPHA, _GL_ONE
  59.     _glEnableClientState _GL_VERTEX_ARRAY
  60.     _glVertexPointer 2, _GL_FLOAT, 0, _OFFSET(vert())
  61.     FOR j = 1 TO 15
  62.         _glColor4f rFactor!, gFactor!, bFactor!, 0.009 + 0.03 * ABS(SIN(clock))
  63.         _glPointSize j
  64.         _glDrawArrays _GL_POINTS, 10, max_v_index
  65.     NEXT
  66.     _glFlush
  67.  
  68. FUNCTION map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!)
  69.     map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
  70.  
  71.  
Title: Re: NEON PEN
Post by: TempodiBasic on November 22, 2020, 07:24:40 am
@Ashish
Hi thanks for suggestion but I must say you that I have already a good master for Opengl
and I have travelled already his lessons to this Website https://ashishkingdom.github.io/OpenGL-Tutorials/ (https://ashishkingdom.github.io/OpenGL-Tutorials/)
Now I need to use Opengl and  to pass again in the OpenGl travel to learn and memorize better.
Ripetita iuvant.

PS:
is your that website, master of OpenGl? 
;-)
Title: Re: NEON PEN
Post by: SierraKen on November 22, 2020, 03:45:04 pm
Today I found _GL_LINE_STRIP so I turned your Neon Pen into making lines. It's not the same neon-look as you had before, but it's just something to learn. I also upped the vert DIM by a lot more. I found out that CLS or even a giant black box using LINE doesn't clear the screen for some reason. I'm still learning this stuff. I had to change your SUB to use the new _GL_LINE_STRIP, I'll post all of the code below. I should probably say too that I'm sure there's a much easier way to make this lines program without using OpenGL and without Dimming the memory. Or at least something very similar. This is just an OpenGL example is all. First click once on the screen, then click again to make your first line. Every line after that is connected to the end of your older line.
But first I want to say that people can also change the width of your Neon Pen (not this lines example below) to make wider lines or drawings by just changing the SUB's line For j=1 to 15 to something like For j=1 to 25.

 
Code: QB64: [Select]
  1. _TITLE "Neon Lines"
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3.  
  4. TYPE vec2
  5.     x AS SINGLE
  6.     y AS SINGLE
  7.  
  8. REDIM SHARED vert(200024) AS vec2, max_v_index
  9. DIM SHARED rFactor!, gFactor!, bFactor!
  10. rFactor! = 0.5: gFactor! = 2.5: bFactor! = 0.5
  11.     'CLS
  12.     LOCATE 1, 1: PRINT "VRAM Usage : "; vram; "KB"
  13.     LOCATE 2, 1: PRINT "Vertices Used : "; max_v_index; "/"; UBOUND(vert)
  14.     vram = (UBOUND(vert) * 4) / 1024
  15.     a$ = INKEY$
  16.     IF a$ = CHR$(27) THEN END
  17.  
  18.     m = _MOUSEBUTTON(1)
  19.     IF m = -1 THEN
  20.         t = t + 1
  21.         px = mx: py = my
  22.         mx = _MOUSEX: my = _MOUSEY
  23.         IF t < 2 THEN GOTO notthistime:
  24.         'px = mx: py = my
  25.         WHILE m = -1 AND max_v_index < UBOUND(vert)
  26.             WHILE _MOUSEINPUT: WEND
  27.             mx = _MOUSEX: my = _MOUSEY
  28.             IF ABS(px - mx) >= ABS(py - my) THEN
  29.                 IF mx >= px THEN s = 1 ELSE s = -1
  30.                 FOR i = px TO mx STEP s
  31.                     vert(max_v_index).x = i
  32.                     vert(max_v_index).y = map(i, px, mx, py, my)
  33.                     max_v_index = max_v_index + 1
  34.                     'IF max_v_index > UBOUND(vert) THEN REDIM _PRESERVE vert(max_v_index * 2) AS vec2
  35.                 NEXT
  36.             ELSE
  37.                 IF my >= py THEN s = 1 ELSE s = -1
  38.                 FOR i = py TO my STEP s
  39.                     vert(max_v_index).x = map(i, py, my, px, mx)
  40.                     vert(max_v_index).y = i
  41.                     max_v_index = max_v_index + 1
  42.                     'IF max_v_index > UBOUND(vert) THEN REDIM _PRESERVE vert(max_v_index * 2) AS vec2
  43.                 NEXT
  44.             END IF
  45.             'px = mx: py = my
  46.             notthistime:
  47.             m = 0
  48.         WEND
  49.     END IF
  50.     _LIMIT 200
  51.  
  52. 'This sub was changed from points to lines.
  53. SUB _GL ()
  54.     STATIC glInit
  55.     IF glInit = 0 THEN
  56.         glInit = 1
  57.  
  58.     END IF
  59.     'set the gl screen so that it can work normal screen coordinates
  60.     _glTranslatef -1, 1, 0
  61.     _glScalef 1 / 400, -1 / 300, 1
  62.  
  63.     _glEnable _GL_BLEND
  64.     _glBlendFunc _GL_SRC_ALPHA, _GL_ONE
  65.     _glEnableClientState _GL_VERTEX_ARRAY
  66.     _glVertexPointer 2, _GL_FLOAT, 0, _OFFSET(vert())
  67.     FOR j = 1 TO 30
  68.         'For j=1 to 15
  69.         '_glColor4f rFactor!, gFactor!, bFactor!, 0.015
  70.         _glColor4f rFactor!, gFactor!, bFactor!, 0.06
  71.         _glPointSize j
  72.         '_glDrawArrays _GL_POINTS, 10, max_v_index
  73.         _glLineWidth 10
  74.         _glDrawArrays _GL_LINE_STRIP, 0, max_v_index
  75.     NEXT
  76.     _glFlush
  77.  
  78. FUNCTION map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!)
  79.     map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
  80.  
Title: Re: NEON PEN
Post by: SierraKen on November 22, 2020, 04:35:05 pm
Here's what your Neon Pen looks like with the wider length I mentioned in my last post. Oh I also had to add more to the Dim for the vert's on this too.

Title: Re: NEON PEN
Post by: TempodiBasic on November 22, 2020, 06:55:19 pm
@SierraKen
Hi I'm seeing that you like it!

if you want clear screen in Opengl you must 1. set the color of clearing (say Black _rgb32(0,0,0,255)) with _glclearcolor and after 2 use _glclear what (generally _gl_color_buffer_bit)
as here
Code: QB64: [Select]
  1.     _GLCLEARCOLOR 1, .5, 0, 1
  2.     _GLCLEAR _GL_COLOR_BUFFER_BIT
the 4th parameter is Alpha channel, so if you want to see as background normal graphic (that made by LINE and erased by CLS) you can use a lower value at the place of 1 (0-1  in Opengl 0-255 in standard graphic).

But all these are info taken from my Opengl master  here https://ashishkingdom.github.io/OpenGL-Tutorials/ (https://ashishkingdom.github.io/OpenGL-Tutorials/).

If you want to learn how to mix normal graphic and Opengl graphic you can see the demo posted by Steve here:  https://www.qb64.org/forum/index.php?topic=3254.msg125353#msg125353 (https://www.qb64.org/forum/index.php?topic=3254.msg125353#msg125353)
but I warning you it is just a little advanced. ;-)
Title: Re: NEON PEN
Post by: SierraKen on November 22, 2020, 09:42:34 pm
Thanks TempodiBasic, but I don't know much more OpenGL I'm going to do. I rarely stay with anything I jump in the middle of. But thanks for the info.