Author Topic: FBSL Capabilities  (Read 8813 times)

0 Members and 1 Guest are viewing this topic.

JRS

  • Guest
FBSL Capabilities
« on: October 12, 2015, 01:29:48 PM »
It's good to see things back to normal:)
« Last Edit: October 13, 2015, 11:54:55 PM by o2admin »

Patrice Terrier

  • Guest
Re: FBSL Capabilities
« Reply #1 on: October 13, 2015, 12:19:11 AM »
To set it even more normal, here is my personnal opinion about FSBL, i also wonder why to put so much work into something used by just a few.

For me it looks like an hybrid sitting between two chairs (c and basic), and this is not a comfortable position because you have to choose between father and mother, as soon as you need to do advanced stuffs.

...

Mike Lobanovsky

  • Guest
Re: FBSL Capabilities
« Reply #2 on: October 13, 2015, 08:54:37 AM »
Hi Charles,

It was a dull Sunday evening, and there was absolutely nothing new or interesting on the BASIC sites I'm in the habit of frequenting, and I was bored, so just for lolz I decided to try and troll Aurel a little (from a distance, with a twig) through some gentle and innocent off-topic to see if he was still alive and kicking. He was, and he responded as expected, and John also chimed in. So there we were, the three thickest trolls of all time in the BASIC world -- me, Aurel, and John -- with our short fugitive exchange of cheerful smily messages that indicated we were all doing well. The eveng didn't look so gloomy to me any more. :)

In contrast to that, Patrice's "advanced stuff" ramification seems to be totally out of this thread's context but still deserves a detailed response since it kind of touches on FBSL's esprit de corps.

Could you move Patrice's message above together with my messages below (please allow me some time to write them) out of this thread and into a separate arbitrarily named topic somewhere on the Open Forum board?

Let Aurel continue to instruct his numerous followers in this O2-specific technical thread unhindered. :)

TIA
« Last Edit: October 13, 2015, 12:46:32 PM by Mike Lobanovsky »

Mike Lobanovsky

  • Guest
Re: FBSL Capabilities
« Reply #3 on: October 13, 2015, 10:49:44 AM »
Hi Patrice,

I'm afraid you aren't fair to me and my FBSL. Perhaps you're yet failing to grasp the full power of FBSL that hosts three self-sufficient and industry-wide compatible independent languages and a lot of built-in libraries to match in one tiny little executable that's usually about 270KB in size, or only 2.5KB+ large when used with the matching Fbsl.dll runtime. The possibility available in FBSL for these three languages to interact with each other directly under a common hood is a welcome extra bonus but not a requirement.

I'm restricted to 20000 chars and can't paste here everything I'd like to, so this message is

to be cont'd...

Mike Lobanovsky

  • Guest
