Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Summer LASER Challenge
#32
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
Reply


Messages In This Thread
Summer LASER Challenge - by TerryRitchie - 07-15-2023, 07:32 PM
RE: Summer LASER Challenge - by bplus - 07-15-2023, 08:10 PM
RE: Summer LASER Challenge - by TerryRitchie - 07-15-2023, 09:48 PM
RE: Summer LASER Challenge - by justsomeguy - 07-15-2023, 09:27 PM
RE: Summer LASER Challenge - by TerryRitchie - 07-15-2023, 09:49 PM
RE: Summer LASER Challenge - by Dav - 07-15-2023, 11:44 PM
RE: Summer LASER Challenge - by TerryRitchie - 07-16-2023, 01:34 AM
RE: Summer LASER Challenge - by GareBear - 07-15-2023, 11:54 PM
RE: Summer LASER Challenge - by Dav - 07-16-2023, 01:42 AM
RE: Summer LASER Challenge - by TerryRitchie - 07-16-2023, 01:58 AM
RE: Summer LASER Challenge - by bplus - 07-16-2023, 02:34 AM
RE: Summer LASER Challenge - by mnrvovrfc - 07-16-2023, 03:35 AM
RE: Summer LASER Challenge - by bplus - 07-16-2023, 02:21 PM
RE: Summer LASER Challenge - by TerryRitchie - 07-17-2023, 02:12 AM
RE: Summer LASER Challenge - by bplus - 07-17-2023, 02:47 PM
RE: Summer LASER Challenge - by TerryRitchie - 07-17-2023, 02:58 PM
RE: Summer LASER Challenge - by SpriggsySpriggs - 07-17-2023, 03:29 PM
RE: Summer LASER Challenge - by TerryRitchie - 07-17-2023, 04:51 PM
RE: Summer LASER Challenge - by bplus - 07-17-2023, 04:22 PM
RE: Summer LASER Challenge - by TerryRitchie - 07-17-2023, 04:34 PM
RE: Summer LASER Challenge - by bplus - 07-17-2023, 05:00 PM
RE: Summer LASER Challenge - by bplus - 07-17-2023, 06:38 PM
RE: Summer LASER Challenge - by bplus - 07-17-2023, 06:43 PM
RE: Summer LASER Challenge - by bplus - 07-18-2023, 02:58 PM
RE: Summer LASER Challenge - by bplus - 07-19-2023, 01:14 AM
RE: Summer LASER Challenge - by James D Jarvis - 07-20-2023, 02:28 AM
RE: Summer LASER Challenge - by bplus - 07-20-2023, 12:44 PM
RE: Summer LASER Challenge - by Dav - 07-21-2023, 03:00 AM
RE: Summer LASER Challenge - by bplus - 07-21-2023, 03:56 PM
RE: Summer LASER Challenge - by grymmjack - 07-21-2023, 04:46 PM
RE: Summer LASER Challenge - by bplus - 07-21-2023, 04:59 PM
RE: Summer LASER Challenge - by SierraKen - 07-27-2023, 02:38 AM
RE: Summer LASER Challenge - by bplus - 07-27-2023, 01:49 PM
RE: Summer LASER Challenge - by SierraKen - 07-27-2023, 02:41 AM
RE: Summer LASER Challenge - by TerryRitchie - 07-27-2023, 11:56 PM
RE: Summer LASER Challenge - by Dav - 07-28-2023, 12:48 AM
RE: Summer LASER Challenge - by bplus - 07-28-2023, 01:20 PM
RE: Summer LASER Challenge - by dbox - 07-28-2023, 06:56 PM
RE: Summer LASER Challenge - by bplus - 07-28-2023, 09:23 PM
RE: Summer LASER Challenge - by SierraKen - 07-29-2023, 10:13 PM
RE: Summer LASER Challenge - by OldMoses - 07-30-2023, 01:02 PM
RE: Summer LASER Challenge - by bplus - 07-30-2023, 02:28 PM
RE: Summer LASER Challenge - by bplus - 07-30-2023, 06:57 PM



Users browsing this thread: 27 Guest(s)