### Author Topic: Moving into the Matrix Rain  (Read 8144 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

#### Ashish ##### Moving into the Matrix Rain
« on: June 23, 2019, 07:30:08 AM »
Hi everyone.
I was just inspire by Bplus's Matrix rain on this topic - https://www.qb64.org/forum/index.php?topic=1152.msg106362
So, I decided to create a similar matrix rain having depth effect.

Code: QB64: [Select]
1. 'Moving into the Matrix Rain
2. 'By Ashish Kushwaha
3. '23 Jun, 2019
4. '
5. 'Inspire by B+ Matrix Rain.
6. _TITLE "Moving into the Matrix Rain"
7.
8.
9. SCREEN _NEWIMAGE(800, 600, 32)
10.
11. TYPE matRain
12.     x AS SINGLE 'x location
13.     y AS SINGLE 'y location
14.     z AS SINGLE 'z location
15.     ay AS SINGLE 'rain velocity
16.     strData AS STRING 'string data of each matrix rain
17.
18. DIM SHARED charImg(74) AS LONG, matRainWidth, matRainHeight 'ascii char from 48 to 122, i.e, total 75 type of chars
19. DIM SHARED glAllow AS _BYTE, matrixRain(700) AS matRain, matrixRainTex(74) AS LONG, mov
20. matRainWidth = _FONTWIDTH * 0.005
21. matRainHeight = _FONTHEIGHT * 0.005
22. CLS , _RGB32(255)
23. FOR i = 0 TO 74
24.     charImg(i) = _NEWIMAGE(_FONTWIDTH * 5, _FONTHEIGHT * 5, 32)
25.     _DEST tmp&
26.     CLS , _RGBA(0, 0, 0, 0)
27.     COLOR _RGB32(0, 255, 0), 1
28.     _PRINTSTRING (0, 0), CHR\$(i + 48)
29.     _DEST charImg(i)
30.     _PUTIMAGE , tmp&
31.
32.
33. glAllow = -1
34.     FOR i = 0 TO UBOUND(matrixRain)
35.         matrixRain(i).y = matrixRain(i).y - matrixRain(i).ay
36.         IF RND > 0.9 THEN
37.             d\$ = ""
38.             FOR k = 1 TO LEN(matrixRain(i).strData)
39.                 d\$ = d\$ + CHR\$(48 + p5random(0, 74)) 'change the character of rain randomly by a chance of 10%
40.             matrixRain(i).strData = d\$
41.         matrixRain(i).z = matrixRain(i).z + 0.00566 'move into the rain
42.         IF matrixRain(i).z > 0.1 THEN 'when behind screen
43.             matrixRain(i).x = p5random(-2, 2)
44.             matrixRain(i).y = p5random(2, 3.7)
45.             matrixRain(i).z = map((i / UBOUND(matrixRain)), 0, 1, -8, -0.2)
46.             matrixRain(i).ay = p5random(0.006, 0.02)
47.     _LIMIT 60
48.
49. SUB _GL ()
50.     STATIC glInit
51.     mov = mov + 0.01
52.     IF NOT glAllow THEN EXIT SUB
53.
54.     IF glInit = 0 THEN
55.         glInit = 1
56.
57.         FOR i = 0 TO UBOUND(matrixRainTex) 'create texture for each ascii character
58.             _GLGENTEXTURES 1, _OFFSET(matrixRainTex(i))
59.
60.             m = _MEMIMAGE(charImg(i))
61.
62.             _GLBINDTEXTURE _GL_TEXTURE_2D, matrixRainTex(i)
63.             _GLTEXIMAGE2D _GL_TEXTURE_2D, 0, _GL_RGBA, _WIDTH(charImg(i)), _HEIGHT(charImg(i)), 0, _GL_BGRA_EXT, _GL_UNSIGNED_BYTE, m.OFFSET
64.
65.
66.             _GLTEXPARAMETERI _GL_TEXTURE_2D, _GL_TEXTURE_MAG_FILTER, _GL_NEAREST
67.             _GLTEXPARAMETERI _GL_TEXTURE_2D, _GL_TEXTURE_MIN_FILTER, _GL_NEAREST
68.             _FREEIMAGE charImg(i)
69.
70.         FOR i = 0 TO UBOUND(matrixRain) 'initialization
71.             n = p5random(1, 15)
72.             FOR j = 1 TO n
73.                 v\$ = CHR\$(p5random(48, 122))
74.                 matrixRain(i).strData = matrixRain(i).strData + v\$
75.             matrixRain(i).x = p5random(-2, 2)
76.             matrixRain(i).y = p5random(2, 3.7)
77.             matrixRain(i).z = map((i / UBOUND(matrixRain)), 0, 1, -8, -0.2)
78.             matrixRain(i).ay = p5random(0.006, 0.02)
79.
80.
81.     _GLENABLE _GL_BLEND 'enabling necessary stuff
82.     _GLENABLE _GL_DEPTH_TEST
83.     _GLENABLE _GL_TEXTURE_2D
84.
85.
86.     _GLCLEARCOLOR 0, 0, 0, 1
87.     _GLCLEAR _GL_COLOR_BUFFER_BIT OR _GL_DEPTH_BUFFER_BIT
88.
89.
90.     _GLMATRIXMODE _GL_PROJECTION
91.     _GLUPERSPECTIVE 60, _WIDTH / _HEIGHT, 0.01, 10.0
92.
93.     _GLROTATEF SIN(mov) * 20, 1, 0, 0 'rotating x-axis a bit, just to get Depth effect.
94.
95.
96.     _GLMATRIXMODE _GL_MODELVIEW
97.
98.     'rendering the rain
99.     FOR i = 0 TO UBOUND(matrixRain)
100.         n = LEN(matrixRain(i).strData)
101.         FOR j = 1 TO n
102.             ca\$ = MID\$(matrixRain(i).strData, j, 1)
103.             'selecting texture on the basis of ascii code.
104.             _GLBINDTEXTURE _GL_TEXTURE_2D, matrixRainTex(ASC(ca\$) - 48)
106.             _GLVERTEX3F matrixRain(i).x - matRainWidth, matrixRain(i).y - matRainHeight + 2 * (j - 1) * matRainHeight, matrixRain(i).z
107.             _GLVERTEX3F matrixRain(i).x - matRainWidth, matrixRain(i).y + matRainHeight + 2 * (j - 1) * matRainHeight, matrixRain(i).z
108.             _GLVERTEX3F matrixRain(i).x + matRainWidth, matrixRain(i).y + matRainHeight + 2 * (j - 1) * matRainHeight, matrixRain(i).z
109.             _GLVERTEX3F matrixRain(i).x + matRainWidth, matrixRain(i).y - matRainHeight + 2 * (j - 1) * matRainHeight, matrixRain(i).z
110.
111.
112. 'taken from p5js.bas
113. 'https://bit.ly/p5jsbas
114. FUNCTION map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!)
115.     map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
116.
117.
118. FUNCTION p5random! (mn!, mx!)
119.     IF mn! > mx! THEN
120.         SWAP mn!, mx!
121.     p5random! = RND * (mx! - mn!) + mn!
122.

