-
Dec 28th, 2020, 01:00 PM
#1
Thread Starter
PowerPoster
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
-
Dec 28th, 2020, 03:35 PM
#2
Re: VB6 - Multithread: the CreateThread(), accept parameters for the function?
You can't arbitrary use CreateThread. What's your end goal?
-
Dec 28th, 2020, 03:40 PM
#3
Thread Starter
PowerPoster
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...
-
Dec 28th, 2020, 03:47 PM
#4
Re: VB6 - Multithread: the CreateThread(), accept parameters for the function?
I gave you the fast code which uses DirectX9 which is GPU-accelerated. What does DrawImageRectanglePoints do?
-
Dec 28th, 2020, 03:56 PM
#5
Thread Starter
PowerPoster
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...
-
Dec 28th, 2020, 05:36 PM
#6
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.
-
Dec 29th, 2020, 03:12 AM
#7
Re: VB6 - Multithread: the CreateThread(), accept parameters for the function?
Should it draw an image using a trapezoid (4-points) path? Notice, trapezoid drawing isn't the same like perspective-correct drawing.
-
Dec 29th, 2020, 09:55 AM
#8
Thread Starter
PowerPoster
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.
-
Dec 29th, 2020, 10:03 AM
#9
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.
-
Dec 29th, 2020, 10:09 AM
#10
Thread Starter
PowerPoster
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?
-
Dec 29th, 2020, 10:25 AM
#11
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.
-
Dec 29th, 2020, 11:01 AM
#12
Re: VB6 - Multithread: the CreateThread(), accept parameters for the function?
the trapezoid seems limited and i can't control it
You can't draw a trapezoid using StretchBlt. I don't want to do wasted work therefore i ask you: do you know the trapezoid <> perspective?
-
Dec 29th, 2020, 11:22 AM
#13
Thread Starter
PowerPoster
Re: VB6 - Multithread: the CreateThread(), accept parameters for the function?
honestly i don't know de difference... it's still confused
-
Dec 29th, 2020, 02:46 PM
#14
Re: VB6 - Multithread: the CreateThread(), accept parameters for the function?
Originally Posted by joaquim
honestly i don't know de difference... it's still confused
When you use a perspective-correct method the near objects are bigger than far ones like in real world. The trapezoid transform doesn't perform this (you can see the grid has the same size along the plane).
-
Dec 29th, 2020, 03:04 PM
#15
Thread Starter
PowerPoster
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
-
Dec 29th, 2020, 03:06 PM
#16
Re: VB6 - Multithread: the CreateThread(), accept parameters for the function?
Originally Posted by joaquim
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
-
Dec 29th, 2020, 03:10 PM
#17
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.
In order to do your transorm you need only the proper interpolation. If you use the perspective method you need the additional W interpolation. If you use the trapezoid one you don't need it.
-
Dec 29th, 2020, 03:22 PM
#18
Thread Starter
PowerPoster
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|