Results 1 to 27 of 27

Thread: DirectDraw draws slower than LineTo API

  1. #1

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    DirectDraw draws slower than LineTo API

    Here's some code that creates a file of 500,000 lines, saves it to disk, loads it, then draws it. For some reason, it takes twice as long to draw then the LineTo Api method... go figure...




    To use the code below you have to:
    put the code in a module
    set startup properties of the project to Sub Main
    add a Form (Form1) to your project
    Check 'DirectX 7 for Visual Basic Type Library' under References


    VB Code:
    1. Option Explicit
    2. 'determines performance of execution for testing purposes only
    3. Private Declare Function GetTickCount Lib "kernel32.dll" () As Long
    4.  
    5. Private Type mapLineType
    6.     XPosStart As Single
    7.     YPosStart As Single
    8.     XPosEnd As Single
    9.     YPosEnd As Single
    10.     Colour As Long
    11.     Thickness As Single
    12. End Type
    13. Private mapLine(500000) As mapLineType
    14. 'below type is needed for LineTo and MoveEx API functions
    15. Private Type POINTAPI
    16.         x As Long
    17.         y As Long
    18. End Type
    19.  
    20. Private DX7 As New DirectX7
    21. Private DD7 As DirectDraw7
    22. Private Primary As DirectDrawSurface7
    23. Private Back As DirectDrawSurface7
    24.  
    25. Public Display As Form1
    26.  
    27. Private Sub InitialiseDirectX()
    28. Dim ddsd As DDSURFACEDESC2, Size As RECT
    29. Dim Clip As DirectDrawClipper
    30.  
    31.     'Instantiate the main DX DirectDraw
    32.     Set DD7 = DX7.DirectDrawCreate("")
    33.    
    34.     'Negotiate a normal windowed display
    35.     DD7.SetCooperativeLevel Display.hWnd, DDSCL_NORMAL
    36.    
    37.     'Create the primary surface used to display completed images
    38.     ddsd.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE
    39.     Set Primary = DD7.CreateSurface(ddsd)
    40.    
    41.     'Create and attach a Clipper to the Primary surface
    42.     Set Clip = DD7.CreateClipper(0)
    43.     Clip.SetHWnd Display.hWnd
    44.     Primary.SetClipper Clip
    45.    
    46.     'Create a back surface used to compose images before display
    47.     ddsd.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
    48.     ddsd.lFlags = DDSD_CAPS Or DDSD_WIDTH Or DDSD_HEIGHT
    49.     ddsd.lWidth = Display.ScaleWidth
    50.     ddsd.lHeight = Display.ScaleHeight
    51.     Set Back = DD7.CreateSurface(ddsd)
    52.    
    53. End Sub
    54. Public Sub cleanup()
    55.  'Reset the display back to the original windows
    56.     DD7.RestoreDisplayMode
    57.    
    58.     'Release objects
    59.     Set DX7 = Nothing
    60.     Set DD7 = Nothing
    61.     Set Back = Nothing
    62.     Set Primary = Nothing
    63.     Unload Form1
    64.     Set Form1 = Nothing
    65. End Sub
    66.  
    67.  
    68. Public Sub main()
    69. Dim mypointapi As POINTAPI
    70. Dim EmptyRect As RECT, DestRect As RECT
    71. Dim i As Long
    72. 'needed for conversion from twips to pixels with API functions
    73. Dim picture1width As Long
    74. Dim picture1height As Long
    75.  
    76. 'performance measuring variable
    77. Dim start As Long
    78. Set Display = New Form1
    79. Display.ScaleMode = vbPixels
    80.    
    81.     'Setup and initialise the DX environment and the Vectoid population
    82. InitialiseDirectX
    83. Form1.Show
    84. picture1width = (Form1.Width / Screen.TwipsPerPixelX)
    85. picture1height = (Form1.Height / Screen.TwipsPerPixelY)
    86. 'make some RANDOM DATA
    87. For i = 1 To 500000
    88. mapLine(i).XPosStart = Int(picture1width * Rnd)
    89. mapLine(i).YPosStart = Int(picture1height * Rnd)
    90. mapLine(i).XPosEnd = Int(picture1width * Rnd)
    91. mapLine(i).YPosEnd = Int(picture1height * Rnd)
    92. mapLine(i).Colour = Int(10000 * Rnd + 1)
    93. mapLine(i).Thickness = Int(1 * Rnd + 1)
    94. Next
    95. Open ("C:\testfile.tst") For Binary As #1
    96. Put #1, 1, mapLine
    97. Close #1
    98.  
    99. 'Begin load and draw
    100. start = GetTickCount
    101. Open ("C:\testfile.tst") For Binary As #1
    102. Get #1, 1, mapLine
    103. Close #1
    104. Debug.Print "loaded in : " & (GetTickCount - start) / 1000 & " seconds"
    105.  
    106. start = GetTickCount
    107.     'clear the back surface
    108.     Back.BltColorFill EmptyRect, vbBlack
    109.    
    110.     'draw the lines to the back surface
    111.     For i = 1 To 500000
    112.         Back.SetForeColor mapLine(i).Colour
    113.         Back.DrawLine mapLine(i).XPosStart, mapLine(i).YPosStart, mapLine(i).XPosEnd, mapLine(i).YPosEnd
    114.     Next
    115.      
    116.     'Get the latest size and position of destination window
    117.     DX7.GetWindowRect Display.hWnd, DestRect
    118.    
    119.    'Blt the back surface to the primary surface
    120.    Primary.Blt DestRect, Back, EmptyRect, DDBLT_WAIT
    121.    
    122.  
    123. Debug.Print "Drawn in :" & (GetTickCount - start) / 1000 & " seconds"
    124. End Sub

  2. #2
    Addicted Member
    Join Date
    Aug 2002
    Posts
    192
    i have about 50 filled circles moving in a dx project, and a regular Circle method vb project, and the vb is faster. Tried this on a friend's system that doesn't have a video card, and the speed difference was even greater

  3. #3

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    I can only assume then, that for 2D graphics, its best to stick to API or native VB functions...

  4. #4
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625
    Lock the bufffer first and then use the LineTo api to draw the line as many times as you want then UnLock the buffer.

    The problem is that each time you call that DrawLine function, it will Lock and UnLock. These Locks take time.
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

  5. #5

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    How would i Lock a buffer? I'm new to DirectX, and really only wanted to learn this much to accomplish a needed task. Any help from a knowledgable directX programmer would be appreciated.

  6. #6
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625
    Back.Lock or something; look in the help file that came with directx sdk
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Anyway, there isn't any way VB native functions could be faster than DX, no matter what, unless you have some hidden blocker in there (like MoMad said, Lock/Unlock)
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  8. #8
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625
    No, LineTo is not vb, its API and it is what directdraw uses. But if you just call the drawline method, it will do this:

    VB Code:
    1. Function DrawLine (bla)
    2.   Buffer.Lock
    3.   Buffer.MoveTo (x,y)
    4.   Buffer.LineTo (x,y)
    5.   Buffer.Unlock
    6. End Function

    The lock takes a while because it was designed for 16bit windows. It waits for the "vertical scanline" or something to do with the monitor and refresh rate and not being used,... so if each lock takes 100ms, imagine what 50000 locks will take?

    Lock the buffer your self and moveto/lineto yourself!!
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    No, the lock wasn't designed for 16-bit. It's a necessity because normaly the video card may move blocks of memory around it's memory at will. Lock will tell it not to do this for a while because we want to access the memory, and it would be bad if it was moved away at that time.

    The inner DirectDraw actually doesn't have a LineTo API. This function is part of the DX wrapper for VB.
    In pure DD you usually have to write your own functions for this.
    Of course there is a reason for this: a VB implementation of a rasterizing algorithm would probably simply be too slow.

    But you're right, locks are synchronized to the vertical retrace, so you can have at best as many locks per second as your monitor refresh rate. E.g. 80 locks/second on an 80Hz screen.
    Probably less if any calculation takes up more than 1/80 of a second (which means you're missing a chance to lock/unlock).
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  10. #10
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625
    Yeah, and i forgot one other thing, it has to do with COM aggregation and multithreading (being threadsafe and all)... or some shznick like that! heh, like i care anyways, just know this, do as little locks as possible, not only you, the functions you call also... blt, fastblt, bitblt, *blt all have locking mechanisms inside them.

    [EDIT]
    Lock was originally designed for 16bits, there are better ways to be threadsafe now, and btw, the dx lock is a mutex which explains why its of 16bit originality.
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

  11. #11
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Basically if you have to lock do it once. Then call all functions that should do something. Then unlock. The most efficient way.

    Actually BitBlts don't really lock the surface as they are a more or less atomic operation. A surface must not be locked when calling the DD-Blitter, so I suppose it has some internal mechanism similar to but faster than locking. Else DD would expose a blitter that accepts pointers to locked mem regions.

    Another reason why the VB wrapper has it's own functions for simple geometry is that VB code has no way to dereference a pointer
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  12. #12
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625
    Hehe, lol
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

  13. #13

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    You know this is all well and dandy, but the fact remains, if you aren't supposed to use DrawLine in the DirectX library, how else do you put a line on the screen? I imagine someone would have enough DirectX programming to show me how else it could be acheived using the code above.

  14. #14
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625
    Havent you read my above post? Do a Lock and this will give you some kind of dc that you can draw on. Then use the API functions MoveToEx and LineTo to draw your lines as much as you like. Then Unlock!
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

  15. #15

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Does a LineTo call work on a DirectX Surface? And if so, how do I get a handle to it (the DX surface)?

  16. #16
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    For the third time: by calling Lock

    You get the surface by creating it - unless you just threw the object away, in which case you should be punished.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  17. #17

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Alright lol, sorry, wasn't getting that part through my head yesterday I guess...

    Anyway, I'm gettin a Type Mismatch on the lock line...2nd parameter, i don't understand why I would have to pass the surface (2nd parameter), if Lock is obviously a member of the surface class... so I must be missing something here...
    VB Code:
    1. start = GetTickCount
    2.     'clear the back surface
    3.     Back.BltColorFill EmptyRect, vbBlack
    4.      
    5.     'lock the surface, retrieve handle from lock
    6.     [b]mysurfaceHandle = Back.Lock(EmptyREct, Back, DDLOCK_WAIT, 0)[/b]
    7.     'draw the lines to the back surface
    8.     For i = 1 To 500000
    9.              
    10.         Back.SetForeColor mapLine(i).Colour
    11.         MoveToEx mysurfaceHandle, mapLine(i).XPosStart, mapLine(i).YPosStart
    12.         LineTo mysurfaceHandle, mapLine(i).XPosEnd, mapLine(i).YPosEnd
    13.        
    14.     Next
    15.     Back.Unlock 0
    16.     'Get the latest size and position of destination window
    17.     DX7.GetWindowRect Display.hWnd, DestRect
    18.    
    19.    'Blt the back surface to the primary surface
    20.    Primary.Blt DestRect, Back, EmptyRect, DDBLT_WAIT

  18. #18
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Don't you have a reference to look that up? What's the function prototype?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  19. #19

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    This is the prototype:
    VB Code:
    1. Lock (r as RECT, desc as DDSURFACEDESC2, flags As CONST_DDLOCKFLAGS, hwnd As Long)

  20. #20
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625
    For crying out loud, here:

    VB Code:
    1. [b]Dim ddsd As DDSURFACEDESC2 ' <-------------- this is not a surface[/b]
    2.     start = GetTickCount
    3.     'clear the back surface
    4.     Back.BltColorFill EmptyRect, vbBlack
    5.      
    6.     'lock the surface, retrieve handle from lock
    7.     [b]mysurfaceHandle = Back.Lock(EmptyREct, ddsd, DDLOCK_WAIT, 0)[/b]
    8.  
    9.     ' =======================
    10.     ' NOW ddsd contains anything you need to know about Back surface!!!
    11.     ' though I dont kno if Lock returns the dc, you might have to
    12.     ' get that from ddsd (not sure), check the directX doc (vb).
    13.     ' =============================
    14.  
    15.     'draw the lines to the back surface
    16.     For i = 1 To 500000
    17.              
    18.         Back.SetForeColor mapLine(i).Colour
    19.         MoveToEx mysurfaceHandle, mapLine(i).XPosStart, mapLine(i).YPosStart
    20.         LineTo mysurfaceHandle, mapLine(i).XPosEnd, mapLine(i).YPosEnd
    21.        
    22.     Next
    23.     Back.Unlock 0
    24.     'Get the latest size and position of destination window
    25.     DX7.GetWindowRect Display.hWnd, DestRect
    26.    
    27.    'Blt the back surface to the primary surface
    28.    Primary.Blt DestRect, Back, EmptyRect, DDBLT_WAIT
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

  21. #21

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Thanks for the tip... like I said, I only have time to learn enough DirectX to accomplish this 1 task..

    The code steps through properly, but still, I cannot get anything to display in the Picturebox. Not sure why, but if you throw this code in a new project, with a picturebox1 and a command1, you can see what may be or may not be happening...

    VB Code:
    1. Option Explicit
    2. 'determines performance of execution for testing purposes only
    3. Private Type POINTAPI
    4.         x As Long
    5.         y As Long
    6. End Type
    7. Private Declare Function GetTickCount Lib "kernel32.dll" () As Long
    8. Private Declare Function LineTo Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
    9. Private Declare Function MoveToEx Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As Long
    10. Private Declare Function GetDC Lib "user32.dll" (ByVal hWnd As Long) As Long
    11.  
    12. Private Type mapLineType
    13.     XPosStart As Single
    14.     YPosStart As Single
    15.     XPosEnd As Single
    16.     YPosEnd As Single
    17.     Colour As Long
    18.     Thickness As Single
    19. End Type
    20. Private mapLine(500000) As mapLineType
    21.  
    22. Private DX7 As New DirectX7
    23. Private DD7 As DirectDraw7
    24. Private Primary As DirectDrawSurface7
    25. Private Back As DirectDrawSurface7
    26. Public Display As Form1
    27.  
    28. Private Sub InitialiseDirectX()
    29. Dim ddsd As DDSURFACEDESC2, Size As RECT
    30. Dim Clip As DirectDrawClipper
    31.  
    32.     'Instantiate the main DX DirectDraw
    33.     Set DD7 = DX7.DirectDrawCreate("")
    34.    
    35.     'Negotiate a normal windowed display
    36.     DD7.SetCooperativeLevel Display.hWnd, DDSCL_NORMAL
    37.    
    38.     'Create the primary surface used to display completed images
    39.     ddsd.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE
    40.     Set Primary = DD7.CreateSurface(ddsd)
    41.    
    42.     'Create and attach a Clipper to the Primary surface
    43.     Set Clip = DD7.CreateClipper(0)
    44.     Clip.SetHWnd Display.hWnd
    45.     Primary.SetClipper Clip
    46.    
    47.     'Create a back surface used to compose images before display
    48.     ddsd.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN
    49.     ddsd.lFlags = DDSD_CAPS Or DDSD_WIDTH Or DDSD_HEIGHT
    50.     ddsd.lWidth = Display.ScaleWidth
    51.     ddsd.lHeight = Display.ScaleHeight
    52.     Set Back = DD7.CreateSurface(ddsd)
    53.    
    54. End Sub
    55. Public Sub Cleanup()
    56.  'Reset the display back to the original windows
    57.     DD7.RestoreDisplayMode
    58.    
    59.     'Release objects
    60.     Set DX7 = Nothing
    61.     Set DD7 = Nothing
    62.     Set Back = Nothing
    63.     Set Primary = Nothing
    64.     Unload Form1
    65.     Set Form1 = Nothing
    66. End Sub
    67.  
    68.  
    69. Public Sub main()
    70. Dim mypointapi As POINTAPI
    71. Dim EmptyRect As RECT, DestRect As RECT
    72. Dim i As Long
    73. 'needed for conversion from twips to pixels with API functions
    74. Dim picture1width As Long
    75. Dim picture1height As Long
    76. Dim mysurface As Long
    77. 'performance measuring variable
    78. Dim start As Long
    79. Set Display = New Form1
    80. Display.ScaleMode = vbPixels
    81.  
    82.     'Setup and initialise the DX environment
    83. InitialiseDirectX
    84. Dim ddsd As DDSURFACEDESC2
    85. Form1.Show
    86. picture1width = (Form1.Width / Screen.TwipsPerPixelX)
    87. picture1height = (Form1.Height / Screen.TwipsPerPixelY)
    88.  
    89. 'make some RANDOM DATA
    90. For i = 1 To 500000
    91. mapLine(i).XPosStart = Int(picture1width * Rnd)
    92. mapLine(i).YPosStart = Int(picture1height * Rnd)
    93. mapLine(i).XPosEnd = Int(picture1width * Rnd)
    94. mapLine(i).YPosEnd = Int(picture1height * Rnd)
    95. mapLine(i).Colour = Int(10000 * Rnd + 1)
    96. mapLine(i).Thickness = Int(1 * Rnd + 1)
    97. Next
    98. Open ("C:\testfile.tst") For Binary As #1
    99. Put #1, 1, mapLine
    100. Close #1
    101.  
    102. 'Begin load and draw
    103. start = GetTickCount
    104. Open ("C:\testfile.tst") For Binary As #1
    105. Get #1, 1, mapLine
    106. Close #1
    107. Debug.Print "loaded in : " & (GetTickCount - start) / 1000 & " seconds"
    108.  
    109. start = GetTickCount
    110.     'clear the back surface
    111.     Back.BltColorFill EmptyRect, vbBlack
    112.    
    113.     Back.Lock EmptyRect, ddsd, DDLOCK_WAIT, 0
    114.     mysurface = Back.GetDC
    115.    
    116.     'draw the lines to the back surface
    117.     For i = 1 To 500000
    118.         Back.SetForeColor mapLine(i).Colour
    119.         MoveToEx mysurface, mapLine(i).XPosStart, mapLine(i).YPosStart, mypointapi
    120.         LineTo mysurface, mapLine(i).XPosEnd, mapLine(i).YPosEnd
    121.     Next
    122.    
    123.     Back.ReleaseDC (mysurface)
    124.     'Get the latest size and position of destination window
    125.     DX7.GetWindowRect Display.hWnd, DestRect
    126.    
    127.    'Blt the back surface to the primary surface
    128.    Primary.Blt DestRect, Back, EmptyRect, DDBLT_WAIT
    129.  
    130. Debug.Print "Drawn in :" & (GetTickCount - start) / 1000 & " seconds"
    131. End Sub
    132.  
    133. Private Sub Command1_Click()
    134. Call main
    135. End Sub
    136.  
    137.  
    138. Private Sub Form_Unload(Cancel As Integer)
    139. Cleanup
    140. End Sub

  22. #22
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Well, it seems you don't need to lock when you call GetDC (that's the way it is in C++). Do you get any errors or does simply nothing happen?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  23. #23
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Or you just forgot to Unlock! Then the blt call would fail!
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  24. #24

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    There are no errors, the code steps through properly. It simply fails to blit the back surface to the picturebox. If I include an unlock statement, I get an Automation Error on the unlock line:
    VB Code:
    1. Back.Unlock EmptyRect

    The entire code is posted above, a simply copy/paste and add a reference to Directx 7 type library...

  25. #25

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    I checked the return values of the MoveToEx and LineTo functions, and they were all nonzero (1 actually), which by definition of the function, means it was sucessful.

  26. #26

    Thread Starter
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Well, at first it appeared this emerging code was drawing faster than the purely LineTO API method (straight to Picturebox)... but after resizing the picturebox to the size I had with the LineTO method, IT IS NOT ANY FASTER, its not noticably slower, but it IS NOT FASTER.

    Thanks for all your help...

  27. #27
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625
    Sorry, use GetDC like you did (it has its own lock method and release dc will unlock it), make sure your surface is associated with the picturebox or whatever it is you are drawing on, also, you cant say Back.SetForeColor, you have to use CreateSolidBrush, and SelectObject api calls.

    I see that all throughout your code you are refering to Display, what is display? If you are drawing on picture1, use picture1 not display.

    When you draw on picture1, put a DoEvents in your loop so you can quit at anytime during the drawing loop.

    Also, you are using display and form1 interchangably.
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

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