Results 1 to 13 of 13

Thread: Direct2d/WIC + OLEEXP in windows 10

  1. #1

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

    Direct2d/WIC + OLEEXP in windows 10

    so, I try to make things work in windows 10 (bought a new computer and I couldn't install windows 7)
    now I imported my projects and I can't make it work.
    the differences between the typelibs are small, so its quite easy to convert (I think) (in windows 7 I use the Trick typelib and in windows 10 I use OLEEXP by fafalone)
    I check the HResult and it seems to work. but I get a crash no matter what I do when I try to convert a WIC into a Direct2d Bitmap.
    here:

    Set Buffer(Id).Bitmap = cTarget.CreateBitmapFromWicBitmap(cConverter, bitmapProperties)

    in the old version I just use "Byval 0&" instead of bitmapProperties, but I can't do that here.
    cConverter seems to work, I can get the pixelsize of the picture.

    theres only 1 picture, and if I "disable" this part, the program start. direct2d works, it show the "rectangles" that I render, all the colors and sizes.
    so the problem is not the initialization but to load a picture into a direct2d bitmap. any suggestions?

  2. #2
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,886

    Lightbulb Re: Direct2d/WIC + OLEEXP in windows 10

    Have you tried using the object browser (F2)? There seem to be two definitions of CreateBitmapFromWicBitmap:

    Code:
    Sub CreateBitmapFromWicBitmap(wicBitmapSource As IWICBitmapSource, bitmapProperties As D2D1_BITMAP_PROPERTIES1, bitmap As ID2D1Bitmap1)
    
    Function CreateBitmapFromWicBitmap(wicBitmapSource As Any, bitmapProperties As Any) As ID2D1Bitmap
    I see you are trying to use the second one maybe? The first parameter (wicBitmapSource) is declared "As Any" so you can't pass "cConverter" directly, try passing "ByVal ObjPtr(cConverter)" instead or use the other declaration of "CreateBitmapFromWicBitmap" (which is a Sub instead of a Function).

  3. #3

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

    Re: Direct2d/WIC + OLEEXP in windows 10

    using ByVal ObjPtr(cConverter) it worked.

    but I can't access the first one. not sure what to use, I tried oleexp.ID2D1DeviceContext but it gives me the same.
    well this worked. the first project works. I will try the second that is bigger.

  4. #4

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

    Re: Direct2d/WIC + OLEEXP in windows 10

    so I was able to update the other project and it works well.
    now, I noticed that OLEEXP include a lot of different versions but Im not sure how to use it, I get lots of problems when trying.
    also, the interpolation modes are just the same I used in windows 7. probably because I use the first version. at least it work.
    if I want to update with a newer version it will make the project locked to windows 10+, but that will also give me better interpolation modes.
    now I need to understand how to use it.

  5. #5
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    289

    Re: Direct2d/WIC + OLEEXP in windows 10

    I would stick to the MS documentation, or better still to the corresponding header files. This is exactly why I don't use TLBs if possible. I don't know of any problems like the ones you describe.

  6. #6

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

    Re: Direct2d/WIC + OLEEXP in windows 10

    I tried all kinds of ways but I can't access the other versions.
    the function D2D1CreateFactory will always create the old version, theres no D2D1CreateFactory1/2, so even if I use ID2D1Factory1-8 as type, the D2D1CreateFactory will still create ID2D1Factory(0)
    Poe told me to use QueryInterface, but theres no option for that.

    sure it works, I can use the basic version, but Im interested in the other as well. but not sure how to do that.

  7. #7
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,886

    Re: Direct2d/WIC + OLEEXP in windows 10

    The returned factory object depends on which IID_ID2D1Factory you pass to the "D2D1CreateFactory" function as the "riid" parameter. Take your pick from that list of IIDs.

  8. #8
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    6,174

    Re: Direct2d/WIC + OLEEXP in windows 10

    qi =
    Code:
    Set

  9. #9

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

    Re: Direct2d/WIC + OLEEXP in windows 10

    so I used IID_ID2D1Factory1 and cFactory as ID2D1Factory1.
    cFactory show the updated structure, but thats normal as I use the type.

    now, to try cFactory, lets use CreateStrokeStyle
    checking F2 I see:

    CreateStrokeStyle(strokeStyleProperties As D2D1_STROKE_STYLE_PROPERTIES, dashes As Any, dashesCount As Long) As ID2D1StrokeStyle
    Member of oleexp.ID2D1Factory
    and
    CreateStrokeStyle(strokeStyleProperties As D2D1_STROKE_STYLE_PROPERTIES1, dashes As Single, dashesCount As Long, strokeStyle As ID2D1StrokeStyle1)
    Member of oleexp.ID2D1Factory1

    but cFactory is showing the first one anyway.
    I try to use the 2nd one, but it gives me error, so its not just a IDE-thing that show the first one.
    surely I use D2D1_STROKE_STYLE_PROPERTIES1 and ID2D1StrokeStyle1 as types here, but they don't work.
    Last edited by baka; Aug 4th, 2024 at 04:04 AM.

  10. #10

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

    Re: Direct2d/WIC + OLEEXP in windows 10

    ok I looked more into it and it seems that I can not do like that.

    so far I have done:

    Set cFactory1 = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, IID_Get(ID2D1Factory, 1), ByVal 0&)
    Set cWriteFactory1 = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, IID_Get(WriteFactory, 1))

    what I do is to create a cFactory1 using the IID_ID2D1Factory1 GUID
    after that I need to create a WriteFactory and Im using the IDWriteFactory1 GUID
    after that I need to call

    cFactory1.CreateDevice

    but Im not sure how to do that, it require a IDXGIDevice type
    and that will allow me to create a ID2D1Device. it will crash.
    looking in c++ examples I can use nullptr, but its not possible here.

    I also read that I can use QueryInterface to create the IDXGIDevice, but can't find such thing.
    any ideas?

    and if Im able to do the above, the next call is CreateDeviceContext that will create the context needed.

  11. #11
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,409

    Re: Direct2d/WIC + OLEEXP in windows 10

    Btw, this works here:

    Code:
    Option Explicit
    
    Private Sub Form_Load()
        Const D3D11_SDK_VERSION As Long = 7
        Dim creationFlags   As Long
        Dim featureLevels() As Long
        Dim hResult         As Long
        Dim d3d11Device     As ID3D11Device1
        Dim d3d11DeviceContext As ID3D11DeviceContext1
        Dim dxgiDevice      As IDXGIDevice1
        
        creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT
        ReDim featureLevels(0 To 2)
        featureLevels(0) = D3D_FEATURE_LEVEL_11_0
        featureLevels(1) = D3D_FEATURE_LEVEL_10_1
        featureLevels(2) = D3D_FEATURE_LEVEL_10_0
        hResult = D3D11CreateDevice(Nothing, D3D_DRIVER_TYPE_HARDWARE, 0, creationFlags, _
                                    featureLevels(0), UBound(featureLevels) + 1, D3D11_SDK_VERSION, _
                                    d3d11Device, 0, d3d11DeviceContext)
        If hResult < 0 Then
            MsgBox "hResult=&H" & Hex$(hResult), vbCritical
            Exit Sub
        End If
        Set dxgiDevice = d3d11Device
        Debug.Print TypeName(dxgiDevice)
    End Sub
    cheers,
    </wqw>

  12. #12
    Frenzied Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    1,886

    Lightbulb Re: Direct2d/WIC + OLEEXP in windows 10

    You call the QueryInterface method on an existing object, passing the IID of the desired interface. The QueryInterface method is always at vTable offset zero and you can call it using DispCallFunc as usual. If you are using a TypeLib that describes the required interfaces then you can simply use the "Set" instruction like fafalone suggested above and that will call QueryInterface for you behind the scene.

    This is how you obtain a IDXGIDevice using oleexp:
    Code:
    Dim DXGIDevice As IDXGIDevice, D3D11Device As ID3D11Device, D3D11DeviceContext As ID3D11DeviceContext
    Const D3D11_SDK_VERSION As Long = 7
        If D3D11CreateDevice(Nothing, D3D_DRIVER_TYPE_HARDWARE, 0, D3D11_CREATE_DEVICE_BGRA_SUPPORT, ByVal 0&, 0, D3D11_SDK_VERSION, D3D11Device, 0, D3D11DeviceContext) = S_OK Then
            Set DXGIDevice = D3D11Device
        End If
    End Sub

  13. #13

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