Run the code & have fun. :)
if (Me.success) {Me.improve()} else {Me.tryAgain()}

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

#### Petr ##### Re: Moving into the Matrix Rain
« Reply #1 on: June 23, 2019, 07:49:09 AM »
Very nice, Ashish!

#### bplus ##### Re: Moving into the Matrix Rain
« Reply #2 on: June 23, 2019, 08:40:41 AM »
Wow Ashish! nice work!

You could probably do a Star Wars crawl with 10 layers!

#### johnno56 ##### Re: Moving into the Matrix Rain
« Reply #3 on: June 23, 2019, 09:11:38 AM »
Nice one Neo...
Logic is the beginning of wisdom.

#### FellippeHeitor ##### Re: Moving into the Matrix Rain
« Reply #4 on: June 23, 2019, 09:19:49 AM »
Wow! Just wow! 👏👏👏👏👏👏

#### Ashish ##### Re: Moving into the Matrix Rain
« Reply #5 on: June 23, 2019, 10:30:27 AM »
@Petr, @Bplus, @Johnno56, @FellippeHeitor
Thanks!!
if (Me.success) {Me.improve()} else {Me.tryAgain()}

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

#### Qwerkey ##### Re: Moving into the Matrix Rain
« Reply #6 on: June 23, 2019, 11:09:35 AM »
Ashish, I echo my esteemed colleagues in their praise.  Your mastery of OPEN_GL is to be envied (I certainly do!).  You remind me that I promised myself to learn some OPEN_GL (from your tutorials), but I seem content to stay in the simple 2D world (or possibly _MAPTRIANGLE(3D) on rare occasions).

