Welcome to TalkGraphics.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2014
    Posts
    1

    Default Question about "Speed" of Graphics Coding.....

    Greetings.

    Below, I have copied a section of code I am using to draw numerous square shaped regions
    into a GUI window. The DO Loop runs through all the squares to
    be drawn in the window (a process repeated through sequential configurations of squares),
    and the Windows API statements are used to do the actual drawing in the window.

    This is an extremely SLOW process, as is evident when I increase the redraw rate.
    Any faster than a 500 ms redraw rate causes the routine to crash.

    I would truly appreciate any help in understanding why this code is so SLOW, when, for example,
    apparently simple cell phone games have such apparently FAST graphics response and redraw rates.....

    Clearly, I'm not getting something essential, but I can't quite figure out what it is.


    DO I=1, NUMBER_OF_AGENTS

    x1 = AGENT_GRAPHIC(I)%X*200
    y1 = -(AGENT_GRAPHIC(I)%Y*200)
    x2 = x1 + 200
    y2 = y1 - 200
    COLOR = AGENT_GRAPHIC(I)%COLOR

    Brush = CreateSolidBrush(color)
    oldBrush = SelectObject(dc, Brush)
    result = Rectangle(dc, x1, y1, x2, y2)
    result = SelectObject(dc, oldBrush)
    result = DeleteObject(Brush)

    ENDDO

  2. #2
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,823

    Default Re: Question about "Speed" of Graphics Coding.....

    Multiplication will be a slow function.
    Cell phones will be using shift operations, effectively adding something to itself (doubling) repeatedly.
    Having the negative operation and brackets is slow so you would use result = Rectangle(dc, x1, -y1, x2, y2) instead.
    All the operations would probably at the one time be made in some matrix to remove the loop check and unpack the calculations.
    All probably done without API calls, like in Xara for the final turbo charge.

    Acorn

    P.S. I have never touched Windows APIs so I am generalising, so it is safe for you to ignore what I've said.
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •