Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
Tips & Tricks / Re: SDK Window including openGl
« Last post by Patrice Terrier on November 13, 2024, 09:06:25 am »
The easiest way, is to use the GDImage WGL_CreateWindow API that is available in both 32 and 64-bit.
It takes care of all the complex PIXELFORMATDESCRIPTOR details, and moreover GDImage has advanced texture support.

Here is the GDImage code for WGL_CreateWindow

Code: [Select]
FUNCTION WGL_CreateWindow ALIAS "WGL_CreateWindow" (BYVAL dwExStyle AS DWORD, _
                                                    BYVAL dwStyle AS DWORD, _
                                                    BYVAL x AS LONG, BYVAL y AS LONG, _
                                                    BYVAL nWidth AS LONG, BYVAL nHeight AS LONG, _
                                                    BYVAL hWndParent AS DWORD, _
                                                    BYVAL CtrlID AS DWORD) EXPORT AS DWORD

    LOCAL IsInitialized, wcStyle, glDC, glRC AS LONG
    LOCAL hWnd, hTemp AS DWORD
    LOCAL wc     AS WndClassEx
    LOCAL zClass AS ASCIIZ * 16
    zClass = "GL_CHARTCTRL"

    ' Create a temporary window for initializing OpenGL context
    hTemp = CreateWindowEx(dwExStyle, $GLImageClassName, "", dwStyle, _
                           0, 0, 0, 0, hWndParent, CtrlID, zInstance(), BYVAL 0)
    IF hTemp THEN
       ' Get device context and rendering context properties from the temporary window
       glDC = ZI_GetProperty(hTemp, %ZI_GLDC)
       glRC = ZI_GetProperty(hTemp, %ZI_GLRC)

       LOCAL pfd AS PIXELFORMATDESCRIPTOR

       ' Set up the PIXELFORMATDESCRIPTOR structure
       pfd.nSize              = SIZEOF(pfd)
       pfd.nVersion           = 1
       pfd.dwFlags            = %PFD_DRAW_TO_WINDOW OR %PFD_SUPPORT_OPENGL OR %PFD_DOUBLEBUFFER OR %PFD_SUPPORT_GDI
       pfd.iPixelType         = 0 ' PFD_TYPE_RGBA
       pfd.cColorBits         = 32
       pfd.cRedBits           = 0
       pfd.cRedShift          = 0
       pfd.cGreenBits         = 0
       pfd.cGreenShift        = 0
       pfd.cBlueBits          = 0
       pfd.cBlueShift         = 0
       pfd.cAlphaBits         = 1
       pfd.cAlphaShift        = 0
       pfd.cAccumBits         = 0
       pfd.cAccumRedBits      = 0
       pfd.cAccumGreenBits    = 0
       pfd.cAccumBlueBits     = 0
       pfd.cAccumAlphaBits    = 0
       pfd.cDepthBits         = 24 ' Depth buffer
       pfd.cStencilBits       = 0
       pfd.cAuxBuffers        = 0
       pfd.iLayerType         = 0 ' %PFD_MAIN_PLANE
       pfd.bReserved          = 0
       pfd.dwLayerMask        = 0
       pfd.dwVisibleMask      = 0
       pfd.dwDamageMask       = 0

       ' Initialize multisampling
       InitMultisample(glDC, pfd)

       IF gn_arbMultisampleFormat THEN
          ' Set up the window class for the OpenGL control
          wcStyle = %CS_HREDRAW OR %CS_VREDRAW OR %CS_DBLCLKS OR %CS_OWNDC
          wc.cbSize = SIZEOF(wc)
          IsInitialized = GetClassInfoEx(zInstance(), zClass, wc)
          IF IsInitialized = 0 THEN
             wc.cbSize        = SIZEOF(wc)
             wc.style         = wcStyle
             wc.lpfnWndProc   = CODEPTR(GL_WindowProc)
             wc.cbClsExtra    = 0
             wc.cbWndExtra    = %Extend_cbWndExtra * 4
             wc.hInstance     = zInstance()
             wc.hIcon         = %NULL
             wc.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
             wc.hbrBackground = %NULL ' Don't paint the class window background
             wc.lpszMenuName  = %NULL
             wc.lpszClassName = VARPTR(zClass)
             wc.hIconSm       = %NULL
             IF RegisterClassEx(wc) THEN IsInitialized = %TRUE
          END IF

          IF IsInitialized THEN
             ' Create the OpenGL control window
             hWnd = CreateWindowEx(dwExStyle, _
                                   zClass, _         ' Make it an OpenGL control
                                   "", _             ' Currently not used
                                   dwStyle, _        ' window style
                                   x, _              ' initial x position
                                   y, _              ' initial y position
                                   nWidth, _         ' Calculate Window Width
                                   nHeight, _        ' Calculate Window Height
                                   hWndParent, _     ' parent window handle
                                   CtrlID, _         ' ControlID
                                   zInstance(), _    ' program instance handle
                                   BYVAL 0)          ' creation parameters
             IF hWnd THEN
                ' Get device context and set pixel format
                glDC = GetDC(hWnd)
                IF SetPixelFormat(glDC, gn_arbMultisampleFormat, pfd) THEN
                   ' Destroy the temporary window and create the OpenGL context
                   DestroyWindow(hTemp)
                   glRC = wglCreateContext(glDC)
                   wglMakeCurrent(glDC, glRC)
                   ZI_SetProperty(hWnd, %ZI_GLDC, glDC)
                   ZI_SetProperty(hWnd, %ZI_GLRC, glRC)
                ELSE
                   ' Fallback: use the temporary window
                   DestroyWindow(hWnd)
                   MoveWindow(hTemp, x, y, nWidth, nHeight, 0)
                   hWnd = hTemp
                END IF
             END IF

          END IF
       ELSE
          ' Fallback: use the temporary window
          MoveWindow(hTemp, x, y, nWidth, nHeight, 0)
          hWnd = hTemp
       END IF
    END IF
    FUNCTION = hWnd
END FUNCTION
22
Tips & Tricks / SDK Window including openGl
« Last post by Frank Brübach on November 12, 2024, 02:26:49 pm »
Hello Patrice.. perhaps you can Help?

I want to include an openGl Window into a SDK winapi frame. Whats the correct way? My attempt so far.. regards frank

Code: [Select]
' test openGL sdk window + window frame included with a control
' how to insert an openGL window frame into a sdk window?
'
#COMPILER PBWIN 10
#COMPILE EXE
#DIM ALL

#INCLUDE ONCE "Win32API.inc"

%IDC_STATIC=1001
%IDC_BUTTON=1002
%BS_PUSHBUTTON      = &H0&

'==============================================================================
FUNCTION WINMAIN (BYVAL hInstance     AS DWORD, _
                  BYVAL hPrevInstance AS DWORD, _
                  BYVAL lpCmdLine     AS ASCIIZ PTR, _
                  BYVAL iCmdShow      AS LONG) AS LONG


    LOCAL Msg        AS tagMsg
    LOCAL wce        AS WndClassEx
    LOCAL szAppName  AS ASCIIZ * 80
    LOCAL szAppName2 AS ASCIIZ * 80
    LOCAL hWnd       AS DWORD
    LOCAL hWndOpgl       AS DWORD

    szAppName         = "HelloWin"
    wce.cbSize        = SIZEOF(wce)
    wce.STYLE         = %CS_HREDRAW OR %CS_VREDRAW
    wce.lpfnWndProc   = CODEPTR(WndProc)
    wce.cbClsExtra    = 0
    wce.cbWndExtra    = 0
    wce.hInstance     = hInstance
    wce.hIcon         = LoadIcon(hInstance, "HELLOWIN")
    wce.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
    wce.hbrBackground = %NULL ' No class background, we do it outselves
    wce.lpszMenuName  = %NULL
    wce.lpszClassName = VARPTR(szAppName)
    wce.hIconSm       = LoadIcon(hInstance, BYVAL %IDI_APPLICATION)

    RegisterClassEx wce


    szAppName2         = "HelloOpenGL"
    wce.cbSize        = SIZEOF(wce)
    wce.STYLE         = %CS_HREDRAW OR %CS_VREDRAW
    wce.lpfnWndProc   = CODEPTR(WndProc)
    wce.cbClsExtra    = 0
    wce.cbWndExtra    = 0
    wce.hInstance     = hInstance
    wce.hIcon         = LoadIcon(hInstance, "HELLOWIN")
    wce.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
    wce.hbrBackground = %NULL ' No class background, we do it outselves
    wce.lpszMenuName  = %NULL
    wce.lpszClassName = VARPTR(szAppName2)
    wce.hIconSm       = LoadIcon(hInstance, BYVAL %IDI_APPLICATION)

    RegisterClassEx wce


    ' Create a window using the registered class
    hWnd = CreateWindow(szAppName, _
                        "The Hello Program", _
                        %WS_OVERLAPPEDWINDOW, _
                        %CW_USEDEFAULT, _
                        %CW_USEDEFAULT, _
                        %CW_USEDEFAULT, _
                        %CW_USEDEFAULT, _
                        %NULL, _
                        %NULL, _
                        hInstance, _
                        BYVAL %NULL)

    IF hWnd = 0 THEN  ' exit on failure
        MSGBOX "Unable to create window"
        EXIT FUNCTION
    END IF

   ' Create a window using the registered class
    hWndOpgl = CreateWindow(szAppName2, _
                        "OpenGL window", _
                        %WS_OVERLAPPEDWINDOW, _
                        %CW_USEDEFAULT, _
                        %CW_USEDEFAULT, _
                        %CW_USEDEFAULT, _
                        %CW_USEDEFAULT, _
                        %NULL, _
                        %NULL, _
                        hInstance, _
                        BYVAL %NULL)

    IF hWndOpgl = 0 THEN  ' exit on failure
        MSGBOX "Unable to create openGLwindow"
        EXIT FUNCTION
    END IF

    LOCAL hCtl AS DWORD
    LOCAL hCtlBtn AS DWORD
    LOCAL hFont AS DWORD

    hCtl = CreateWindowEx(0, "Static", "openGL", _
              %WS_CHILD OR %WS_VISIBLE OR %WS_CLIPSIBLINGS OR %WS_TABSTOP OR _
              %SS_NOTIFY OR %SS_LEFT, _ '%SS_RIGHT
               18, 40, 440, 324, _
               hwnd, %IDC_STATIC, GetModuleHandle(""), BYVAL %NULL)
    IF hFont THEN SendMessage hCtl, %WM_SETFONT, hFont, 0

    hCtlBtn = CreateWindowEx(0, "Button", "push-me", _
              %WS_CHILD OR %WS_VISIBLE OR %BS_PUSHBUTTON OR _
              %WS_CLIPSIBLINGS OR %WS_TABSTOP, _
               650, 440, 80, 24, _
               hwnd, %IDC_BUTTON, GetModuleHandle(""), BYVAL %NULL)
    IF hFont THEN SendMessage hCtlBtn, %WM_SETFONT, hFont, 0

    IF hWnd = 0 THEN
      MessageBox(0, "Window Creation Failed!", "Error", 0)
      EXIT FUNCTION
    END IF

    ' Display the window on the screen
    ShowWindow hWnd, iCmdShow
    UpdateWindow hWnd

    DO WHILE GetMessage(Msg, %NULL, 0, 0)
        TranslateMessage Msg
        DispatchMessage Msg
    LOOP
    FUNCTION = msg.wParam