#### TempodiBasic ##### Re: Moving into the Matrix Rain
« Reply #7 on: June 23, 2019, 02:15:34 PM »
@Qwerkey
don't mind it up! Give time to the time, here you must follow your flow, not a work timetable with checkpoints.
Think about me that I play chess from when I was fifteen and I have  always promised to me to go on in my attitute until to get the master level (about 2000-2200 ELO) and for now I range always about 1300(+-100)ELO . :-)
Programming isn't difficult, only it's  consuming time and coffee

#### TempodiBasic ##### Re: Moving into the Matrix Rain
« Reply #8 on: June 23, 2019, 02:16:44 PM »
@Ashish
Hi I find it cool! Very Cool!
And I'm waiting for when you let me navigate into the matrix with keyboard input...
Programming isn't difficult, only it's  consuming time and coffee

#### SMcNeill ##### Re: Moving into the Matrix Rain
« Reply #9 on: June 23, 2019, 04:18:41 PM »
Question:  Is the min/max check really needed in the function?

FUNCTION p5random! (mn!, mx!)
IF mn! > mx! THEN
SWAP mn!, mx!
END IF
p5random! = RND * (mx! - mn!) + mn!
END FUNCTION

Let’s say I send it the values 6,1 to generate a number from 1 to 6.  Let’s pseudo-solve it, without the swap.

p5random! = RND * (mx! - mn!) + mn!

P5 = RND * (1 - 6) + 6
P5 = RND * (-5) + 6

A random number will be generated from 0 to -4.9999999 (RND * -5).  Add 6 to that and we get a value between 6 and 1.0000001.

Swapping the values give a return range between 1 and 5.9999999, which is subtly different, but is that difference worth the conditional check inside a function which gets called multiple times in a loop?  Why bother with the speed bump in the program — especially since it just reduces possible functionality, in case the user might like to get results between 6 and 1, instead of between 1 and 6.

When it comes to this type of error-checking, I’d rather ignore  it, and trust it won’t make much difference even inside a program where the values accidentally get swapped.  No need to add automatic checks which I can manually code for, when truly necessary, myself.

*********************

With that said, I doubt changing it would make much actual difference in execution speed here.  The values are hard-coded and the min is always less than the max, so that SWAP never actually takes place for us.  A single IF check takes very little time to execute, and without any swapping going on (Which can slow down performance by shuffling memory values.), the change in speed is going to be rather small...

(But, as Rho pointed out with the error-checking with arrays and \$CHECKING:OFF, that minute delay can add considerable lag to performance, if called multiple times in large, inner loops.)

I’m just curious if it’s really necessary, or if it might be something you’d want to remove from the p5random function, since the variance in the results is so small, and since the check actually swaps values so rarely.  (In this program, it doesn’t swap them at all.)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

#### Ashish ##### Re: Moving into the Matrix Rain
« Reply #10 on: June 24, 2019, 02:57:01 AM »
Thanks TempodiBasic, Qwerky. Qwerky, I'm very sad that I'm not able to work a lot on this. You see I also code less now. The reason
is that now I'm in 11th standard. This is the crucial stage of my education. So, I'm focussing on that. Well, don't worry. I will definitely
complete the tutorials stuff in future.

