Results 1 to 4 of 4

Thread: TBGL_GBufferDefineFromArray how without function overloading ?

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

    TBGL_GBufferDefineFromArray how without function overloading ?

    Petr, I was wondering how you handled different parameter values, like vec2f or vec3f and rgb or rgba in TBGL_GBufferDefineFromArray
    without function overloading?
    Thanks for any tips.
    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

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,778
    Blog Entries
    3
    Rep Power
    691
    Hi Kent,

    in TBGL_GBufferCreate you specify if buffer is 2D or 3D. Then the TBGL_GBufferDefineFromArray presumes 2f or 3f accordingly. I parse just pointer to whatever is passed there, so type does not matter.


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  3. #3
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,778
    Blog Entries
    3
    Rep Power
    691
    In pure thinBASIC, you can go polymorphic with passing parameter as UDT this way:
    uses "TBGL", "Console"
    
    
    dim arr2d(3) as tbgl_tVector2f
    dim arr3d(3) as tbgl_tVector3f
             
    TellMeWhatItIs(arr2d)
    TellMeWhatItIs(arr3d)
    
    
    waitkey
             
    function TellMeWhatItIs(byref x() as any)
    
    
      select case sizeOf(x(1))
        case sizeOf(tbgl_tVector2f)
          printl "It is 2D!"
          
        case sizeOf(tbgl_tVector3f)
          printl "It is 3D!"
          
        case else
          printl "I am dazed and confused"
          
      end select    
    
    
    end function
    

    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  4. #4
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    61
    Posts
    3,869
    Rep Power
    397
    Thanks Petr.
    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

Similar Threads

  1. about TALLY function
    By primo in forum thinBasic General
    Replies: 2
    Last Post: 14-02-2016, 13:52
  2. [Q]: Function f() PTR?
    By ReneMiner in forum thinBasic General
    Replies: 3
    Last Post: 18-07-2013, 20:29
  3. Replies: 4
    Last Post: 31-10-2012, 19:31
  4. Is there a bit-shift function?
    By ISAWHIM in forum thinBasic General
    Replies: 18
    Last Post: 29-09-2008, 17:05
  5. ALL & SOME function examples
    By marcuslee in forum Samples for help file
    Replies: 3
    Last Post: 08-09-2008, 21:30

Posting Permissions

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