END FUNCTION


'==============================================================================
SUB DrawGradient (BYVAL hDC AS DWORD)
'------------------------------------------------------------------------------
    ' Custom draw procedure for gradiend fill
    '--------------------------------------------------------------------------

    LOCAL rectFill AS RECT
    LOCAL rectClient AS RECT
    LOCAL fStep AS SINGLE
    LOCAL hBrush AS DWORD
    LOCAL lOnBand AS LONG

    GetClientRect WindowFromDC(hDC), rectClient
    fStep = rectClient.nbottom / 200

    FOR lOnBand = 0 TO 199
        SetRect rectFill, 0, lOnBand * fStep, rectClient.nright + 1, (lOnBand + 1) * fStep
        hBrush = CreateSolidBrush(RGB(0, 0, 255 - lOnBand))
        Fillrect hDC, rectFill, hBrush
        DeleteObject hBrush
    NEXT

END SUB


'==============================================================================
FUNCTION WndProc (BYVAL hWnd AS DWORD, BYVAL wMsg AS DWORD, _
                  BYVAL wParam AS DWORD, BYVAL lParam AS LONG) EXPORT AS LONG

    LOCAL hDC    AS DWORD
    LOCAL hInstance AS DWORD
    LOCAL pPaint AS PAINTSTRUCT
    LOCAL tRect  AS RECT

    SELECT CASE wMsg

    CASE %WM_CREATE

    CASE %WM_COMMAND
      SELECT CASE LOWRD(wParam)
      CASE %IDOK
          IF HIWRD(wParam) = %BN_CLICKED THEN
              'Trigger search code..
          END IF

      CASE %IDC_BUTTON
          IF HIWRD(wParam) = %BN_CLICKED THEN
              MSGBOX "pushed"
          END IF
      END SELECT

    CASE %WM_PAINT
        hDC = BeginPaint(hWnd, pPaint)
        GetClientRect hWnd, tRect
        SetBkMode hDC, %TRANSPARENT
        SetTextColor hDC, %WHITE
        DrawText hDC, "Hello, openGL Windows!", -1, tRect, %DT_SINGLELINE OR %DT_CENTER OR %DT_VCENTER
        EndPaint hWnd, pPaint
        FUNCTION = 1
        EXIT FUNCTION

    CASE %WM_ERASEBKGND
        hDC = wParam
        DrawGradient hDC
        FUNCTION = 1
        EXIT FUNCTION

    CASE %WM_DESTROY
        PostQuitMessage 0
        EXIT FUNCTION

    END SELECT

    FUNCTION = DefWindowProc(hWnd, wMsg, wParam, lParam)

