Author Topic: Early WIP on v2.55  (Read 164318 times)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55 :: !!! AHTUNG, Part II !!!
« Reply #45 on: October 31, 2018, 05:46:02 pm »
Patrice,

The spinner include file is not full. It misses the zBitmapToImage (IN HDC hDC) function that is still in GDImage.dll.

Will you please supply me with the function source code now?

TIA
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1987
    • zapsolution
Re: Early WIP on v2.55
« Reply #46 on: October 31, 2018, 06:21:42 pm »

Here it is
Code: [Select]
LONG_PTR zBitmapToImage (IN HDC hDC) { // dllexport AS LONG
    BITMAPINFO bi = {0};
    BITMAP bm = {0};
    LONG_PTR lpImg = NULL;
    long MaxBound;

    HBITMAP hBitmap = ZI_GetBitmapFromDC(hDC);
    if (hBitmap) {
       GetObject(hBitmap, sizeof(bm), &bm);

       bi.bmiHeader.biSize        = sizeof(bi.bmiHeader);
       bi.bmiHeader.biWidth       = bm.bmWidth;
       bi.bmiHeader.biHeight      = -bm.bmHeight; // Put top in TOP instead on bottom!
       bi.bmiHeader.biPlanes      = 1;
       bi.bmiHeader.biBitCount    = 32;
       bi.bmiHeader.biCompression = BI_RGB;

       MaxBound = bm.bmWidth * bm.bmHeight * 4;
       if ((long)g_ByteArray.max_size() < MaxBound) { g_ByteArray.resize(MaxBound); }
       //vector<BYTE>::pointer ptr = &g_ByteArray[0];
       if (GetDIBits(hDC, hBitmap, 0, bm.bmHeight, &g_ByteArray[0], &bi, DIB_RGB_COLORS)) {
          if (GdipCreateBitmapFromScan0(bm.bmWidth, bm.bmHeight, bm.bmWidth * 4, PixelFormat32bppARGB, &g_ByteArray[0], lpImg) != 0) {
              lpImg = NULL;
          }
       }
    }
    return lpImg;
}

BTW, did you see what happen to the GDI count each time we enable/disable mipmap textures...
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #47 on: October 31, 2018, 06:36:09 pm »
1. Thank you but the code is still incomplete. That function pulls in another ZI_GetBitmapFromDC(IN HDC hDC). Can I have it too? (that's exactly why I'm usually reluctant to work with 3rd party pandora boxes ;) )

2. Let's make it one at a time. Perhaps our current effort will help reduce total losses in the other parts of OR project. :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1987
    • zapsolution
Re: Early WIP on v2.55
« Reply #48 on: October 31, 2018, 06:42:57 pm »
Code: [Select]
HBITMAP ZI_GetBitmapFromDC(IN HDC hDC) {
    HBITMAP nRet = NULL;
    if (hDC) {
        nRet = HBITMAP(GetCurrentObject(hDC, OBJ_BITMAP));
    }
    return nRet;
}
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #49 on: October 31, 2018, 06:48:00 pm »
Thanks!

And while we're at it, can you also tell me (in terms of lfFaceName, lfWeight, dpi() height, and kerning width) exactly which font your geo data skinned edit boxes are using with the current SKS settings?
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1987
    • zapsolution
Re: Early WIP on v2.55
« Reply #50 on: October 31, 2018, 06:57:23 pm »
Code: [Select]
HFONT skFontDlg() { // dllexport
    static HFONT hFont;
    LOGFONT lf = {0};
    if (hFont == 0) {
       lf.lfHeight         = -13;
       lf.lfWidth          = 0;
       lf.lfCharSet        = 1; // DEFAULT_CHARSET;
       lf.lfOutPrecision   = 6; // OUT_DEFAULT_PRECIS;
       lf.lfClipPrecision  = 0; // OUT_DEFAULT_PRECIS;
       lf.lfQuality        = 0; // DEFAULT_QUALITY;
       lf.lfPitchAndFamily = 0; // DEFAULT_PITCH | FF_DONTCARE;
       lf.lfWeight         = 800;
       wstring sUseFont = UseThisFont();
       wcscpy_s(lf.lfFaceName, (WCHAR*) sUseFont.c_str());
       hFont = CreateFontIndirect(&lf);
    }
    return hFont;
}
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #51 on: October 31, 2018, 07:04:19 pm »
Thanks again! :D

Now I need zCreateDIBSection() too...  :'(
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1987
    • zapsolution
