Page 2 of 6 FirstFirst 12345 ... LastLast
Results 41 to 80 of 201

Thread: Direct2D Typelib+ for VB6

  1. #41

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

    Re: Direct2D Typelib+ for VB6

    awesome! thx a bunch The trick!
    I will create a new project using direct2d and see if i can re-create the game im doing in gdi. I will post the progress.

    not sure whats best, you should discuss and see whats the best approach for this. maybe cooperate?
    no matter what i appreciate you both taking your time for it.

  2. #42

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

    Re: Direct2D Typelib+ for VB6

    ok, Im now trying the typelib.
    the first thing is cRenderTarget.DrawBitmap
    It says: destinationRectangle as any but the type used in the demo is D2D1_SIZE_F that contains width and height, shouldn't it be D2D1_RECT_F instead?
    it seem to work with either so maybe it doesnt matter?

    another parameter is interpolationmode and I can choose between 3 (dword, linear and nearest_neighbor)
    is there a way to not use any interpolation at all? when not resizing i would not want any interpolation.
    linear seems to be the best quality, what kind of interpolation is that? bilinear? bicubic? not sure what dword is but i can't use it, creates an error.

    as I have a Long value for the background color I need either RGB or RGBLong.
    Using ColorF2 doesnt work. Not sure if im doing it wrong, but this function seems to work for RBG:
    Code:
    Private Function RGBa(ByVal R&, ByVal G&, ByVal B&, Optional ByVal Alpha! = 1) As D2D1_COLOR_F
        With RGBa
            .R = R / 255!
            .G = G / 255!
            .B = B / 255!
            .a = Alpha
        End With
    End Function
    for Long I just do:
    Code:
    Private Function RGBL(ByVal Lng&, Optional Byval Alpha! = 1) As D2D1_COLOR_F
        Dim R&, G&, B&
    
        B = Lng \ 65536
        G = (Lng - B * 65536) \ 256
        R = Lng - B * 65536 - G * 256
        RGBL = RGBa(R, G, B, Alpha)
    End Function

  3. #43
    PowerPoster
    Join Date
    Feb 2015
    Posts
    2,672

    Re: Direct2D Typelib+ for VB6

    It says: destinationRectangle as any but the type used in the demo is D2D1_SIZE_F that contains width and height, shouldn't it be D2D1_RECT_F instead?
    What's the demo exactly?

    another parameter is interpolationmode and I can choose between 3 (dword, linear and nearest_neighbor)
    is there a way to not use any interpolation at all? when not resizing i would not want any interpolation.
    If you don't transform the image it doesn't affect. When you rotate/scale/skew - it affects (see ImageDrawings demo). dword - is not mode.

    Using ColorF2 doesnt work. Not sure if im doing it wrong, but this function seems to work for RBG:
    It's work with &HAARRGGBB.

  4. #44

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

    Re: Direct2D Typelib+ for VB6

    demo: ImageDrawings, in Form_Load() you use D2D1.SizeF(100,100)

    right now my project is using 1 picture (1024x579) that is a background with clouds.
    I use the DrawBitmap function to create a moving animation that will loop the image, copying 800x579.
    the animation works, but theres still stuttering every 1½ seconds. sure im just using a timer right now so its not 100% accurate.
    so, now with Direct2D, what is the best way to render and to prevent stuttering?

  5. #45

  6. #46

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

    Re: Direct2D Typelib+ for VB6

    The trick i was thinking about waitforvblank or VSync.
    I read in a forum about calling "IDXGIObject" to access WaitForVBlank, that is called before EndDraw to sync with the monitor.

    here's a "test" project (source code).
    even when compiled theres some "stuttering".
    https://www92.zippyshare.com/v/XJgUVYNZ/file.html

    I will use a loop when I figure out things. but the timer should be enough accurate for just 1 picture.

  7. #47
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: Direct2D Typelib+ for VB6

    Baka,

    Here's the code for my TimerEx also. It uses the QueryPerformanceCounter & QueryPerformanceFrequency for a much more accurate timer than VB's Timer() function. I've given it to you in Notepad (rather than just the code from the IDE) form so you can get the VB_PredeclaredId = True and Attribute Value.VB_UserMemId = 0 settings. Just put it into a .CLS module with Notepad, and then add to your project. No need to declare any object variable, or anything. Just use TimerEx like a new function in the language.

    This will help if you use a Loop rather than a timer event for your frames. I just put this in my loop to make it run at the desired speed. It completely eliminates any pauses caused by VB's slow timer control.

    Code:
    
    VERSION 1.0 CLASS
    BEGIN
      MultiUse = -1  'True
      Persistable = 0  'NotPersistable
      DataBindingBehavior = 0  'vbNone
      DataSourceBehavior  = 0  'vbNone
      MTSTransactionMode  = 0  'NotAnMTSObject
    END
    Attribute VB_Name = "TimerEx"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = True
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    '
    ' This class has VB_PredeclaredId = True.
    ' Also, the Value is set to the default property.
    ' Therefore, TimerEx will just act like a new built-in function.
    ' No need to declare an object variable or explicitly instantiate.
    '
    Option Explicit
    '
    Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long
    Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long
    '
    Private cFreq As Currency
    '
    
    Private Sub Class_Initialize()
        QueryPerformanceFrequency cFreq
    End Sub
    
    Public Function Value() As Double
    Attribute Value.VB_UserMemId = 0
        ' Must be Public (not Friend) so we can set default property.
        ' Returns seconds, a double, with high-precision.
        ' Caller is responsible for keeping track of start/stop times.
        ' Basically, it works exactly like the built-in Timer function, but with much more precision.
        Dim cValue As Currency
        QueryPerformanceCounter cValue
        Value = cValue / cFreq  ' The division will return a double, and it also cancels out the Currency decimal points.
    End Function
    
    
    Best Of Luck,
    Elroy

    EDIT1: Also, the units returned by TimerEx is seconds, but it's a Double and very accurate with the use of the Double's decimal points.

    EDIT2: And just to say it, I'd save the value for TimerEx at the beginning of rendering one of your cloud frames, do the rendering, and then fall into a loop, waiting for the appropriate amount of time to expire, looking at your saved time value and comparing it against more calls to TimerEx.
    Last edited by Elroy; May 24th, 2018 at 09:15 AM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  8. #48

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

    Re: Direct2D Typelib+ for VB6

    thx Elroy, but this "test" project is just to figure out the stuttering, I do have a loop in my other game, not vb6.timer.
    in my Gdi32 project I also get stuttering when I go below 100fps, that because I don't have any means to get the exact moment the monitor refreshes, that is why Im asking if we can do differently with Direct2D, otherwise I have the exact same problem with Direct2D I have with Gdi32.
    no matter how precise the timer is, theres no point when we can not sync.
    in my Gdi32 project, I refresh so many times that we don't notice that its not in-sync. that is why when I reach 125fps, I don't see any stuttering, its quite smooth, but still is very bad optimized and a waste of cpu.

    even if we can not get any sync with Direct2D its better then Gdi32 anyway, the auto-size feature is quite neat, I dont need to do anything, Direct2D is doing it automatically, I just need to adjust the x/y mouse and thats it.

  9. #49

  10. #50

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

    Re: Direct2D Typelib+ for VB6

    nice! thx for explaining that. i dont even need to do any fps-measurements now.
    is there a return variable to get the vsync rate?
    I read in a forum that Direct2D uses vsync, and if used on a laptop the sync could change from 60fps to 30fps to save power.
    if going slower I also need to know how fast so that I can adjust the speed of the animations.
    I could get it using a timer, but if theres a parameter for it, i would save me time making one!

  11. #51

  12. #52

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

    Re: Direct2D Typelib+ for VB6

    ok. i will add the timer , i need a timer anyway as i use a "timer" in-game as i need to calculate seconds. not a big deal. thanks
    Last edited by baka; May 24th, 2018 at 12:15 PM.

  13. #53

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

    Re: Direct2D Typelib+ for VB6

    So, some samples depend on OLEEXP - olelib With Modern Interfaces by fafalone, v4.3 as far as I can see.

    Can it be internalized by any of the *four* typelibs that come in the zip?

    cheers,
    </wqw>

  15. #55

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

    Re: Direct2D Typelib+ for VB6

    Quote Originally Posted by The trick View Post
    wqweto,

    I don't want to use the internal definitions of the UDTs and the interfaces because in that case we can't assign the same types defined in the different typelibs.
    You can both assign equal GUIDs to UDTs to create compatible structs. Assignment in VB6 should work across typelibs, although personally never tested it.

    cheers,
    </wqw>

  17. #57

  18. #58

  19. #59

  20. #60

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

    Re: Direct2D Typelib+ for VB6

    hello, im back from a weekend trip. thanks for the DirectWrite, Its essential so its much appreciated.
    2 things:

    1
    the demos, I can't make work: CustomRenderer
    I get error: Compile Error, Error in Loading DLL and I get that from "Dim cCustRender As CRenderer"
    everything else works.

    2
    I use AddFontResourceEx to add a custom fonts in GDI. is there a equivalent in DirectWrite?
    googling I found this: https://stackoverflow.com/questions/...ile-at-runtime
    but Im unsure how to do it!

  21. #61

  22. #62
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    673

    Re: Direct2D Typelib+ for VB6

    Quote Originally Posted by The trick View Post
    1. Can you please provide screenshot? What dll exactly?
    2. It isn't implemented yet. The article how to do it here.
    in my system win7 32 chinese . have error

    can you fix?

    Name:  error.jpg
