Results 1 to 9 of 9

Thread: .Cls is slow!!!! Anything fast to replace it?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Great White North, ey?
    Posts
    202

    .Cls is slow!!!! Anything fast to replace it?

    I know why my game only gets 13 fps! I used the .cls to clear my background. Then I set it to .refresh, I get over 80 fps! but nothing clears. Anything else I could try?

  2. #2
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    You might try drawing a solid colored rectangle over your screen:
    Code:
    Me.Line(0, 0)-(640, 480), vbWhite, BF
    Also, You could try just Bltting your background over everything that has been drawn, thus clearing.

    Z.

  3. #3
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Line, Zaei?
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  4. #4
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Yup. The "BF" Parameter tells the line function to draw a Box, and Fill it with the color parameter.

    Z.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Location
    Great White North, ey?
    Posts
    202
    Huh, what is that suppose to do? Anyways, I tried it and it makes my screen flicker. I've had about enough of this stupid VB graphic routines >, it's time to start porting my game to DirectX.

    Oh yeh, one quick question, can I cls just a part of a picture and not the whole thing?

  6. #6
    Hyperactive Member DovyWeiss's Avatar
    Join Date
    Feb 2002
    Location
    Miami Beach, FL
    Posts
    366
    Change the co-ordinates in Zaei's code.

  7. #7
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Draw the Box to the back buffer to avoid the flicker.

    Z.

  8. #8
    Fanatic Member
    Join Date
    Jun 1999
    Location
    California, USA
    Posts
    662
    Originally posted by Zaei
    You might try drawing a solid colored rectangle over your screen:
    Code:
    Me.Line(0, 0)-(640, 480), vbWhite, BF
    Also, You could try just Bltting your background over everything that has been drawn, thus clearing.

    Z.
    using the built in wraper functions in vb is a slower method. set your properties like forecolor, fillcolor, and fillstyle and then use the api to draw the rectangle. it will use the brush of the dc you draw to, which incidently is set by the properties you just changed (i.e. fillcolor)

  9. #9
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Some wrappers are slower, and Line is one of them. PaintPicture is not, just for the sake of example. On the other hand, if you need to draw lines, or rectangles of different colors, then you lose the advantages gained because everytime you set a color proprty for instance, VB will automatically re-generate the brush, slowing down the code.

    Z.

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