END FUNCTION
[/Post]
23
Eye Candies / Re: BassBox Plugin 64-bit
« Last post by Patrice Terrier on October 09, 2024, 05:52:33 pm »
The whole project has been updated with new plugins.
24
64-bit SDK programming / Re: GDplus
« Last post by Patrice Terrier on September 25, 2024, 03:50:22 pm »
Here is the PowerBASIC version, using almost the same code than the C/C++ version.
25
Eye Candies / BassBox Plugin 64-bit
« Last post by Patrice Terrier on September 19, 2024, 06:23:34 pm »
The purpose of this VS2022 application is to switch easily from one plugin to another to check the OpenGL FPO effects transposed to 64-bit.
Most of them inherit from the original 32-bit version written long ago in PowerBASIC.



To navigate from one plugin to another move the cursor to the left or right edge of the window, and click on the auto/hide arrow.

Use drag & drop to play a specific audio file, and see how the effects interact with it.

Here is the BBP API to use to communicate with the plugin DLL.
See in the WM_TIMER message the gl_DrawScene() code using BBP_RenderOpenGL to pass the wimdata pointer to the DLL.

Code: [Select]
#pragma once
typedef ULONGLONG QWORD;

const int BBP_RENDER       = 1;       // Render the scene.
const int BBP_CREATE       = 2;       // Retrieve Title, Name, Version, Render mode.
const int BBP_INIT         = 3;       // Init the OpenGL.
const int BBP_SIZE         = 4;       // The size of the control has changed.
const int BBP_KEYBOARD     = 5;       // All keyborad message.
const int BBP_MOUSE        = 6;       // All mouse messages.
const int BBP_DESTROY      = 7;       // Free Up resources.
const int BBP_NEWSOUND     = 8;       // We are playing a new sound file.

const int BBP_GDIPLUS      = 0;       // GDImage GDIPLUS compatible mode.
const int BBP_OPENGL       = 1;       // OpenGL mode.
const int BBP_DIRECTX      = 2;       // DirectX mode (for future extension).

const int BBP_SUCCESS      = 0;
const int BBP_ERROR        = -1;

typedef struct {
    UINT msg;                   // The plugin's message (see above constant list).
    HWND parent;                // The parent window handle.
    HDC dc;                     // The parent window DC (while in play mode).
    HGLRC rc;                   // The parent OpenGL RC (while in play mode).
    WORD lpeak;                 // The left audio channel peak value (while in play mode).
    WORD rpeak;                 // The right audio channel peak value (while in play mode).
    char title[32];             // Plugin's name or title.
    char author[64];            // Plugin's author name.
    DWORD version;              // LOWRD major, HIWRD minor.
    long renderto;              // BBP_GDIPLUS, BBP_OPENGL, BBP_DIRECTX.
    long backargb;              // Default ARGB color background.
    float* fftdata;             // dword pointer to the FFT() as single array.
    WORD fftsize;               // Size of the FFT array.

    UINT winmsg;                // True Windows message.
    WPARAM wparam;              // wParam
    LPARAM lparam;              // lParam

    short* wimdata;             // dword pointer to the wave MM_WIM_DATA.
    QWORD medialength;          // Media length.
    QWORD mediapos;             // Media pos.

    char reserved[50];          // Reserved for future extension.
} BBPLUGIN;