Views: 859
Size:  27.4 KB

  23. #63

  24. #64

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

    Re: Direct2D Typelib+ for VB6

    questions:
    Im trying to use 2 render hwnd.
    one I call cTarget and is set to be rendered in picturebox1
    and the other cTargetSys on picturebox2
    I have tried with different approaches but always giving me the error: automation error (runtime error "-2003238891" (88990015)

    first I render cTarget first, using the .presentOptions = D2D1_PRESENT_OPTIONS_NONE, with begin to end.
    after that I call cTargetSys, that i using .presentOptions = D2D1_PRESENT_OPTIONS_IMMEDIATELY to make it immediately.
    but I get the error.

    are there any way to 2 hwnd or do I need to make it on 1 hwnd only?

  25. #65

  26. #66

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

    Re: Direct2D Typelib+ for VB6

    here the source: https://www80.zippyshare.com/v/RywqEggN/file.html

    i also use a typelib (custom) that includes a bunch of API im using. i added the ODL if you want to look into it.

  27. #67

  28. #68

  29. #69

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

    Re: Direct2D Typelib+ for VB6

    review of the latest build:
    - SaveImage
    try to run or make I get:
    Unexpected error (32810)
    at "Private Sub Form_Load()"

    everything else works! the old errors are fixed. also, I can change the target flag to either SOFTWARE or HARDWARE and both works!

  30. #70

  31. #71

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

    Re: Direct2D Typelib+ for VB6

    original: https://postimg.cc/gallery/3geeungqk/
    Attachment 159389Attachment 159391

    also, the demo CustomFont loads from the resource file, how to load from external file?
    Last edited by baka; May 31st, 2018 at 12:22 PM.

  32. #72

  33. #73
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: Direct2D Typelib+ for VB6

    Here's a harder one, save an image from a render target using Windows 7 interfaces. (MSDN only shows the windows 8+ interfaces)

    edit: also thanks for all the hard work on this Trick. I won't be releasing a typelib for a long time. If I do it will most likely be a large all in one typelib, including all of DirectX, sort of like SharpDX/SlimDX for VB6.
    Last edited by DEXWERX; May 31st, 2018 at 01:07 PM.

  34. #74
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    673

    Re: Direct2D Typelib+ for VB6

    Quote Originally Posted by The trick View Post
    Updation.

    Fixed bug with "Compile Error, Error in Loading DLL".
    Added example with embedded fonts collection.

    Still shows error "load dll error"

  35. #75

  36. #76
    PowerPoster
    Join Date
    Feb 2015
    Posts
    2,672

    Re: Direct2D Typelib+ for VB6

    Here's a harder one, save an image from a render target using Windows 7 interfaces. (MSDN only shows the windows 8+ interfaces)
    Yes, but CreateWicBitmapRenderTarget works since Vista SP2. It's look like a compiler error (bug?).

    also thanks for all the hard work on this Trick. I won't be releasing a typelib for a long time. If I do it will most likely be a large all in one typelib, including all of DirectX, sort of like SharpDX/SlimDX for VB6.
    Okay, then maybe i'll post that sources on CodeBank (after i add comments, fix bugs, and make more examples).

    BTW, i accept the suggestions for the new demos.

  37. #77

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

    Re: Direct2D Typelib+ for VB6

    what kind of termination/unload should be applied for direct2d?
    right now I just use Set variable$ = Nothing.
    the same when I unload a picture, and re-use the bitmap, as :

    Set Image(0) = LoadImageEx(Filename) that is a ID2D1Bitmap
    and when Im unloading it I use:
    Set Image(0) = Nothing

    is this enough of do I need to do more?
    I notice that direct2d is not stable in IDE. if Im running a few times and do some changes in the project (like adding a picturebox) the IDE can crash (need to save the project before running)

  38. #78

  39. #79

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

    Re: Direct2D Typelib+ for VB6

    ok, just run it once in IDE, click the "X" to quit, and add a textbox anywhere and run again. it will crash.
    https://www30.zippyshare.com/v/FwjwVIvf/file.html

    but if you run it again without adding anything it will run without crashing.
    that is why im asking if there a termination/unload procedure.
    Last edited by baka; Jun 2nd, 2018 at 08:23 AM.

  40. #80

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

    Re: Direct2D Typelib+ for VB6

    I asked in one of my previously post about the refresh rate, since D2D1_PRESENT_OPTIONS is following the monitor refresh-rate, i think its useless to calculate fps.
    sure, the fps could fluctuate a bit, but nothing i want to monitor, the user need to take responsibility to not overuse the cpu/gpu when running the game, or change the refresh rate during play.

    the easiest way is to use the API GetDeviceCaps with the parameter VREFRESH.
    it's working on my machine and im running windows 7.
    my questions, is this compatible with all windows version, also 10? any other method that can be used?
    Last edited by baka; Jun 3rd, 2018 at 09:01 AM.

Page 2 of 6 FirstFirst 12345 ... 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