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
    68
    Posts
    3,865
    Rep Power
    405

    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
    7,153
    Rep Power
    736
    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 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  3. #3
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,153
    Rep Power
    736
    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 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

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

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
  •