Re: FBSL Capabilities
« Reply #4 on: October 13, 2015, 10:52:11 AM »
(cont'd)

Below is an example of DynC-based JIT compilable FBSL script that doesn't use a single byte of any other language besides ANSI C to run a well known NeHe OpenGL tutorial. The code is copy-paste compatible with GCC or TCC in its entirety and uses standard headers from the MinGW/GCC distro, and the original author's ANSI C code, in the other include files.

Code: C
  1. DynC Main()
  2.  
  3.   /***********************************************
  4.   *                                              *
  5.   *        Jeff Molofee's OpenGL Basecode        *
  6.   *                                              *
  7.   *            http://nehe.gamedev.net           *
  8.   *                                              *
  9.   *                    2003                      *
  10.   *                                              *
  11.   ***********************************************/
  12.  
  13.   #include <windows.h> // Header File For The Windows Library
  14.   #include <gl/gl.h> // Header File For The OpenGL32 Library
  15.   #include <gl/glu.h> // Header File For The GLu32 Library
  16.   #include "Data/NeHeGL.h" // Header File For The NeHeGL Basecode
  17.  
  18.   #pragma comment(lib, "opengl32")
  19.   #pragma comment(lib, "glu32")
  20.  
  21.   #define WM_TOGGLEFULLSCREEN(WM_USER + 1) // Application Define Message For Toggling
  22.  
  23.   static BOOL g_isProgramLooping; // Window Creation Loop, For FullScreen/Windowed Toggle
  24.                                   // Between Fullscreen / Windowed Mode
  25.   static BOOL g_createFullScreen; // If TRUE, Then Create Fullscreen
  26.  
  27.   #include "Data/GLWindow.h" // Jeff Molofee's GL Window Basecode
  28.  
  29.   // Program Entry (WinMain)
  30.   int main()
  31.   {
  32.     Application application; // Application Structure
  33.     GL_Window window; // Window Structure
  34.     Keys keys; // Key Structure
  35.     BOOL isMessagePumpActive; // Message Pump Active?
  36.     MSG msg; // Window Message Structure
  37.    
  38.     // Fill Out Application Data
  39.     application.className = "OpenGL"; // Application Class Name
  40.     application.hInstance = GetModuleHandle(NULL); // Application Instance
  41.    
  42.     // Fill Out Window
  43.     ZeroMemory(&window, sizeof(GL_Window)); // Make Sure Memory Is Zeroed
  44.     window.keys = &keys; // Window Key Structure
  45.     window.init.application = &application; // Window Application
  46.    
  47.     // Window Title
  48.     window.init.title = "Lesson 42: Multiple Viewports... 2003 NeHe Productions... Building Maze!";
  49.    
  50.     window.init.width = 1024; // Window Width
  51.     window.init.height = 768; // Window Height
  52.     window.init.bitsPerPixel = 32; // Bits Per Pixel
  53.     window.init.isFullScreen = TRUE; // Fullscreen? (Set To TRUE)
  54.    
  55.     ZeroMemory(&keys, sizeof(Keys)); // Zero keys Structure
  56.    
  57.     // Ask The User If They Want To Start In FullScreen Mode? (Remove These 4 Lines If You Want To Force Fullscreen)
  58.     if (MessageBox(HWND_DESKTOP, "Would You Like To Run In Fullscreen Mode?", "Start FullScreen?", MB_YESNO | MB_ICONQUESTION) == IDNO)
  59.     {
  60.       window.init.isFullScreen = FALSE; // If Not, Run In Windowed Mode
  61.     }
  62.    
  63.     // Register A Class For Our Window To Use
  64.     if (RegisterWindowClass(&application) == FALSE) // Did Registering A Class Fail?
  65.     {
  66.       // Failure
  67.       MessageBox(HWND_DESKTOP, "Error Registering Window Class!", "Error", MB_OK | MB_ICONEXCLAMATION);
  68.       return -1; // Terminate Application
  69.     }
  70.    
  71.     g_isProgramLooping = TRUE; // Program Looping Is Set To TRUE
  72.     g_createFullScreen = window.init.isFullScreen; // g_createFullScreen Is Set To User Default
  73.     while (g_isProgramLooping) // Loop Until WM_QUIT Is Received
  74.     {
  75.       // Create A Window
  76.       window.init.isFullScreen = g_createFullScreen; // Set Init Param Of Window Creation To Fullscreen?
  77.       if (CreateWindowGL(&window) == TRUE) // Was Window Creation Successful?
  78.       {
  79.         // At This Point We Should Have A Window That Is Setup To Render OpenGL
  80.         if (Initialize(&window, &keys) == FALSE) // Call User Initialization
  81.         {
  82.           // Failure
  83.           TerminateApplication(&window); // Close Window, This Will Handle The Shutdown
  84.         }
  85.         else // Otherwise (Start The Message Pump)
  86.         { // Initialize was a success
  87.           isMessagePumpActive = TRUE; // Set isMessagePumpActive To TRUE
  88.           while (isMessagePumpActive == TRUE) // While The Message Pump Is Active
  89.           {
  90.             // Success Creating Window.  Check For Window Messages
  91.             if (PeekMessage(&msg, window.hWnd, 0, 0, PM_REMOVE) != 0)
  92.             {
  93.               // Check For WM_QUIT Message
  94.               if (msg.message != WM_QUIT) // Is The Message A WM_QUIT Message?
  95.               {
  96.                 DispatchMessage(&msg); // If Not, Dispatch The Message
  97.               }
  98.               else // Otherwise (If Message Is WM_QUIT)
  99.               {
  100.                 isMessagePumpActive = FALSE; // Terminate The Message Pump
  101.               }
  102.             }
  103.             else // If There Are No Messages
  104.             {
  105.               if (window.isVisible == FALSE) // If Window Is Not Visible
  106.               {
  107.                 WaitMessage(); // Application Is Minimized Wait For A Message
  108.               }
  109.             }
  110.           } // Loop While isMessagePumpActive == TRUE
  111.         } // If (Initialize (...
  112.        
  113.         // Application Is Finished
  114.         Deinitialize(); // User Defined DeInitialization
  115.        
  116.         DestroyWindowGL(&window); // Destroy The Active Window
  117.       }
  118.       else // If Window Creation Failed
  119.       {
  120.         // Error Creating Window
  121.         MessageBox(HWND_DESKTOP, "Error Creating OpenGL Window", "Error", MB_OK | MB_ICONEXCLAMATION);
  122.         g_isProgramLooping = FALSE; // Terminate The Loop
  123.       }
  124.     } // While (isProgramLooping)
  125.    
  126.     UnregisterClass(application.className, application.hInstance); // UnRegister Window Class
  127.     return 0;
  128.   } // End Of WinMain()
  129.  
  130.   GL_Window* g_window; // Window Structure
  131.   Keys* g_keys; // Keyboard
  132.  
  133.   // User Defined Variables
  134.   int mx, my; // General Loops (Used For Seeking)
  135.  
  136.   const width = 128; // Maze Width  (Must Be A Power Of 2)
  137.   const height = 128; // Maze Height (Must Be A Power Of 2)
  138.  
  139.   BOOL done; // Flag To Let Us Know When It's Done
  140.   BOOL sp; // Spacebar Pressed?
  141.  
  142.   BYTE r[4], g[4], b[4]; // Random Colors (4 Red, 4 Green, 4 Blue)
  143.   BYTE* tex_data; // Holds Our Texture Data
  144.  
  145.   GLfloat xrot, yrot, zrot; // Use For Rotation Of Objects
  146.  
  147.   GLUquadricObj* quadric; // The Quadric Object
  148.  
  149.   void UpdateTex(int dmx, int dmy) // Update Pixel dmx, dmy On The Texture
  150.   {
  151.     tex_data[0 + ((dmx + (width* dmy))* 3)] = 255; // Set Red Pixel To Full Bright
  152.     tex_data[1 + ((dmx + (width* dmy))* 3)] = 255; // Set Green Pixel To Full Bright
  153.     tex_data[2 + ((dmx + (width* dmy))* 3)] = 255; // Set Blue Pixel To Full Bright
  154.   }
  155.  
  156.   void Reset(void) // Reset The Maze, Colors, Start Point, Etc
  157.   {
  158.     int loop;
  159.    
  160.     ZeroMemory(tex_data, width* height* 3); // Clear Out The Texture Memory With 0's
  161.    
  162.     srand(GetTickCount()); // Try To Get More Randomness
  163.    
  164.     for (loop = 0; loop < 4; loop++) // Loop So We Can Assign 4 Random Colors
  165.     {
  166.       r[loop] = rand() % 128 + 128; // Pick A Random Red Color (Bright)
  167.       g[loop] = rand() % 128 + 128; // Pick A Random Green Color (Bright)
  168.       b[loop] = rand() % 128 + 128; // Pick A Random Blue Color (Bright)
  169.     }
  170.    
  171.     mx = (int)(rand() % (width / 2)) * 2; // Pick A New Random X Position
  172.     my = (int)(rand() % (height / 2)) * 2; // Pick A New Random Y Position
  173.   }
  174.  
  175.   BOOL Initialize(GL_Window* window, Keys* keys) // Any GL Init Code & User Initialiazation Goes Here
  176.   {
  177.     tex_data = (BYTE*)malloc(width * height * 3); // Allocate Space For Our Texture
  178.    
  179.     g_window = window; // Window Values
  180.     g_keys = keys; // Key Values
  181.    
  182.     Reset(); // Call Reset To Build Our Initial Texture, Etc.
  183.    
  184.     // Start Of User Initialization
  185.     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
  186.     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
  187.     glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  188.     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  189.     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, tex_data);
  190.    
  191.     glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background
  192.     glClearDepth(1.0f); // Depth Buffer Setup
  193.    
  194.     glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing
  195.     glEnable(GL_DEPTH_TEST); // Enable Depth Testing
  196.    
  197.     glEnable(GL_COLOR_MATERIAL); // Enable Color Material (Allows Us To Tint Textures)
  198.    
  199.     glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
  200.    
  201.     quadric = gluNewQuadric(); // Create A Pointer To The Quadric Object
  202.     gluQuadricNormals(quadric, GLU_SMOOTH); // Create Smooth Normals
  203.     gluQuadricTexture(quadric, GL_TRUE); // Create Texture Coords
  204.    
  205.     glEnable(GL_LIGHT0); // Enable Light0 (Default GL Light)
  206.    
  207.     return TRUE; // Return TRUE (Initialization Successful)
  208.   }
  209.  
  210.   void Deinitialize(void) // Any User DeInitialization Goes Here
  211.   {
  212.     free(tex_data); // Delete Our Texture Data (Freeing Up Memory)
  213.   }
  214.  
  215.   void Update(float milliseconds) // Perform Motion Updates Here
  216.   {
  217.     int dir, x, y; // Will Hold Current Direction
  218.    
  219.     if (g_keys->keyDown[VK_ESCAPE]) // Is ESC Being Pressed?
  220.     TerminateApplication(g_window); // Terminate The Program
  221.    
  222.     if (g_keys->keyDown[VK_F1]) // Is F1 Being Pressed?
  223.     ToggleFullscreen(g_window); // Toggle Fullscreen Mode
  224.    
  225.     if (g_keys->keyDown[0x20] && !sp) // Check To See If Spacebar Is Pressed
  226.     {
  227.       sp = TRUE; // If So, Set sp To TRUE (Spacebar Pressed)
  228.       Reset(); // If So, Call Reset And Start A New Maze
  229.     }
  230.    
  231.     if (!g_keys->keyDown[0x20]) // Check To See If Spacebar Has Been Released
  232.     sp = FALSE; // If So, Set sp To FALSE (Spacebar Released)
  233.    
  234.     xrot += (float)(milliseconds) * 0.02f; // Increase Rotation On The X-Axis
  235.     yrot += (float)(milliseconds) * 0.03f; // Increase Rotation On The Y-Axis
  236.     zrot += (float)(milliseconds) * 0.015f; // Increase Rotation On The Z-Axis
  237.    
  238.     done = TRUE; // Set done To True
  239.     for (x = 0; x < width; x += 2) // Loop Through All The Rooms
  240.     {
  241.       for (y = 0; y < height; y += 2) // On X And Y Axis
  242.       {
  243.         if (tex_data[((x + (width* y))* 3)] == 0) // If Current Texture Pixel (Room) Is Blank
  244.         done = FALSE; // We Have To Set done To False (Not Finished Yet)
  245.       }
  246.     }
  247.    
  248.     if (done) // If done Is True Then There Were No Unvisited Rooms
  249.     {
  250.       // Display A Message At The Top Of The Window, Pause For A Bit And Then Start Building A New Maze!
  251.       SetWindowText(g_window->hWnd, "Lesson 42: Multiple Viewports... 2003 NeHe Productions... Maze Complete!");
  252.       Sleep(5000);
  253.       SetWindowText(g_window->hWnd, "Lesson 42: Multiple Viewports... 2003 NeHe Productions... Building Maze!");
  254.       Reset();
  255.     }
  256.    
  257.     // Check To Make Sure We Are Not Trapped (Nowhere Else To Move)
  258.     if (((mx > (width - 4) || tex_data[(((mx + 2) + (width* my))* 3)] == 255)) && ((mx < 2 || tex_data[(((mx - 2) + (width * my)) * 3)] == 255)) &&
  259.     ((my > (height - 4) || tex_data[((mx + (width* (my + 2)))* 3)] == 255)) && ((my < 2 || tex_data[((mx + (width * (my - 2))) * 3)] == 255)))
  260.     {
  261.       do // If We Are Trapped
  262.       {
  263.         mx = (int)(rand() % (width / 2)) * 2; // Pick A New Random X Position
  264.         my = (int)(rand() % (height / 2)) * 2; // Pick A New Random Y Position
  265.       }
  266.       while (tex_data[((mx + (width* my))* 3)] == 0); // Keep Picking A Random Position Until We Find
  267.     } // One That Has Already Been Tagged (Safe Starting Point)
  268.    
  269.     dir = (int)(rand() % 4); // Pick A Random Direction
  270.    
  271.     if ((dir == 0) && (mx <= (width - 4))) // If The Direction Is 0 (Right) And We Are Not At The Far Right
  272.     {
  273.       if (tex_data[(((mx + 2) + (width* my))* 3)] == 0) // And If The Room To The Right Has Not Already Been Visited
  274.       {
  275.         UpdateTex(mx + 1, my); // Update The Texture To Show Path Cut Out Between Rooms
  276.         mx += 2; // Move To The Right (Room To The Right)
  277.       }
  278.     }
  279.    
  280.     else if ((dir == 1) && (my <= (height - 4))) // If The Direction Is 1 (Down) And We Are Not At The Bottom
  281.     {
  282.       if (tex_data[((mx + (width* (my + 2)))* 3)] == 0) // And If The Room Below Has Not Already Been Visited
  283.       {
  284.         UpdateTex(mx, my + 1); // Update The Texture To Show Path Cut Out Between Rooms
  285.         my += 2; // Move Down (Room Below)
  286.       }
  287.     }
  288.    
  289.     else if ((dir == 2) && (mx >= 2)) // If The Direction Is 2 (Left) And We Are Not At The Far Left
  290.     {
  291.       if (tex_data[(((mx - 2) + (width* my))* 3)] == 0) // And If The Room To The Left Has Not Already Been Visited
  292.       {
  293.         UpdateTex(mx - 1, my); // Update The Texture To Show Path Cut Out Between Rooms
  294.         mx -= 2; // Move To The Left (Room To The Left)
  295.       }
  296.     }
  297.    
  298.     else if ((dir == 3) && (my >= 2)) // If The Direction Is 3 (Up) And We Are Not At The Top
  299.     {
  300.       if (tex_data[((mx + (width* (my - 2)))* 3)] == 0) // And If The Room Above Has Not Already Been Visited
  301.       {
  302.         UpdateTex(mx, my - 1); // Update The Texture To Show Path Cut Out Between Rooms
  303.         my -= 2; // Move Up (Room Above)
  304.       }
  305.     }
  306.    
  307.     UpdateTex(mx, my); // Update Current Room
  308.   }
  309.  
  310.   void Draw(void) // Our Drawing Routine
  311.   {
  312.     RECT rect; // Holds Coordinates Of A Rectangle
  313.     int loop;
  314.    
  315.     GetClientRect(g_window->hWnd, &rect); // Get Window Dimensions
  316.     int window_width = rect.right - rect.left; // Calculate The Width (Right Side-Left Side)
  317.     int window_height = rect.bottom - rect.top; // Calculate The Height (Bottom-Top)
  318.    
  319.     // Update Our Texture... This Is The Key To The Programs Speed... Much Faster Than Rebuilding The Texture Each Time
  320.     glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, tex_data);
  321.    
  322.     glClear(GL_COLOR_BUFFER_BIT); // Clear Screen
  323.    
  324.     for (loop = 0; loop < 4; loop++) // Loop To Draw Our 4 Views
  325.     {
  326.       glColor3ub(r[loop], g[loop], b[loop]); // Assign Color To Current View
  327.      
  328.       if (loop == 0) // If We Are Drawing The First Scene
  329.       {
  330.         // Set The Viewport To The Top Left.  It Will Take Up Half The Screen Width And Height
  331.         glViewport(0, window_height / 2, window_width / 2, window_height / 2);
  332.         glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
  333.         glLoadIdentity(); // Reset The Projection Matrix
  334.         // Set Up Ortho Mode To Fit 1/4 The Screen (Size Of A Viewport)
  335.         gluOrtho2D(0, window_width / 2, window_height / 2, 0);
  336.       }
  337.      
  338.       else if (loop == 1) // If We Are Drawing The Second Scene
  339.       {
  340.         // Set The Viewport To The Top Right.  It Will Take Up Half The Screen Width And Height
  341.         glViewport(window_width / 2, window_height / 2, window_width / 2, window_height / 2);
  342.         glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
  343.         glLoadIdentity(); // Reset The Projection Matrix
  344.         // Set Up Perspective Mode To Fit 1/4 The Screen (Size Of A Viewport)
  345.         gluPerspective(45.0, (GLfloat)(width) / (GLfloat)(height), 0.1f, 500.0);
  346.       }
  347.      
  348.       else if (loop == 2) // If We Are Drawing The Third Scene
  349.       {
  350.         // Set The Viewport To The Bottom Right.  It Will Take Up Half The Screen Width And Height
  351.         glViewport(window_width / 2, 0, window_width / 2, window_height / 2);
  352.         glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
  353.         glLoadIdentity(); // Reset The Projection Matrix
  354.         // Set Up Perspective Mode To Fit 1/4 The Screen (Size Of A Viewport)
  355.         gluPerspective(45.0, (GLfloat)(width) / (GLfloat)(height), 0.1f, 500.0);
  356.       }
  357.      
  358.       else // If We Are Drawing The Fourth Scene
  359.       {
  360.         // Set The Viewport To The Bottom Left.  It Will Take Up Half The Screen Width And Height
  361.         glViewport(0, 0, window_width / 2, window_height / 2);
  362.         glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
  363.         glLoadIdentity(); // Reset The Projection Matrix
  364.         // Set Up Perspective Mode To Fit 1/4 The Screen (Size Of A Viewport)
  365.         gluPerspective(45.0, (GLfloat)(width) / (GLfloat)(height), 0.1f, 500.0);
  366.       }
  367.      
  368.       glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
  369.       glLoadIdentity(); // Reset The Modelview Matrix
  370.      
  371.       glClear(GL_DEPTH_BUFFER_BIT); // Clear Depth Buffer
  372.      
  373.       if (loop == 0) // Are We Drawing The First Image?  (Original Texture... Ortho)
  374.       {
  375.         glBegin(GL_QUADS); // Begin Drawing A Single Quad
  376.         // We Fill The Entire 1/4 Section With A Single Textured Quad.
  377.         glTexCoord2f(1.0f, 0.0f); glVertex2i(window_width / 2, 0);
  378.         glTexCoord2f(0.0f, 0.0f); glVertex2i(0, 0);
  379.         glTexCoord2f(0.0f, 1.0f); glVertex2i(0, window_height / 2);
  380.         glTexCoord2f(1.0f, 1.0f); glVertex2i(window_width / 2, window_height / 2);
  381.         glEnd(); // Done Drawing The Textured Quad
  382.       }
  383.      
  384.       else if (loop == 1) // Are We Drawing The Second Image?  (3D Texture Mapped Sphere... Perspective)
  385.       {
  386.         glTranslatef(0.0f, 0.0f, -14.0f); // Move 14 Units Into The Screen
  387.        
  388.         glRotatef(xrot, 1.0f, 0.0f, 0.0f); // Rotate By xrot On The X-Axis
  389.         glRotatef(yrot, 0.0f, 1.0f, 0.0f); // Rotate By yrot On The Y-Axis
  390.         glRotatef(zrot, 0.0f, 0.0f, 1.0f); // Rotate By zrot On The Z-Axis
  391.        
  392.         glEnable(GL_LIGHTING); // Enable Lighting
  393.         gluSphere(quadric, 4.0f, 32, 32); // Draw A Sphere
  394.         glDisable(GL_LIGHTING); // Disable Lighting
  395.       }
  396.      
  397.       else if (loop == 2) // Are We Drawing The Third Image?  (Texture At An Angle... Perspective)
  398.       {
  399.         glTranslatef(0.0f, 0.0f, -2.0f); // Move 2 Units Into The Screen
  400.         glRotatef(-45.0f, 1.0f, 0.0f, 0.0f); // Tilt The Quad Below Back 45 Degrees.
  401.         glRotatef(zrot / 1.5f, 0.0f, 0.0f, 1.0f); // Rotate By zrot/1.5 On The Z-Axis
  402.        
  403.         glBegin(GL_QUADS); // Begin Drawing A Single Quad
  404.         glTexCoord2f(1.0f, 1.0f); glVertex3f(1.0f, 1.0f, 0.0f);
  405.         glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 0.0f);
  406.         glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 0.0f);
  407.         glTexCoord2f(1.0f, 0.0f); glVertex3f(1.0f, -1.0f, 0.0f);
  408.         glEnd(); // Done Drawing The Textured Quad
  409.       }
  410.      
  411.       else // Are We Drawing The Fourth Image?  (3D Texture Mapped Cylinder... Perspective)
  412.       {
  413.         glTranslatef(0.0f, 0.0f, -7.0f); // Move 7 Units Into The Screen
  414.         glRotatef(-xrot / 2, 1.0f, 0.0f, 0.0f); // Rotate By -xrot/2 On The X-Axis
  415.         glRotatef(-yrot / 2, 0.0f, 1.0f, 0.0f); // Rotate By -yrot/2 On The Y-Axis
  416.         glRotatef(-zrot / 2, 0.0f, 0.0f, 1.0f); // Rotate By -zrot/2 On The Z-Axis
  417.        
  418.         glEnable(GL_LIGHTING); // Enable Lighting
  419.         glTranslatef(0.0f, 0.0f, -2.0f); // Translate -2 On The Z-Axis (To Rotate Cylinder Around The Center, Not An End)
  420.         gluCylinder(quadric, 1.5f, 1.5f, 4.0f, 32, 16); // Draw A Cylinder
  421.         glDisable(GL_LIGHTING); // Disable Lighting
  422.       }
  423.     }
  424.    
  425.     glFlush(); // Flush The GL Rendering Pipeline
  426.   }
  427.  
  428. End DynC





