07-27-2023, 02:38 AM
There is also the old _GL SUB from many years ago. Here is a neon line drawer I made. But I'm not sure if GL can work with regular graphics on the same screen. Not sure if I ever achieved that.
Code: (Select All)
_Title "NEON PEN"
Screen _NewImage(800, 600, 32)
Type vec2
x As Single
y As Single
End Type
ReDim Shared vert(200024) As vec2, max_v_index
Dim Shared rFactor!, gFactor!, bFactor!
rFactor! = 0.5: gFactor! = 2.5: bFactor! = 0.5
Do
'CLS
Locate 1, 1: Print "VRAM Usage : "; vram; "KB"
Locate 2, 1: Print "Vertices Used : "; max_v_index; "/"; UBound(vert)
vram = (UBound(vert) * 4) / 1024
a$ = InKey$
If a$ = Chr$(27) Then End
If a$ = " " Then
Line (0, 0)-(800, 600), _RGB32(0, 0, 0), BF
vert = 0
End If
While _MouseInput: Wend
m = _MouseButton(1)
If m = -1 Then
t = t + 1
px = mx: py = my
mx = _MouseX: my = _MouseY
If t < 2 Then GoTo notthistime:
'px = mx: py = my
While m = -1 And max_v_index < UBound(vert)
While _MouseInput: Wend
mx = _MouseX: my = _MouseY
If Abs(px - mx) >= Abs(py - my) Then
If mx >= px Then s = 1 Else s = -1
For i = px To mx Step s
vert(max_v_index).x = i
vert(max_v_index).y = map(i, px, mx, py, my)
max_v_index = max_v_index + 1
'IF max_v_index > UBOUND(vert) THEN REDIM _PRESERVE vert(max_v_index * 2) AS vec2
Next
Else
If my >= py Then s = 1 Else s = -1
For i = py To my Step s
vert(max_v_index).x = map(i, py, my, px, mx)
vert(max_v_index).y = i
max_v_index = max_v_index + 1
'IF max_v_index > UBOUND(vert) THEN REDIM _PRESERVE vert(max_v_index * 2) AS vec2
Next
End If
'px = mx: py = my
notthistime:
m = 0
Wend
End If
_Limit 200
Loop
'This sub was changed from points to lines.
Sub _GL ()
Static glInit
If glInit = 0 Then
glInit = 1
End If
_glViewport 0, 0, _Width, _Height
'set the gl screen so that it can work normal screen coordinates
_glTranslatef -1, 1, 0
_glScalef 1 / 400, -1 / 300, 1
_glEnable _GL_BLEND
_glBlendFunc _GL_SRC_ALPHA, _GL_ONE
_glEnableClientState _GL_VERTEX_ARRAY
_glVertexPointer 2, _GL_FLOAT, 0, _Offset(vert())
For j = 1 To 30
'For j=1 to 15
'_glColor4f rFactor!, gFactor!, bFactor!, 0.015
_glColor4f rFactor!, gFactor!, bFactor!, 0.06
_glPointSize j
'_glDrawArrays _GL_POINTS, 10, max_v_index
_glLineWidth 10
_glDrawArrays _GL_LINE_STRIP, 0, max_v_index
Next
_glFlush
End Sub
Function map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!)
map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
End Function