static FARPROC BBP_ProcHandle(IN FARPROC hProc, IN long RW) {
    static FARPROC WasHproc;
    if (RW) WasHproc = hProc;
    return WasHproc;
}

static long BBP_Plugin(OUT BBPLUGIN &BBP) {
    long nRet = BBP_ERROR;
    if (IsWindow(gP.hGL)) {
        HGLRC glRC = (HGLRC) (ZI_GetProperty(gP.hGL, ZI_GLRC));
        if (glRC) {
            long_proc (BBPLUGIN*);
            zProc hProc = (zProc) BBP_ProcHandle(0, 0);
            if (hProc) { nRet = hProc(&BBP); }
        }
    }
    return nRet;
}

static WCHAR* BBP_ActivePlugin(IN WCHAR* sPluginName, IN long RW) {
    static WCHAR sWasPluginName[MAX_PATH];
    if (RW) { wcscopy(sWasPluginName, sPluginName); }
    return sWasPluginName;
}

static void MarqueeUpdate() {
    WCHAR drive[_MAX_DRIVE]; ClearMemory(drive, sizeof(drive));
    WCHAR dir[_MAX_DIR]; ClearMemory(dir, sizeof(dir));
    WCHAR fname[_MAX_FNAME]; ClearMemory(fname, sizeof(fname));
    WCHAR ext[_MAX_EXT]; ClearMemory(ext, sizeof(ext));
    wsplitpath(gB.audiofile, drive, dir, fname, ext);
    ClearMemory(gP.plugintitle, sizeof(gP.plugintitle));
    wcscopy(gP.plugintitle, gP.title, MAX_PATH * 2);
    Add_Str(gP.plugintitle, gP.version);
    Add_Str(gP.plugintitle, L" by "); Add_Str(gP.plugintitle, gP.author);
    Add_Str(gP.plugintitle, L", playing \""); Add_Str(gP.plugintitle, fname); Add_Str(gP.plugintitle, ext); Add_Str(gP.plugintitle, L"\"");
    ZD_SetObjectText(ID_COPYRIGHT, gP.plugintitle);
}

static void BBP_Reset() {
    BBPLUGIN BBP; ClearMemory(&BBP, sizeof(BBP));
    BBP.msg = BBP_CREATE;
    BBP_Plugin(BBP);

    ClearMemory(gP.title, sizeof(gP.title));
    wcscopy(gP.title, cswconv(BBP.title), strSize(gP.title));// C string to WCHAR
    ClearMemory(gP.author, sizeof(gP.author));
    wcscopy(gP.author, cswconv(BBP.author), strSize(gP.author));// C string to WCHAR

    BYTE majorVersion = (BYTE)(BBP.version & 0xFF);
    BYTE minorVersion = (BYTE)((BBP.version >> 8) & 0xFF);
    ClearMemory(gP.version, sizeof(gP.version));
    swprintf(gP.version, strSize(gP.version), L" (%d.%d)", majorVersion, minorVersion);

    MarqueeUpdate();

    //BBProc(BBP);
    if (BBP.renderto == BBP_OPENGL) {

        glDisable(GL_BLEND);
        glDisable(GL_TEXTURE_2D);
        glDisable(GL_DEPTH_TEST);
        glDisable(GL_LIGHT0);
        glDisable(GL_LIGHT1);
        glDisable(GL_LIGHT2);
        glDisable(GL_LIGHT3);
        glDisable(GL_LIGHT4);
        glDisable(GL_LIGHT5);
        glDisable(GL_LIGHT6);
        glDisable(GL_LIGHT7);
        glDisable(GL_LIGHTING);
        glDisable(GL_COLOR_MATERIAL);
        glDisable(GL_ALPHA_TEST);
        glDisable(GL_NORMALIZE);

        glDisable(GL_LINE_SMOOTH);

        glGetError();

    }
}

