Popular Post UEZ Posted October 13, 2016 Popular Post Share Posted October 13, 2016 (edited) Here some graphical examples written completely in FreeBasic just for fun. _WinAPI_SetWindowTitleIcon Check for Numeric Entry in an EditBox using RegEx CreateWindowEx (hGUI) Example FB 3D Starfield Rotating Flight FB File2Bas Code Generator FB Fire Particles FB Fireworks FB GFX Examples FB Image to Trapezoid Transformation FB Layered Parallax Effect FB Plasma FB Puristic Clock FB Rotating Cube FB Rotating Earth FB Rutt Etra Izer Effect FB Simple Recursive Tree Generator FB Snowfall FB Tunnel Flight FB Water Effect FMOD Examples GDI - GDI+ 3D Sinus Wave GDI - GDI+ Animated Pythagoras Tree GDI - GDI+ Bezier Lines GDI - GDI+ Particles - Repulsive Force Sim v2.0 GDI - GDI+ Plasma v5 Booster GDI - GDI+ Random Pattern GDI - GDI+ Space Flight GDI - GDI+ Tunnel Flight - WipeOut Style GDI Classic Raytraced Tunnel GDI Elastic Twister Effect GDI Exploding Pixels GDI Infinite Image Zoom Flight GDI Liquid Pixels GDI Mandelbrot GDI Particle Repulsion Grid GDI Particles Mouse Attraction GDI Starfield GDI The Nautilus Raymarcher GDI Worm Tunnel Flight GDI+ 3D Starfield Scrolling v1 Booster GDI+ 3D Starfield Scrolling v3 Booster GDI+ Convert Bitmap to ASCII GDI+ GIF Anim to ASCII Player GDI+ Image Painting GDI+ Impossible Possible GDI+ Kaleidoscope GDI+ Performance Test - Au3 vs FB GDI+ Polar Clock GDI+ Rotating Earth GDI+ Spiral Text GDI+ Star Wars Scroller GDI+ Streamer GDI+ Swiss Railway Clock GDI+ The MATRIX Ini Read - Write Rutt_Etra_Izer_Booster Stack TitchySID uFMOD Download: FreeBasic Examples build 2019-05-08.rar I will add new examples from time to time. FreeBasic source codes are also included. Edited May 10, 2019 by UEZ Added some more examples Gianni, argumentum, iamtheky and 6 others 9 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
wakillon Posted October 15, 2016 Share Posted October 15, 2016 Very nice effects ! You play with graphics with a disconcerting skilfulness. It's a pleasure for the eyes ! AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
trancexx Posted October 16, 2016 Share Posted October 16, 2016 I was curious why the executables are that big and whether free version of Visual Studio can be set to produce smaller exes. So I rewrote your code in C(++) and compiled it. I ended up with 5.5kb executables after removing CRT dependencies (by using Taylor series to approximate sin and cos) Pythagoras.zip I hate default settings ...shit. UEZ 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
UEZ Posted October 16, 2016 Author Share Posted October 16, 2016 19 hours ago, wakillon said: Very nice effects ! You play with graphics with a disconcerting skilfulness. It's a pleasure for the eyes ! Thank you. 53 minutes ago, trancexx said: I was curious why the executables are that big and whether free version of Visual Studio can be set to produce smaller exes. So I rewrote your code in C(++) and compiled it. I ended up with 5.5kb executables after removing CRT dependencies (by using Taylor series to approximate sin and cos) Pythagoras.zip I hate default settings ...shit. Well done. Can you please post your C++ code? I want to see how you did that in C++. Apropos dependencies: why didn't you use the inline ASM functions for Sin/Cos instead of approx. using Taylor series? Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
trancexx Posted October 16, 2016 Share Posted October 16, 2016 (edited) 7 hours ago, UEZ said: Well done. Can you please post your C++ code? I want to see how you did that in C++. Apropos dependencies: why didn't you use the inline ASM functions for Sin/Cos instead of approx. using Taylor series? Inline ASM when I have real compiler to work with? No thanks. As for sin and cos approximations, this could be the code (in AutoIt): Func cos_($x) If $x < 0 Then $x = -$x While $x >= 3.14159265359 $x -= 6.28318530718 WEnd Return 1.0 - ($x * $x / 2) * (1 - ($x * $x / 12) * (1 - ($x * $x / 30) * (1 - $x * $x / 56))) EndFunc Func sin_($x) Return cos_($x - 1.570796326795) EndFunc Source of the exe is pretty much your AutoIt code. I just copy/passed it and cleaned a bit: #include <windows.h> #pragma comment( linker, "/entry:MwWinMain" ) __forceinline float cos_(float x) { if (x < 0.0f) x = -x; while (3.14159265359f < x) x -= 6.28318530718f; return 1.0f - (x*x / 2.0f)*(1.0f - (x*x / 12.0f) * (1.0f - (x*x / 30.0f) * (1.0f - x*x / 56.0f))); } __forceinline float sin_(float x) { return cos_(x - 1.570796326795f); } __forceinline WCHAR* int_to_wstr(int val) { static WCHAR buf[32] = { 0 }; int i = 30; for (; val && i; --i, val /= 10) buf[i] = L"0123456789"[val % 10]; return &buf[i + 1]; } // Global Variables: HWND hWnd; WCHAR szTitle[50] = L"GDI Animated Pythagoras Tree v2.5 / FPS: "; // The title bar text WCHAR* szWindowClass = L"UEZ_thingy"; // the main window class name UINT_PTR IDT_TIMER1 = 100; UINT_PTR IDT_TIMER2 = 1000; HDC $hDC; HDC $hGfxDC; int $iW = 1200, $iH = 700; HBITMAP $hBitmapGDI; HGDIOBJ $hObjOld, $hPen, $hBrush, $hPen_Old, $hBrush_Old; int $iFPS = 0; // Forward declarations of functions included in this code module: __forceinline ATOM MyRegisterClass(); __forceinline bool InitInstance(); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int APIENTRY MwWinMain() { MyRegisterClass(); if (!InitInstance()) return FALSE; MSG msg; // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } ExitProcess((int)msg.wParam); } __forceinline ATOM MyRegisterClass() { WNDCLASSEXW wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = nullptr; wcex.hIcon = nullptr; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);// (HBRUSH)(GetStockObject(WHITE_BRUSH)); wcex.lpszMenuName = nullptr; wcex.lpszClassName = szWindowClass; wcex.hIconSm = nullptr; return RegisterClassExW(&wcex); } __forceinline bool InitInstance() { hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, $iW, $iH, nullptr, nullptr, nullptr, nullptr); if (!hWnd) return false; $hDC = GetDC(hWnd); $hBitmapGDI = CreateCompatibleBitmap($hDC, $iW, $iH); $hGfxDC = CreateCompatibleDC($hDC); $hObjOld = SelectObject($hGfxDC, $hBitmapGDI); $hPen = GetStockObject(DC_PEN); $hBrush = GetStockObject(DC_BRUSH); $hPen_Old = SelectObject($hGfxDC, $hPen); $hBrush_Old = SelectObject($hGfxDC, $hBrush); SetStretchBltMode($hDC, WHITEONBLACK); ShowWindow(hWnd, 1); UpdateWindow(hWnd); SetTimer(hWnd, // handle to main window IDT_TIMER1, // timer identifier 10, //interval nullptr); // no timer callback SetTimer(hWnd, // handle to main window IDT_TIMER2, // timer identifier 1000, //interval nullptr); // no timer callback return true; } void PythagorasRec(HDC $hDC, int $iX1, int $iY1, int $iX2, int $iY2, int $iRecDepth) { auto $iBGR1 = ((255 - ($iRecDepth + 10) * 10) << 8) + $iRecDepth * 20; static float $i = 0; int $dx = $iX2 - $iX1; int $dy = $iY1 - $iY2; int $iX3 = $iX2 - $dy; int $iY3 = $iY2 - $dx; int $iX4 = $iX1 - $dy; int $iY4 = $iY1 - $dx; int $iX5 = $iX4 + ($dx - $dy) / (2.5f - cos_(($iX4 + $i) / 400) / 1.5f); int $iY5 = $iY4 - ($dx + $dy) / (2.25f + sin_(($iX5 + $iY4 - $i) / 500)); $i += 0.06666f; BeginPath($hDC); MoveToEx($hDC, $iX1, $iY1, nullptr); LineTo($hDC, $iX2, $iY2); LineTo($hDC, $iX3, $iY3); LineTo($hDC, $iX4, $iY4); LineTo($hDC, $iX1, $iY1); EndPath($hDC); // DllCall($hDLL_gdi32, "dword", "SetDCPenColor", "handle", $hDC, "dword", $iBGR1) SetDCBrushColor($hDC, $iBGR1 | 0x305090); FillPath($hDC); //; DllCall($hDLL_gdi32, "bool", "StrokeAndFillPath", "handle", $hDC) if ($iRecDepth > 0) { PythagorasRec($hDC, $iX4, $iY4, $iX5, $iY5, $iRecDepth - 1); PythagorasRec($hDC, $iX5, $iY5, $iX3, $iY3, $iRecDepth - 1); } } // // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) // // PURPOSE: Processes messages for the main window. // // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_TIMER: if (wParam == IDT_TIMER1) { BitBlt($hGfxDC, 0, 0, $iW, $iH, $hGfxDC, 0, 0, WHITENESS); PythagorasRec($hGfxDC, 550, 700, 650, 700, 8); BitBlt($hDC, 0, 0, $iW, $iH, $hGfxDC, 0, 0, SRCCOPY); ++$iFPS; return 0; } else if (wParam == IDT_TIMER2) { WCHAR* sFPS = int_to_wstr($iFPS); $iFPS = 0; szTitle[41] = *sFPS; szTitle[42] = *++sFPS; SetWindowText(hWnd, szTitle); return 0; } break; case WM_DESTROY: KillTimer(hWnd, IDT_TIMER1); KillTimer(hWnd, IDT_TIMER2); SelectObject($hGfxDC, $hPen_Old); DeleteObject($hPen); SelectObject($hGfxDC, $hBrush_Old); DeleteObject($hBrush); SelectObject($hGfxDC, $hObjOld); ReleaseDC(hWnd, $hDC); DeleteDC($hGfxDC); DeleteObject($hBitmapGDI); PostQuitMessage(0); return 0; case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = BeginPaint(hWnd, &ps); //// TODO: Add any drawing code that uses hdc here... EndPaint(hWnd, &ps); } break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } Edited October 16, 2016 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
UEZ Posted October 16, 2016 Author Share Posted October 16, 2016 @trancexx thanks. At the first look C++ code looks more difficult but it isn't at least compared with Pythagoras code. The C++ code made me curious and I will install the monster Visual Studio once again. Thanks for sharing. Btw, I add your Sin_/Cos_ function to FB just to compare the speed. I expected that the ASM inline is faster but isn't. Might be because the API calls amortize the speed difference. Xandy 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
AndyG Posted October 17, 2016 Share Posted October 17, 2016 18 hours ago, UEZ said: I expected that the ASM inline is faster but isn't. Might be because the API calls amortize the speed difference. ASM (handcoded) is (a little bit) faster, but what you meant are the "native" FPU-Code FSIN(), FCOS() and FSINCOS(), where are way slower than an (as mentioned and showed by trancexx) approximation. Calling the/an API-function is once more slower... One of the reasons, why trancexx used __forceinline which causes the compiler to inline this function into code. That means, no jumps/calls into a function! Makes the code some bytes bigger, but faster 19 hours ago, UEZ said: The C++ code made me curious and I will install the monster Visual Studio once again. I deinstalled VS yesterday....i am waiting for a compiler which is able to use "real" SIMD when switch on the SSE-Flag. I examined the EXE with IDApro. Yes, the compiler produces short and (in most cases) fast(?!) code using (half-hearted) processor-features which were introduced about 20 years ago... The only code i saw from a compiler using SIMD (as intended) was from the newest INTEL C++/FORTRAN-Compiler XE (v17.0). And to get this performance it is necessary to program in a "vectorizing" style ( and/or excessive use of _intrinsics_(), which force the compiler to fast(?!) code) . Or use OpenMP, CILK and other features/libraries. But all this is fu*** sh** to push their (INTEL´s) CPU´s. If the program/algorithm is good to parallelize, OpenCL/CUDA on a price-adjusted GPU is up to 50 to 100 times faster than the code running on a CPU. Enough whining, we have AutoIt after all... Xandy 1 Link to comment Share on other sites More sharing options...
UEZ Posted October 17, 2016 Author Share Posted October 17, 2016 @trancexx: I installed VS 2015 Pro. How can I get run your source code? I opened a Win32Project and pasted your code into the editor but when I try to run it I get ems. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
trancexx Posted October 17, 2016 Share Posted October 17, 2016 (edited) 1 hour ago, UEZ said: @trancexx: I installed VS 2015 Pro. How can I get run your source code? I opened a Win32Project and pasted your code into the editor but when I try to run it I get ems. All default? If yes then add #include <stdafx.h> at the top of that code, switch to "Release" "x86" then click "Debug" and select "Start Without Debugging" Edited October 17, 2016 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
UEZ Posted October 17, 2016 Author Share Posted October 17, 2016 (edited) Aha, working. Now I can play with code. THANKS. Edited October 17, 2016 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
trancexx Posted October 17, 2016 Share Posted October 17, 2016 Oh, and to get small exes you'll need to change default settings for both compiler and linker. Otherwise you end up with plenty of BS. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
UEZ Posted October 17, 2016 Author Share Posted October 17, 2016 @trancexx: what have you done that the output (exe) is that small? My output is approx. 100kb. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
UEZ Posted October 17, 2016 Author Share Posted October 17, 2016 1 minute ago, trancexx said: Oh, and to get small exes you'll need to change default settings for both compiler and linker. Otherwise you end up with plenty of BS. Can you tell me if it's not too complicated to explain. Otherwise I can live also with 100kb. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
trancexx Posted October 17, 2016 Share Posted October 17, 2016 4 minutes ago, UEZ said: Can you tell me if it's not too complicated to explain. Otherwise I can live also with 100kb. Sure. First of all delete all resource files from solution explorer window (right click on "Resource Files" -> delete. Then do the same for header files. Then remove #include #include "stdafx.h" line. Then go to "Project" and select bottom item (it should be "Some_Name Properties...", then expand "C/C++" and click "Precompiled Headers". On the right click "Use (/Yu)" and then select "Not Using Precompiled Headers". Then on the left expand "Linker" and choose "Manifest File". Then on the right click "Yes /blah blah" and select "No ..." UEZ 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
trancexx Posted October 17, 2016 Share Posted October 17, 2016 You should be on 6.5kb now. Few more tweaks and you're done. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
UEZ Posted October 17, 2016 Author Share Posted October 17, 2016 (edited) 5 minutes ago, trancexx said: You should be on 6.5kb now. Few more tweaks and you're done. Yep, exactly 6.5kb. 10.000 things to learn... Thanks again. Edited October 17, 2016 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
AndyG Posted October 22, 2016 Share Posted October 22, 2016 On 17.10.2016 at 10:33 PM, UEZ said: 10.000 things to learn... Or ask some of the 10.000 M$-Programmers why they are able to produce such a beautiful and outstanding piece of Software but not able to place a "Build smallest/shortest output possible" Button. I am afraid, at our next joint beer, you will tell me that you added a "Build smallest/shortest output possible"-Button into the VS (by AutoIt of course! ). I am looking forward to...the beer, not the button trancexx 1 Link to comment Share on other sites More sharing options...
Lakes Posted January 22, 2017 Share Posted January 22, 2017 @UEZ, that FreeBasic 3D SinePlot got me interested, do you use one of the FreeBasic IDEs and if so, which one? 2015 - Still no flying cars, instead blankets with sleeves. Link to comment Share on other sites More sharing options...
UEZ Posted January 22, 2017 Author Share Posted January 22, 2017 @Lakes: here a list of IDEs: https://www.freebasic-portal.de/downloads/ides-fuer-freebasic/ I personally using FbEdit. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Lakes Posted January 22, 2017 Share Posted January 22, 2017 Thanks. 2015 - Still no flying cars, instead blankets with sleeves. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now