(to be cont'd...)

Mike Lobanovsky

  • Guest
Re: FBSL Capabilities
« Reply #5 on: October 13, 2015, 12:35:02 PM »
(cont'd)

FBSL BASIC is a fast 3rd generation procedural SDK-style BASIC interpreter largely code- and functionally-compatible with PB, FB and similar, as well as directly with Win32 API and 3rd-party STDCALL/CDECL libraries, through its strong-typed data interface, and sufficiently compatible with both procedural and COM-/Variant-based OOP'ed VB6 through its own COM, OOP, and typeless Variant-based automatic data conversion functionality.

At the same time, FBSL BASIC offers all the base functionality of historical BASICs in both console and graphics modes to cater for the beginner-level audience they targeted, as BASIC's initial "B" still suggests. ;)

Compared to many other contemporary interpretative BASICs of equal particular functionality, FBSL BASIC often proves faster and/or more compact and/or less cryptic. For example, an FBSL equivalent of Liberty Basic sprite engine functionality reimplemented entirely in FBSL BASIC without resorting to its much faster C and Asm JIT counterparts, proves at least twice faster than R.Russell's LB Booster, and much faster than Liberty Basic's original. The FBSL BASIC reimplementation of original LB quest shown below manages 10,000 simultaneous animated snowflake sprites with the main character's animation and background music still functional, and the main window, still responsive to mouse actions. In contrast to that, original LB would choke with just 1000, and LBB, with 2000 animated flake sprites in view:




Further, while PB's inline assembly has been useful and mostly Intel-style compatible, it was certainly lagging behind. FBSL's Dynamic Assembler whose engine "weighs" only some 40KB when compiled, is almost copy-paste compatible with Masm32 barring minor differences in denoting labels (Masm and others would use colons where DynAsm uses commercial ats -- an FBSL BASIC-compatible way to denote addresses). At the same time, DynAsm fully supports MMX and 3DNow! instruction sets -- something that always remained beyond PB-ers' reach. It could've supported SSE too, but that would bloat the engine with yet another 20KB, and we at FBSL are very sensitive about such things (Small Is Beautiful!).

Here's an example of MMX-enhanced DynAsm procedure that performs line by line interpolation by addition of pixel colors of one sprite with another in yet one more 2D sprite library available in FBSL in the form of 75KB large DynAsm script include file:
Code: OxygenBasic
  1. DynAsm SAdd(%SrcPtr, %DestPtr, %w, %h, %WS, %WD)
  2.   push ebp
  3.   mov ebp, esp
  4.   push ebx
  5.   push esi
  6.   push edi
  7.  
  8.   mov edi, DestPtr
  9.   mov esi, SrcPtr
  10.  
  11.   sub esi, edi
  12.   shl DWORD PTR [w], 2
  13.   mov ebx, w
  14.   mov edx, h
  15.   shl DWORD PTR [WD], 2
  16.   sub WD, ebx
  17.   shl DWORD PTR [WS], 2
  18.   sub WS, ebx
  19.   mov eax, WD
  20.   sub WS, eax
  21.   lea esp, [esp] ; alignment
  22.  
  23.   @ProcessScanLine
  24.   mov ecx, ebx
  25.   add ecx, edi
  26.  
  27.   @@
  28.   movd mm0, DWORD PTR [esi + edi]
  29.   movd mm1, DWORD PTR [edi]
  30.   paddusb mm0, mm1
  31.   movd DWORD PTR [edi], mm0
  32.   add edi, 4
  33.   cmp edi, ecx
  34.   jnz @B
  35.  
  36.   add esi, WS
  37.   add edi, WD
  38.   dec edx
  39.   jnz ProcessScanLine
  40.  
  41.   emms
  42.  
  43.   pop edi
  44.   pop esi
  45.   pop ebx
  46.   pop ebp
  47.  
  48.   ret 24
  49. End DynAsm
Just copy-paste this assembly into the Masm32 editor, change @ProcessScanLine and @@ to ProcessScanLine: and @@:, respectively, supply with a Masm32-style procedure definition and use it freely in your statically compiled Masm32 creations.

The library comprises over 50 MMX-enhanced procedures and implements high-speed color blending in animated 24- and 32-bpp color sprites. It also does per-pixel directional and Phong point lighting, normal mapping, and pixel perfect collision detection of transparent sprites.



The 5,500 code line long library is complemented with 1,100 line long sprite class code written in FBSL's BASIC OOP.

And last but not least, below is an Fbsl_Tiny (Fbsl.dll runtime-assisted) executable that uses that library and associated class to animate 650 sprites at 110FPS (> 4 times faster than would be sufficient for smooth animation) in a Lissajous screensaver fashion. A full-screen borderless version of the same would do it at 75FPS on my computer. Its binary size is only 18KB. A C++ equivalent of it might be as large as some 70KB with about 40KB for the library, 20KB, for the class definition, and 10KB, for the launcher, window, and sprite control code. ;)





So, if you would ever ask me
... why to put so much work into something used by just a few
again, my answer will always be:

Because I Can! :D

[attachment deleted by admin]
« Last Edit: October 13, 2015, 04:31:29 PM by Mike Lobanovsky »

Patrice Terrier

  • Guest
Re: FBSL Capabilities
« Reply #6 on: October 13, 2015, 01:38:32 PM »
Mike--

Can you write a standalone DLL with it, or a standalone 64-bit exe, or an application with hundred of windows each of them full of child controls, the answer is probably no.

I see you as a Genius programmer leaving on a desert island.

But, if you can convince the orphans of the PB community to switch to FSBL, then you could rescue some of the DDT's whales that have been left on the shore by the tide.

...

JRS

  • Guest
Re: FBSL Capabilities
« Reply #7 on: October 13, 2015, 03:25:39 PM »
Patrice,

I think people need to get over BASIC being dead, crippled, ... and focus on the application they're trying to build. If BASIC makes sense, then use it. BASIC doesn't have to be to reason you wrote your application in the first place.

John

Mike Lobanovsky

  • Guest
Re: FBSL Capabilities
« Reply #8 on: October 13, 2015, 03:42:57 PM »
Can you write a standalone DLL with it...

My proprietary build of FBSL v3.5 RC3 is currently capable of static compilation of DynC code (similar to the OpenGL NeHe example program above) to standalone .EXE and .DLL binaries. Public builds of RC2 and RC3 just have this feature disabled.

Quote
... or a standalone 64-bit exe ...

My top secret very early WIP FBSL v4 (codename LAX) is already capable of JIT and static compilation of graphical or console-/terminal-only pure or mixed procedural strongly-typed BASIC, ANSI C and AT&T assembly code to native executables and dynamically loadable libraries (.DLL and .SO) on 32- and 64-bit Windows and Linux platforms (at least under Ubuntu and elementaryOS that are installed natively on my PCs), and also of JIT-only compilation on 64-bit Mac OS X platforms starting with Mac OS X v10.7 Lion, all using an early prototype of a tiny unified multi-platform statically-linked native GUI library currently based on Araq/Claro GUI with a minimum of base-level common controls to ensure platform independence of general-purpose BASIC/C/AT&T code in LAX scripts.

Not ready to show off anything yet tho.

Quote
... or an application with hundred of windows each of them full of child controls, the answer is probably no.

The answer is Yessir. :) This single-threaded FBSL v3.5 BASIC script:
Code: OxygenBasic
  1. #Option Implicit
  2. #Include <Include\Windows.inc>
  3.  
  4. Dim hwnds[]
  5.  
  6. For i = 0 To 255
  7.   hwnds[i] = FbslForm("Form #" & i)
  8.   For j = 0 To 31
  9.     FbslControl("static", hwnds[i], "Static #" & j, 1000 + j, _
  10.     j * 8, j * 4, 80, 28, _
  11.     WS_CHILD BOr WS_VISIBLE, WS_EX_STATICEDGE)
  12.   Next
  13. Next
  14.  
  15. For Each elem In hwnds
  16.   Show(elem)
  17.   DoEvents
  18. Next
  19.  
  20. Begin Events
  21.   If CBMSG = WM_CLOSE Then
  22.     ExitProgram(0)
  23.   End If
  24. End Events
