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

Thread: A challenge porting from FreeBasic (and originally from C)

  1. #1
    Member sblank's Avatar
    Join Date
    Feb 2010
    Location
    Wayne City, Illinois
    Posts
    80
    Rep Power
    23

    A challenge porting from FreeBasic (and originally from C)

    Hi Petr, Eros, and Michael,

    I'm attaching a neat little program from FreeBasic which I translated from C. The original program was from a math professor friend of mine, George Francis (at U of I... George uses my Python OpenGL text with his REU freshmen).

    I would like to translate this program to thinBasic, but the glGetFloatv command, which fetches the aff() matrix (affine matrix) in the chaptrack() function seems problematic. Heck, there are a few other commands that are difficult for this thinBasic newbie, also!

    Anyway, if time permits, please take a look and see if anything can be recommended?

    What I like about this program is that it allows you to visualize 3D parametric surfaces and rotate them "trackball" style with the mouse (there is a python version in my text, also).

    The tro.zip file contains both the .bas file and the .exe file.

    Thanks,

    Stan
    Attached Files Attached Files

  2. #2
    Hi Stan,

    i have to go to work now and look at the code tonight if noone beats me
    to it. What do you mean by difficult for tbgl?

    Michael

  3. #3
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,138
    Rep Power
    733
    Hi Stan,

    if you need OpenGL functions, they are available via headers.

    You include them to script this way:
      #INCLUDE Once "%APP_INCLUDEPATH%\thinbasic_gl.inc"
      #INCLUDE Once "%APP_INCLUDEPATH%\thinbasic_glu.inc"
    
    as demonstrates TBGL_UsingAPI.tBasic sample script. So that's the way if you need to port the code line by line. You can freely mix TBGL and OpenGL code as you need.

    GLUT is not present in thinBasic, as its (in my opinion) unlucky architecture forcing the organization of program sparked the idea to start creating TBGL giving programmer more freedom back in 2005.

    The 3D function plotting is quite popular topic in ThinBASIC, recently the user zak presented nice implementation here:
    http://www.thinbasic.com/community/s...1268#post81268


    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
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,138
    Rep Power
    733
    Why not take advantage of ability to draw in 3D to dialog?
    Why not evaluate expressions on the fly?

    Here goes example which allows both mouse manipulation of the 3D plot, but also definition of the function on the fly. All that in resizeable ThinBASIC dialog.


    Petr
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by Petr Schreiber; 11-11-2010 at 14:39.
    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

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

    you have the ability to ... amaze your readers.

    Great example
    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

  6. #6
    Member sblank's Avatar
    Join Date
    Feb 2010
    Location
    Wayne City, Illinois
    Posts
    80
    Rep Power
    23
    Hi Michael,

    As a thinBasic and TBGL beginner, I did not see the possibility of using raw OpenGL code... but Petr has set me on the correct path!

    I'll echo Eros... Petr has the ability to amaze!

    I now have a nice programming project for the weekend!

    Thanks for the reply,

    Stan

    Quote Originally Posted by Michael Hartlef View Post
    Hi Stan,

    i have to go to work now and look at the code tonight if noone beats me
    to it. What do you mean by difficult for tbgl?

    Michael

  7. #7
    Member sblank's Avatar
    Join Date
    Feb 2010
    Location
    Wayne City, Illinois
    Posts
    80
    Rep Power
    23
    Wow... you have blown me out of the water completely!

    Very, very nice! And I mean VERY nice!

    Thanks,

    Stan

    Quote Originally Posted by Petr Schreiber View Post
    Why not take advantage of ability to draw in 3D to dialog?
    Why not evaluate expressions on the fly?

    Here goes example which allows both mouse manipulation of the 3D plot, but also definition of the function on the fly. All that in resizeable ThinBASIC dialog.


    Petr

  8. #8
    Member sblank's Avatar
    Join Date
    Feb 2010
    Location
    Wayne City, Illinois
    Posts
    80
    Rep Power
    23
    Thanks Petr,

    Great information... I wasn't aware that I could include opengl headers. Now I have a project for the weekend!

    GLUT is an odd (and old) window management system, but unfortunately for me, that is how I learned to use OpenGL. However, it is possible to teach an "old dog" new tricks and I can learn another (better) method.

    It's going to be fun working with and learning thinBasic! I can already see that there are no real limitations to anything we need to accomplish.

    Thanks again,

    Stan

    Quote Originally Posted by Petr Schreiber View Post
    Hi Stan,

    if you need OpenGL functions, they are available via headers.

    You include them to script this way:
      #INCLUDE Once "%APP_INCLUDEPATH%\thinbasic_gl.inc"
      #INCLUDE Once "%APP_INCLUDEPATH%\thinbasic_glu.inc"
    
    as demonstrates TBGL_UsingAPI.tBasic sample script. So that's the way if you need to port the code line by line. You can freely mix TBGL and OpenGL code as you need.

    GLUT is not present in thinBasic, as its (in my opinion) unlucky architecture forcing the organization of program sparked the idea to start creating TBGL giving programmer more freedom back in 2005.

    The 3D function plotting is quite popular topic in ThinBASIC, recently the user zak presented nice implementation here:
    http://www.thinbasic.com/community/s...1268#post81268


    Petr

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

    I am happy it worked for you.

    GLUT is an odd (and old) window management system, but unfortunately for me, that is how I learned to use OpenGL
    I grew up on GLUT as well, I slept with its printed specification under pillow, but there was a moment I realised I need more control - especially the glutMainLoop, which could be quit only by exiting application made me decide to seek other approaches.


    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

  10. #10
    Member sblank's Avatar
    Join Date
    Feb 2010
    Location
    Wayne City, Illinois
    Posts
    80
    Rep Power
    23
    I can understand what you mean, particularly from the programming examples you have in thinBasic and in the bonus packs. I can discard GLUT... I simply need to think differently

    My true interests in graphical programming are the visualization of mathematical objects (fractals, curves, surfaces... functional, implicit, and parametric, Riemann, etc.) and physics simulations. Your physics examples are fantastic and that is another area that I'm noting for further exploration.

    Very nice work... and I have SO much to learn!

    Stan

    Quote Originally Posted by Petr Schreiber View Post
    Thanks Stan,

    I am happy it worked for you.


    I grew up on GLUT as well, I slept with its printed specification under pillow, but there was a moment I realised I need more control - especially the glutMainLoop, which could be quit only by exiting application made me decide to seek other approaches.


    Petr

Page 1 of 2 12 LastLast

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
  •