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

Thread: Testing older code, TB throws up

  1. #1

    Testing older code, TB throws up

    Hi Eros,

    I am browsing through my huge library of TB code from back then and found that the parser doesn't like some things these days. Maybe TB has changed in the last 7 years, i don't know.

    For an example, this function definition:

    Function SDL_LoadWAV (ByRef szFile As Asciiz, ByVal spec As SDL_AudioSpec Ptr, ByRef audio_buf As DWord, ByRef audio_len As DWord) As DWord
    
       FUNCTION = SDL_LoadWAV_RW(SDL_RWFromFile(szFile, "rb"), 1, spec, audio_buf, audio_len)
    END FUNCTION
    
    The parser complains about the PTR after SDL_AudioSpec. It expects a ). Is PTR not valid anymore?

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,782
    Rep Power
    10
    Ciao Michael,

    well, just a little some thousands of changes occurred in the last 7 years

    I will check, it should allow to pass.
    If you are in hurry just pass a LONG when you need to pass a pointer to something.

    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    No problem Eros, I am just going through some old code of mine and others I had collected over the years. And I am sure that thinBasic has envolved over such a long time. I am glad to see that you still keep your motivation high to support TB!!!!!

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,782
    Rep Power
    10
    Michael,

    I checked Core source code and I cannot find the possibility to declare function/sub parameters using PTR like: Byval <paramName> As <anytype> PTR
    I also checked in old version code but nothing.
    If you are sure it was thinBasic code, it is very strange: maybe some code ported from other Basic but never used?

    Instead that syntax is supported in thinBasic only when using DECLARE Function/Sub .... to interface external functions from DLLs.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  5. #5
    It is inside an SDL.inc file . MAybe it was a powerbasic file. The calling tbasic script was from Kent, but maybe it never worked. Sorry.

    But could you look at the attached scripts if you have a chance? The parser always complains and I don't know why?
    Attached Files Attached Files

  6. #6
    Hi Michael
    about the SDL there is an old posts here
    http://www.thinbasic.com/community/s...ders-supported
    haven't read it yet. hope it contains an answer.
    but about the buggy scripts, i have corrected 3 and still trying the fourth.
    Bezier-Try_Frankos_NURBS_2D.tbasic : thinbasic stopped at :
    %GL_MAP1_VERTEX_3 = &H00D97
    since it is loaded before, it is defined in thinbasic_gl.inc
    so i have deleted it
    HoverCraftAI_JasonMod_ works again if we corrected
    Dim stime, etime, dtime, ifps, fps as single
    seems was working before
    Attached Files Attached Files

  7. #7
    Thanks primo. I see that with the missing type declaration now (etime).
    And thanks for the link too. Next time I will better search the forum first!

    I wonder what the problem with the render text demo is.

    Eros: Imho the parser should have complaint about the missing type of give it a standard type.
    Same goes for a duplicatedefinition of identifieres.

  8. #8
    Hi Michael
    regarding RenderedTextDemo02.tbasic
    in line 31 glTexImage2D ( %GL_TEXTURE_2D.... texture) change texture to texture(1)
    and change all the words size to sizo since size seems a keyword
    the original thread is here
    http://www.thinbasic.com/community/s...namic-textures
    the Petr version in Page 2 gives more interesting graphics, just apply the same changes above
    here is kryton9 program again (corrected to the current TB version)
    ' Demo 2 of Rendered Text by Kryton9
    ' based on the great base code from
    ' Demonstration of rendering to texture
    ' Copyright (C) 2005  Julien Guertault
    
    Uses "TBGL"
    uses "UI"
    #INCLUDE "%APP_INCLUDEPATH%\thinbasic_gl.inc"
    #INCLUDE "%APP_INCLUDEPATH%\thinbasic_glu.inc"
    
    %_sizo  = 256
    
    static texture(3 * %_sizo * %_sizo) as GLvoid
    static texture_id as GLuint
    static window_width as LONG = 500 
    static window_height as LONG = 500 
    dim speed as double = 75
    dim sizze as double = 2
    dim hWnd as dword
    
    hWnd = TBGL_CreateWindowEX("Render to texture - press ESC to quit",window_width,window_height,32,0)
    TBGL_ShowWindow
     
    '/* OpenGL settings */
    glEnable (%GL_DEPTH_TEST) 
    
    '/* Texture setting */
    glEnable (%GL_TEXTURE_2D) 
    glGenTextures (1, texture_id) 
    glBindTexture (%GL_TEXTURE_2D, texture_id) 
    glTexImage2D ( %GL_TEXTURE_2D, 0, %GL_RGB, %_sizo, %_sizo, 0, %GL_RGB, %GL_UNSIGNED_BYTE, texture(1)) 
    glTexParameteri (%GL_TEXTURE_2D, %GL_TEXTURE_MIN_FILTER, %GL_LINEAR) 
    glTexParameteri (%GL_TEXTURE_2D, %GL_TEXTURE_MAG_FILTER, %GL_LINEAR) 
    glTexParameteri (%GL_TEXTURE_2D, %GL_TEXTURE_WRAP_S, %GL_CLAMP) 
    glTexParameteri (%GL_TEXTURE_2D, %GL_TEXTURE_WRAP_T, %GL_CLAMP) 
     
    GetAsyncKeyState(%VK_ESCAPE)      ' Resets ESC key status before checking
    
    while IsWindow(hWnd)
       
      glClear (%GL_COLOR_BUFFER_BIT OR %GL_DEPTH_BUFFER_BIT)
      glLoadIdentity
      glTranslatef (0, 0, -10) 
      glRotatef (30, 1, 0, 0) 
      glRotatef (GetTickCount/speed, 0, 1, 0) 
    
      '/* Define a view-port adapted to the texture */
      glMatrixMode(%GL_PROJECTION) 
      glLoadIdentity () 
      gluPerspective (20, 1, 5, 15) 
      glViewport(0, 0, %_sizo, %_sizo) 
      glMatrixMode(%GL_MODELVIEW) 
    
      '/* Render to buffer */
      glClearColor (255, 175, 1, 0) 
      glClear (%GL_COLOR_BUFFER_BIT or %GL_DEPTH_BUFFER_BIT)  
      plane()
      'Cube ()
      glFlush () 
    
      '/* Copy buffer to texture */
      glCopyTexSubImage2D(%GL_TEXTURE_2D, 0, 5, 5, 0, 0, %_sizo - 10, %_sizo - 10) 
    
      '/* Render to screen */
      glMatrixMode(%GL_PROJECTION) 
      glLoadIdentity () 
      gluPerspective (20, window_width / window_height, 5, 15) 
      glViewport(0, 0, window_width, window_height) 
      glMatrixMode(%GL_MODELVIEW) 
      glClearColor (0, 0, 0, 0) 
      glClear (%GL_COLOR_BUFFER_BIT or %GL_DEPTH_BUFFER_BIT) 
      'plane()
      Cube ()
     
      TBGL_DrawFrame
    
      if GetAsyncKeyState(%VK_ESCAPE) THEN exit while   
      if GetAsyncKeyState(%VK_UP) THEN speed += 1 : if speed <= 0 then speed = 1 endif
      if GetAsyncKeyState(%VK_DOWN) THEN speed -= 1  
      if GetAsyncKeyState(%VK_RIGHT) THEN sizze += 0.1 :sleep 100
      if GetAsyncKeyState(%VK_LEFT) THEN sizze -= 0.1 :sleep 100
      if GetAsyncKeyState(%VK_SPACE) THEN
         sizze = 2
         speed = 75
      end if
      
      TBGL_SetWindowTitle (hwnd,"ESC to quit  speed = "+Format$(speed,"0.00")+"   sizo = "+Format$(sizze,"0.00"))
      
    wend
    
    TBGL_DestroyWindow               ' Closes TBGL window
    
    
    sub Cube()
    
      glBegin %GL_QUADS 
    
      glTexCoord2i (0, 0) : glVertex3f (-1, -1, -1) 
      glTexCoord2i (0, 1) : glVertex3f (-1, -1,  1) 
      glTexCoord2i (1, 1) : glVertex3f (-1,  1,  1) 
      glTexCoord2i (1, 0) : glVertex3f (-1,  1, -1) 
    
      glTexCoord2i (0, 0) : glVertex3f ( 1, -1, -1) 
      glTexCoord2i (0, 1) : glVertex3f ( 1, -1,  1) 
      glTexCoord2i (1, 1) : glVertex3f ( 1,  1,  1) 
      glTexCoord2i (1, 0) : glVertex3f ( 1,  1, -1) 
    
      glTexCoord2i (0, 0) : glVertex3f (-1, -1, -1) 
      glTexCoord2i (0, 1) : glVertex3f (-1, -1,  1) 
      glTexCoord2i (1, 1) : glVertex3f ( 1, -1,  1) 
      glTexCoord2i (1, 0) : glVertex3f ( 1, -1, -1) 
    
      glTexCoord2i (0, 0) : glVertex3f (-1,  1, -1) 
      glTexCoord2i (0, 1) : glVertex3f (-1,  1,  1) 
      glTexCoord2i (1, 1) : glVertex3f ( 1,  1,  1) 
      glTexCoord2i (1, 0) : glVertex3f ( 1,  1, -1) 
    
      glTexCoord2i (0, 0) : glVertex3f (-1, -1, -1) 
      glTexCoord2i (0, 1) : glVertex3f (-1,  1, -1) 
      glTexCoord2i (1, 1) : glVertex3f ( 1,  1, -1) 
      glTexCoord2i (1, 0) : glVertex3f ( 1, -1, -1) 
    
      glTexCoord2i (0, 0) : glVertex3f (-1, -1,  1) 
      glTexCoord2i (0, 1) : glVertex3f (-1,  1,  1) 
      glTexCoord2i (1, 1) : glVertex3f ( 1,  1,  1) 
      glTexCoord2i (1, 0) : glVertex3f ( 1, -1,  1) 
    
      glEnd 
    end sub
    
    sub plane()
     glBegin %GL_QUADS
        glColor3ub 255,   0,   0 : glTexCoord2i 0,0 : glVertex3f -sizze , -sizze, 0 
        glColor3ub 0  , 255,   0 : glTexCoord2i 0,1 : glVertex3f  sizze , -sizze, 0
        glColor3ub 0  ,   0, 255 : glTexCoord2i 1,1 : glVertex3f  sizze ,  sizze, 0
        glColor3ub 255, 200,   0 : glTexCoord2i 1,0 : glVertex3f -sizze ,  sizze, 0
      glEnd 
      glColor3ub 255, 175, 0
    end sub
    

  9. #9
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,782
    Rep Power
    10
    Quote Originally Posted by Michael Hartlef View Post
    It is inside an SDL.inc file . MAybe it was a powerbasic file. The calling tbasic script was from Kent, but maybe it never worked. Sorry.

    But could you look at the attached scripts if you have a chance? The parser always complains and I don't know why?
    In script scrollingtext_2.tbasic variable defined twice

    FUNCTION ScrollText()  STATIC MoveLeft as boolean = %true
      STATIC cx,cy, xpos as long
      static Characterwidth as long = 12       ' change this value if you choose another font. Always use a fixed font, otherwise it won't work.
      Static maxpos As Long = (Len($ScrollText)*Characterwidth)-cx
      Static MoveLeft As Boolean = %TRUE     '<<<-----------Defined twice
    
    In script RenderedTextDemo02.tbasic a pointer to the first element of the array is needed, 9th parameter is declared as GLpointer (alias of DWord) while texture is declared as GLVoid alias of ANY.
    So pass somthing like VarPtr(texture(1))

    glTexImage2D ( %GL_TEXTURE_2D, 0, %GL_RGB, %_SIZE, %_SIZE, 0, %GL_RGB, %GL_UNSIGNED_BYTE, VarPtr(texture(1)))
    
    In script HoverCraftAI_JasonMod_.tbasic some variables are declared as VARIANT because they have no type declared.
    In older versions of thinBasic variables declared without type were considered DOUBLE but when I introduced VARIANT this changed.

    Change line 8 from
    Dim stime, etime, dtime, ifps, fps As Quad
    
    to
    Dim stime, etime, dtime, ifps, fps As Quad as Quad '---or whatever type
    

    In script Bezier-Try_Frankos_NURBS_2D.tbasic an hexadecimal number is not valid. It must have an even number of digits after &H.

    Change line 9 from
    %GL_MAP1_VERTEX_3 = &H00D97
    
    to something like
    %GL_MAP1_VERTEX_3 = &H000D97
    



    I will see if I can better intercepts those kind of errors and give better error messages.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  10. #10
    Thank you both!!!

Page 1 of 2 12 LastLast

Similar Threads

  1. Possible approaches for testing
    By Petr Schreiber in forum thinBasic Beta testing
    Replies: 1
    Last Post: 12-11-2015, 19:06
  2. funDialox demo (testing)
    By Lionheart008 in forum Module Classes
    Replies: 9
    Last Post: 12-05-2012, 09:12
  3. SandBox Testing
    By ISAWHIM in forum Code
    Replies: 15
    Last Post: 12-10-2008, 11:12

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
  •