Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Sine Wave Dynamic Texture Fonty thingy

  1. #1
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Post Sine Wave Dynamic Texture Fonty thingy

    had a play around with kryton9 code and thought back to my amiga days.

    This seems to work sometimes and not others.


    enjoy.

    Feel free to tweak. Use Left and RIght to adjust frequency.

    2012-02-13 - Updated to fix the message loop and some minor improvements
    Attached Files Attached Files
    Last edited by Michael Clease; 13-02-2012 at 21:07. Reason: update
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  2. #2

    Re: Sine Wave Dynamic Texture Fonty thingy

    Nice Effect.

    If you're interested it Ran at 32 FPS on my Laptop which hasn't got a Middle Mouse Button.
    Operating System: Windows 10 Home 64-bit
    CPU: Intel Celeron N4000 CPU @ 1.10GHz
    Memory: 4.00GB RAM
    Graphics: Intel UHD Graphics 600

  3. #3
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Re: Sine Wave Dynamic Texture Fonty thingy

    i just disabled all the timing stuff it only runs at 79 FPS

    Try changing the blocksize to a larger number.

    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  4. #4
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: Sine Wave Dynamic Texture Fonty thingy

    Cool Idea and effect.
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  5. #5
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: Sine Wave Dynamic Texture Fonty thingy

    Hi,

    thanks for the code! I love SIN function in all its forms and uses
    On my PC with onboard card it runs also at fixed 32FPS.

    Bye,
    Petr

    P.S. One thing - try to always use "TBGL_UseTexture 1/0" instead of "glEnable/glDisable ( %GL_TEXTURE_2D )", it is better optimised for TBGL pipeline. In this case it would not improve performance, but when dealing with models it could ( little bit, but yes ).

    Why ? Model buffers take care of being independent on states and they do auto cleanup, internal variables help to optimize that better than via OpenGL driver queries. Performance difference is not dramatic, but when you need to get every frame from your card ...

    P.P.S While TBGLiing your code I did something that now it runs on 64 FPS
    [code=thinbasic]
    ' Sin Wave V1.0.0.02
    ' thx to Kryton9 for pointing me in that direction
    ' based on the great base code from
    ' Demonstration of rendering to texture
    ' Copyright (C) 2005 Julien Guertault
    '
    ' Abraxas 2007
    '
    Uses "TBGL"
    USES "UI"

    #INCLUDE "%APP_INCLUDEPATH%\thinbasic_gl.inc"
    #INCLUDE "%APP_INCLUDEPATH%\thinbasic_glu.inc"

    %ScrnWidth = 640 ' Window width
    %ScrnHeight = 480 ' Window Height
    %BlockSizeX = 2 ' Size of block
    %SIZEX = 640 ' size of texture X
    %SIZEY = 72 ' Size of texture Y
    %TexTile = %SIZEx/%BlockSizeX ' For the Texture slices

    dim texture(3 * %SIZEX * %SIZEY) as GLvoid
    dim texture_id as GLuint = 1

    DIM sMsg as string
    DIM WinTITLE AS STRING VALUE "Sine Wave - press Middle mouse to quit"
    DIM Message AS STRING VALUE "Sine Wave"
    DIM X AS SINGLE VALUE 0
    DIM Y AS SINGLE VALUE 0
    dim n as SINGLE value 0
    DIM tx AS SINGLE value 0
    DIM m as SINGLE value 0
    DIM R AS SINGLE VALUE 0
    DIM a as SINGLE VALUE 0
    DIM b as SINGLE VALUE 0
    DIM Freq as SINGLE VALUE 0

    Dim ThisTime, LastTime, TimeDelta as dword
    DIM EXITFLAG AS BYTE VALUE 0

    DIM hWnd AS DWORD VALUE = TBGL_CreateWindowEx(WinTITLE, %ScrnWidth , %ScrnHeight, 32, 0) ' Creates OpenGL window, it returns handle
    DIM hFont AS DWORD = Font_Create("Courier New", 72) ' Define the Font I want to use
    TBGL_BuildFont hFont ' Build the Font
    TBGL_ClearFrame ' Prepares clear frame
    TBGL_ShowWindow ' Shows the window


    '/* Texture setting */
    tbgl_UseTexture 1
    tbgl_BindTexture texture_id
    glTexImage2D (%GL_TEXTURE_2D, 0, %GL_RGB, %SIZEX, %SIZEY, 0, %GL_RGB, %GL_UNSIGNED_BYTE, texture)
    glTexParameterF (%GL_TEXTURE_2D, %GL_TEXTURE_MIN_FILTER, %GL_LINEAR)
    glTexParameterF (%GL_TEXTURE_2D, %GL_TEXTURE_MAG_FILTER, %GL_LINEAR)
    glTexParameterF (%GL_TEXTURE_2D, %GL_TEXTURE_WRAP_S, %GL_CLAMP)
    glTexParameterF (%GL_TEXTURE_2D, %GL_TEXTURE_WRAP_T, %GL_CLAMP)

    while tbgl_isWindow(hWnd)

    LastTime = ThisTime
    ThisTime = GetTickCount
    TimeDelta= ThisTime-LastTime
    If TimeDelta = 0 THEN TimeDelta = 1

    TBGL_RenderMatrix2D
    TBGL_ClearFrame ' Prepares clear frame
    ' TBGL_ResetMatrix ' Not realy needed after CLEARFRAME
    TBGL_Camera 0,0,1,0,0,0 ' Setups camera to look from 0,0,1 to 0,0,0
    ' TBGL_Color 0, 0, 0 ' Setting color this way affects even font

    TBGL_Translate 0,0,1 '
    glDISABLE (%GL_TEXTURE_2D) ' Disable Textures

    ' IF a < 1 THEN b = +1 ' add a bit of wobble
    ' IF a > 40 THEN b = -1
    '
    ' a += b

    TBGL_Color 255,255,255 ' Setting color this way affects even font
    TBGL_PrintFont message, a, 1, 0 ' Output message to buffer
    '/* Copy buffer to texture */
    glCopyTexSubImage2D(%GL_TEXTURE_2D, 0, 0, 0, 0, 0, %SizeX, %SIZEY )

    tbgl_UseTexture 1
    tbgl_BindTexture texture_id

    for n = 1 to %ScrnWidth/%BlockSizeX
    R += Freq ' sine frequency
    tx += 1/%TexTile
    tbgl_BeginPoly %GL_QUADS
    tbgl_TexCoord2D ( tx-1/%TexTile, 0) : tbgl_Vertex ( %BlockSizeX*n-%BlockSizeX , %ScrnHeight/2+10*SIN(r+m))
    tbgl_TexCoord2D ( tx , 0) : tbgl_Vertex ( %BlockSizeX*n , %ScrnHeight/2+10*SIN(R+m))
    tbgl_TexCoord2D ( tx , 1) : tbgl_Vertex ( %BlockSizeX*n , %ScrnHeight/2+10*SIN(R+m)+100)
    tbgl_TexCoord2D ( tx-1/%TexTile, 1) : tbgl_Vertex ( %BlockSizeX*n-%BlockSizeX , %ScrnHeight/2+10*SIN(R+m)+100)
    tbgl_EndPoly
    next
    tx = 0 ' reset my sub textile counter
    r = 0 ' reset ripple
    m += 0.1 ' phase shift my sine wave
    TBGL_DrawFrame ' Swaps the buffers - displays rendered image
    TBGL_SetWindowTitle(hWnd, "Sine Wave - press ESC to quit - Running at " & TBGL_GetFramerate & " FPS Freq " & Freq )
    if tbgl_GetWindowKeyState( hWnd, %VK_LEFT) THEN
    IF Freq > 0.01 THEN Freq -=0.001
    ENDIF
    if tbgl_GetWindowKeyState( hWnd, %VK_RIGhT) THEN
    IF Freq < 0.2 THEN Freq +=0.001
    ENDIF

    if tbgl_GetWindowKeyState( hWnd, %VK_ESCAPE) THEN exitFLAG = %TRUE

    If ExitFLAG = %TRUE THEN EXIT WHILE

    if TimeDelta > 1000/70 then sleep 1000/70 '-TimeDelta


    wend

    TBGL_KillFont

    TBGL_DestroyWindow ' Closes OpenGL window
    [/code]
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  6. #6
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: Sine Wave Dynamic Texture Fonty thingy

    You know I was looking at this and thinking wow this would be a great start to a dynamic text texture editor. Have some controls to adjust parameters, color, expression, size, rotation and then save the info out to an ini file and then write a subroutine that could load from the ini, this sub would be called once, then a render subroutine that can be used to draw the effect. I guess the same could be done with regular textures too. So two powerful effects could be universal to use in all our apps.

    I would do it, but I started enough projects that I need to finish and make universal use too for out programs.
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  7. #7
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Re: Sine Wave Dynamic Texture Fonty thingy

    Petr your version doesnt work on my machine can you post the the tbasic file so i confirm its not just a cut and paste problem.

    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  8. #8
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: Sine Wave Dynamic Texture Fonty thingy

    It worked on my computer just selecting and pasting to let you know. Probably just missed getting something in the copy as you said.
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  9. #9
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: Sine Wave Dynamic Texture Fonty thingy

    Hi Abraxas,

    please find attached version here.
    But it is not better than yours, just few lines changed


    Bye,
    Petr
    Attached Files Attached Files
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  10. #10
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: Sine Wave Dynamic Texture Fonty thingy

    All the examples in this thread are giving errors. To save time, just look at the previous post's attachment from Petr.
    Abraxas_SinWave.tbasic

    It says a parenthesis is missing when there is one?
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

Page 1 of 2 12 LastLast

Similar Threads

  1. canvas sine curve
    By zak in forum UI (User Interface)
    Replies: 6
    Last Post: 19-08-2010, 21:05

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •