QB64.org Forum

Active Forums => Programs => Topic started by: Ashish on June 01, 2020, 03:56:30 am

Title: COVID-19 in QB64
Post by: Ashish on June 01, 2020, 03:56:30 am
WARNING : Use mask. Sanitize your hands after closing the program.

Code: QB64: [Select]
  1. 'COVID-19 in QB64
  2. 'By Ashish
  3. '1 Jun, 2020
  4. '
  5. 'WARNING:Use mask. Apply santizer after closing the program.
  6.  
  7. _TITLE "I'm Covid-19"
  8. SCREEN _NEWIMAGE(600, 600, 32)
  9.  
  10.     SUB glutSolidSphere (BYVAL radius AS DOUBLE, BYVAL slices AS LONG, BYVAL stack AS LONG)
  11.     SUB gluLookAt (BYVAL eyeX#, BYVAL eyeY#, BYVAL eyeZ#, BYVAL centerX#, BYVAL centerY#, BYVAL centerZ#, BYVAL upX#, BYVAL upY#, BYVAL upZ#)
  12.  
  13.  
  14. DIM SHARED glAllow AS _BYTE
  15. TYPE vec3
  16.     x AS SINGLE
  17.     y AS SINGLE
  18.     z AS SINGLE
  19.  
  20. TYPE COVID19
  21.     pos AS vec3
  22.     r AS SINGLE
  23.  
  24. DIM SHARED virus AS COVID19
  25.  
  26. virus.r = 0.3
  27.  
  28. glAllow = -1
  29.     _LIMIT 1
  30.  
  31. SUB _GL ()
  32.     STATIC init, aspect, rotY
  33.  
  34.     IF glAllow = 0 THEN EXIT SUB
  35.     IF init = 0 THEN
  36.         init = 1
  37.         aspect = _WIDTH / _HEIGHT
  38.         _glViewport 0, 0, _WIDTH, _HEIGHT
  39.     END IF
  40.  
  41.     _glEnable _GL_DEPTH_TEST
  42.     _glEnable _GL_LIGHTING
  43.     _glEnable _GL_LIGHT0
  44.  
  45.     _glLightfv _GL_LIGHT0, _GL_AMBIENT, glVec4(0.0, 0.0, 0.0, 1)
  46.     _glLightfv _GL_LIGHT0, _GL_DIFFUSE, glVec4(0.8, 0.8, 0.8, 1)
  47.     _glLightfv _GL_LIGHT0, _GL_SPECULAR, glVec4(1, 1, 1, 1)
  48.     _glLightfv _GL_LIGHT0, _GL_POSITION, glVec4(0, 0, 10, 1)
  49.  
  50.  
  51.  
  52.     _glMatrixMode _GL_PROJECTION
  53.     _gluPerspective 50, aspect, 0.1, 10
  54.  
  55.     _glMatrixMode _GL_MODELVIEW
  56.     gluLookAt 0, 0, 2, 0, 0, 0, 0, 1, 0
  57.  
  58.  
  59.     _glLineWidth 2.0
  60.     _glPointSize 10.0
  61.  
  62.     _glTranslatef virus.pos.x, virus.pos.y, virus.pos.z
  63.     _glRotatef rotY, 0.5, 1, 0
  64.     rotY = rotY + 1
  65.  
  66.     _glMaterialfv _GL_FRONT_AND_BACK, _GL_DIFFUSE, glVec4(0, 0.9, 0, 1)
  67.  
  68.     glutSolidSphere virus.r, 20, 20
  69.  
  70.     _glDisable _GL_LIGHTING
  71.     _glColor3f 1, 0, 0
  72.     _glBegin _GL_LINES
  73.     FOR phi = 0.4 TO _PI(2) STEP .5
  74.         FOR theta = 0.3 TO _PI STEP .5
  75.             _glVertex3f virus.r * SIN(theta) * COS(phi), virus.r * SIN(theta) * SIN(phi), virus.r * COS(theta)
  76.             _glVertex3f (0.1 + virus.r) * SIN(theta) * COS(phi), (0.1 + virus.r) * SIN(theta) * SIN(phi), (0.1 + virus.r) * COS(theta)
  77.         NEXT
  78.     NEXT
  79.     _glEnd
  80.     _glBegin _GL_POINTS
  81.     FOR phi = 0.4 TO _PI(2) STEP .5
  82.         FOR theta = 0.3 TO _PI STEP .5
  83.             _glVertex3f (0.1 + virus.r) * SIN(theta) * COS(phi), (0.1 + virus.r) * SIN(theta) * SIN(phi), (0.1 + virus.r) * COS(theta)
  84.         NEXT
  85.     NEXT
  86.     _glEnd
  87.     _glEnable _GL_LIGHTING
  88.  
  89.  
  90.  
  91.  
  92. FUNCTION glVec4%& (x, y, z, w) 'give the offset of the given vector
  93.     STATIC internal_vec4(3)
  94.     internal_vec4(0) = x
  95.     internal_vec4(1) = y
  96.     internal_vec4(2) = z
  97.     internal_vec4(3) = w
  98.     glVec4%& = _OFFSET(internal_vec4())
  99.  
Title: Re: COVID-19 in QB64
Post by: _vince on June 01, 2020, 08:49:25 am
Nice work, ashishh. I made yours a little more efficient:

Code: QB64: [Select]
  1. 'COVID-19 in QB64
  2. 'By Ashish
  3. '1 Jun, 2020
  4. '
  5. 'WARNING:Use mask. Apply santizer after closing the program.
  6.  
  7. _TITLE "I'm Covid-19"
  8. SCREEN _NEWIMAGE(600, 600, 32)
  9.  
  10.     SUB glutSolidSphere (BYVAL radius AS DOUBLE, BYVAL slices AS LONG, BYVAL stack AS LONG)
  11.     SUB gluLookAt (BYVAL eyeX#, BYVAL eyeY#, BYVAL eyeZ#, BYVAL centerX#, BYVAL centerY#, BYVAL centerZ#, BYVAL upX#, BYVAL upY#, BYVAL upZ#)
  12.  
  13.  
  14. DIM SHARED glAllow AS _BYTE
  15. TYPE vec3
  16.     x AS SINGLE
  17.     y AS SINGLE
  18.     z AS SINGLE
  19.  
  20. TYPE COVID19
  21.     POS AS vec3
  22.     r AS SINGLE
  23.  
  24. DIM SHARED virus AS COVID19
  25.  
  26. virus.r = 0.3
  27.  
  28. glAllow = -1
  29.     _LIMIT 1
  30.  
  31. SUB _GL ()
  32.     STATIC init, aspect, rotY
  33.  
  34.     IF glAllow = 0 THEN EXIT SUB
  35.     IF init = 0 THEN
  36.         init = 1
  37.         aspect = _WIDTH / _HEIGHT
  38.         _glViewport 0, 0, _WIDTH, _HEIGHT
  39.     END IF
  40.  
  41.     _glEnable _GL_DEPTH_TEST
  42.     _glEnable _GL_LIGHTING
  43.     _glEnable _GL_LIGHT0
  44.  
  45.     _glLightfv _GL_LIGHT0, _GL_AMBIENT, glVec4(0.0, 0.0, 0.0, 1)
  46.     _glLightfv _GL_LIGHT0, _GL_DIFFUSE, glVec4(0.8, 0.8, 0.8, 1)
  47.     _glLightfv _GL_LIGHT0, _GL_SPECULAR, glVec4(1, 1, 1, 1)
  48.     _glLightfv _GL_LIGHT0, _GL_POSITION, glVec4(0, 0, 10, 1)
  49.  
  50.  
  51.  
  52.     _glMatrixMode _GL_PROJECTION
  53.     _gluPerspective 50, aspect, 0.1, 10
  54.  
  55.     _glMatrixMode _GL_MODELVIEW
  56.     gluLookAt 0, 0, 2, 0, 0, 0, 0, 1, 0
  57.  
  58.  
  59.     _glLineWidth 2.0
  60.     _glPointSize 10.0
  61.  
  62.     _glTranslatef virus.POS.x, virus.POS.y, virus.POS.z
  63.     _glRotatef rotY, 0.5, 1, 0
  64.     rotY = rotY + 1
  65.  
  66.     _glMaterialfv _GL_FRONT_AND_BACK, _GL_DIFFUSE, glVec4(0, 0.9, 0, 1)
  67.  
  68.     glutSolidSphere virus.r, 20, 20
  69.  
  70.     _glDisable _GL_LIGHTING
  71.     _glColor3f 1, 0, 0
  72.     _glBegin _GL_LINES
  73.     'FOR phi = 0.4 TO _PI(2) STEP .5
  74.     'FOR theta = 0.3 TO _PI STEP .5
  75.  
  76.     rr = 0.18
  77.     a = _ASIN(rr / (0.1 + virus.r))
  78.     FOR theta = a TO _PI STEP a
  79.         aa = rr / ((0.1 + virus.r) * SIN(theta))
  80.         FOR phi = aa TO _PI(2) STEP aa
  81.             _glVertex3f virus.r * SIN(theta) * COS(phi), virus.r * SIN(theta) * SIN(phi), virus.r * COS(theta)
  82.             _glVertex3f (0.1 + virus.r) * SIN(theta) * COS(phi), (0.1 + virus.r) * SIN(theta) * SIN(phi), (0.1 + virus.r) * COS(theta)
  83.         NEXT
  84.     NEXT
  85.  
  86.     _glEnd
  87.     _glBegin _GL_POINTS
  88.     FOR theta = a TO _PI STEP a
  89.         aa = rr / ((0.1 + virus.r) * SIN(theta))
  90.         FOR phi = aa TO _PI(2) STEP aa
  91.             _glVertex3f (0.1 + virus.r) * SIN(theta) * COS(phi), (0.1 + virus.r) * SIN(theta) * SIN(phi), (0.1 + virus.r) * COS(theta)
  92.         NEXT
  93.     NEXT
  94.     _glEnd
  95.     _glEnable _GL_LIGHTING
  96.  
  97.  
  98.  
  99.  
  100. FUNCTION glVec4%& (x, y, z, w) 'give the offset of the given vector
  101.     STATIC internal_vec4(3)
  102.     internal_vec4(0) = x
  103.     internal_vec4(1) = y
  104.     internal_vec4(2) = z
  105.     internal_vec4(3) = w
  106.     glVec4%& = _OFFSET(internal_vec4())
  107.  
Title: Re: COVID-19 in QB64
Post by: Dimster on June 01, 2020, 09:30:13 am
So Ashish - how would you invisage the cure? Would it be a large razor blade to shave off those stubbles or perhaps a blanket with perferations through which those antenna would fit but the rest of the blanket would encompas the green ball of the virus. Perhaps just a flood of chlorine to overwhelm it. It's actually hard to image something so innocuous is so deadly.
Title: Re: COVID-19 in QB64
Post by: Real2Two on June 01, 2020, 09:36:09 am
Nice work, ashishh. I made yours a little more efficient:

Code: QB64: [Select]
  1. 'COVID-19 in QB64
  2. 'By Ashish
  3. '1 Jun, 2020
  4. '
  5. 'WARNING:Use mask. Apply santizer after closing the program.
  6.  
  7. _TITLE "I'm Covid-19"
  8. SCREEN _NEWIMAGE(600, 600, 32)
  9.  
  10.     SUB glutSolidSphere (BYVAL radius AS DOUBLE, BYVAL slices AS LONG, BYVAL stack AS LONG)
  11.     SUB gluLookAt (BYVAL eyeX#, BYVAL eyeY#, BYVAL eyeZ#, BYVAL centerX#, BYVAL centerY#, BYVAL centerZ#, BYVAL upX#, BYVAL upY#, BYVAL upZ#)
  12.  
  13.  
  14. DIM SHARED glAllow AS _BYTE
  15. TYPE vec3
  16.     x AS SINGLE
  17.     y AS SINGLE
  18.     z AS SINGLE
  19.  
  20. TYPE COVID19
  21.     POS AS vec3
  22.     r AS SINGLE
  23.  
  24. DIM SHARED virus AS COVID19
  25.  
  26. virus.r = 0.3
  27.  
  28. glAllow = -1
  29.     _LIMIT 1
  30.  
  31. SUB _GL ()
  32.     STATIC init, aspect, rotY
  33.  
  34.     IF glAllow = 0 THEN EXIT SUB
  35.     IF init = 0 THEN
  36.         init = 1
  37.         aspect = _WIDTH / _HEIGHT
  38.         _glViewport 0, 0, _WIDTH, _HEIGHT
  39.     END IF
  40.  
  41.     _glEnable _GL_DEPTH_TEST
  42.     _glEnable _GL_LIGHTING
  43.     _glEnable _GL_LIGHT0
  44.  
  45.     _glLightfv _GL_LIGHT0, _GL_AMBIENT, glVec4(0.0, 0.0, 0.0, 1)
  46.     _glLightfv _GL_LIGHT0, _GL_DIFFUSE, glVec4(0.8, 0.8, 0.8, 1)
  47.     _glLightfv _GL_LIGHT0, _GL_SPECULAR, glVec4(1, 1, 1, 1)
  48.     _glLightfv _GL_LIGHT0, _GL_POSITION, glVec4(0, 0, 10, 1)
  49.  
  50.  
  51.  
  52.     _glMatrixMode _GL_PROJECTION
  53.     _gluPerspective 50, aspect, 0.1, 10
  54.  
  55.     _glMatrixMode _GL_MODELVIEW
  56.     gluLookAt 0, 0, 2, 0, 0, 0, 0, 1, 0
  57.  
  58.  
  59.     _glLineWidth 2.0
  60.     _glPointSize 10.0
  61.  
  62.     _glTranslatef virus.POS.x, virus.POS.y, virus.POS.z
  63.     _glRotatef rotY, 0.5, 1, 0
  64.     rotY = rotY + 1
  65.  
  66.     _glMaterialfv _GL_FRONT_AND_BACK, _GL_DIFFUSE, glVec4(0, 0.9, 0, 1)
  67.  
  68.     glutSolidSphere virus.r, 20, 20
  69.  
  70.     _glDisable _GL_LIGHTING
  71.     _glColor3f 1, 0, 0
  72.     _glBegin _GL_LINES
  73.     'FOR phi = 0.4 TO _PI(2) STEP .5
  74.     'FOR theta = 0.3 TO _PI STEP .5
  75.  
  76.     rr = 0.18
  77.     a = _ASIN(rr / (0.1 + virus.r))
  78.     FOR theta = a TO _PI STEP a
  79.         aa = rr / ((0.1 + virus.r) * SIN(theta))
  80.         FOR phi = aa TO _PI(2) STEP aa
  81.             _glVertex3f virus.r * SIN(theta) * COS(phi), virus.r * SIN(theta) * SIN(phi), virus.r * COS(theta)
  82.             _glVertex3f (0.1 + virus.r) * SIN(theta) * COS(phi), (0.1 + virus.r) * SIN(theta) * SIN(phi), (0.1 + virus.r) * COS(theta)
  83.         NEXT
  84.     NEXT
  85.  
  86.     _glEnd
  87.     _glBegin _GL_POINTS
  88.     FOR theta = a TO _PI STEP a
  89.         aa = rr / ((0.1 + virus.r) * SIN(theta))
  90.         FOR phi = aa TO _PI(2) STEP aa
  91.             _glVertex3f (0.1 + virus.r) * SIN(theta) * COS(phi), (0.1 + virus.r) * SIN(theta) * SIN(phi), (0.1 + virus.r) * COS(theta)
  92.         NEXT
  93.     NEXT
  94.     _glEnd
  95.     _glEnable _GL_LIGHTING
  96.  
  97.  
  98.  
  99.  
  100. FUNCTION glVec4%& (x, y, z, w) 'give the offset of the given vector
  101.     STATIC internal_vec4(3)
  102.     internal_vec4(0) = x
  103.     internal_vec4(1) = y
  104.     internal_vec4(2) = z
  105.     internal_vec4(3) = w
  106.     glVec4%& = _OFFSET(internal_vec4())
  107.  

Why did you evolve the virus?
Title: Re: COVID-19 in QB64
Post by: TempodiBasic on June 01, 2020, 07:54:32 pm
Hy Guys

@  Ashish Cool your coronavirus' motion

@ Vince Yes the surface now is more regular... it is a mutant kind of coronavirus

I'm following Ashish tutorial on Opengl, but slowly!
So I decide to try a tip to get a second littler coronavirus together with the first showed by Ashish's code....
and for error of my presupponitions I get this MAD coronavirus
Code: QB64: [Select]
  1. 'COVID-19 in QB64
  2. 'By Ashish
  3. '1 Jun, 2020
  4. '
  5. 'WARNING:Use mask. Apply santizer after closing the program.
  6.  
  7. _TITLE "I'm Covid-19"
  8. SCREEN _NEWIMAGE(600, 600, 32)
  9.  
  10.     SUB glutSolidSphere (BYVAL radius AS DOUBLE, BYVAL slices AS LONG, BYVAL stack AS LONG)
  11.     SUB gluLookAt (BYVAL eyeX#, BYVAL eyeY#, BYVAL eyeZ#, BYVAL centerX#, BYVAL centerY#, BYVAL centerZ#, BYVAL upX#, BYVAL upY#, BYVAL upZ#)
  12.  
  13.  
  14. DIM SHARED glAllow AS _BYTE
  15. TYPE vec3
  16.     x AS SINGLE
  17.     y AS SINGLE
  18.     z AS SINGLE
  19.  
  20. TYPE COVID19
  21.     POS AS vec3
  22.     r AS SINGLE
  23.  
  24. DIM SHARED virus AS COVID19, viru AS COVID19
  25.  
  26. viru.r = 0.10
  27. viru.POS.x = .3
  28. viru.POS.y = .3
  29. viru.POS.z = .3
  30.  
  31. virus.r = 0.3
  32.  
  33. glAllow = -1
  34.     _LIMIT 1
  35.  
  36. SUB _GL ()
  37.     STATIC init, aspect, rotY
  38.  
  39.     IF glAllow = 0 THEN EXIT SUB
  40.     IF init = 0 THEN
  41.         init = 1
  42.         aspect = _WIDTH / _HEIGHT
  43.         _glViewport 0, 0, _WIDTH, _HEIGHT
  44.     END IF
  45.  
  46.     _glEnable _GL_DEPTH_TEST
  47.     _glEnable _GL_LIGHTING
  48.     _glEnable _GL_LIGHT0
  49.  
  50.     _glLightfv _GL_LIGHT0, _GL_AMBIENT, glVec4(0.0, 0.0, 0.0, 1)
  51.     _glLightfv _GL_LIGHT0, _GL_DIFFUSE, glVec4(0.8, 0.8, 0.8, 1)
  52.     _glLightfv _GL_LIGHT0, _GL_SPECULAR, glVec4(1, 1, 1, 1)
  53.     _glLightfv _GL_LIGHT0, _GL_POSITION, glVec4(0, 0, 10, 1)
  54.  
  55.  
  56.  
  57.     _glMatrixMode _GL_PROJECTION
  58.     _gluPerspective 50, aspect, 0.1, 10
  59.  
  60.     _glMatrixMode _GL_MODELVIEW
  61.     gluLookAt 0, 0, 2, 0, 0, 0, 0, 1, 0
  62.  
  63.  
  64.     _glLineWidth 2.0
  65.     _glPointSize 10.0
  66.  
  67.     _glTranslatef virus.POS.x, virus.POS.y, virus.POS.z
  68.     _glRotatef rotY, 0.5, 1, 0
  69.     rotY = rotY + 1
  70.  
  71.     _glTranslatef viru.POS.x, viru.POS.y, viru.POS.z
  72.     _glRotatef rotY, 0.5, 1, 0
  73.     rotY = rotY + 1
  74.  
  75.     _glMaterialfv _GL_FRONT_AND_BACK, _GL_DIFFUSE, glVec4(0, 0.9, 0, 1)
  76.  
  77.     glutSolidSphere virus.r, 20, 20
  78.     glutSolidSphere viru.r, 20, 20
  79.  
  80.     _glDisable _GL_LIGHTING
  81.     _glColor3f 1, 0, 0
  82.     _glBegin _GL_LINES
  83.     FOR phi = 0.4 TO _PI(2) STEP .5
  84.         FOR theta = 0.3 TO _PI STEP .5
  85.             _glVertex3f virus.r * SIN(theta) * COS(phi), virus.r * SIN(theta) * SIN(phi), virus.r * COS(theta)
  86.             _glVertex3f (0.1 + virus.r) * SIN(theta) * COS(phi), (0.1 + virus.r) * SIN(theta) * SIN(phi), (0.1 + virus.r) * COS(theta)
  87.  
  88.             _glVertex3f viru.r * SIN(theta) * COS(phi), viru.r * SIN(theta) * SIN(phi), viru.r * COS(theta)
  89.             _glVertex3f (0.1 + viru.r) * SIN(theta) * COS(phi), (0.1 + viru.r) * SIN(theta) * SIN(phi), (0.1 + viru.r) * COS(theta)
  90.  
  91.         NEXT
  92.     NEXT
  93.     _glEnd
  94.     _glBegin _GL_POINTS
  95.     FOR phi = 0.4 TO _PI(2) STEP .5
  96.         FOR theta = 0.3 TO _PI STEP .5
  97.             _glVertex3f (0.1 + virus.r) * SIN(theta) * COS(phi), (0.1 + virus.r) * SIN(theta) * SIN(phi), (0.1 + virus.r) * COS(theta)
  98.  
  99.             _glVertex3f (0.1 + viru.r) * SIN(theta) * COS(phi), (0.1 + viru.r) * SIN(theta) * SIN(phi), (0.1 + viru.r) * COS(theta)
  100.         NEXT
  101.     NEXT
  102.     _glEnd
  103.     _glEnable _GL_LIGHTING
  104.  
  105.  
  106.  
  107.  
  108. FUNCTION glVec4%& (x, y, z, w) 'give the offset of the given vector
  109.     STATIC internal_vec4(3)
  110.     internal_vec4(0) = x
  111.     internal_vec4(1) = y
  112.     internal_vec4(2) = z
  113.     internal_vec4(3) = w
  114.     glVec4%& = _OFFSET(internal_vec4())
  115.  
  116.  

Thanks to look at
Title: Re: COVID-19 in QB64
Post by: Ashish on June 02, 2020, 01:35:43 am
@vince Thanks. You made the spikes to look more uniformly distributed.

@Dimster IDK. I think human will evolve from this. Not all are dying from this idiot virus. OR I think, the one who will be genetically fittest would survive this. I know little about biology, so my opinion may be wrong. :)
Title: Re: COVID-19 in QB64
Post by: Ashish on June 02, 2020, 02:10:29 am
@TempodiBasic
Very nice try... Look like virus has become very angry. Ok, jokes apart.

You will soon learn all 3D in OpenGL. Its not that too hard.

Okay, so lets talk about your modification to the code.

1. You created another variable of the type COVID19 and initialize its property. Like (r, pos.x, etc). This is fine.

2. The real issue is in SUB _GL() : But why?
You know, I'm using a command _glTranslatef. But what this do? Well... The value you pass it to is added to the current origin.
In OpenGL, the initial origin is center of the screen. That is the reference point. In coordinates, you can say origin is (0,0,0).
Now, if you call _glTranslatef 0.5,0.5,0. Origin will become  (0+0.5,0+0.5,0) or (0.5,0.5,0).
If you again call _glTranslatef -0.5,0.5,0. Origin will become  (0.5+(-0.5),0.5+0.5,0+0) or (0,1,0).

You have clearly noticed that in second calling, the positions were not added in (0,0,0) but in (0.5,0.5,0). This is because
(0.5,0.5,0) was our current origin before calling _glTranslatef for second time. As you can see, I already said this above.

And in your code you are doing the same thing. The virus is being drawn, but it inside the my virus, because its radius is small.

In order to render 2 viruses, you need to do this -

(i) translate the origin to my virus position by _glTranslatef

(ii) Do all the drawing stuff

(iii) Return to the our original origin (0,0,0). You can return to the original origin by again calling _glTranslatef with negative sign on the position of my virus. This will make the values to cancel out and the origin is again (0,0,0)

(iv)Now, translate the origin to your virus as you did in your code with _glTranslatef

(v)Do all the drawing stuff for your virus, as you did in your code.

And this must work.
As an exercise, I'm waiting for your new code with above modification.



OMG: This is the longest post I've ever written.  :D

PS: About the weird movement of your virus. That's because, since the origin in your code neither matches virus nor viru, the rotation is done from other origin.
Title: Re: COVID-19 in QB64
Post by: TempodiBasic on June 02, 2020, 04:10:43 am
Hi Ashish, thanks for time and energy to pass  me useful informations to do better code in OpenGl!

Last time I have imagined a my way to let see the 2 viruses but the code was uncomplete and I'm tired so I went to bed to get some rest.
Today morning I find your complete answer, but I see also that to complete my way I need to write just a color statement so for now I post this code.  Then I'll try to get the result in a more elegant way following your right suggestions.

COVID19 and its son
Code: QB64: [Select]
  1. 'COVID-19 in QB64
  2. 'By Ashish
  3. '1 Jun, 2020
  4. '
  5. 'WARNING:Use mask. Apply santizer after closing the program.
  6. ' 2 Jun, 2020    added a little son of COVID-19  TDB
  7.  
  8. _TITLE "I'm Covid-19 with my little son"
  9. SCREEN _NEWIMAGE(600, 600, 32)
  10.  
  11.     SUB glutSolidSphere (BYVAL radius AS DOUBLE, BYVAL slices AS LONG, BYVAL stack AS LONG)
  12.     SUB gluLookAt (BYVAL eyeX#, BYVAL eyeY#, BYVAL eyeZ#, BYVAL centerX#, BYVAL centerY#, BYVAL centerZ#, BYVAL upX#, BYVAL upY#, BYVAL upZ#)
  13.  
  14.  
  15. DIM SHARED glAllow AS _BYTE
  16. TYPE vec3
  17.     x AS SINGLE
  18.     y AS SINGLE
  19.     z AS SINGLE
  20.  
  21. TYPE COVID19
  22.     POS AS vec3
  23.     r AS SINGLE
  24.  
  25. DIM SHARED virus AS COVID19, viru AS COVID19
  26.  
  27. viru.r = 0.10
  28. viru.POS.x = .5
  29. viru.POS.y = .5
  30. viru.POS.z = .5
  31.  
  32. virus.r = 0.3
  33.  
  34. glAllow = -1
  35.     _LIMIT 1
  36.  
  37. SUB _GL ()
  38.     STATIC init, aspect, rotY
  39.  
  40.     IF glAllow = 0 THEN EXIT SUB
  41.     IF init = 0 THEN
  42.         init = 1
  43.         aspect = _WIDTH / _HEIGHT
  44.         _glViewport 0, 0, _WIDTH, _HEIGHT
  45.     END IF
  46.  
  47.     _glEnable _GL_DEPTH_TEST
  48.     _glEnable _GL_LIGHTING
  49.     _glEnable _GL_LIGHT0
  50.  
  51.     _glLightfv _GL_LIGHT0, _GL_AMBIENT, glVec4(0.0, 0.0, 0.0, 1)
  52.     _glLightfv _GL_LIGHT0, _GL_DIFFUSE, glVec4(0.8, 0.8, 0.8, 1)
  53.     _glLightfv _GL_LIGHT0, _GL_SPECULAR, glVec4(1, 1, 1, 1)
  54.     _glLightfv _GL_LIGHT0, _GL_POSITION, glVec4(0, 0, 10, 1)
  55.  
  56.  
  57.  
  58.     _glMatrixMode _GL_PROJECTION
  59.     _gluPerspective 50, aspect, 0.1, 10
  60.  
  61.     _glMatrixMode _GL_MODELVIEW
  62.     gluLookAt 0, 0, 2, 0, 0, 0, 0, 1, 0
  63.  
  64.  
  65.     _glLineWidth 2.0
  66.     _glPointSize 10.0
  67.  
  68.     _glTranslatef virus.POS.x, virus.POS.y, virus.POS.z
  69.     _glRotatef rotY, 0.5, 1, 0
  70.     rotY = rotY + 1
  71.  
  72.  
  73.     _glMaterialfv _GL_FRONT_AND_BACK, _GL_DIFFUSE, glVec4(0, 0.9, 0, 1)
  74.  
  75.     glutSolidSphere virus.r, 20, 20
  76.  
  77.     _glDisable _GL_LIGHTING
  78.     _glColor3f 1, 0, 0
  79.     _glBegin _GL_LINES
  80.     FOR phi = 0.4 TO _PI(2) STEP .5
  81.         FOR theta = 0.3 TO _PI STEP .5
  82.             _glVertex3f virus.r * SIN(theta) * COS(phi), virus.r * SIN(theta) * SIN(phi), virus.r * COS(theta)
  83.             _glVertex3f (0.1 + virus.r) * SIN(theta) * COS(phi), (0.1 + virus.r) * SIN(theta) * SIN(phi), (0.1 + virus.r) * COS(theta)
  84.         NEXT
  85.     NEXT
  86.     _glEnd
  87.     _glBegin _GL_POINTS
  88.     FOR phi = 0.4 TO _PI(2) STEP .5
  89.         FOR theta = 0.3 TO _PI STEP .5
  90.             _glVertex3f (0.1 + virus.r) * SIN(theta) * COS(phi), (0.1 + virus.r) * SIN(theta) * SIN(phi), (0.1 + virus.r) * COS(theta)
  91.         NEXT
  92.     NEXT
  93.     _glEnd
  94.  
  95.     '----
  96.  
  97.  
  98.     _glTranslatef viru.POS.x, viru.POS.y, viru.POS.z
  99.     _glRotatef rotY, 0.5, 1, 0
  100.     rotY = rotY + 1
  101.     _glColor3f 0, 1, 0
  102.     _glMaterialfv _GL_FRONT_AND_BACK, _GL_DIFFUSE, glVec4(0, 0.9, 0, 1)
  103.  
  104.  
  105.     glutSolidSphere viru.r, 10, 10
  106.  
  107.  
  108.     _glDisable _GL_LIGHTING
  109.     _glColor3f 1, 0, 0
  110.     _glBegin _GL_LINES
  111.     FOR phi = 0.4 TO _PI(2) STEP .5
  112.         FOR theta = 0.3 TO _PI STEP .5
  113.             _glVertex3f viru.r * SIN(theta) * COS(phi), viru.r * SIN(theta) * SIN(phi), viru.r * COS(theta)
  114.             _glVertex3f (0.1 + viru.r) * SIN(theta) * COS(phi), (0.1 + viru.r) * SIN(theta) * SIN(phi), (0.1 + viru.r) * COS(theta)
  115.         NEXT
  116.     NEXT
  117.     _glEnd
  118.  
  119.     _glBegin _GL_POINTS
  120.     FOR phi = 0.4 TO _PI(2) STEP .5
  121.         FOR theta = 0.3 TO _PI STEP .5
  122.             _glVertex3f (0.1 + viru.r) * SIN(theta) * COS(phi), (0.1 + viru.r) * SIN(theta) * SIN(phi), (0.1 + viru.r) * COS(theta)
  123.         NEXT
  124.     NEXT
  125.     _glEnd
  126.     _glEnable _GL_LIGHTING
  127.  
  128.  
  129. FUNCTION glVec4%& (x, y, z, w) 'give the offset of the given vector
  130.     STATIC internal_vec4(3)
  131.     internal_vec4(0) = x
  132.     internal_vec4(1) = y
  133.     internal_vec4(2) = z
  134.     internal_vec4(3) = w
  135.     glVec4%& = _OFFSET(internal_vec4())
  136.  

  [ This attachment cannot be displayed inline in 'Print Page' view ]  
PS
https://ashishkingdom.github.io/OpenGL-Tutorials/ (https://ashishkingdom.github.io/OpenGL-Tutorials/)
I find great this tutorial! But for me some lessons are too plenty of informations that I must take more time to go on.
For now I'm at Texture chapter and I'll coping with the Mask part.
Title: Re: COVID-19 in QB64
Post by: qbkiller101 on June 02, 2020, 04:26:41 am
This is what you get if you randomly enter your nose into numbers you shouldn't enter your nose in variables you shouldn't enter your nose in noses which enter their nose in noses which enter noses in noses
Code: QB64: [Select]
  1. 'COVID-19 in QB64
  2. 'By Ashish
  3. '1 Jun, 2020
  4. '
  5. 'WARNING:Use mask. Apply santizer after closing the program.
  6. ' 2 Jun, 2020    added a little son of COVID-19  TDB
  7.  
  8. _TITLE "I'm Covid-19 with my little son"
  9. SCREEN _NEWIMAGE(550, 600, 32)
  10.  
  11.     SUB glutSolidSphere (BYVAL radius AS DOUBLE, BYVAL slices AS LONG, BYVAL stack AS LONG)
  12.     SUB gluLookAt (BYVAL eyeX#, BYVAL eyeY#, BYVAL eyeZ#, BYVAL centerX#, BYVAL centerY#, BYVAL centerZ#, BYVAL upX#, BYVAL upY#, BYVAL upZ#)
  13.  
  14.  
  15. DIM SHARED glAllow AS _BYTE
  16. TYPE vec3
  17.     x AS SINGLE
  18.     y AS SINGLE
  19.     z AS SINGLE
  20.  
  21. TYPE COVID19
  22.     POS AS vec3
  23.     r AS SINGLE
  24.  
  25. DIM SHARED virus AS COVID19, viru AS COVID19
  26.  
  27. viru.r = 0.5
  28. viru.POS.x = .75
  29. viru.POS.y = .75
  30. viru.POS.z = .75
  31.  
  32. virus.r = 0.5
  33.  
  34. glAllow = -1
  35.     _LIMIT 50
  36.  
  37. SUB _GL ()
  38.     STATIC init, aspect, rotY
  39.  
  40.     IF glAllow = 0 THEN EXIT SUB
  41.     IF init = 0 THEN
  42.         init = 2
  43.         aspect = _WIDTH / _HEIGHT + 1
  44.         _glViewport 0, 0, _WIDTH, _HEIGHT
  45.     END IF
  46.  
  47.     _glEnable _GL_DEPTH_TEST
  48.     _glEnable _GL_LIGHTING
  49.     _glEnable _GL_LIGHT0
  50.  
  51.     _glLightfv _GL_LIGHT0, _GL_AMBIENT, glVec4(0.0, 0.0, 0.0, 1)
  52.     _glLightfv _GL_LIGHT0, _GL_DIFFUSE, glVec4(0.8, 0.8, 0.8, 1)
  53.     _glLightfv _GL_LIGHT0, _GL_SPECULAR, glVec4(1, 10, 1, 1)
  54.     _glLightfv _GL_LIGHT0, _GL_POSITION, glVec4(0, 0, 5, 1)
  55.  
  56.  
  57.  
  58.     _glMatrixMode _GL_PROJECTION
  59.     _gluPerspective 50, aspect, 0.1, 10
  60.  
  61.     _glMatrixMode _GL_MODELVIEW
  62.     gluLookAt 0, 0, 2, 0, 0, 0, 0, 1, 0
  63.  
  64.  
  65.     _glLineWidth 3.0
  66.     _glPointSize 10.0
  67.  
  68.     _glTranslatef virus.POS.x, virus.POS.y, virus.POS.z
  69.     _glRotatef rotY, 1, 1, 0
  70.     rotY = rotY + 1
  71.  
  72.  
  73.     _glMaterialfv _GL_FRONT_AND_BACK, _GL_DIFFUSE, glVec4(0, 1.9, 0, 1)
  74.  
  75.     glutSolidSphere virus.r, 20, 20
  76.  
  77.     _glDisable _GL_LIGHTING
  78.     _glColor3f 1, 0, 0
  79.     _glBegin _GL_LINES
  80.     FOR phi = 0.4 TO _PI(2) STEP .5
  81.         FOR theta = 0.3 TO _PI STEP 5
  82.             _glVertex3f virus.r * SIN(theta) * COS(phi), virus.r * SIN(theta) * SIN(phi), virus.r * COS(theta)
  83.             _glVertex3f (0.1 + virus.r) * SIN(theta) * COS(phi), (0.1 + virus.r) * SIN(theta) * SIN(phi), (0.1 + virus.r) * COS(theta)
  84.         NEXT
  85.     NEXT
  86.     _glEnd
  87.     _glBegin _GL_POINTS
  88.     FOR phi = 0.4 TO _PI(2) STEP 1
  89.         FOR theta = 0.3 TO _PI STEP .5
  90.             _glVertex3f (0.1 + virus.r) * SIN(theta) * COS(phi), (0.1 + virus.r) * SIN(theta) * SIN(phi), (0.1 + virus.r) * COS(theta)
  91.         NEXT
  92.     NEXT
  93.     _glEnd
  94.  
  95.     '----
  96.  
  97.  
  98.     _glTranslatef viru.POS.x, viru.POS.y, viru.POS.z
  99.     _glRotatef rotY, 0.5, 2, 0
  100.     rotY = rotY + 1
  101.     _glColor3f 0, 1, 0
  102.     _glMaterialfv _GL_FRONT_AND_BACK, _GL_DIFFUSE, glVec4(0, 0.9, 0, 1)
  103.  
  104.  
  105.     glutSolidSphere viru.r, 10, 10
  106.  
  107.  
  108.     _glDisable _GL_LIGHTING
  109.     _glColor3f 1, 0, 5
  110.     _glBegin _GL_LINES
  111.     FOR phi = 0.4 TO _PI(2) STEP .5
  112.         FOR theta = 0.3 TO _PI STEP .5
  113.             _glVertex3f viru.r * SIN(theta) * COS(phi), viru.r * SIN(theta) * SIN(phi), viru.r * COS(theta)
  114.             _glVertex3f (0.1 + viru.r) * SIN(theta) * COS(phi), (0.1 + viru.r) * SIN(theta) * SIN(phi), (0.1 + viru.r) * COS(theta)
  115.         NEXT
  116.     NEXT
  117.     _glEnd
  118.  
  119.     _glBegin _GL_POINTS
  120.     FOR phi = 0.4 TO _PI(2) STEP .5
  121.         FOR theta = 0.3 TO _PI STEP .5
  122.             _glVertex3f (0.1 + viru.r) * SIN(theta) * COS(phi), (0.1 + viru.r) * SIN(theta) * SIN(phi), (0.1 + viru.r) * COS(theta)
  123.         NEXT
  124.     NEXT
  125.     _glEnd
  126.     _glEnable _GL_LIGHTING
  127.  
  128.  
  129. FUNCTION glVec4%& (x, y, z, w) 'give the offset of the given vector
  130.     STATIC internal_vec4(3)
  131.     internal_vec4(0) = x
  132.     internal_vec4(1) = y
  133.     internal_vec4(2) = z
  134.     internal_vec4(3) = w
  135.     glVec4%& = _OFFSET(internal_vec4())
  136.  
  137.  
basically i randomly picked numbers then changed them
Title: Re: COVID-19 in QB64
Post by: Ashish on June 02, 2020, 05:47:31 am
@TempodiBasic Cool! A very nice start. Oh, before drawing your virus, you forgot to turn on lights effect.
Insert this
Code: QB64: [Select]
  1. _glEnable _GL_LIGHTING
before drawing your sphere. This will turn on lighting effects. :)

Oh, I see, you have completed colors section of OpenGL. You know, the glVec4() I'm using before drawing sphere and its spike is
actually defining its color. ;)) Feel free to modify the color of the son of the virus. :P

@qbkiller101 bruh, man you have changed the aspect. Also, you are passing color value which is greater than 1 using glVec4()
Playing hard with numbers.
Do you really want to play with numbers.... I have a puzzle for you then
Create a 10 digit number so that the first digit is the number of zeros in the number, the second digit is the number of ones in the number, the third digit is the number of twos, etc.
Title: Re: COVID-19 in QB64
Post by: TempodiBasic on June 02, 2020, 09:49:11 am
Hi Ashish,
yes going on with practice I can learn more about _GLcommands
thanks for feedback but please take a look to this new example in which I try to modularize the SUB _GL()

Code: QB64: [Select]
  1. 'COVID-19 in QB64
  2. 'By Ashish
  3. '1 Jun, 2020
  4. '
  5. 'WARNING:Use mask. Apply santizer after closing the program.
  6. ' 2 Jun, 2020    added a little son of COVID-19  TDB
  7. ' 2 Jun, 2020    modularizing  the _GL actions   TDB
  8. _TITLE "I'm Covid-19 with my little son"
  9.  
  10. SCREEN _NEWIMAGE(600, 600, 32)
  11.  
  12.     SUB glutSolidSphere (BYVAL radius AS DOUBLE, BYVAL slices AS LONG, BYVAL stack AS LONG)
  13.     SUB gluLookAt (BYVAL eyeX#, BYVAL eyeY#, BYVAL eyeZ#, BYVAL centerX#, BYVAL centerY#, BYVAL centerZ#, BYVAL upX#, BYVAL upY#, BYVAL upZ#)
  14.  
  15. DIM SHARED glAllow AS _BYTE
  16. TYPE vec3
  17.     x AS SINGLE
  18.     y AS SINGLE
  19.     z AS SINGLE
  20.  
  21. TYPE COVID19
  22.     POS AS vec3
  23.     r AS SINGLE
  24.     rotY AS SINGLE
  25.     rotX AS SINGLE
  26.     Vxz AS SINGLE
  27.     Vyz AS SINGLE
  28.  
  29. DIM SHARED virus AS COVID19, viru AS COVID19
  30.  
  31. Initialize
  32.     _LIMIT 1
  33. END ' a logical end to the flow
  34.  
  35. '------------ SUBs and FUNCTIONs----------------------------
  36. SUB Initialize
  37.     viru.r = 0.10
  38.     viru.POS.x = .5
  39.     viru.POS.y = .5
  40.     viru.POS.z = .5
  41.     viru.Vxz = 10
  42.     viru.Vyz = 10
  43.  
  44.     virus.r = 0.3
  45.     virus.POS.y = 0
  46.     virus.POS.x = 0
  47.     virus.POS.z = 0
  48.     virus.Vxz = 20
  49.     virus.Vyz = 20
  50.  
  51.     glAllow = -1
  52.  
  53.  
  54. SUB InitGL (in, aspe)
  55.     IF in = 0 THEN
  56.         in = 1
  57.         aspe = _WIDTH / _HEIGHT
  58.         _glViewport 0, 0, _WIDTH, _HEIGHT
  59.     END IF
  60.  
  61. SUB DrawLines (viru AS COVID19)
  62.     _glColor3f 1, 0, 0
  63.     _glBegin _GL_LINES
  64.     FOR phi = 0.4 TO _PI(2) STEP .5
  65.         FOR theta = 0.3 TO _PI STEP .5
  66.             _glVertex3f viru.r * SIN(theta) * COS(phi), viru.r * SIN(theta) * SIN(phi), viru.r * COS(theta)
  67.             _glVertex3f (0.1 + viru.r) * SIN(theta) * COS(phi), (0.1 + viru.r) * SIN(theta) * SIN(phi), (0.1 + viru.r) * COS(theta)
  68.         NEXT
  69.     NEXT
  70.     _glEnd
  71.  
  72.  
  73. SUB DrawPoints (viru AS COVID19)
  74.     _glBegin _GL_POINTS
  75.     FOR phi = 0.4 TO _PI(2) STEP .5
  76.         FOR theta = 0.3 TO _PI STEP .5
  77.             _glVertex3f (0.1 + viru.r) * SIN(theta) * COS(phi), (0.1 + viru.r) * SIN(theta) * SIN(phi), (0.1 + viru.r) * COS(theta)
  78.         NEXT
  79.     NEXT
  80.     _glEnd
  81.  
  82. SUB DrawVirus (v AS COVID19)
  83.     ' setting  position and rotation
  84.     _glTranslatef v.POS.x, v.POS.y, v.POS.z
  85.     _glRotatef v.rotY, 0.5, 1, 0
  86.     v.rotY = v.rotY + 1
  87.     _glColor3f 0, 1, 0
  88.     _glMaterialfv _GL_FRONT_AND_BACK, _GL_DIFFUSE, glVec4(0, 0.9, 0, 1)
  89.  
  90.     ' make the sphere
  91.     glutSolidSphere v.r, v.Vxz, v.Vyz
  92.  
  93.     _glDisable _GL_LIGHTING
  94.     ' make lines
  95.     DrawLines v
  96.     ' make points
  97.     DrawPoints v
  98.     _glEnable _GL_LIGHTING
  99.  
  100. SUB _GL ()
  101.     STATIC init, aspect, rotY
  102.  
  103.     IF glAllow = 0 THEN EXIT SUB
  104.  
  105.     InitGL init, aspect
  106.  
  107.     _glEnable _GL_DEPTH_TEST
  108.     _glEnable _GL_LIGHTING
  109.     _glEnable _GL_LIGHT0
  110.  
  111.     _glLightfv _GL_LIGHT0, _GL_AMBIENT, glVec4(0.0, 0.0, 0.0, 1)
  112.     _glLightfv _GL_LIGHT0, _GL_DIFFUSE, glVec4(0.8, 0.8, 0.8, 1)
  113.     _glLightfv _GL_LIGHT0, _GL_SPECULAR, glVec4(1, 1, 1, 1)
  114.     _glLightfv _GL_LIGHT0, _GL_POSITION, glVec4(0, 0, 10, 1)
  115.  
  116.  
  117.  
  118.     _glMatrixMode _GL_PROJECTION
  119.     _gluPerspective 50, aspect, 0.1, 10
  120.  
  121.     _glMatrixMode _GL_MODELVIEW
  122.     gluLookAt 0, 0, 2, 0, 0, 0, 0, 1, 0
  123.  
  124.  
  125.     _glLineWidth 2.0
  126.     _glPointSize 10.0
  127.  
  128.     DrawVirus virus
  129.     DrawVirus viru
  130.  
  131.  
  132. FUNCTION glVec4%& (x, y, z, w) 'give the offset of the given vector
  133.     STATIC internal_vec4(3)
  134.     internal_vec4(0) = x
  135.     internal_vec4(1) = y
  136.     internal_vec4(2) = z
  137.     internal_vec4(3) = w
  138.     glVec4%& = _OFFSET(internal_vec4())
  139.  

the next step is an array of virus COVID19  :-)
each with its color ;)
Title: Re: COVID-19 in QB64
Post by: TempodiBasic on June 02, 2020, 09:56:48 am
@qbkiller101 
fine evolution of the theme, but its title must be changed into "COVID19 fights COVID20" because it seems that 2 different viruses are competing for the same place!
Title: Re: COVID-19 in QB64
Post by: qbkiller101 on June 02, 2020, 10:02:32 am
It's not meant to be anything and btw I don't know 3d graphics at all
I just randomly messed with nubers :\
Title: Re: COVID-19 in QB64
Post by: TempodiBasic on June 02, 2020, 10:57:54 am
Hi guys

see here :-) the task is performed! Here is a family of viruses...LOL thanks to Ashish to start this thread and the tips!

