Author Topic: Tutor-17 (C++ VS2022 GDImage64 tutorial)  (Read 4082 times)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1984
    • zapsolution
Tutor-17 (C++ VS2022 GDImage64 tutorial)
« on: September 01, 2023, 07:24:42 pm »
Seventeenth post of a series, translated from the "WinDev and PowerBASIC",
to explain the use of GDImage64 in procedural* programming mode with Visual Studio 2022.

About Tutor_17
This is a C++ transcription of a PowerBASIC demo written in 2009 with the official release of GDImage 5.00.
It was the first version able to mix 2D and 3D OpenGL into the same graphic control.
The application itself is skinned with WinLIFT, and share the same background wallpaper with all child controls.

The Cube
Is using 3 OpenGL cubes (1 main and 2 clones), with each face using a distinct texture.

Wallpaper background
You can click with the right mouse button on the main cube, to change the wallpaper background.

WinLIFT 6.00
Is an experimental version converted to VS2022, the whole code has been revisited for further code size reduction.
New API skMinTrackSizeX ();
return the minimum width size of main window once skinned.
New API skMinTrackSizeY ();
return the minimum height size of main window once skinned.
New API skUseThisBackground(IN HWND hWnd, IN WCHAR* zItem);
To change on the fly the wallpaper background without using the top left icon,
even when the .sks parameter is disabled "BACKGROUNDPATH,      resource\Background"
The skInitEngine API has an extra optional parameter:
skInitEngine (IN WCHAR* zSkinFile, IN WCHAR* zUserKey, IN HWND hParent);

GDImage 7.16
Is an experimental version converted to VS2022, with a new API named "ZD_GLtoBitmap" to dynamically turn the OpenGL context into a ZOBJECT sprite bitmap (see the RenderAnimation() procedure).


Last but not least,
the size of the standalone binary EXE is only 17 Kb.


   
* procedural programming mode, is based on direct use of the FLAT API (Windows SDK) that is the core meat of the OS.
« Last Edit: September 05, 2023, 09:17:27 am by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Shao Voon Wong

  • Newbie
  • *
  • Posts: 12
Re: Tutor-17 (C++ VS2022 GDImage64.dll tutorial)
« Reply #1 on: September 02, 2023, 08:42:37 am »
Hi Patrice,

Cool animation. Why is there no program window and the background is totally transparent when I run the program from Visual Studio? Is there a trick to it?

When I double-click to run the program from the release folder on File Explorer, I get to see the program window as shown on this forum thread.

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1984
    • zapsolution
Re: Tutor-17 (C++ VS2022 GDImage64.dll tutorial)
« Reply #2 on: September 02, 2023, 08:54:35 am »
Good question ...

Probably because the current folder used in debug mode is not the same than in release mode.

I could check in WinLIFT the complete folder path, and see what is different in debug mode than in release mode.

BTW, in this tutor I am detecting the different cube faces using a single color, see in the Drawcube(Hitdetection) procedure glColor4ub(0,0,ID,255).
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1984
    • zapsolution
Re: Tutor-17 (C++ VS2022 GDImage64.dll tutorial)
« Reply #3 on: September 02, 2023, 09:00:28 am »
I think to remember that GDIPLUS needs a fully qualified path, and since the .sks file has been moved to the resource folder, it is not found in debug mode, because the active folder is different.

I shall use zTrace to answer this question, and post a new WinLIFT version that will solve this debug issue.
Patrice
(Always working with the latest Windows version available...)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1984
    • zapsolution
Re: Tutor-17 (C++ VS2022 GDImage64.dll tutorial)
« Reply #4 on: September 02, 2023, 11:04:25 am »
The first post of this thread has been updated with a new WinLIFT64.dll using fully qualified paths that should work in debug mode.
« Last Edit: September 02, 2023, 11:11:55 am by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Shao Voon Wong

  • Newbie
  • *
  • Posts: 12
Re: Tutor-17 (C++ VS2022 GDImage64.dll tutorial)
« Reply #5 on: September 03, 2023, 06:55:33 am »
I do not see any upload in the first post of this thread.

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1984
    • zapsolution
Re: Tutor-17 (C++ VS2022 GDImage64.dll tutorial)
« Reply #6 on: September 03, 2023, 08:06:20 am »
Here it is now, I did a few changes in the new WinLIFT VS2022 experimental version.  ;)
« Last Edit: September 03, 2023, 08:10:03 am by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Shao Voon Wong

  • Newbie
  • *
  • Posts: 12
Re: Tutor-17 (C++ VS2022 GDImage64.dll tutorial)
« Reply #7 on: September 04, 2023, 12:01:22 pm »
Thanks Patrice!

Regarding the cloned cubes, what other information is cloned when we clone an object? Why the event callback in GDImageEnableEvents() is not cloned?

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1984
    • zapsolution
Re: Tutor-17 (C++ VS2022 GDImage64.dll tutorial)
« Reply #8 on: September 04, 2023, 02:45:03 pm »
You can manage the clone(s) using their own object ID in the callback.

long CALLBACK GDImageCallBack(IN HWND hWnd, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam) {
    long nRet = 0; // Do not stop the event processing in GDImage

    static BOOL LeftMouseClick;

    long nID = ZI_MouseOverObjectID(); // <--- You can get the clone ID here

    switch (uMsg) {

    case WM_RBUTTONDOWN:
        if (nID == IDS_3DOBJECT) LeftMouseClick = TRUE;
        break;

    case WM_RBUTTONUP:
        if (nID == IDS_3DOBJECT && LeftMouseClick == TRUE) {
            gP.MouseHit = -1; LeftMouseClick = FALSE;
        }
        break;
    }

    return nRet;
}


However in this specific case, the clone(s) do not duplicate the OpenGL object, they clone only the bitmap of the IDS_3DOBJECT.
« Last Edit: September 04, 2023, 02:49:57 pm by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)