Menu

Performance

Anonymous
2003-10-09
2003-10-14
  • Anonymous

    Anonymous - 2003-10-09

    The display performance of the engine can be improved considerably by using small number of calls to the Win32 GDI in the "undraw" method.
    It's nothing special, but it does make a big difference :)

    This can be seen most clearly if you maximise the engine window in wireframe mode with the landschap.3en model loaded.

    Just place the following at the top of the draw.bas module:

    Public Declare Function SetPixel Lib "GDI32" (ByVal hDC As Long, ByVal x As Long, ByVal Y As Long, ByVal crColor As Long) As Long
    Public Declare Function LineTo Lib "GDI32" (ByVal hDC As Long, ByVal x As Long, ByVal Y As Long) As Long
    Public Declare Function MoveToEx Lib "GDI32" (ByVal hDC As Long, ByVal x As Long, ByVal Y As Long, lpPoint As POINTAPI) As Long

    Public Type POINTAPI
            x As Long
            Y As Long
    End Type

    And then replace the "undraw" method internals with:

        Dim i As Long, j As Long, k As Long
        Dim ptLast As POINTAPI
       
        frm_main.engine.Refresh
       
        frm_main.engine.ForeColor = vbBlack
        k = frm_main.engine.Width
        For j = 0 To frm_main.engine.Height 'Draw lines from the top down.
            i = MoveToEx(frm_main.engine.hDC, 0, j, ptLast)
            i = LineTo(frm_main.engine.hDC, k, j)
        Next
        frm_main.engine.ForeColor = vbWhite
       
        i = MoveToEx(frm_main.engine.hDC, frm_main.engine.Width / 2, frm_main.engine.Height / 2, ptLast)

     
    • Jeroen De Vlieger

      thanks subaquatique,

      I will certainly try it. and if it speeds up the code up like you say, it will.
      It wil be permanently used in the next versions of the beta.

      More precisely If that way of drawing is more efficient it will be an approach for the flatschading function.

         jeroen
           (admin)

       

Log in to post a comment.

MongoDB Logo MongoDB