Results 1 to 18 of 18

Thread: VB6 - Multithread: the CreateThread(), accept parameters for the function?

  1. #1

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,904

    VB6 - Multithread: the CreateThread(), accept parameters for the function?

    the CreateThread(), accept parameters(even arrays) for the adressed function?
    Code:
    Public Sub Thread( byref start as long)
    
    Dim i As Long
    i=start
        Do While True
    
            Form1.botton.Caption = i
    
            i = i + 1
    
            If i > 32000000 Then i = 0
    
        Loop
    
    End Sub
    Code:
    Public hThread1 As Long, hThread1_ID As Long
    hThread1 = CreateThread(ByVal 0&, ByVal 0&, AddressOf Thread, _
    
    ByVal 0&, ByVal 0&, hThread1_ID)
    Now we must destroy the Thread:
    Code:
    TerminateThread hThread1, 0
    CloseHandle hThread1
    anotherthing: how i know the Thread is finish? we can't destroy the Thread before finish it
    VB6 2D Sprite control

    To live is difficult, but we do it.

  2. #2

  3. #3

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,904

    Re: VB6 - Multithread: the CreateThread(), accept parameters for the function?

    make my DrawImageRectanglePoints() for be used on multithread way... for be more faster.
    and i need make another little simple update: change use a small size memory image for then draw it....
    using these 2 things, the DrawImageRectanglePoints() can be more faster...
    VB6 2D Sprite control

    To live is difficult, but we do it.

  4. #4

  5. #5

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,904

    Re: VB6 - Multithread: the CreateThread(), accept parameters for the function?

    i know, but before i start learning Directx 9, maybe i can win some speed.
    DrawImageRectanglePoints() do:
    1 - save the destination image on memory(1500X700);
    2 - we had load the image, from another function(200X200)(like you see the memory destination image is too big... i just need the 200X200);
    3 - create a pixel array for both images(is more easy for draw it pixel a pixel on destination memory image);
    4 - we get the 2 vertical line dots(these give me the horizontal origin and destination line dots;
    5 - we get horizontal line dots for we see where we can draw the pixel.
    6 - the destination image is finished.. so we draw it.
    from these 6 steps, only the 2nd tip is the best for win some speed... and using the multithread for the entire function, maybe i can win much more speed...
    PS: i need spend some time for learn the DirectX 9 basics and how to use it.... but maybe, before start it, i can win some speed on my DrawImageRectanglePoints () function...
    VB6 2D Sprite control

    To live is difficult, but we do it.

  6. #6
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: VB6 - Multithread: the CreateThread(), accept parameters for the function?

    Multi-threading isn't going to help here unless you have one of those super high end rigs with like 16 or 20+ cores. If you're running this on a standard desktop or laptop PC with 4-8 cores, the performance boost will be negligible. Also, with graphics processing, you want to utilize the GPU as much as possible. GPUs utilize hundreds of cores. Your one or two extra CPU cores ain't gonna amount to much in comparison.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  7. #7

  8. #8

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,904

    Re: VB6 - Multithread: the CreateThread(), accept parameters for the function?

    my CPU:Intel(R) Core(TM)2 Duo CPU T9500 @ 2.60GHz 2.60 GHz 64bits
    the trapezoid seems limited and i can't control it
    i have 1 function for it:
    Code:
    Private Sub TrapezoidBltUpdate(DestinationPoints() As Position3D, ByVal DestinationHDC As Long, ByVal TranspColor As Long, ByVal OriginHDC As Long, ByVal OriginWidth As Long, ByVal OriginHeight As Long, Optional ByVal Tilled As Boolean = False)
        Dim ScanLines As Long
        Dim FullWidth As Long
        Dim ScanWidth As Single
        Dim ScanLeft As Single
        Dim Delta As Single
        Dim sbmOrig As StretchBltModes
        Dim ScanLine As Long
        Dim ScanZ As Single
        Dim ScanZDec As Single
        
        'DestinationPoints(0) is UpperLeft
        'DestinationPoints(1) is UpperRight
        'DestinationPoints(2) is LowRight
        'DestinationPoints(3) is LowLeft
        
       
            ScanLines = ScaleY(OriginHeight, .ScaleMode, vbPixels)
            Debug.Print ScanLines
            FullWidth = ScaleX(OriginWidth, ScaleMode, vbPixels)
            ScanWidth = OriginWidth * PctTop / 100
            ScanLeft = (OriginWidth - ScanWidth) / 2
            Delta = ScanLeft / ScanLines
            'Picture2.BackColor = TranspColor
            sbmOrig = SetStretchBltMode(DestinationHDC, HALFTONE)
            ScanZ = 1 + (PctTop / 100)
            ScanZDec = ((PctTop / 100)) / ScanLines
            
            For ScanLine = 0 To ScanLines - 1
                StretchBlt DestinationHDC, _
                           ScaleX(ScanLeft, .ScaleMode, vbPixels), _
                           ScanLine, _
                           ScaleX(ScanWidth, .ScaleMode, vbPixels), _
                           1, _
                           .hdc, _
                           0, _
                           ScanLine * ScanZ, _
                           FullWidth, _
                           1
                ScanLeft = ScanLeft - Delta
                ScanWidth = ScanWidth + 2 * Delta
                ScanZ = ScanZ - ScanZDec
            Next
        End With
        SetStretchBltMode DestinationHDC, sbmOrig
        If (Tilled = False) Then
            TransparentBlt DestinationHDC, _
                           0, _
                           0, _
                           ScaleX(ScaleWidth, ScaleMode, vbPixels), _
                           ScaleY(ScaleHeight, ScaleMode, vbPixels), _
                           Picture2.hdc, _
                           0, _
                           0, _
                           FullWidth, _
                           ScanLines, _
                           TranspColor
        End If
    End Sub
    i don't have the control for it
    but i can use the StrechBlt() for win speed... and\or BitBlt() for tiles
    Last edited by joaquim; Dec 29th, 2020 at 10:04 AM.
    VB6 2D Sprite control

    To live is difficult, but we do it.

  9. #9
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: VB6 - Multithread: the CreateThread(), accept parameters for the function?

    as the Trick and others suggested, use DirectX, you have the typelib and assistance from members with knowledge of that.
    I abandoned gdi/gdi+ because no matter what I did it was never good enough. now with Direct2D I have what I need.

    unfortunately u need to start over, its a learning process, but, it should not take as long as it took to get it done in gdi/gdi+ since your own knowledge of graphic is not nothing.

    its useless time you put on trying to go around the problem, with tricks and hacks. in the end, gdi is old and very limited.
    we do have gpu for a reason and the engines that uses it are made so that u dont need to do any hacks.

  10. #10

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,904

    Re: VB6 - Multithread: the CreateThread(), accept parameters for the function?

    honesty i need time and have 'afraid'... why!?! the Directx seems like a new language.... using Windows API we must do several things just for create a Window... yes we need several things for only draw an image with DirectX.... maybe i can use a simple\basic tutorial for start doing some basic staff like load the texture and then draw it...
    let me be fare: why the Microsoft don't use GPU on GDI\GDI+ functions?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  11. #11
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: VB6 - Multithread: the CreateThread(), accept parameters for the function?

    because we have DirectX for that.
    and GDI32 is using hardware acceleration, but not GDI+
    but its not intended for 3D, its just for 2D and text and simple animations.
    and its about compatibility. to enchant GDI+ it could break things.

  12. #12

  13. #13

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,904

    Re: VB6 - Multithread: the CreateThread(), accept parameters for the function?

    honestly i don't know de difference... it's still confused
    VB6 2D Sprite control

    To live is difficult, but we do it.

  14. #14

  15. #15

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,904

    Re: VB6 - Multithread: the CreateThread(), accept parameters for the function?

    thank you so much for correct me.
    maybe i can find a function for that on internet, but i don't belive that i can use Z and ZDepth.
    but i get your point.. thanks for that.
    anotherthing: i don't know if you have seen my DrawImagePlanePoints(): https://www.vbforums.com/showthread....=1#post5504573
    i win speed.. but i'm getting trouble on create the memory image with my result image... at least i win speed
    VB6 2D Sprite control

    To live is difficult, but we do it.

  16. #16
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,872

    Re: VB6 - Multithread: the CreateThread(), accept parameters for the function?

    Quote Originally Posted by joaquim View Post
    honestly i don't know de difference... it's still confused
    Maybe you should explain what your goal is.
    Based on all previous threads over the years I assume you want to make a 3D game.
    Based on your goal you maybe can get better help instead of focusing on micro optimizations with a frame rate of 2 fps

  17. #17

  18. #18

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,904

    Re: VB6 - Multithread: the CreateThread(), accept parameters for the function?

    the speed seems to be more than 2fps.. seems more or less... but if i use more images.. maybe it will be 2fps
    VB6 2D Sprite control

    To live is difficult, but we do it.

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