Hi guys I was wondering if someone could help as I am using Blitzmax and I am reading data values in to an array
to create my sine wave, but the values just don't work right, plus there seams to be a speed issue as well, here is
my code Thanks.
Framework brl.GLMax2D
Import BRL.BMPLoader
Import BRL.Retro
SetGraphicsDriver GLMax2DDriver()
Const Xres:Int = 800
Const Yres:Int = 600
Global Image:TImage = LoadAnimImage("sfont16.bmp", 16, 16, 0, 59)
Global Fonts:TPixmap[] = Image.pixmaps
Global Scrlpos:Int
Global Tpos:Int = 1
Global SineAdd:Int
Global Y1:Float[80] ' Arrays for Sine values
Global Y2:Float[84]
Global Angle:Int ' Array counter
Graphics(Xres, Yres, 32, GRAPHICS_BACKBUFFER)
glViewport 0, 0, Xres, Yres
glMatrixMode GL_PROJECTION
glLoadIdentity()
gluOrtho2D(0.0, Xres, 0.0, Yres)
glMatrixMode GL_MODELVIEW
glLoadIdentity
Global Scrolltext:String = " "
Scrolltext:+"this is my opengl sine wave scroll text routine this was part "
Scrolltext:+"written for me on the dbf forum by raizor and shockwave.. wrap! "
Scrolltext:+" "
Scrolltext = Upper(Scrolltext)
Type FPS
Global Counter, Time, TFPS
Function Calc%()
Counter:+1
If Time < MilliSecs() Then
TFPS = Counter
Time = MilliSecs() + 1000
Counter = 0
EndIf
Return TFPS
EndFunction
EndType
RestoreData Data1
For Local a:Int = 0 To 79
ReadData Y1[a] ' Read values in to array for sine wave 1
Next
RestoreData Data2
For Local b:Int = 0 To 83
ReadData Y2 ' Read values in to array for sine wave 2
Next
Repeat
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glEnable(GL_TEXTURE_2D)
glPushMatrix()
glLoadIdentity()
GLDrawText("FPS: " + FPS.Calc(), 20, 20)
SineAdd:-3
Scroller()
glPopMatrix()
Flip(-1)
Until KeyDown(KEY_ESCAPE)
EndGraphics
End
Function Scroller()
Local Drawpos:Int
Local Textadd:Int
Local Letter:Int
Local Font:Int
Scrlpos:+2
glColor4f(1, 1, 1, 1)
If Scrlpos > 16 Then
Scrlpos = Scrlpos - 16
Tpos = Tpos + 1
If Tpos > Len(Scrolltext) - 52 Then Tpos = 1
End If
Drawpos = (-16) - Scrlpos
Repeat
If Scrlpos > 15 Then
Angle:+1
If Angle = 84 Then Angle = 0
End If
Letter = Asc(Mid(Scrolltext, (Tpos + Textadd), 1)) - 32
Font = GLTexFromPixmap(Fonts[Letter])
glBindTexture(GL_TEXTURE_2D, Font)
' Old Methods
'YCord1 = (Yres / 2) + (40 * Sin(SineAdd + Drawpos))
'YCord2 = (Yres / 2) + (40 * Sin(SineAdd + Drawpos) + 16)
glLoadIdentity()
glBegin(GL_QUADS)
glColor4f(0.2, 0.2, 1, 1) ' Blue Colour
glTexCoord2f 0, 1; glVertex3f 0 + Drawpos, 0 + Y1[Angle], 0 ' Bottom Left
glTexCoord2f 1, 1; glVertex3f 16 + Drawpos, 0 + Y2[Angle], 0 ' Bottom Right
glColor4f(1, 1, 1, 1) ' White Colour
glTexCoord2f 1, 0; glVertex3f 16 + Drawpos, 16 + Y2[Angle], 0 ' Top Right
glTexCoord2f 0, 0; glVertex3f 0 + Drawpos, 16 + Y1[Angle], 0 ' Top Left
glEnd
Textadd:+1
Drawpos:+16
Until Drawpos >= Xres
End Function
#Data1
DefData 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319
DefData 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339
DefData 338, 337, 336, 335, 334, 333, 332, 331, 330, 329, 328, 327, 326, 325, 324, 323, 322, 321, 320, 319
DefData 318, 317, 316, 315, 314, 313, 312, 311, 310, 309, 308, 307, 306, 305, 304, 303, 302, 301, 300, 299
#Data2
DefData 375, 378, 381, 384, 387, 390, 393, 396, 399, 402, 405, 408, 411, 414, 417, 420, 423, 426, 429, 432, 435, 438, 441, 444, 447, 450, 453, 456, 459, 462, 465, 468, 471, 474, 477, 480, 483, 486, 489, 492, 495, 498
DefData 498, 495, 492, 489, 486, 483, 480, 477, 474, 471, 468, 465, 462, 459, 456, 453, 450, 447, 444, 441, 438, 435, 432, 429, 426, 423, 420, 417, 414, 411, 408, 405, 402, 399, 396, 393, 390, 387, 384, 381, 378, 375