Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pixelling OpenGl
#1
Hi
I must confirm that the interaction and the possibility to share ideas and thoughts is fundamental to keep alive the joy of coding.
It often happens that reading post of other member of this community an idea of a project borns as reflex of the post or as a travel starting from the post.

Here a demo that I started it looking at the Kpop matrix code of Vince and shifting towards a different plan/goal.
some screenshots

[Image: Pixelling-in-Open-Gl-1.jpg]


[Image: Pixelling-in-Open-Gl-2.jpg]


[Image: Pixelling-in-Open-Gl-3.jpg]


[Image: Pixelling-in-Open-Gl-4.jpg]

the first three are taken from videos ( the 1st and the 2nd from The Persuaders! Roger Moore & Tony Curtis the 3rd from a video played by MediaPlayer) while the 4th has been taken from Browser on Kpop Matrix thread


here the code to copy, paste, save and run in QB64pe
Code: (Select All)

Rem starting from the cool demo of Vince: Kpop matrix at this URL "https://qb64phoenix.com/forum/showthread.php?tid=3518"
Rem Pixelling in OpenGl is the answer to the question: how could be done in OpenGl without characters?
Rem so this snippet transforms the image of the whole screen into a pixel model using a pixel with dimensions width 8 and height 16


DefLng A-Z

Dim Init As Integer
Init = 0
img = _ScreenImage ' it takes the screen and its width and height
Sw = _Width(img)
Sh = _Height(img)
W = (Sw / 2)
H = Sh - 80 ' it excludes the title bar of window
Screen _NewImage(W, H, 32) ' it creates a window large the half of screen desktop
_ScreenMove W, 0 ' it moves windows on the right half of desktop
_Title "Pixelling in OpenGl"

Init = 2 ' it starts to use OpenGL graphic
Do
    img = _ScreenImage(0, 0, Sw / 2, Sh) ' it captures the left half screen
    _Source img ' it reads from img
    _Limit 30
Loop Until _KeyHit = 27
End

Sub _GL
    Shared Sw As Long, Sh As Long, Init As Integer
    ' initialization of gl side
    If Init = 0 Then
        _glViewport 0, 0, Sw / 4, Sh / 2 ' it sets viewport
        _glClearColor 0, 0, 0, 0 ' it sets color used for delete images
        Init = 1 ' flag goes to the next stadium
        Exit Sub
    ElseIf Init = 1 Then
        Exit Sub ' it is too early to make Opengl graphic outuput
    End If

    _glMatrixMode _GL_MODELVIEW 'it sets stack modelview as matrix for operations
    _glTranslatef -1, 1, 0 ' it translates the new graphic operations with this matrix towards matrix of matrixmode
    _glScalef (1 / (Sw / 4)), (-1 / (Sh / 2)), 1 'it mulitplies the current matrix with matrix of scaling passed as arguments

    For Y = 0 To (Sh / 16) - 1 ' for the height of image using h character image as meter
        For X = 0 To (Sw / 8) - 1 ' for the width of image using w character image as meter

            z = Point(X * 8 + 4, Y * 16 + 8) 'it takes color of pixel

            _glColor3ub _Red(z), _Green(z), _Blue(z) ' it sets the RGB  of color of pixel

            _glBegin _GL_QUADS ' it draws a filled square/rectangle with the following vertexes
            _glVertex2f X * 8, Y * 16
            _glVertex2f X * 8, (Y + 1) * 16
            _glVertex2f (X + 1) * 8, (Y + 1) * 16
            _glVertex2f (X + 1) * 8, Y * 16
            _glEnd
        Next
    Next
    _glFlush ' it forces to show OpenGl output
End Sub

PS 
The Persuaders was a cult serie in my childhood, do you know this serie?
Reply
#2
(03-17-2025, 09:48 PM)TempodiBasic Wrote: Hi
I must confirm that the interaction and the possibility to share ideas and thoughts is fundamental to keep alive the joy of coding.
It often happens that reading post of other member of this community an idea of a project borns as reflex of the post or as a travel starting from the post.

