Page 5 of 6 FirstFirst ... 23456 LastLast
Results 161 to 200 of 201

Thread: Direct2D Typelib+ for VB6

  1. #161

  2. #162
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: Direct2D Typelib+ for VB6

    Quote Originally Posted by The trick View Post
    There are conflicts with the newer versions of oleexp regarding to WIC. The new oleexp already has WIC declarations which are incompatible with wicvb.tlb. I can't compile this TLB because of UUID redefinitions and this TLB requires some OLEEXP types.


    ADDED:


    The sources of the typelib are in the attachment. I've updated the references to OLEEXP5.1 but wicvb.tlb won't work so SaveImage project won't work too. You could remove wicvb.tlb from the references and use OLEEXP interfaces declarations instead with the small modifications of the code.



    I have no experience in using this Direct 2d, can you send the "saved image" project modified to work without problem and new versions of oleexp like as 5.1?


    about your attached i saw these errors after open and run demos projects with some defaults with 4.3 oleexp and replaced with oleexp 5.1 :


    about CustomRenderer and Inline object projects these errors :
    image link : https://postimg.cc/CdNf50GP







    about ImageDrawings project this error :
    image link : https://postimg.cc/vxLyRYMq







    about SaveImage this error :
    image link : https://postimg.cc/rzFwzwzW





    about Laser its same basic drawing project :
    image link : https://postimg.cc/m1t4jhF5



    can u attach modified projects to work without error?
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  3. #163
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    Re: Direct2D Typelib+ for VB6

    Honestly I have no idea how oleexp.UUID is a type mismatch for an argument expecting oleexp.UUID.

  4. #164

  5. #165

  6. #166

  7. #167

    Thread Starter
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Direct2D Typelib+ for VB6

    my references:
    - Direct2D1 v1.10
    - Wincodec v1.0
    - OLEEXP v5.01

    so if I would update from OLEEXP 5.01 to 5.1 it will stop working?
    the WIC is only used to load PNG files. with some scaling/rotating and thats it.

  8. #168
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    Re: Direct2D Typelib+ for VB6

    Quote Originally Posted by The trick View Post
    wicvb.tlb refers to the types from OLEEXP4.3 whenas D2D refers to the types declared in OLEEXP5.1
    I'm talking about the version you posted in #159 that doesn't reference wicvb.tlb, and using it with oleexp 5.1.


    Sidenote: If people ever wonder why oleexp is a massive single library, it's because of issues like this. The trick, would it be ok if I incorporated your D2D libraries into oleexp? I'll of course credit you.
    Last edited by fafalone; Dec 7th, 2022 at 04:44 AM.

  9. #169

    Thread Starter
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Direct2D Typelib+ for VB6

    if u can incorporate wic+d2d into oleexp it would be best, at least to avoid this kind of situations.
    the other alternative is to make d2d+wic its own tlb that don't need any dependencies from oleexp or other

    another thing.
    d2d is compatible with windows 7, so all the new features we get in windows 10 (more interpolation modes, SVG rendering etc) are not implemented.
    if so it could make it not working in windows 7 anymore.

    do u think its possible to add more features without messing with compatibility?
    so, say,
    if u system is windows 10 u can use a better interpolation mode, but if windows 7, it will use the default D2D1_INTERPOLATION_MODE_LINEAR

    because I can't use
    D2D1_INTERPOLATION_MODE_CUBIC,
    D2D1_INTERPOLATION_MODE_MULTI_SAMPLE_LINEAR,
    D2D1_INTERPOLATION_MODE_ANISOTROPIC,
    D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC,

    https://learn.microsoft.com/en-us/wi...rpolation_mode

    it says Platform Update for Windows 7 (and that should be available for all windows 7, part of the updates)
    Last edited by baka; Dec 7th, 2022 at 05:00 AM.

  10. #170
    PowerPoster
    Join Date
    Feb 2015
    Posts
    2,672

    Re: Direct2D Typelib+ for VB6

    Quote Originally Posted by fafalone View Post
    I'm talking about the version you posted in #159 that doesn't reference wicvb.tlb, and using it with oleexp 5.1.
    Yes Direct2D and DirectWrite use OLEEXP5.1 in #159 post but wicvb.tlb doesn't because it has the same UUID for WIC interfaces.

    Quote Originally Posted by fafalone View Post
    The trick, would it be ok if I incorporated your D2D libraries into oleexp? I'll of course credit you.
    Yes it would be very good.

    BTW why don't you use HRESULT in your WIC implementation?

  11. #171
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    Re: Direct2D Typelib+ for VB6

    Because it's easier to check success/handle failure when you can access the HRESULT directly instead of having to rely on VB raising runtime errors and jumping into a handler.

    I made sure to use them in the callback interfaces... are there others that are used with Implements that aren't using all HRESULT?

    It'll be a day or two before I post the version with it merged... there's quite a bit of syntax incompatible with MKTYPLIB; oleexp can't be compiled with midl.
    Last edited by fafalone; Dec 7th, 2022 at 08:10 AM.

  12. #172
    PowerPoster
    Join Date
    Feb 2015
    Posts
    2,672

    Re: Direct2D Typelib+ for VB6

    Quote Originally Posted by fafalone View Post
    I made sure to use them in the callback interfaces... are there others that are used with Implements that aren't using all HRESULT?

    It'll be a day or two before I post the version with it merged... there's quite a bit of syntax incompatible with MKTYPLIB; oleexp can't be compiled with midl.
    For example when use wicvb.tlb (uses HRESULT):
    Code:
        ' // Create WIC bitmap that is saved to file
        Set cBitmap = cWicFactory.CreateBitmap(Me.ScaleWidth, Me.ScaleHeight, _
                                               WIC.GUID_WICPixelFormat32bppPBGRA, WICBitmapCacheOnLoad)
    
        ' // Inverse half pixels
        Set cLock = cBitmap.Lock(WIC.WICRect(0, 0, Me.ScaleWidth, Me.ScaleHeight / 2), WICBitmapLockWrite)
    If i'd use OLEEXP WIC definitions (without HRESULT):

    Code:
        ' // Create WIC bitmap that is saved to file
        If cWicFactory.CreateBitmap(Me.ScaleWidth, Me.ScaleHeight, _
                                     WIC.GUID_WICPixelFormat32bppPBGRA, WICBitmapCacheOnLoad, cBitmap) < 0 Then
            ' error handle
        End If
    
        ' // Inverse half pixels
        If cBitmap.Lock(WIC.WICRect(0, 0, Me.ScaleWidth, Me.ScaleHeight / 2), WICBitmapLockWrite, cLock) < 0 Then
            ' error handle
        End If
    The second one is like C-style coding. Nothing bad just i prefer to use [out, retval] and etc in VB.

  13. #173

    Thread Starter
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Direct2D Typelib+ for VB6

    same here, I also prefer HRESULT

  14. #174
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: Direct2D Typelib+ for VB6

    Quote Originally Posted by The trick View Post
    I've removed the OLEEXP references from the typelibraries (some types was redefinited like UUID and some changed to void*/IUnknown). Some projects use OLEEXP but you can use any version now because it's a VB reference not a tlb reference.

    thanks i downloaded from post 166,all project attached work good exepct these 3 projects :

    custom font project error:



    custom render project error:




    save image error :




    Is it not possible that these 3 projects work without the need for oleexp 5.1 (without depened)?
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  15. #175
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    Re: Direct2D Typelib+ for VB6

    I believe The trick was saying he removed the oleexp dependency *from the TLBs*, so you can use any version because only VB is referencing it and VB doesn't depend on it being byte-for-byte identical.

    If you remove it entirely you'll have to replace all the constants/declares that are in it.

  16. #176

  17. #177
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: Direct2D Typelib+ for VB6

    i removed oleexp from refrences of that 3 projects and fixed these project like as this :

    in custom font :
    Code:
    ' orginal depend on oleexp
    'Err.Raise E_INVALIDARG
    ' without oleexp
    Err.Raise &H80070057
    in save image :
    i redeclared this type without need oleexp now :
    Code:
    Private Type SAFEARRAYBOUND
        cElements As Long
        lLbound As Long
    End Type
    but about custom render project ,how can redeclare this sub movememory as i shown in post 174
    Code:
    Private Function IDWriteTextRendererImp_GetCurrentTransform( _
                     ByVal pClientDrawingContext As Long) As DWVBLib.DWRITE_MATRIX
        MoveMemory IDWriteTextRendererImp_GetCurrentTransform, mcRenderTarget.GetTransform, _
                    Len(IDWriteTextRendererImp_GetCurrentTransform)
    End Function
    i can just see this sub like as this :
    Code:
    Sub MoveMemory(pDest As Any, pSource As Any, ByteLen As Long)

    i have another question too to i wanna do something like this :

    i want show a png pic with direct 2d like as layred window and then i rotate it like as 3d with rotate effect or skew effect like this :
    for example i want just rotate that png on Y and then show it like as layred window

    Name:  1111.jpg