Re: Early WIP on v2.55
« Reply #52 on: October 31, 2018, 07:22:01 pm »
Code: [Select]
HBITMAP zCreateDIBSection (IN HDC hDC, IN long nWidth, IN long nHeight, IN long nBitCount) { // exportdll
    BITMAPINFO bi = { 0 };
    BYTE* lpBitmapBits = NULL;
    bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
    bi.bmiHeader.biWidth = nWidth;
    bi.bmiHeader.biHeight = nHeight;
    bi.bmiHeader.biPlanes = 1;
    bi.bmiHeader.biBitCount = (WORD) nBitCount;
    bi.bmiHeader.biCompression = BI_RGB;
    return CreateDIBSection(hDC, &bi, DIB_RGB_COLORS, (LPVOID*)&lpBitmapBits, NULL, 0);
}
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #53 on: October 31, 2018, 07:33:02 pm »
Thanks, thanks, and thanks!  ;D

Quote
wstring sUseFont = UseThisFont(); // MLL ???
wcscpy_s(lf.lfFaceName, (WCHAR*)sUseFont.c_str());

So you mean to say you do not know exactly the answer to my question?

Actually, it seems to be Trebuchet MS at lf.lfHeight = -11 and lf.lfWeight = 400...  :-\
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #54 on: October 31, 2018, 07:55:46 pm »
Done as advised, thanks a million! :)

I was asking because I had implemented the model load time counter in a separate thread but I can't modify the edit box text across threads (and that's natural), especially when the main thread is totally blocked out by the tight loops while parsing, triangulating, calculating normals, tangents and bitangents etc. etc. etc.

So I'm using a worker thread window that overlays the edit box and mimics its looks quite nicely, but there's a very very subtle difference in the font look and most probably in the glyph kerning (separation) value... ???

But it looks and works like a charm even the way it is now. :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1987
    • zapsolution
Re: Early WIP on v2.55
« Reply #55 on: October 31, 2018, 08:42:33 pm »
Here is the "Quark.png" that could be used to replace the ObjReader.ski, but that doesn't make any difference, i suspect the use of thread to be the culprit.
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55 :: !!! AHTUNG NUMMER DREI !!!
« Reply #56 on: October 31, 2018, 09:09:57 pm »
Yes, you shouldn't select the brush into hDC. FillRect() doesn't need it.

BUT IF YOU STILL SELECTED IT, YOU SHOULD HAVE SAVED THE OLD BRUSH AND RESELECTED IT THERE AGAIN BEFORE HDC DELETION!

---------------------------------------------------------------------------------------

Thanks for the image, I'll use it for my tests.

Quote
... the use of thread to be the culprit.

Negative:
  • My multithreaded load time counter is also using GDI objects heavily but leaks none.
  • My Objector spinner is also multithreaded, and though its has very different code (it was my own solution, after all), it utilizes the same SKI files and has a similar fundamental approach. It uses GDI and GDI+ objects heavily but leaks none either.
  • I was already able to spot a couple GDI errors in Spinner.h, which helped me to fix two GDI object leaks, and reduce the overall count of leaked objects from 8 to 6. That's a good indication I'm moving in the right direction.
The rest of Spinner.h + dependent functions seems now OK, GDI-wise, including RenderAnimation(). Next I'll have to read up more on GDI+ and see if there are any peculiarities about the deletion of its objects too.

But!

Regarding texture reload and mipmapping, IMHO there are no outstanding problems, but not so with the skinned menu.

!!! Gosh, it's leaking GDI objects like hell by hundreds !!!

:o ??? :'(
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Patrice Terrier

  • Administrator
  • *****
  • Posts: 1987
    • zapsolution
Re: Early WIP on v2.55
« Reply #57 on: October 31, 2018, 10:51:45 pm »
I just checked the latest ObjReader32 written in PowerBASIC, and the problem is there also.  :'(

Added:
Looks likes the use of checkbox in menu is causing the havoc.
The skMarlett font must be created once for all, and removed at the end of session.

DeleteObject(Fmarlett);
« Last Edit: November 01, 2018, 07:34:22 am by Patrice Terrier »
Patrice
(Always working with the latest Windows version available...)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #58 on: November 01, 2018, 07:47:19 am »
Did you go to sleep last night at all, my friend? :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)

Michael Lobko-Lobanovsky

  • Administrator
  • *****
  • Posts: 1481
Re: Early WIP on v2.55
« Reply #59 on: November 01, 2018, 08:16:25 am »
DeleteObject(Fmarlett);

Ha-ha, congrats my friend! That did the trick!!!  :D

Here is the new WLFT pandora, you know what to do once downloaded  :-X

Deleted without downloading. I was able to spot the target you were hinting at, and recompiled myself. Everything's in perfect order with the menu now. :)

Quote
But there is still the 6 GDI leaks when using the spinner  ::)

We'll fix those ones eventually as well, my friend, won't we? :D


Thanks for your great effort! And your projects are awesome pieces of programming art! :)
Mike
(3.6GHz Intel Core i5 Quad w/ 16GB RAM, nVidia GTX 1060Ti w/ 6GB VRAM, Windows 7 Ultimate Sp1)