@Steve
Yes, you are absolutely right. I didn't thought for about this in depth. BTW, The function was coded by FellippeHeitor. You can ask from him.
if (Me.success) {Me.improve()} else {Me.tryAgain()}

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

Marked as best answer by Ashish on February 26, 2020, 05:17:49 AM

#### Ashish ##### Re: Moving into the Matrix Rain
« Reply #11 on: June 25, 2019, 11:53:23 AM »
@Ashish
Hi I find it cool! Very Cool!
And I'm waiting for when you let me navigate into the matrix with keyboard input...
Here it is -
W/w for moving forward.
S/s for moving backward.
A/a for moving left.
D/d for moving right.
Code: QB64: [Select]
1. 'Moving into the Matrix Rain
2. 'MOD : Supports navigation from keyboard. For TempodiBasic (25 Jun, 2019)
3. 'By Ashish Kushwaha
4. '23 Jun, 2019
5. '
6. 'Inspire by B+ Matrix Rain.
7. _TITLE "Moving into the Matrix Rain"
8.
9.
10. SCREEN _NEWIMAGE(800, 600, 32)
11.
12. TYPE matRain
13.     x AS SINGLE 'x location
14.     y AS SINGLE 'y location
15.     z AS SINGLE 'z location
16.     ay AS SINGLE 'rain velocity
17.     strData AS STRING 'string data of each matrix rain
18.
19. TYPE location
20.         ' y as single
21.
22. DIM SHARED charImg(74) AS LONG, matRainWidth, matRainHeight 'ascii char from 48 to 122, i.e, total 75 type of chars
23. DIM SHARED glAllow AS _BYTE, matrixRain(700) AS matRain, matrixRainTex(74) AS LONG
24. DIM SHARED currLoc AS location
25.
26. matRainWidth = _FONTWIDTH * 0.005
27. matRainHeight = _FONTHEIGHT * 0.005
28. CLS , _RGB32(255)
29. FOR i = 0 TO 74
30.     charImg(i) = _NEWIMAGE(_FONTWIDTH * 5, _FONTHEIGHT * 5, 32)
31.     _DEST tmp&
32.     CLS , _RGBA(0, 0, 0, 0)
33.     COLOR _RGB32(0, 255, 0), 1
34.     _PRINTSTRING (0, 0), CHR\$(i + 48)
35.     _DEST charImg(i)
36.     _PUTIMAGE , tmp&
37.
38.
39. glAllow = -1
40.
41.         currLoc.z = 0 : currLoc.x = 0
42.
43.         IF _KEYDOWN(ASC("w")) OR _KEYDOWN(ASC("W")) THEN currLoc.z = -1
44.         IF _KEYDOWN(ASC("s")) OR _KEYDOWN(ASC("S")) THEN currLoc.z = 1
45.         IF _KEYDOWN(ASC("a")) OR _KEYDOWN(ASC("A")) THEN currLoc.x = -1
46.         IF _KEYDOWN(ASC("d")) OR _KEYDOWN(ASC("D")) THEN currLoc.x = 1
47.
48.     FOR i = 0 TO UBOUND(matrixRain)
49.         matrixRain(i).y = matrixRain(i).y - matrixRain(i).ay
50.         IF RND > 0.9 THEN
51.             d\$ = ""
52.             FOR k = 1 TO LEN(matrixRain(i).strData)
53.                 d\$ = d\$ + CHR\$(48 + p5random(0, 74)) 'change the character of rain randomly by a chance of 10%
54.             matrixRain(i).strData = d\$
55.         ' matrixRain(i).z = matrixRain(i).z + 0.00566 'move into the rain
56.                 IF currLoc.z = -1 THEN matrixRain(i).z = matrixRain(i).z + 0.00766
57.                 IF currLoc.z = 1 THEN matrixRain(i).z = matrixRain(i).z - 0.00766
58.                 IF currLoc.x = -1 THEN matrixRain(i).x = matrixRain(i).x + 0.00766
59.                 IF currLoc.x = 1 THEN matrixRain(i).x = matrixRain(i).x - 0.00766
60.
61.         IF matrixRain(i).z > 0.1 OR matrixRain(i).z<-8 OR matrixRain(i).x>3 OR matrixRain(I).x<-3 THEN 'when behind screen
62.             matrixRain(i).x = p5random(-3, 3)
63.             matrixRain(i).y = p5random(2, 3.7)
64.             matrixRain(i).z = map((i / UBOUND(matrixRain)), 0, 1, -8, -0.2)
65.             matrixRain(i).ay = p5random(0.006, 0.02)
66.     _LIMIT 60
67.
68. SUB _GL ()
69.     STATIC glInit
70.     IF NOT glAllow THEN EXIT SUB
71.
72.     IF glInit = 0 THEN
73.         glInit = 1
74.
75.         FOR i = 0 TO UBOUND(matrixRainTex) 'create texture for each ascii character
76.             _GLGENTEXTURES 1, _OFFSET(matrixRainTex(i))
77.
78.             m = _MEMIMAGE(charImg(i))
79.
80.             _GLBINDTEXTURE _GL_TEXTURE_2D, matrixRainTex(i)
81.             _GLTEXIMAGE2D _GL_TEXTURE_2D, 0, _GL_RGBA, _WIDTH(charImg(i)), _HEIGHT(charImg(i)), 0, _GL_BGRA_EXT, _GL_UNSIGNED_BYTE, m.OFFSET
82.
83.
84.             _GLTEXPARAMETERI _GL_TEXTURE_2D, _GL_TEXTURE_MAG_FILTER, _GL_NEAREST
85.             _GLTEXPARAMETERI _GL_TEXTURE_2D, _GL_TEXTURE_MIN_FILTER, _GL_NEAREST
86.             _FREEIMAGE charImg(i)
87.
88.         FOR i = 0 TO UBOUND(matrixRain) 'initialization
89.             n = p5random(1, 15)
90.             FOR j = 1 TO n
91.                 v\$ = CHR\$(p5random(48, 122))
92.                 matrixRain(i).strData = matrixRain(i).strData + v\$
93.             matrixRain(i).x = p5random(-3, 3)
94.             matrixRain(i).y = p5random(2, 3.7)
95.             matrixRain(i).z = map((i / UBOUND(matrixRain)), 0, 1, -8, -0.2)
96.             matrixRain(i).ay = p5random(0.006, 0.02)
97.
98.
99.     _GLENABLE _GL_BLEND 'enabling necessary stuff
100.     _GLENABLE _GL_DEPTH_TEST
101.     _GLENABLE _GL_TEXTURE_2D
102.
103.
104.     _GLCLEARCOLOR 0, 0, 0, 1
105.     _GLCLEAR _GL_COLOR_BUFFER_BIT OR _GL_DEPTH_BUFFER_BIT
106.
107.
108.     _GLMATRIXMODE _GL_PROJECTION
109.     _GLUPERSPECTIVE 60, _WIDTH / _HEIGHT, 0.01, 10.0
110.
111.
112.     _GLMATRIXMODE _GL_MODELVIEW
113.
114.     'rendering the rain
115.     FOR i = 0 TO UBOUND(matrixRain)
116.         n = LEN(matrixRain(i).strData)
117.         FOR j = 1 TO n
118.             ca\$ = MID\$(matrixRain(i).strData, j, 1)
119.             'selecting texture on the basis of ascii code.
120.             _GLBINDTEXTURE _GL_TEXTURE_2D, matrixRainTex(ASC(ca\$) - 48)
122.             _GLVERTEX3F matrixRain(i).x - matRainWidth, matrixRain(i).y - matRainHeight + 2 * (j - 1) * matRainHeight, matrixRain(i).z
123.             _GLVERTEX3F matrixRain(i).x - matRainWidth, matrixRain(i).y + matRainHeight + 2 * (j - 1) * matRainHeight, matrixRain(i).z
124.             _GLVERTEX3F matrixRain(i).x + matRainWidth, matrixRain(i).y + matRainHeight + 2 * (j - 1) * matRainHeight, matrixRain(i).z
125.             _GLVERTEX3F matrixRain(i).x + matRainWidth, matrixRain(i).y - matRainHeight + 2 * (j - 1) * matRainHeight, matrixRain(i).z
126.
127.
128. 'taken from p5js.bas
129. 'https://bit.ly/p5jsbas
130. FUNCTION map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!)
131.     map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
132.
133.
134. FUNCTION p5random! (mn!, mx!)
135. '    IF mn! > mx! THEN
136. '        SWAP mn!, mx!
137. '    END IF
138.     p5random! = RND * (mx! - mn!) + mn!
139.
140.
« Last Edit: June 25, 2019, 11:54:29 AM 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