Views: 675
Size:  29.8 KB

    how can do that? i hv no experience about direct 2d and show like as layred window useing direct 2d,any sample about it?
    am i need use direct 2d for that rotate 3d or any sample without need direct 2d?
    Last edited by Black_Storm; Dec 8th, 2022 at 06:45 PM.
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  18. #178
    PowerPoster
    Join Date
    Feb 2015
    Posts
    2,672

    Re: Direct2D Typelib+ for VB6

    Quote Originally Posted by Black_Storm View Post
    how can do that? i hv no experience about direct 2d and show like as layred window useing direct 2d,any sample about it?
    am i need use direct 2d for that rotate 3d or any sample without need direct 2d?
    Open ImageDrawings project and replace transform to:

    Code:
        cRenderTarget.SetTransform D2D1.Matrix3x2F_SetProduct(D2D1.Matrix3x2F_Translation2(-tSize.Width / 2, 0), _
                                    D2D1.Matrix3x2F(Cos(fPhase / 10), Sin(fPhase / 10) / 2, 0, 1, tSize.Width, tSize.Height / 2))

  19. #179
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: Direct2D Typelib+ for VB6

    about my question in post 177 custom render project ,i fixed movememory function with this declaration :
    Code:
    Private Declare Sub RtlMoveMemory Lib "kernel32.dll" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
    and then i removed oleexp from refrences of custom render project.

    Quote Originally Posted by The trick View Post
    Open ImageDrawings project and replace transform to:

    Code:
        cRenderTarget.SetTransform D2D1.Matrix3x2F_SetProduct(D2D1.Matrix3x2F_Translation2(-tSize.Width / 2, 0), _
                                    D2D1.Matrix3x2F(Cos(fPhase / 10), Sin(fPhase / 10) / 2, 0, 1, tSize.Width, tSize.Height / 2))
    this is my means , i just make a fake image for preview :
    how can do that like as this ?
    image link : https://postimg.cc/KKP78bYV


    - how can centered in form?
    - and still about show like as leyred window too?
    Last edited by Black_Storm; Dec 13th, 2022 at 05:53 PM.
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  20. #180
    Fanatic Member Black_Storm's Avatar
    Join Date
    Sep 2007
    Location
    any where
    Posts
    575

    Re: Direct2D Typelib+ for VB6

    i found that rotate effect as i shown in post 179 and layered window with opengl by this :
    https://www.vbforums.com/showthread....layered-window
    [ ... active on skype and discord ... ] ,[always strive to achieve your dreams] , [always try,dont stop,never say never]

  21. #181

  22. #182

  23. #183
    Hyperactive Member
    Join Date
    Dec 2008
    Location
    Argentina
    Posts
    439

    Re: Direct2D Typelib+ for VB6

    Good job, thanks for sharing, I'm not sure if it's my problem, but I think wicvb.tlb or dwvb.tlb have a problem, did anyone else have problems? I had to use the old tlb, but again, maybe it's a problem in the my record.
    leandroascierto.com Visual Basic 6 projects

  24. #184

  25. #185

    Thread Starter
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Direct2D Typelib+ for VB6

    so decided to "try" the newer typelib by The trick,
    but I can't use it. I get an error using "UUID"
    no matter what I do, it seems I need to use the older OLEEXP to make it work.

    I can see the UUID in the typelib of the new "Direct2D_V2_10" collection from The trick,
    but somehow that UUID that is used by cWicFactory seems to only accept the OLD OLEEXP UUID

  26. #186

  27. #187

    Thread Starter
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Direct2D Typelib+ for VB6

    yeah. it worked!
    I did try it before and I got an error, but retrying again and it worked.
    most be a conflict when I changed the typelib.

    (I now remove all typelibs instead of adding a new one, it seems VB6 like to change the typelib itself)

  28. #188

    Thread Starter
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Direct2D Typelib+ for VB6

    so apart from that mismatch where the typelib conflicted, I just needed to change IUnknown to IStream
    and a few RECT/Point and a couple of API to make it work without OLEEXP.
    as such a big project it took me a couple of minutes to change.
    I think its best with as little typelib possible, this to prevent issues.

  29. #189

    Thread Starter
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Direct2D Typelib+ for VB6

    this is mostly for the Trick.

    I do have some issue with memory leaks, (https://www.vbforums.com/showthread....y-buffer-cache)
    so I asked Sage/Poe: https://poe.com

    here's the answer:

    Yes, there is a way to dispose/cleanup Direct2D bitmaps. Direct2D provides a ID2D1Bitmap interface that represents a bitmap image. To release the resources associated with a bitmap, you can call the ID2D1Bitmap::Release method.
    You should call the Release method on all Direct2D objects that you create when you are done using them to avoid memory leaks. It's also a good practice to set the pointer to nullptr after releasing the object to avoid using a dangling pointer.
    Yes, here is an example of how to release a Direct2D bitmap in Visual Basic 6:
    Code:
    Dim bitmap As ID2D1Bitmap ' obtain a pointer to the bitmap
    If Not bitmap Is Nothing Then
        bitmap.Release
        Set bitmap = Nothing
    End If
    but I can't find any "Release" command.
    is there a way to do this? or maybe u need to update the typelib?

  30. #190

  31. #191

    Thread Starter
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Direct2D Typelib+ for VB6

    but there seems to be some memory leaks.

    as I wrote in the other thread.

    memory usage: mainmenu - map1 - map2 - mainmenu
    only software: 52MB - 315MB - 115MB - 110MB
    only hardware: 52MB - 315MB - 116MB - 116MB

    start hardware: 52MB - change to software - 435MB - 564MB - 352MB - 479MB
    start software: 52MB - change to hardware - 54MB - 321MB - 125MB - 114MB

    as u can see something is changing when I switch from hardware to software
    maybe u know why this is happening? I cleanup using = nothing and set all variables to nothing before I restart the engine and reload.

  32. #192
    PowerPoster
    Join Date
    Feb 2015
    Posts
    2,672

    Re: Direct2D Typelib+ for VB6

    Quote Originally Posted by baka View Post
    but there seems to be some memory leaks.

    as I wrote in the other thread.

    memory usage: mainmenu - map1 - map2 - mainmenu
    only software: 52MB - 315MB - 115MB - 110MB
    only hardware: 52MB - 315MB - 116MB - 116MB

    start hardware: 52MB - change to software - 435MB - 564MB - 352MB - 479MB
    start software: 52MB - change to hardware - 54MB - 321MB - 125MB - 114MB

    as u can see something is changing when I switch from hardware to software
    maybe u know why this is happening? I cleanup using = nothing and set all variables to nothing before I restart the engine and reload.
    I don't know what you do. Maybe you didn't cleanup other resources or have circular references.

  33. #193

    Thread Starter
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Direct2D Typelib+ for VB6

    when I call the "change mode" I exit the game-loop. outside of it. I call Restart.
    Init rendertype is just the cFactory/cWicFactory and different RenderTarget creations + brushes creation.
    LoadImage/ReLoadDual are the exact same functions I use to load assets.

    Code:
    Sub Restart(Optional rendertype As Byte)
        Dim i&
    
        DestroyD2D
        Init rendertype
        
        For i = 0 To UBound(Canvas)
            If Canvas(i).Filename <> vbNullString Then
                Select Case Canvas(i).Mode
                    Case 0: LoadImage Canvas(i).Filename, Canvas(i).Flip, i
                    Case 1: ReloadDual Canvas(i).Filename, Canvas(i).Flip, i
                End Select
            End If
        Next i
    End Sub
    Code:
    Private Sub DestroyD2D()
        Dim i&
        For i = 0 To UBound(Canvas): Set Canvas(i).Bitmap = Nothing: Next i  ' Remove All Bitmaps
        For i = 0 To UBound(brushes): Set brushes(i) = Nothing: Next i       ' Remove All Brushes
        Set tTarget = Nothing
        Set cTarget = Nothing
        Set hTarget = Nothing
        Set cWicFactory = Nothing
        Set cFactory = Nothing
    End Sub
    when Restart is done it will enter the gameloop again. nothing else.


    ok I did another test.
    when u use "CTRL+ALT+DEL" it will go to login-page. when u return to desktop the direct2d need to restart. and when it do, it will use the EXACT same reload function.
    but this time the memory is unchanged. in any maps it will return and reload it to the same memory-usage.
    ONLY when I change between hardware > software this happens.
    Last edited by baka; May 19th, 2023 at 06:23 AM.

  34. #194

    Thread Starter
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Direct2D Typelib+ for VB6

    is it possible to update your typelib adding

    WICBitmapInterpolationMode

    typedef enum WICBitmapInterpolationMode {
    WICBitmapInterpolationModeNearestNeighbor = 0,
    WICBitmapInterpolationModeLinear = 0x1,
    WICBitmapInterpolationModeCubic = 0x2,
    WICBitmapInterpolationModeFant = 0x3,
    WICBitmapInterpolationModeHighQualityCubic = 0x4,
    WICBITMAPINTERPOLATIONMODE_FORCE_DWORD = 0x7fffffff
    } ;

    so we get WICBitmapInterpolationModeHighQualityCubic as well?
    the idea is that if u are using windows 10 u get that option unlocked.
    I tried using "4" but it didnt work, the person in windows 10 told me it was identical to 3 (I get the same result in windows 7, 4 is like 3)

    asked Poe and he told me:
    When you use a typelib in your VB6 project, the values of the enumeration are determined by the typelib itself and not by the underlying operating system. Since the typelib was created before the addition of WICBitmapInterpolationModeHighQualityCubic, it doesn't have knowledge of that value.

    When you compile your executable and run it on Windows 10, the typelib is still the same and doesn't magically update with new values. Therefore, when you specify "4", the VB6 runtime interprets it as an unrecognized value and likely falls back to a default behavior,

    now sure if its possible to do.

    happy new year

  35. #195
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: Direct2D Typelib+ for VB6

    Quote Originally Posted by baka View Post
    Therefore, when you specify "4", the VB6 runtime interprets it as an unrecognized value and likely falls back to a default behavior. . .
    VB6 has no problem using 4 (or "4") as enum value because you can use integer variables and literals instead of enum variables and literals anywhere in code without even a warning from the compiler.

    The one not recognizing 4 as an interpolation mode is likely win7 impl of D3D which falls back to its default interpolation mode.

    Btw, you can easily "fix" the issue (if typelib update is not avaiable) by simply declaring Public Const WICBitmapInterpolationModeHighQualityCubic As Long = 4 somewhere in a standard module of your project.

    cheers,
    </wqw>

  36. #196
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,996

    Re: Direct2D Typelib+ for VB6

    Quote Originally Posted by baka View Post
    asked Poe and he told me:
    When you use a typelib in your VB6 project, the values of the enumeration are determined by the typelib itself and not by the underlying operating system. Since the typelib was created before the addition of WICBitmapInterpolationModeHighQualityCubic, it doesn't have knowledge of that value.

    When you compile your executable and run it on Windows 10, the typelib is still the same and doesn't magically update with new values.
    That part is right.

    Quote Originally Posted by baka View Post
    Therefore, when you specify "4", the VB6 runtime interprets it as an unrecognized value and likely falls back to a default behavior,
    That part is wrong. VB6 does not perform any validation over enums, whether a value corresponds to an emun member or not.

    An enum is just a Long, nothing else.
    Enums are a set of constants (type Long) put together. And a constant is a named value, just to help the programmer 1) with intellisense and 2) because in the name itself there is usually some 'explanation' of what it does.

    But an enum (or a constant type Long) is just a Long value expressed by a name rather than a number, that is converted to a number on compilation, and the program (function in a DLL) receiving that number does not know whether that Long number was originally generated by a constant, an emun, a literal number, an Hex expression (&H4), a variable read from a file, or whatever. The value is received as a Long, and that's it.

    To avoid any issue pass your literal ByVal and with the & at the end:

    Code:
    ...   , ByVal 4&, ...

  37. #197

    Thread Starter
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Direct2D Typelib+ for VB6

    I talked to fafalone and I will do some testing to make 100% sure. I have the trick typelib, fafalone typelib and an edited-typelib (fafalones) without the 4th enum.

    will make a small project that will use the 3 typelibs.
    will use byval 4& as u say as well.

  38. #198
    New Member
    Join Date
    Jan 2024
    Posts
    1

    Re: Direct2D Typelib+ for VB6

    Is there a specific reason why changing from hardware to software mode triggers a change in memory usage, while other scenarios, like switching from hardware to software after using "CTRL+ALT+DEL," show consistent memory behavior? Additionally, have you explored alternatives or additional cleanup methods to address the memory fluctuations when switching modes?

  39. #199
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    Re: Direct2D Typelib+ for VB6

    Well when you use hardware acceleration some stuff is put in the memory of your graphics card. With software rendering it's all in system memory.

  40. #200
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    5,651

    Re: Direct2D Typelib+ for VB6

    If anyone is interested, I've ported all of the The trick's samples from Direct2D_V2_10.zip to 64bit compatible twinBASIC projects, using WinDevLib instead of several typelibs, exploiting tB's ability to use Implements on derived interfaces and As Any arguments, among others.

    https://github.com/fafalone/D2DSamples - Ports of The trick's Direct2D examples


    Huge thanks to The trick, these are great learning resources. I of course left all the credits to him in the projects.

Page 5 of 6 FirstFirst ... 23456 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width