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

0 Members and 1 Guest are viewing this topic.

FellippeHeitor

  • Guest
Re: Moving into the Matrix Rain
« Reply #15 on: June 26, 2019, 07:45:51 am »
This is working fine in v1.3 in Linux.  I haven't tried it in v1.2 because it currently isn't installed.  I will test it there later.

Ashish is using some syntax that’s specific of v1.3, don’t even bother unless you’re actually intending to adapt it for older versions.

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Star Wars Crawl
« Reply #16 on: June 26, 2019, 09:10:53 am »
VERY Nice Ashish.!

I found 2 issues on my system:
1) This only works for QB64 v1.3 and not v1.2 without changes.
2) When I try to run it in Windows vm in 1.2 && 1.3 I get the blue text, white title text, and then just a bunch of white area and not the text that scrolls up the screen.

This is working fine in v1.3 in Linux.  I haven't tried it in v1.2 because it currently isn't installed.  I will test it there later.
Thanks.
1. I fixed the code, so that can work 1.2 too without making changes.
2. This was also reported by Fellippe. Is it windows XP?

...
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.
You are right. OpenGL is very fast. It render the texture at the same time when CLS is used. Also, the data is being feed by _MEM.
I fixed the flickering issue by using two images & avoiding CLS.

Okay, Here is the lastest code -
Code: QB64: [Select]
  1. '###########################
  2. '# StarWars Opening Crawl  #
  3. '# By Ashish               #
  4. '###########################
  5.  
  6. _TITLE "STARSWARS Opening crawl"
  7.  
  8. SCREEN _NEWIMAGE(800, 600, 32)
  9.  
  10. DIM SHARED glAllow, text&, text2&, lines$(26)
  11. DIM SHARED starWars&
  12.  
  13. text& = _NEWIMAGE(280, (ubound(lines$)+1)*_FONTHEIGHT, 32)
  14. text2& = _COPYIMAGE(text&)
  15. starWars& = _NEWIMAGE(65, 17, 32)
  16.  
  17. _DEST starWars&
  18. COLOR _RGB32(255,255,255)
  19. _PRINTSTRING (0, 0), "STARWARS"
  20.  
  21. FOR i = 0 TO UBOUND(lines$)
  22.     READ a$
  23.     lines$(i) = a$
  24.  
  25. COLOR _RGB(0, 0, 255)
  26. centerPrint "A long time ago in galaxy far,", _WIDTH, 280
  27. centerPrint "far away...", _WIDTH, 308
  28. FOR i = 0 TO 255 STEP 5
  29.     LINE (0, 0)-(_WIDTH, _HEIGHT), _RGB32(0, 0, 0, i), BF
  30.     _DISPLAY
  31.     _DELAY 0.01
  32. _PUTIMAGE (_WIDTH / 2 - _WIDTH(starWars&) * 3, _HEIGHT / 2 - _HEIGHT(starWars&) * 3)-STEP(_WIDTH(starWars&) * 6, _HEIGHT(starWars&) * 6), starWars&
  33. FOR i = 0 TO 255 STEP 5
  34.     LINE (0, 0)-(_WIDTH, _HEIGHT), _RGB32(0, 0, 0, i), BF
  35.     _DISPLAY
  36.     _DELAY 0.01
  37. _DEST text2&
  38. COLOR _RGB(255,220,0),_RGB(0,0,0)
  39. FOR i = 0 TO UBOUND(lines$)
  40.         IF i = UBOUND(lines$) THEN COLOR _RGB(255, 0, 255)
  41.         centerPrint lines$(i), _WIDTH, y + i * _FONTHEIGHT
  42.  
  43. glAllow = -1
  44. COLOR _RGB(255, 220, 0), _RGBA(0, 0, 0, 0)
  45. y = _HEIGHT(text&)+10
  46.  
  47.  
  48.     _DEST text&
  49.         _putimage (0,y),text2&
  50.     y = y - 1
  51.     _LIMIT 30
  52. LOOP UNTIL y < -_HEIGHT(text2&)-10
  53.  
  54. DATA "It is a period of civil war"
  55. DATA "Rebel spaceships, striking"
  56. DATA "from a hidden base, have "
  57. DATA "won their first victory"
  58. DATA "against the evil Galactic"
  59. DATA "Empire."
  60. DATA ""
  61. DATA ""
  62. DATA "During the battle, rebel"
  63. DATA "spies managed to steel"
  64. DATA "secret plans to the Empire's"
  65. DATA "ultimate weapon, the DEATH"
  66. DATA "STAR, an armored space station"
  67. DATA "with enough to destroy an entire"
  68. DATA "planet."
  69. DATA ""
  70. DATA ""
  71. DATA "Pursued by the Empire's sinister"
  72. DATA "agents, Princess Leia races"
  73. DATA "home abroad her starship,"
  74. DATA "custodian of the stolen plans"
  75. DATA "that cansave her people and"
  76. DATA "restore the freedom to the galaxy"
  77. DATA ""
  78. DATA ""
  79. DATA ""
  80. DATA "QB64 Rocks!"
  81.  
  82. SUB centerPrint (t$, w, y)
  83.     _PRINTSTRING ((w / 2) - (LEN(t$) * _FONTWIDTH) / 2, y), t$
  84.  
  85. SUB _GL ()
  86.     STATIC glInit, tex&, texMem AS _MEM', clock!
  87.     IF NOT glAllow THEN EXIT SUB
  88.     IF glInit = 0 THEN
  89.         glInit = -1
  90.         _glViewport 0, 0, _WIDTH, _HEIGHT
  91.         texMem = _MEMIMAGE(text&)
  92.         _glGenTextures 1, _OFFSET(tex&)
  93.     END IF
  94.        
  95.         IF glInit = -1 then clock! = clock! + 0.01
  96.  
  97.     _glEnable _GL_TEXTURE_2D
  98.     _glEnable _GL_DEPTH_TEST
  99.  
  100.  
  101.  
  102.     _glMatrixMode _GL_PROJECTION
  103.     _gluPerspective 60.0, _WIDTH / _HEIGHT, 0.01, 10
  104.  
  105.     _glMatrixMode _GL_MODELVIEW
  106.        
  107.     _glBindTexture _GL_TEXTURE_2D, tex&
  108.     _glTexImage2D _GL_TEXTURE_2D, 0, _GL_RGB, _WIDTH(texMem.IMAGE), _HEIGHT(texMem.IMAGE), 0, _GL_BGRA_EXT, _GL_UNSIGNED_BYTE, texMem.OFFSET
  109.     _glTexParameteri _GL_TEXTURE_2D, _GL_TEXTURE_MAG_FILTER, _GL_LINEAR
  110.     _glTexParameteri _GL_TEXTURE_2D, _GL_TEXTURE_MIN_FILTER, _GL_LINEAR
  111.  
  112.     _glBegin _GL_QUADS
  113.     _glTexCoord2f 0, 1: _glVertex3f -0.8, -1, -0.5 'bottom left     #
  114.     _glTexCoord2f 1, 1: _glVertex3f 0.8, -1, -0.5 'bottom right     # Coordinates sign are same as in Cartesian Plane   (3D)
  115.     _glTexCoord2f 1, 0: _glVertex3f 0.8, 3, -7 'upper right       #
  116.     _glTexCoord2f 0, 0: _glVertex3f -0.8, 3, -7 ' upper left      #
  117.     _glEnd
  118.  
  119.  
  120.     _glFlush
  121.  
  122.  
« Last Edit: June 26, 2019, 09:12:30 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

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Moving into the Matrix Rain
« Reply #17 on: June 26, 2019, 10:36:35 am »
Hi Ashish,

Yep! another great. 2nd version runs much smoother.

Very nice once again. :)

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Moving into the Matrix Rain
« Reply #18 on: June 26, 2019, 11:40:54 am »
Yes. Window XP is the issue. It has some problem with OpenGL textures format.
No. On my machine, Windows XP in VM smoothly runs it.
https://ashishkingdom.github.io/OpenGL-Tutorials
^^^ If a person complete above till textures along with solving exercises, then I think it will be easier for everyone to code simple 3D stuff like this.
« Last Edit: June 26, 2019, 12:05:32 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 OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: Moving into the Matrix Rain
« Reply #19 on: July 01, 2019, 06:11:07 pm »
That was great, I found myself leaning back and forth...