//long BBProc (OUT BBPLUGIN &BBP);
static void BBP_Detached(IN HWND hWnd, OUT HMODULE &hLib) {
    BBPLUGIN BBP; ClearMemory(&BBP, sizeof(BBP));
    if (hLib) {
        BBP.msg = BBP_DESTROY;
        BBP.parent = hWnd;
        BBP_Plugin(BBP);
        //BBProc(BBP);

        // use brute force to delete any existing texture
        long Tmax = 64;
        long* DT = new long[Tmax]; memset(DT, 0, Tmax);
        for (long K = 0; K < Tmax; K++) { DT[K] = K; }
        glDeleteTextures(Tmax, (GLuint*)&DT[0]);
        delete[] DT;

        BBP_ProcHandle(0, 1); FreeLibrary(hLib); hLib = 0;
    }
}

static void BBP_ResizeOpenGL() {
    if (IsWindow(gP.hGL)) {
        BBPLUGIN BBP; ClearMemory(&BBP, sizeof(BBP));
        BBP.msg          = BBP_SIZE;
        BBP.parent       = gP.hGL;
        BBP_Plugin(BBP);
        //BBProc(BBP);
    }
}

// Load/unload plugin DLL to/from memory
static long BBP_LoadPlugin(IN HWND hWnd, IN WCHAR* zPlugin) {
    long nDone = BBP_ERROR;
    long nLen = lstrlen(zPlugin);
    if ((nLen) && (_wcsicmp(zPlugin, BBP_ActivePlugin(0,0)) != 0)) {
        if (FileExist(zPlugin)) {
            if (gP.hLib) BBP_Detached(hWnd, gP.hLib);
            gP.hLib = LoadLibrary(zPlugin);
            if (gP.hLib) {
                FARPROC hProc = GetProcAddress(gP.hLib, "BBProc");
                if (hProc) {
                    BBP_ProcHandle(hProc, 1);
                    BBP_ActivePlugin(zPlugin, 1);
                    // Reset plugin to default
                    BBP_Reset();
                    nDone = BBP_SUCCESS;
                }
            }
        }
    } else if (nLen == 0) {
        if (gP.hLib) BBP_Detached(hWnd, gP.hLib);
    }
    return nDone;
}

static long BBP_AttachPlugin(WCHAR* zPlugin) {
    gP.pluginloaded = 0;
    if (IsWindow(gP.hGL)) {
        if (BBP_LoadPlugin(gP.hGL, zPlugin) == BBP_SUCCESS) {
            gP.pluginloaded = -1;
            BBPLUGIN BBP; ClearMemory(&BBP, sizeof(BBP));
            BBP.msg          = BBP_INIT;
            BBP.parent       = gP.hGL;
            BBP.dc           = (HDC) ZI_GetProperty(gP.hGL, ZI_GLDC);
            BBP.rc           = (HGLRC) ZI_GetProperty(gP.hGL, ZI_GLRC);
            BBP.backargb     = 0;
            BBP_Plugin(BBP);

            //if (IsWindowVisible(gP.hGL)) { SetMetadataText(ID_VIDEO_SIZE, gB.plugintitle); }

            BBP.msg          = BBP_SIZE;
            BBP_Plugin(BBP);

            wcscopy(gP.bin.lastplugin, zPlugin);

            gP.pluginloaded = -1;
        }
    }
    return gP.pluginloaded;
}

static void BBP_RenderOpenGL(IN DWORD nLevel, IN short* pInt) {

    BBPLUGIN BBP; ClearMemory(&BBP, sizeof(BBP));

    HDC glDC = (HDC) (ZI_GetProperty(gP.hGL, ZI_GLDC));
    HGLRC glRC = (HGLRC) (ZI_GetProperty(gP.hGL, ZI_GLRC));
    if (glRC) {

        BBP.msg          = BBP_RENDER;
        BBP.parent       = gP.hGL;
        BBP.dc           = glDC;
        BBP.rc           = glRC;
        BBP.lpeak        = SolvePeak(LOWORD(nLevel), 128);
        BBP.rpeak        = SolvePeak(HIWORD(nLevel), 128);
        BBP.backargb     = 0;
        BBP.fftdata      = (float*) BassChannelGetData();
        BBP.fftsize      = 256;
        BBP.medialength  = gB.medialength;
        BBP.mediapos     = gB.mediapos;
        BBP.wimdata      = pInt;

        BBP_Plugin(BBP);
        //BBProc(BBP);

        // Refresh display
        SwapBuffers(glDC);

        InvalidateRect(gP.hGL, NULL, 0);
        UpdateWindow(gP.hGL);
    }
    ReleaseDC(gP.hGL, glDC);
}