Code: QB64: [Select]
  1. 'COVID-19 in QB64
  2. 'By Ashish
  3. '1 Jun, 2020
  4. '
  5. 'WARNING:Use mask. Apply santizer after closing the program.
  6. ' 2 Jun, 2020    added a little son of COVID-19  TDB
  7. ' 2 Jun, 2020    modularizing  the _GL actions   TDB
  8. '2 Jun, 2020     an array of virus and a continuous restarting by Enter and quit by Space TDB
  9. _TITLE "We are all Covid-19 :-)"
  10.  
  11. SCREEN _NEWIMAGE(600, 600, 32)
  12.  
  13.     SUB glutSolidSphere (BYVAL radius AS DOUBLE, BYVAL slices AS LONG, BYVAL stack AS LONG)
  14.     SUB gluLookAt (BYVAL eyeX#, BYVAL eyeY#, BYVAL eyeZ#, BYVAL centerX#, BYVAL centerY#, BYVAL centerZ#, BYVAL upX#, BYVAL upY#, BYVAL upZ#)
  15.  
  16. DIM SHARED glAllow AS _BYTE
  17. TYPE vec3
  18.     x AS SINGLE
  19.     y AS SINGLE
  20.     z AS SINGLE
  21. TYPE colorRGBA
  22.     R AS SINGLE
  23.     G AS SINGLE
  24.     B AS SINGLE
  25.     A AS SINGLE
  26.  
  27. TYPE COVID19
  28.     POS AS vec3
  29.     r AS SINGLE
  30.     rotY AS SINGLE
  31.     rotX AS SINGLE
  32.     Vxz AS SINGLE
  33.     Vyz AS SINGLE
  34.     C AS colorRGBA
  35.  
  36. DIM SHARED virus(1 TO 10) AS COVID19
  37. Initialize
  38.     k = _KEYHIT
  39.     LOCATE 1, 1: PRINT "Space to quit, Enter to change viruses"
  40.     _LIMIT 1
  41.     IF k = 13 THEN Initialize
  42. LOOP UNTIL k = 32
  43. END ' a logical end to the flow
  44.  
  45. '------------ SUBs and FUNCTIONs----------------------------
  46. SUB Initialize
  47.     FOR z = 1 TO 10 STEP 1
  48.         virus(z).r = 0.1 + (RND / 5)
  49.         virus(z).POS.y = 1 - (RND * 2)
  50.         virus(z).POS.x = 1 - (RND * 2)
  51.         virus(z).POS.z = 0
  52.         virus(z).Vxz = 20 - (RND * 10)
  53.         virus(z).Vyz = 20 - (RND * 10)
  54.         virus(z).C.R = 1 - (RND * 1)
  55.         virus(z).C.G = 1 - (RND * 1)
  56.         virus(z).C.B = 1 - (RND * 1)
  57.         virus(z).C.A = 1 - (RND * 1)
  58.     NEXT z
  59.     glAllow = -1
  60.  
  61.  
  62. SUB InitGL (in, aspe)
  63.     IF in = 0 THEN
  64.         in = 1
  65.         aspe = _WIDTH / _HEIGHT
  66.         _glViewport 0, 0, _WIDTH, _HEIGHT
  67.     END IF
  68.  
  69. SUB DrawLines (viru AS COVID19)
  70.     _glColor3f 1, 0, 0
  71.     _glBegin _GL_LINES
  72.     FOR phi = 0.4 TO _PI(2) STEP .5
  73.         FOR theta = 0.3 TO _PI STEP .5
  74.             _glVertex3f viru.r * SIN(theta) * COS(phi), viru.r * SIN(theta) * SIN(phi), viru.r * COS(theta)
  75.             _glVertex3f (0.1 + viru.r) * SIN(theta) * COS(phi), (0.1 + viru.r) * SIN(theta) * SIN(phi), (0.1 + viru.r) * COS(theta)
  76.         NEXT
  77.     NEXT
  78.     _glEnd
  79.  
  80.  
  81. SUB DrawPoints (viru AS COVID19)
  82.     _glBegin _GL_POINTS
  83.     FOR phi = 0.4 TO _PI(2) STEP .5
  84.         FOR theta = 0.3 TO _PI STEP .5
  85.             _glVertex3f (0.1 + viru.r) * SIN(theta) * COS(phi), (0.1 + viru.r) * SIN(theta) * SIN(phi), (0.1 + viru.r) * COS(theta)
  86.         NEXT
  87.     NEXT
  88.     _glEnd
  89.  
  90. SUB DrawVirus (v AS COVID19)
  91.     ' setting  position and rotation
  92.     _glTranslatef v.POS.x, v.POS.y, v.POS.z
  93.     _glRotatef v.rotY, 0.5, 1, 0
  94.     v.rotY = v.rotY + 1
  95.  
  96.     _glEnable _GL_LIGHTING ' thanks to Ashish
  97.     _glMaterialfv _GL_FRONT_AND_BACK, _GL_DIFFUSE, glVec4(v.C.R, v.C.G, v.C.B, v.C.A)
  98.  
  99.     ' make the sphere
  100.     glutSolidSphere v.r, v.Vxz, v.Vyz
  101.  
  102.     _glDisable _GL_LIGHTING
  103.     ' make lines
  104.     DrawLines v
  105.     ' make points
  106.     DrawPoints v
  107.     _glEnable _GL_LIGHTING
  108.  
  109. SUB _GL ()
  110.     STATIC init, aspect
  111.  
  112.     IF glAllow = 0 THEN EXIT SUB
  113.  
  114.     InitGL init, aspect
  115.  
  116.     _glEnable _GL_DEPTH_TEST
  117.     _glEnable _GL_LIGHTING
  118.     _glEnable _GL_LIGHT0
  119.  
  120.     _glLightfv _GL_LIGHT0, _GL_AMBIENT, glVec4(0.0, 0.0, 0.0, 1)
  121.     _glLightfv _GL_LIGHT0, _GL_DIFFUSE, glVec4(0.8, 0.8, 0.8, 1)
  122.     _glLightfv _GL_LIGHT0, _GL_SPECULAR, glVec4(1, 1, 1, 1)
  123.     _glLightfv _GL_LIGHT0, _GL_POSITION, glVec4(0, 0, 10, 1)
  124.  
  125.  
  126.  
  127.     _glMatrixMode _GL_PROJECTION
  128.     _gluPerspective 50, aspect, 0.1, 10
  129.  
  130.     _glMatrixMode _GL_MODELVIEW
  131.     gluLookAt 0, 0, 2, 0, 0, 0, 0, 1, 0
  132.  
  133.  
  134.     _glLineWidth 2.0
  135.     _glPointSize 10.0
  136.     FOR z = 1 TO 10 STEP 1
  137.         DrawVirus virus(z)
  138.     NEXT z
  139.  
  140.  
  141. FUNCTION glVec4%& (x, y, z, w) 'give the offset of the given vector
  142.     STATIC internal_vec4(3)
  143.     internal_vec4(0) = x
  144.     internal_vec4(1) = y
  145.     internal_vec4(2) = z
  146.     internal_vec4(3) = w
  147.     glVec4%& = _OFFSET(internal_vec4())
  148.  

here a screenshot   [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: COVID-19 in QB64
Post by: TempodiBasic on June 02, 2020, 11:17:54 am
@qbkiller101
hey man

your good luck with numbers, also when you have messed them, is clear!
Have you tried at casinò in Las Vegas?
 The nature  makes mutations by messing our inner data! Those mutations sometime  are bad (see genetic illness) some time they are good (see Xmen)!


@vince
I find very interesting how you have uniformed the distribution of spikes on the surface of the virus, I have used the original code of Ashish because on 2 opposite pole it draws a crown.
Title: Re: COVID-19 in QB64
Post by: Ashish on June 02, 2020, 12:16:12 pm
WOW @TempodiBasic .

I made some little change in the code so the each virus rotate on its axis.

Code: QB64: [Select]
  1. 'COVID-19 in QB64
  2. 'By Ashish
  3. '1 Jun, 2020
  4. '
  5. 'WARNING:Use mask. Apply santizer after closing the program.
  6. ' 2 Jun, 2020    added a little son of COVID-19  TDB
  7. ' 2 Jun, 2020    modularizing  the _GL actions   TDB
  8. '2 Jun, 2020     an array of virus and a continuous restarting by Enter and quit by Space TDB
  9. '2 Jun, 2020 made the viruses rotate on its axis.
  10. _TITLE "We are all Covid-19 :-)"
  11.  
  12. SCREEN _NEWIMAGE(600, 600, 32)
  13.  
  14.     SUB glutSolidSphere (BYVAL radius AS DOUBLE, BYVAL slices AS LONG, BYVAL stack AS LONG)
  15.     SUB gluLookAt (BYVAL eyeX#, BYVAL eyeY#, BYVAL eyeZ#, BYVAL centerX#, BYVAL centerY#, BYVAL centerZ#, BYVAL upX#, BYVAL upY#, BYVAL upZ#)
  16.  
  17. DIM SHARED glAllow AS _BYTE
  18. TYPE vec3
  19.     x AS SINGLE
  20.     y AS SINGLE
  21.     z AS SINGLE
  22. TYPE colorRGBA
  23.     R AS SINGLE
  24.     G AS SINGLE
  25.     B AS SINGLE
  26.     A AS SINGLE
  27.  
  28. TYPE COVID19
  29.     POS AS vec3
  30.     r AS SINGLE
  31.     rotY AS SINGLE
  32.     rotX AS SINGLE
  33.     Vxz AS SINGLE
  34.     Vyz AS SINGLE
  35.     C AS colorRGBA
  36.  
  37. DIM SHARED virus(1 TO 10) AS COVID19
  38. Initialize
  39.     k = _KEYHIT
  40.     LOCATE 1, 1: PRINT "Space to quit, Enter to change viruses"
  41.     _LIMIT 1
  42.     IF k = 13 THEN Initialize
  43. LOOP UNTIL k = 32
  44. END ' a logical end to the flow
  45.  
  46. '------------ SUBs and FUNCTIONs----------------------------
  47. SUB Initialize
  48.     FOR z = 1 TO 10 STEP 1
  49.         virus(z).r = 0.1 + (RND / 5)
  50.         virus(z).POS.y = 1 - (RND * 2)
  51.         virus(z).POS.x = 1 - (RND * 2)
  52.         virus(z).POS.z = 1 - (RND * 2) 'virus(z).POS.z = 0
  53.         virus(z).Vxz = 20 - (RND * 10)
  54.         virus(z).Vyz = 20 - (RND * 10)
  55.         virus(z).C.R = 1 - (RND * 1)
  56.         virus(z).C.G = 1 - (RND * 1)
  57.         virus(z).C.B = 1 - (RND * 1)
  58.         virus(z).C.A = 1 - (RND * 1)
  59.     NEXT z
  60.     glAllow = -1
  61.  
  62.  
  63. SUB InitGL (in, aspe)
  64.     IF in = 0 THEN
  65.         in = 1
  66.         aspe = _WIDTH / _HEIGHT
  67.         _glViewport 0, 0, _WIDTH, _HEIGHT
  68.     END IF
  69.  
  70. SUB DrawLines (viru AS COVID19)
  71.     _glColor3f 1, 0, 0
  72.     _glBegin _GL_LINES
  73.     FOR phi = 0.4 TO _PI(2) STEP .5
  74.         FOR theta = 0.3 TO _PI STEP .5
  75.             _glVertex3f viru.r * SIN(theta) * COS(phi), viru.r * SIN(theta) * SIN(phi), viru.r * COS(theta)
  76.             _glVertex3f (0.1 + viru.r) * SIN(theta) * COS(phi), (0.1 + viru.r) * SIN(theta) * SIN(phi), (0.1 + viru.r) * COS(theta)
  77.         NEXT
  78.     NEXT
  79.     _glEnd
  80.  
  81.  
  82. SUB DrawPoints (viru AS COVID19)
  83.     _glBegin _GL_POINTS
  84.     FOR phi = 0.4 TO _PI(2) STEP .5
  85.         FOR theta = 0.3 TO _PI STEP .5
  86.             _glVertex3f (0.1 + viru.r) * SIN(theta) * COS(phi), (0.1 + viru.r) * SIN(theta) * SIN(phi), (0.1 + viru.r) * COS(theta)
  87.         NEXT
  88.     NEXT
  89.     _glEnd
  90.  
  91. SUB DrawVirus (v AS COVID19)
  92.     _glPushMatrix 'save the previous position & rotation
  93.     ' setting  position and rotation
  94.     _glTranslatef v.POS.x, v.POS.y, v.POS.z
  95.     _glRotatef v.rotY, 0.5, 1, 0
  96.     v.rotY = v.rotY + 2
  97.  
  98.     _glEnable _GL_LIGHTING ' thanks to Ashish
  99.     _glMaterialfv _GL_FRONT_AND_BACK, _GL_DIFFUSE, glVec4(v.C.R, v.C.G, v.C.B, v.C.A)
  100.  
  101.     ' make the sphere
  102.     glutSolidSphere v.r, v.Vxz, v.Vyz
  103.  
  104.     _glDisable _GL_LIGHTING
  105.     ' make lines
  106.     DrawLines v
  107.     ' make points
  108.     DrawPoints v
  109.     _glEnable _GL_LIGHTING
  110.  
  111.     _glPopMatrix 'restore the original position & rotation
  112.  
  113. SUB _GL ()
  114.     STATIC init, aspect
  115.  
  116.     IF glAllow = 0 THEN EXIT SUB
  117.  
  118.     InitGL init, aspect
  119.  
  120.     _glEnable _GL_DEPTH_TEST
  121.     _glEnable _GL_LIGHTING
  122.     _glEnable _GL_LIGHT0
  123.  
  124.     _glLightfv _GL_LIGHT0, _GL_AMBIENT, glVec4(0.0, 0.0, 0.0, 1)
  125.     _glLightfv _GL_LIGHT0, _GL_DIFFUSE, glVec4(0.8, 0.8, 0.8, 1)
  126.     _glLightfv _GL_LIGHT0, _GL_SPECULAR, glVec4(1, 1, 1, 1)
  127.     _glLightfv _GL_LIGHT0, _GL_POSITION, glVec4(0, 0, 10, 1)
  128.  
  129.  
  130.  
  131.     _glMatrixMode _GL_PROJECTION
  132.     _gluPerspective 50, aspect, 0.1, 10
  133.  
  134.     _glMatrixMode _GL_MODELVIEW
  135.     gluLookAt 0, 0, 3, 0, 0, 0, 0, 1, 0
  136.  
  137.     _glLineWidth 2.0
  138.     _glPointSize 10.0
  139.     FOR z = 1 TO 10 STEP 1
  140.         DrawVirus virus(z)
  141.     NEXT z
  142.  
  143.  
  144. FUNCTION glVec4%& (x, y, z, w) 'give the offset of the given vector
  145.     STATIC internal_vec4(3)
  146.     internal_vec4(0) = x
  147.     internal_vec4(1) = y
  148.     internal_vec4(2) = z
  149.     internal_vec4(3) = w
  150.     glVec4%& = _OFFSET(internal_vec4())
  151.  
  152.  


PS : Can you make the coronavirus rain? :P
Title: Re: COVID-19 in QB64
Post by: TempodiBasic on June 02, 2020, 01:09:23 pm
Hi Ashish
I find this to rain viruses

Code: QB64: [Select]
  1. 'COVID-19 in QB64
  2. 'By Ashish
  3. '1 Jun, 2020
  4. '
  5. 'WARNING:Use mask. Apply santizer after closing the program.
  6. ' 2 Jun, 2020    added a little son of COVID-19  TDB
  7. ' 2 Jun, 2020    modularizing  the _GL actions   TDB
  8. '2 Jun, 2020     an array of virus and a continuous restarting by Enter and quit by Space TDB
  9. '2 Jun, 2020 made the viruses rotate on its axis.
  10. _TITLE "We are all Covid-19 :-)"
  11.  
  12. SCREEN _NEWIMAGE(600, 600, 32)
  13.  
  14.     SUB glutSolidSphere (BYVAL radius AS DOUBLE, BYVAL slices AS LONG, BYVAL stack AS LONG)
  15.     SUB gluLookAt (BYVAL eyeX#, BYVAL eyeY#, BYVAL eyeZ#, BYVAL centerX#, BYVAL centerY#, BYVAL centerZ#, BYVAL upX#, BYVAL upY#, BYVAL upZ#)
  16.  
  17. DIM SHARED glAllow AS _BYTE
  18. TYPE vec3
  19.     x AS SINGLE
  20.     y AS SINGLE
  21.     z AS SINGLE
  22. TYPE colorRGBA
  23.     R AS SINGLE
  24.     G AS SINGLE
  25.     B AS SINGLE
  26.     A AS SINGLE
  27.  
  28. TYPE COVID19
  29.     POS AS vec3
  30.     r AS SINGLE
  31.     rotY AS SINGLE
  32.     rotX AS SINGLE
  33.     Vxz AS SINGLE
  34.     Vyz AS SINGLE
  35.     C AS colorRGBA
  36.  
  37. DIM SHARED virus(1 TO 10) AS COVID19
  38. Initialize
  39.     k = _KEYHIT
  40.     LOCATE 1, 1: PRINT "Space to quit, Enter to change viruses"
  41.     _LIMIT 1
  42.     IF k = 13 THEN Initialize
  43. LOOP UNTIL k = 32
  44. END ' a logical end to the flow
  45.  
  46. '------------ SUBs and FUNCTIONs----------------------------
  47.  
  48. SUB Initialize
  49.     FOR z = 1 TO 10 STEP 1
  50.         virus(z).r = 0.1 + (RND / 5)
  51.         virus(z).POS.y = 1 - (RND * 2)
  52.         virus(z).POS.x = 1 - (RND * 2)
  53.         virus(z).POS.z = 1 - (RND * 2) 'virus(z).POS.z = 0
  54.         virus(z).Vxz = 20 - (RND * 10)
  55.         virus(z).Vyz = 20 - (RND * 10)
  56.         virus(z).C.R = 1 - (RND * 1)
  57.         virus(z).C.G = 1 - (RND * 1)
  58.         virus(z).C.B = 1 - (RND * 1)
  59.         virus(z).C.A = 1 - (RND * 1)
  60.     NEXT z
  61.     glAllow = -1
  62.  
  63.  
  64. SUB InitGL (in, aspe)
  65.     IF in = 0 THEN
  66.         in = 1
  67.         aspe = _WIDTH / _HEIGHT
  68.         _glViewport 0, 0, _WIDTH, _HEIGHT
  69.     END IF
  70.  
  71. SUB DrawLines (viru AS COVID19)
  72.     _glColor3f 1, 0, 0
  73.     _glBegin _GL_LINES
  74.     FOR phi = 0.4 TO _PI(2) STEP .5
  75.         FOR theta = 0.3 TO _PI STEP .5
  76.             _glVertex3f viru.r * SIN(theta) * COS(phi), viru.r * SIN(theta) * SIN(phi), viru.r * COS(theta)
  77.             _glVertex3f (0.1 + viru.r) * SIN(theta) * COS(phi), (0.1 + viru.r) * SIN(theta) * SIN(phi), (0.1 + viru.r) * COS(theta)
  78.         NEXT
  79.     NEXT
  80.     _glEnd
  81.  
  82.  
  83. SUB DrawPoints (viru AS COVID19)
  84.     _glBegin _GL_POINTS
  85.     FOR phi = 0.4 TO _PI(2) STEP .5
  86.         FOR theta = 0.3 TO _PI STEP .5
  87.             _glVertex3f (0.1 + viru.r) * SIN(theta) * COS(phi), (0.1 + viru.r) * SIN(theta) * SIN(phi), (0.1 + viru.r) * COS(theta)
  88.         NEXT
  89.     NEXT
  90.     _glEnd
  91.  
  92. SUB DrawVirus (v AS COVID19)
  93.     ' raining effect
  94.     v.POS.y = v.POS.y - 0.02
  95.     IF v.POS.y <= -1 THEN v.POS.y = 1
  96.  
  97.     _glPushMatrix 'save the previous position & rotation
  98.     ' setting  position and rotation
  99.     _glTranslatef v.POS.x, v.POS.y, v.POS.z
  100.     _glRotatef v.rotY, 0.5, 1, 0
  101.     v.rotY = v.rotY + 2
  102.  
  103.     _glEnable _GL_LIGHTING ' thanks to Ashish
  104.     _glMaterialfv _GL_FRONT_AND_BACK, _GL_DIFFUSE, glVec4(v.C.R, v.C.G, v.C.B, v.C.A)
  105.  
  106.     ' make the sphere
  107.     glutSolidSphere v.r, v.Vxz, v.Vyz
  108.  
  109.     _glDisable _GL_LIGHTING
  110.     ' make lines
  111.     DrawLines v
  112.     ' make points
  113.     DrawPoints v
  114.     _glEnable _GL_LIGHTING
  115.  
  116.     _glPopMatrix 'restore the original position & rotation
  117.  
  118. SUB _GL ()
  119.     STATIC init, aspect
  120.  
  121.     IF glAllow = 0 THEN EXIT SUB
  122.  
  123.     InitGL init, aspect
  124.  
  125.     _glEnable _GL_DEPTH_TEST
  126.     _glEnable _GL_LIGHTING
  127.     _glEnable _GL_LIGHT0
  128.  
  129.     _glLightfv _GL_LIGHT0, _GL_AMBIENT, glVec4(0.0, 0.0, 0.0, 1)
  130.     _glLightfv _GL_LIGHT0, _GL_DIFFUSE, glVec4(0.8, 0.8, 0.8, 1)
  131.     _glLightfv _GL_LIGHT0, _GL_SPECULAR, glVec4(1, 1, 1, 1)
  132.     _glLightfv _GL_LIGHT0, _GL_POSITION, glVec4(0, 0, 10, 1)
  133.  
  134.  
  135.  
  136.     _glMatrixMode _GL_PROJECTION
  137.     _gluPerspective 50, aspect, 0.1, 10
  138.  
  139.     _glMatrixMode _GL_MODELVIEW
  140.     gluLookAt 0, 0, 3, 0, 0, 0, 0, 1, 0
  141.  
  142.     _glLineWidth 2.0
  143.     _glPointSize 10.0
  144.     FOR z = 1 TO 10 STEP 1
  145.         DrawVirus virus(z)
  146.     NEXT z
  147.     _glFlush
  148.  
  149.  
  150. FUNCTION glVec4%& (x, y, z, w) 'give the offset of the given vector
  151.     STATIC internal_vec4(3)
  152.     internal_vec4(0) = x
  153.     internal_vec4(1) = y
  154.     internal_vec4(2) = z
  155.     internal_vec4(3) = w
  156.     glVec4%& = _OFFSET(internal_vec4())
  157.  

simple I put at start of DrawVirus these lines of code

Quote
   ' raining effect
    v.POS.y = v.POS.y - 0.02
    IF v.POS.y <= -1 THEN v.POS.y = 1

Thanks for the suggestion
Title: Re: COVID-19 in QB64
Post by: Ashish on June 02, 2020, 11:34:46 pm
Amazing work, @TempodiBasic :)
Title: Re: COVID-19 in QB64
Post by: qbkiller101 on June 03, 2020, 01:44:49 am
@TempodiBasic tried opening a zillion times but still
  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: COVID-19 in QB64
Post by: Ashish on June 03, 2020, 02:20:57 am
@qbkiller101
Add this before _SCREENMOVE _MIDDLE on line 44.

Code: QB64: [Select]
Title: Re: COVID-19 in QB64
Post by: qbkiller101 on June 03, 2020, 02:23:50 am
worked.
@TempodiBasic enter to quit isnt working
Title: Re: COVID-19 in QB64
Post by: Ashish on June 03, 2020, 02:34:58 am
@qbkiller101 First of all, it is space to quite.

secondly, It may be working but it will be delay since the loop is completing its one cycle in one second, this is because of _LIMIT 1.
Change _LIMIT 1 to _LIMIT 30.

Here's the updated code with all glitch fixed.

Code: QB64: [Select]
  1.     'COVID-19 in QB64
  2.     'By Ashish
  3.     '1 Jun, 2020
  4.     '
  5.     'WARNING:Use mask. Apply santizer after closing the program.
  6.     ' 2 Jun, 2020    added a little son of COVID-19  TDB
  7.     ' 2 Jun, 2020    modularizing  the _GL actions   TDB
  8.     '2 Jun, 2020     an array of virus and a continuous restarting by Enter and quit by Space TDB
  9.     '2 Jun, 2020 made the viruses rotate on its axis.
  10.     _TITLE "We are all Covid-19 :-)"
  11.      
  12.     SCREEN _NEWIMAGE(600, 600, 32)
  13.      
  14.         SUB glutSolidSphere (BYVAL radius AS DOUBLE, BYVAL slices AS LONG, BYVAL stack AS LONG)
  15.         SUB gluLookAt (BYVAL eyeX#, BYVAL eyeY#, BYVAL eyeZ#, BYVAL centerX#, BYVAL centerY#, BYVAL centerZ#, BYVAL upX#, BYVAL upY#, BYVAL upZ#)
  16.     END DECLARE
  17.      
  18.     DIM SHARED glAllow AS _BYTE
  19.     TYPE vec3
  20.         x AS SINGLE
  21.         y AS SINGLE
  22.         z AS SINGLE
  23.     END TYPE
  24.     TYPE colorRGBA
  25.         R AS SINGLE
  26.         G AS SINGLE
  27.         B AS SINGLE
  28.         A AS SINGLE
  29.     END TYPE
  30.      
  31.     TYPE COVID19
  32.         POS AS vec3
  33.         r AS SINGLE
  34.         rotY AS SINGLE
  35.         rotX AS SINGLE
  36.         Vxz AS SINGLE
  37.         Vyz AS SINGLE
  38.         C AS colorRGBA
  39.     END TYPE
  40.      
  41.     DIM SHARED virus(1 TO 10) AS COVID19
  42.     Initialize
  43.     DO
  44.         k = _KEYHIT
  45.         LOCATE 1, 1: PRINT "Space to quit, Enter to change viruses"
  46.         _LIMIT 30
  47.         IF k = 13 THEN Initialize
  48.     LOOP UNTIL k = 32
  49.     END ' a logical end to the flow
  50.      
  51.     '------------ SUBs and FUNCTIONs----------------------------
  52.      
  53.     SUB Initialize
  54.         FOR z = 1 TO 10 STEP 1
  55.             virus(z).r = 0.1 + (RND / 5)
  56.             virus(z).POS.y = 1 - (RND * 2)
  57.             virus(z).POS.x = 1 - (RND * 2)
  58.             virus(z).POS.z = 1 - (RND * 2) 'virus(z).POS.z = 0
  59.             virus(z).Vxz = 20 - (RND * 10)
  60.             virus(z).Vyz = 20 - (RND * 10)
  61.             virus(z).C.R = 1 - (RND * 1)
  62.             virus(z).C.G = 1 - (RND * 1)
  63.             virus(z).C.B = 1 - (RND * 1)
  64.             virus(z).C.A = 1 - (RND * 1)
  65.         NEXT z
  66.         glAllow = -1
  67.     END SUB
  68.      
  69.      
  70.     SUB InitGL (in, aspe)
  71.         IF in = 0 THEN
  72.             in = 1
  73.             aspe = _WIDTH / _HEIGHT
  74.             _GLVIEWPORT 0, 0, _WIDTH, _HEIGHT
  75.         END IF
  76.     END SUB
  77.      
  78.     SUB DrawLines (viru AS COVID19)
  79.         _GLCOLOR3F 1, 0, 0
  80.         _GLBEGIN _GL_LINES
  81.         FOR phi = 0.4 TO _PI(2) STEP .5
  82.             FOR theta = 0.3 TO _PI STEP .5
  83.                 _GLVERTEX3F viru.r * SIN(theta) * COS(phi), viru.r * SIN(theta) * SIN(phi), viru.r * COS(theta)
  84.                 _GLVERTEX3F (0.1 + viru.r) * SIN(theta) * COS(phi), (0.1 + viru.r) * SIN(theta) * SIN(phi), (0.1 + viru.r) * COS(theta)
  85.             NEXT
  86.         NEXT
  87.         _GLEND
  88.      
  89.     END SUB
  90.      
  91.     SUB DrawPoints (viru AS COVID19)
  92.         _GLBEGIN _GL_POINTS
  93.         FOR phi = 0.4 TO _PI(2) STEP .5
  94.             FOR theta = 0.3 TO _PI STEP .5
  95.                 _GLVERTEX3F (0.1 + viru.r) * SIN(theta) * COS(phi), (0.1 + viru.r) * SIN(theta) * SIN(phi), (0.1 + viru.r) * COS(theta)
  96.             NEXT
  97.         NEXT
  98.         _GLEND
  99.     END SUB
  100.      
  101.     SUB DrawVirus (v AS COVID19)
  102.         ' raining effect
  103.         v.POS.y = v.POS.y - 0.02
  104.         IF v.POS.y <= -1 THEN v.POS.y = 1
  105.      
  106.         _GLPUSHMATRIX 'save the previous position & rotation
  107.         ' setting  position and rotation
  108.         _GLTRANSLATEF v.POS.x, v.POS.y, v.POS.z
  109.         _GLROTATEF v.rotY, 0.5, 1, 0
  110.         v.rotY = v.rotY + 2
  111.      
  112.         _GLENABLE _GL_LIGHTING ' thanks to Ashish
  113.         _GLMATERIALFV _GL_FRONT_AND_BACK, _GL_DIFFUSE, glVec4(v.C.R, v.C.G, v.C.B, v.C.A)
  114.      
  115.         ' make the sphere
  116.         glutSolidSphere v.r, v.Vxz, v.Vyz
  117.      
  118.         _GLDISABLE _GL_LIGHTING
  119.         ' make lines
  120.         DrawLines v
  121.         ' make points
  122.         DrawPoints v
  123.         _GLENABLE _GL_LIGHTING
  124.      
  125.         _GLPOPMATRIX 'restore the original position & rotation
  126.     END SUB
  127.      
  128.     SUB _GL ()
  129.         STATIC init, aspect
  130.      
  131.         IF glAllow = 0 THEN EXIT SUB
  132.      
  133.         InitGL init, aspect
  134.      
  135.         _GLENABLE _GL_DEPTH_TEST
  136.         _GLENABLE _GL_LIGHTING
  137.         _GLENABLE _GL_LIGHT0
  138.      
  139.         _GLLIGHTFV _GL_LIGHT0, _GL_AMBIENT, glVec4(0.0, 0.0, 0.0, 1)
  140.         _GLLIGHTFV _GL_LIGHT0, _GL_DIFFUSE, glVec4(0.8, 0.8, 0.8, 1)
  141.         _GLLIGHTFV _GL_LIGHT0, _GL_SPECULAR, glVec4(1, 1, 1, 1)
  142.         _GLLIGHTFV _GL_LIGHT0, _GL_POSITION, glVec4(0, 0, 10, 1)
  143.      
  144.      
  145.      
  146.         _GLMATRIXMODE _GL_PROJECTION
  147.         _GLUPERSPECTIVE 50, aspect, 0.1, 10
  148.      
  149.         _GLMATRIXMODE _GL_MODELVIEW
  150.         gluLookAt 0, 0, 3, 0, 0, 0, 0, 1, 0
  151.      
  152.         _GLLINEWIDTH 2.0
  153.         _GLPOINTSIZE 10.0
  154.         FOR z = 1 TO 10 STEP 1
  155.             DrawVirus virus(z)
  156.         NEXT z
  157.         _GLFLUSH
  158.     END SUB
  159.      
  160.      
  161.     FUNCTION glVec4%& (x, y, z, w) 'give the offset of the given vector
  162.         STATIC internal_vec4(3)
  163.         internal_vec4(0) = x
  164.         internal_vec4(1) = y
  165.         internal_vec4(2) = z
  166.         internal_vec4(3) = w
  167.         glVec4%& = _OFFSET(internal_vec4())
  168.      
  169.  
Title: Re: COVID-19 in QB64
Post by: qbkiller101 on June 03, 2020, 02:37:16 am
thx
plz reply someone to this https://www.qb64.org/forum/index.php?topic=2660.0 (https://www.qb64.org/forum/index.php?topic=2660.0)
Title: Re: COVID-19 in QB64
Post by: TempodiBasic on June 03, 2020, 04:27:33 am
@qbkiller101
 yes that issue is alternating on my Notebook, and think that Window Defender has trolled me lanching a warning of a Troian blabla C.cl! in the file compiled! But after some google research I have found so many different source for that warning of windows defender! :-))

the issue has been already fixed by Ashish.
The not immediate response of program to the keyboard is the low cycle of run (_LIMIT 1), as Ashish has stressed if you want a program with  more performance you must arise that _LIMIT.
Thanks to try.

@Ashish
Thanks for appreciations, and moreover thanks to having teached me _SCREENEXISTS that I don't know.
If I have time today I go on with Mask tutorial and the rest.

Good Coding
Title: Re: COVID-19 in QB64
Post by: Richard Frost on July 13, 2020, 12:19:49 am
Neato-o, but it frequently freezes on startup for me because of the _SCREENMOVE _MIDDLE.
Commenting that out, or adding a _DELAY .5 after it, fixes it.

Title: Re: COVID-19 in QB64
Post by: TempodiBasic on July 13, 2020, 01:58:44 pm
Yes you're right and your modifications are a workaround while this is the solution
https://www.qb64.org/forum/index.php?topic=2652.msg118726#msg118726 (https://www.qb64.org/forum/index.php?topic=2652.msg118726#msg118726)
Thanks to try code