easily creates 8K simultaneously visible controls on 256 simultaneously visible forms each of which remains perfectly responsive and manageable under Win 7's DWM though of course it is an overkill for the XP window manager. It will probably be stressful for both FBSL and the coder to manage such a crazy GUI in a common Begin/End Events loop through the hWnd/ID mess, but certainly feasible if absolutely needed.

Quote
... if you can convince the orphans of the PB community to switch to FSBL ...

No need to. Most of people that are still using PowerBASIC in some form or another are evidently on the wrong side of their fifties, sixties and seventies, which effectively means they will have a fair chance to use their existing 32-bit apps and develop new ones either i) till Windows drops its support for 32 bits in yet very distant future; or ii) to the day they die.

[attachment deleted by admin]
« Last Edit: October 13, 2015, 04:10:24 PM by Mike Lobanovsky »

Aurel

  • Guest
Re: FBSL Capabilities
« Reply #9 on: October 13, 2015, 10:01:44 PM »
Quote
Let Aurel continue to instruct his numerous followers in this O2-specific technical thread unhindered

 :D :D :D

NO PROBLEMO....

Patrice Terrier

  • Guest
Re: FBSL Capabilities
« Reply #10 on: October 14, 2015, 12:29:03 AM »
Mike--

You and me we are not speaking the same {language}.
I am speaking for the professional market, not for the hobbyist's one.