static void BBP_NewSound() {
    BBPLUGIN BBP; ClearMemory(&BBP, sizeof(BBP));
    BBP.msg = BBP_NEWSOUND;
    BBP_Plugin(BBP);
}

If you are familiar with OpenGL programming, the VS2022 source code of each plugin is also attached in the Plugins_dll.7z

26
Eye Candies / BassBox64 (updated)
« Last post by Patrice Terrier on August 28, 2024, 10:14:19 am »
The previous post has been updated with a new version.

New:
Preprocess mouse messages to use either left or right button to fire a WM_COMMAND.
Save window coordinates.
Memory foot print reduction.
Further optimization.

Bug fix:
In case of playing multiple audio files. The selection order was not respected.
When playing a sound tracker, the file name was truncated by the previous wsplitpath function.
27
The concept / ShaderPlay
« Last post by Patrice Terrier on August 08, 2024, 01:11:50 pm »
ShaderPlay is derivated from ORV64.
Its purpose is to play ShaderToy static animations.



It is written in C/C++ with VS2022, and does use TClib.lib to produce a tiny 15 Kb binary.
Each schader file is stored in a distinct subfolder, under the 3D_models parent folder.

The shader code file is using the .fs extension, it is sligthy different from the original ShaderToy to match the OR (ObjReader) specifications.

For the purpose of ShaderPlay, each project is provided with a specific sound track to shut down automatically the shader once audio comes to full completion (except when playing in loop mode).
28
The concept / ParticLines
« Last post by Patrice Terrier on July 24, 2024, 02:25:28 pm »
The original project was written in Pascal by Jan Horn (passed in 2002).

This current VS2022 version has been converted from PowerBASIC (GDImage 5.00) to C/C++ (GDImage64 7.16).



The window is using the GDImage anti-aliased WGL_CreateWindow API to create the 3D container and to produce the smooth particle tail lines.

The WinLIFT theme is based on the Windows Seven style that was used by the year 2010.

TClib.lib is used to produce the small binary executable of only 17Kb.
29
Tips & Tricks / Re: CPU Meter
« Last post by Patrice Terrier on July 08, 2024, 06:16:49 pm »
This is version 2.00.

It has been reworked to match the CPU processor percentage computation used in Windows 11.

On previous Windows 10, they were using "Processor(_Total)\\% Processor Time"

The solution is to use PDH (Performance Data Helper) and the Processor Utility request
nStatus = PdhAddEnglishCounter(cpuQuery, L"\\Processor Information(_Total)\\% Processor Utility", NULL, &cpuTotal);

\\Processor Information(_Total)\\% Processor Utility
  • Description: This counter measures the percentage of processor utility across all processors.
  • Utility: It provides a more detailed and modern view of processor usage, taking into account various factors like the efficiency of processing and modern CPU architectures.
  • Availability: This counter is generally available on newer systems with modern processors. It can give a more accurate representation of CPU utilization in multi-core and hyper-threaded environments.
\\Processor(_Total)\\% Processor Time
  • Description: This counter measures the percentage of time the processor is busy executing a non-idle thread.
  • Utility: It is a more traditional counter that has been available in Windows for a long time. It reflects the CPU load by measuring the active time versus the idle time of the CPU.
  • Availability: This counter is widely available across different versions of Windows and provides a consistent measure of CPU usage.
Note:
The project use TCLib.lib to produce a tiny 29 Kb binary executable.

30
Eye Candies / BassBox64 (alias BB64) full VS2022 project
« Last post by Patrice Terrier on June 23, 2024, 07:15:47 pm »
BassBox64 (alias BB64)
is a C/C++ VS2022 64-bit version, using a totaly different GUI, with huge size optimization.
The OpenGL visual plugins are still those from the PowerBASIC 32-bit version.



When visual plugins are enabled, press the left or right mouse button to change them.
You can also use the mouse buttons to select a specific image background.



Pages: 1 2 [3] 4 5 ... 10