#### TempodiBasic ##### Re: Moving into the Matrix Rain
« Reply #12 on: June 25, 2019, 07:40:04 PM »
Hi Ashish
very cool!

I find fantastic to move into the wood of falling letters...
and Neo has revelead to me the secret to win the Matrix....

If do you want to know it  read in the mirror the next sentence.

!etunimarofgnihtonoD

Programming isn't difficult, only it's  consuming time and coffee

#### Ashish ##### Re: Star Wars Crawl
« Reply #13 on: June 26, 2019, 05:21:40 AM »
...
You could probably do a Star Wars crawl with 10 layers!
Here is my try on making Star Wars crawl
Code: QB64: [Select]
1. _TITLE "STARSWARS Opening crawl"
2.
3. SCREEN _NEWIMAGE(800, 600, 32)
4.
5. DIM SHARED glAllow, text&, text2&, lines\$(26)
6. DIM SHARED starWars&
7.
8. text& = _NEWIMAGE(256, 600, 32)
9. text2& = _NEWIMAGE(256, 600, 32)
10. starWars& = _NEWIMAGE(65, 17, 32)
11.
12. _DEST starWars&
13. _PRINTSTRING (0, 0), "STARWARS"
14.
15. FOR i = 0 TO UBOUND(lines\$)
17.     lines\$(i) = a\$
18.
19. COLOR _RGB(0, 0, 255)
20. centerPrint "A long time ago in galaxy far,", _WIDTH, 280
21. centerPrint "far away...", _WIDTH, 308
22. FOR i = 0 TO 255 STEP 5
23.     LINE (0, 0)-(_WIDTH, _HEIGHT), _RGB32(0, 0, 0, i), BF
24.     _DELAY 0.01
25. _PUTIMAGE (_WIDTH / 2 - _WIDTH(starWars&) * 3, _HEIGHT / 2 - _HEIGHT(starWars&) * 3)-STEP(_WIDTH(starWars&) * 6, _HEIGHT(starWars&) * 6), starWars&
26. FOR i = 0 TO 255 STEP 5
27.     LINE (0, 0)-(_WIDTH, _HEIGHT), _RGB32(0, 0, 0, i), BF
28.     _DELAY 0.01
29.
30.
31. glAllow = -1
32. COLOR _RGB(255, 220, 0), _RGBA(0, 0, 0, 0)
33. y = 610
34.
35.
36.     _DEST text&
37.     COLOR _RGB(255, 220, 0), 1
38.     FOR i = 0 TO UBOUND(lines\$)
39.         IF i = UBOUND(lines\$) THEN COLOR _RGB(255, 0, 255)
40.         _PRINTSTRING ((_WIDTH / 2) - (LEN(lines\$(i)) * _FONTWIDTH) / 2, y + i * _FONTHEIGHT), lines\$(i)
41.     y = y - 0.5
42.     _LIMIT 60
43. LOOP UNTIL y < -(UBOUND(lines\$) - 1) * _FONTHEIGHT
44.
45. DATA "It is a period of civil war"
46. DATA "Rebel spaceships, striking"
47. DATA "from a hidden base, have "
48. DATA "won their first victory"
49. DATA "against the evil Galactic"
50. DATA "Empire."
51. DATA ""
52. DATA ""
53. DATA "During the battle, rebel"
54. DATA "spies managed to steel"
55. DATA "secret plans to the Empire's"
56. DATA "ultimate weapon, the DEATH"
57. DATA "STAR, an armored space station"
58. DATA "with enough to destroy an entire"
59. DATA "planet."
60. DATA ""
61. DATA ""
62. DATA "Pursued by the Empire's sinister"
63. DATA "agents, Princess Leia races"
64. DATA "home abroad her starship,"
65. DATA "custodian of the stolen plans"
66. DATA "that cansave her people and"
67. DATA "restore the freedom to the galaxy"
68. DATA ""
69. DATA ""
70. DATA ""
71. DATA "QB64 Rocks!"
72.
73. SUB centerPrint (t\$, w, y)
74.     _PRINTSTRING ((w / 2) - (LEN(t\$) * _FONTWIDTH) / 2, y), t\$
75.
76. SUB _GL ()
77.     STATIC glInit, tex&, texMem AS _MEM
78.     IF NOT glAllow THEN EXIT SUB
79.     IF glInit = 0 THEN
80.         glInit = -1
81.         texMem = _MEMIMAGE(text&)
82.         _GLGENTEXTURES 1, _OFFSET(tex&)
83.
84.
85.     _GLENABLE _GL_TEXTURE_2D
86.     _GLENABLE _GL_DEPTH_TEST
87.
88.
89.
90.     _GLMATRIXMODE _GL_PROJECTION
91.     _GLUPERSPECTIVE 60.0, _WIDTH / _HEIGHT, 0.01, 10
92.
93.     _GLMATRIXMODE _GL_MODELVIEW
94.
95.     _GLBINDTEXTURE _GL_TEXTURE_2D, tex&
96.     _GLTEXIMAGE2D _GL_TEXTURE_2D, 0, _GL_RGB, _WIDTH(texMem.IMAGE), _HEIGHT(texMem.IMAGE), 0, _GL_BGRA_EXT, _GL_UNSIGNED_BYTE, texMem.OFFSET
97.     _GLTEXPARAMETERI _GL_TEXTURE_2D, _GL_TEXTURE_MAG_FILTER, _GL_LINEAR
98.     _GLTEXPARAMETERI _GL_TEXTURE_2D, _GL_TEXTURE_MIN_FILTER, _GL_LINEAR
99.
101.     _GLTEXCOORD2F 0, 1: _GLVERTEX3F -0.4, -1, -0.5 'bottom left     #
102.     _GLTEXCOORD2F 1, 1: _GLVERTEX3F 0.4, -1, -0.5 'bottom right     # Coordinates sign are same as in Cartesian Plane   (3D)
103.     _GLTEXCOORD2F 1, 0: _GLVERTEX3F 0.4, 3, -7 'upper right       #
104.     _GLTEXCOORD2F 0, 0: _GLVERTEX3F -0.4, 3, -7 ' upper left      #
105.
106.
107.
if (Me.success) {Me.improve()} else {Me.tryAgain()}

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

#### TempodiBasic ##### Re: Moving into the Matrix Rain
« Reply #14 on: June 26, 2019, 07:30:46 AM »
Hi Ashish
Cool!
on my Toshiba celeron with Win10 and QB64 1.3 it runs fine!

Just sometimes a bit of flickering  that I have not been able to correct pitching the _Limit's Value.

while some attempts to use an intermediate panel/canvas and _PutImage to avoid CLS (in my little experience CLS is against very fast graphic routines) give me strange results... it maybe that _gLfunctions are faster than _putimage!

Thanks to share.
Programming isn't difficult, only it's  consuming time and coffee