Author Topic: _SMOOTH bug? [SOLVED]  (Read 2955 times)

0 Members and 1 Guest are viewing this topic.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
_SMOOTH bug? [SOLVED]
« on: October 16, 2019, 10:32:16 am »
Hi try this source code:

Code: QB64: [Select]
  1.  
  2.  
  3.  
  4. SCREEN _NEWIMAGE(800, 600, 32)
  5. VIRTUAL& = _NEWIMAGE(600, 600, 32)
  6. _PUTIMAGE , i, VIRTUAL&
  7. pieces = 66
  8.  
  9.  
  10. uhel = _PI
  11.  
  12.  
  13.     uhel = uhel + n
  14.     CLS
  15.     FOR B = 1 TO pieces
  16.         X = 400 + COS(uhel) * 400
  17.         Y = 300 + SIN(uhel) * 300
  18.  
  19.         X3 = 400 + COS(uhel + _PI / pieces) * 400
  20.         Y3 = 300 + SIN(uhel + _PI / pieces) * 300
  21.  
  22.  
  23.         PSET (X, Y)
  24.         uhel = uhel + _PI / pieces
  25.         '   SLEEP
  26.  
  27.         X2 = B * (800 / pieces)
  28.         xx = 800 / pieces
  29.  
  30.  
  31.         _MAPTRIANGLE (X2, 0)-(X2 + xx, 0)-(X2, 599), VIRTUAL& TO(X, Y)-(X3, Y3)-(X2, 599), _SMOOTH
  32.         _MAPTRIANGLE (X2 + xx, 0)-(X2, 599)-(X2 + xx, 599), VIRTUAL& TO(X3, Y3)-(X2, 599)-(X2 + xx, 599), _SMOOTH
  33.     NEXT
  34.     _DISPLAY
  35.     _LIMIT 20
  36.     uhel = _PI: n = n + .1
  37.  

Works? OK! Press twice ALt + Enter!  Invalid handle error occur. Why?

Then comment _SMOOTH in source code, recompile and run it again. Now all works fine also after twice press Alt + Enter.
« Last Edit: October 19, 2019, 02:14:49 am by Petr »

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: _SMOOTH bug?
« Reply #1 on: October 16, 2019, 12:04:44 pm »
Hi Petr! How are you?
The mistake is that you are using _SMOOTH at the place of destination handle. So, at initial condition the value of _SMOOTH is 0 (because there is no anti-aliasing). When we press ALT+ENTER twice, smooth is being enable and therefore, _SMOOTH function return -1. And QB64 treat -1 as an invalid handle.
 
Replace
Code: QB64: [Select]
  1. _MAPTRIANGLE (X2, 0)-(X2 + xx, 0)-(X2, 599), VIRTUAL& TO(X, Y)-(X3, Y3)-(X2, 599), _SMOOTH
  2.  
To
Code: QB64: [Select]
  1. _MAPTRIANGLE (X2, 0)-(X2 + xx, 0)-(X2, 599), VIRTUAL& TO(X, Y)-(X3, Y3)-(X2, 599), , _SMOOTH
  2.  
Notice the double comma at the last? I think you must have understood what I wanted to say.
« Last Edit: October 16, 2019, 12:07:52 pm by Ashish »
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: _SMOOTH bug?
« Reply #2 on: October 16, 2019, 01:35:10 pm »
Oh man! Thank you Ashish! I didn't realize it at all! So a mistake on my side.
To your question:  how am I? Well, it's not good now. Did not only us national singer Karel Gott die (of which I wrote in my forum signature and on the day of his funeral), but also the neighbor died and, to make matters worse, a colleague from work is  hanged himself. Well, it was really too bad now.
I'm slowly returning to programming. Very slowly, because there is not much time and there is a lot of work around.

Thank you for your help.