And when i speak about hundred of child controls, i am speaking of hundred of different classes, like: listbox, combo, listview, tab control, marquee, spinner, input field, web field, rtf field, graphic field, OpenGL container, group field, etc. etc. etc.
Plus a visual designer to populate each window form, with child controls, altogether with anchor properties and subclassing facilities, etc.

Using a programming tool that relies on the work of a single man, will lead sooner or later to the Bob Zales's syndrom, who didn't thought that one day he would die.

For myself i made the decision to use only SDK programming, to easily switch from one language to another and avoid like the plague to use proprietary syntax or encapsulations hidding what is realy going on under the hood, and this ensure the companies i am working with, that somebody would be able to take on my work the day i become unavailable, or the day they decide to stop working with me.

...

JRS

  • Guest
Re: FBSL Capabilities
« Reply #11 on: October 14, 2015, 01:43:20 AM »
Patrice,

I think Mike, Eros and I are all in the same boat with their BASIC projects. It's really a labor of love as Eros puts it with the hope others will use it as well.

I'm tired of telling people about the benefits of Script BASIC and have stopped promoting the open source project. It has become a static effort and used primarily by me.

John

Patrice Terrier

  • Guest
Re: FBSL Capabilities
« Reply #12 on: October 14, 2015, 03:44:09 AM »
Quote
It's really a labor of love...It has become a static effort and used primarily by me.
Yep, another definition of being an hobbyist ;)