Here a demo that I started it looking at the Kpop matrix code of Vince and shifting towards a different plan/goal.
some screenshots

[Image: Pixelling-in-Open-Gl-1.jpg]


[Image: Pixelling-in-Open-Gl-2.jpg]


[Image: Pixelling-in-Open-Gl-3.jpg]


[Image: Pixelling-in-Open-Gl-4.jpg]

the first three are taken from videos ( the 1st and the 2nd from The Persuaders! Roger Moore & Tony Curtis the 3rd from a video played by MediaPlayer) while the 4th has been taken from Browser on Kpop Matrix thread


here the code to copy, paste, save and run in QB64pe
Code: (Select All)

Rem starting from the cool demo of Vince: Kpop matrix at this URL "https://qb64phoenix.com/forum/showthread.php?tid=3518"
Rem Pixelling in OpenGl is the answer to the question: how could be done in OpenGl without characters?
Rem so this snippet transforms the image of the whole screen into a pixel model using a pixel with dimensions width 8 and height 16


DefLng A-Z

Dim Init As Integer
Init = 0
img = _ScreenImage ' it takes the screen and its width and height
Sw = _Width(img)
Sh = _Height(img)
W = (Sw / 2)
H = Sh - 80 ' it excludes the title bar of window
Screen _NewImage(W, H, 32) ' it creates a window large the half of screen desktop
_ScreenMove W, 0 ' it moves windows on the right half of desktop
_Title "Pixelling in OpenGl"

Init = 2 ' it starts to use OpenGL graphic
Do
    img = _ScreenImage(0, 0, Sw / 2, Sh) ' it captures the left half screen
    _Source img ' it reads from img
    _Limit 30
Loop Until _KeyHit = 27
End

Sub _GL
    Shared Sw As Long, Sh As Long, Init As Integer
    ' initialization of gl side
    If Init = 0 Then
        _glViewport 0, 0, Sw / 4, Sh / 2 ' it sets viewport
        _glClearColor 0, 0, 0, 0 ' it sets color used for delete images
        Init = 1 ' flag goes to the next stadium
        Exit Sub
    ElseIf Init = 1 Then
        Exit Sub ' it is too early to make Opengl graphic outuput
    End If

    _glMatrixMode _GL_MODELVIEW 'it sets stack modelview as matrix for operations
    _glTranslatef -1, 1, 0 ' it translates the new graphic operations with this matrix towards matrix of matrixmode
    _glScalef (1 / (Sw / 4)), (-1 / (Sh / 2)), 1 'it mulitplies the current matrix with matrix of scaling passed as arguments

    For Y = 0 To (Sh / 16) - 1 ' for the height of image using h character image as meter
        For X = 0 To (Sw / 8) - 1 ' for the width of image using w character image as meter

            z = Point(X * 8 + 4, Y * 16 + 8) 'it takes color of pixel

            _glColor3ub _Red(z), _Green(z), _Blue(z) ' it sets the RGB  of color of pixel

            _glBegin _GL_QUADS ' it draws a filled square/rectangle with the following vertexes
            _glVertex2f X * 8, Y * 16
            _glVertex2f X * 8, (Y + 1) * 16
            _glVertex2f (X + 1) * 8, (Y + 1) * 16
            _glVertex2f (X + 1) * 8, Y * 16
            _glEnd
        Next
    Next
    _glFlush ' it forces to show OpenGl output
End Sub

PS 
The Persuaders was a cult serie in my childhood, do you know this serie?

Nice project! The Persuaders is a classic, love that retro vibe. Did the show inspire the pixel effects?
Reply
#3
Quote: Did the show inspire the pixel effects?
yeah the original answer to the question  "aside the characters of ASCII art, how was the graphic in the time of that show?"  is " a low level graphic with too few pixel so that lines were like stairs with steps" 
and so I went on
Reply
#4
wow looks familiar, very nice
Reply




Users browsing this thread: 1 Guest(s)