...

Mike Lobanovsky

  • Guest
Re: FBSL Capabilities
« Reply #13 on: October 14, 2015, 05:02:35 AM »
Tell you what, Patrice,

You won't survive a minute at BP dot org. You're gonna be labeled an elitist and anathematized forever, so don't even try. ;D

(FYI I've been and still am a professional freelancer for about seven years since I retired from running a private business and my primary PL is C. But I am also fond of compiler development and I'm getting as much drive and fun out of it as you are from your 3D models and music visuals :) )

As for professionality, reliability and maintainability of FBSL code, I hereby declare the following:

1. For a funny* net amount of EUR 3,000.0 (say Euro Threethousandonly, banking expenses to be borne by the Sender) or its equivalent sum in USD or GBP and using the existing version of FBSL v3.5 RC3 only, I will create a 32-bit virtual machine that will be able to:
  • install, and boot into, MS-DOS v3.3 and successfully run many of its native general-purpose programs and utilities and likely a few CGA graphics DOS games such as e.g. early Leisure Suit Larry


  • further install on top of existing MS-DOS v3.3, and boot into, MS Windows'95 and successfuly run a couple of its simpler utilities as e.g. Notepad and/or MS Paint. W'95 game compatibility is not guaranteed.

2. For an even funnier** net amount of EUR 7,500.0 (say Euro Seventhousandfivehundredonly, banking expenses to be borne by the Sender) or its equivalent sum in USD or GBP and using the existing version of FBSL v3.5 RC3 only, I will recreate the entire KolibriOS graphics operating system bootable from a 1.44MB floppy disk, that will run successfully many of this OS' original general-purpose applications:



Anybody eager to bet? :)

_______________________________________________
* average monthly salary of a skilled developer in the Republic of Belarus, excluding bonuses
** less than three monthly salaries of a skilled developer in the Republic of Belarus, excluding bonuses

Patrice Terrier

  • Guest
Re: FBSL Capabilities
« Reply #14 on: October 14, 2015, 05:26:29 AM »
I am not elitist, just a very pragmatic 01010101 binary man.

Will it serves the need of my customers YES or NO, that's all.


However about my personnal inclination, then this is another story, and i can work for several days on a 3D model just for free, kind of hobby i would say ;)

Indeed i think i am more of a perfectionist  ::)

...