Announcement

Collapse
No announcement yet.

Speaking of sprite engine

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
    Chris Boss
    Member

  • Chris Boss
    replied
    Actually I examined your code and found something that produced an error in the frame count:

    Code:
    '// This is the callback being used for all the animations
    SUB RenderAnimation()
        STATIC Flip AS LONG, nAngle AS LONG
        '// Draw active frame to memory DC
        Flip = NOT Flip
        IF Flip THEN
           CALL RedrawClone()
        ELSE '// Redraw everything
           CALL RedrawSprite()
        END IF
    END SUB
    '
    '// Update the brain rotation
    SUB RedrawSprite()
        LOCAL nFrame AS LONG
        nFrame = ZD_GetObjectFrameToUse(%IDS_WALKER) + 1: IF nFrame > ZD_GetObjectFrameCount(%IDS_WALKER) THEN nFrame = 1
        CALL ZD_SetObjectFrameToUse(%IDS_WALKER, nFrame, %TRUE)'FALSE)
    END SUB
    '
    SUB RedrawClone()
        LOCAL K, nFrame AS LONG
        FOR K = 1 TO %MAX_SPRITE
            nFrame = ZD_GetObjectFrameToUse(%IDS_WALKER + K) + 1: IF nFrame > ZD_GetObjectFrameCount(%IDS_WALKER + K) THEN nFrame = 1
            CALL ZD_SetObjectFrameToUse(%IDS_WALKER + K, nFrame, %FALSE)
        NEXT
    END SUB
    The RenderAnimation routine (called every iteration) is toggling betweeb animating the primary sprite and then animating all the others (clones).

    When I change the code so all the sprites are animated every frame, the frame rate drops to only 3.29 frames per second.

    Now I then turned off the callbacks for messages:

    Code:
    SUB GDImageEnableEvents(BYVAL hGDImageCtrl AS LONG)
        LOCAL lpCallBack AS DWORD
        lpCallBack = CODEPTR(GDImageCallBack)
        ' turn off all message callbacks
    '    CALL ZI_EventMessageEx(hGDImageCtrl, lpCallBack, %WM_LBUTTONDOWN, %TRUE)
    '    CALL ZI_EventMessageEx(hGDImageCtrl, lpCallBack, %WM_LBUTTONUP, %TRUE)
    '    CALL ZI_EventMessageEx(hGDImageCtrl, lpCallBack, %WM_LBUTTONDBLCLK, %TRUE)
    '    CALL ZI_EventMessageEx(hGDImageCtrl, lpCallBack, %WM_RBUTTONDOWN, %TRUE)
    '    CALL ZI_EventMessageEx(hGDImageCtrl, lpCallBack, %WM_KEYDOWN, %TRUE)
    '    CALL ZI_EventMessageEx(hGDImageCtrl, lpCallBack, %WM_KEYUP, %TRUE)
    '    CALL ZI_EventMessageEx(hGDImageCtrl, lpCallBack, %WM_MOUSEMOVE, %TRUE)
    '    CALL ZI_EventMessageEx(hGDImageCtrl, lpCallBack, %WM_NCHITTEST, %TRUE)
    '    CALL ZI_EventMessageEx(hGDImageCtrl, lpCallBack, %WM_MOUSEWHEEL, %TRUE)
    '    CALL ZI_EventMessageEx(hGDImageCtrl, lpCallBack, %WM_SIZE, %TRUE)
    END SUB
    Now it brings the frame rate up to 6 fps and after a few other tweaks (turned off what ever I could) I got it up to 7.5 fps.

    certainly not on Emachine, indeed i even didn't think that it could run on it.
    I find that quite strange. Even if you develop on a high end PC, those who purchase your software tools may desire to target the average PC user. My 2.5 ghz Emachine is quite average and is a good example of what end users may be using. It is running XP Home (upgraded to SP2), original had 256 meg ram and upgraded to 768 meg ram (my brothers in law gave me a 512 meg ram chip) and I replaced the onboard video with a decent 3D capable video card (not high end, but not cheap either). At 2.5 ghz the CPU is clearly up to par with many current PC's available at mass market stores.

    What kind of computer do you expect the end users (not your customers, but your customers customers) will be using ?
    Chris Boss
    Member
    Last edited by Chris Boss; 3 Sep 2009, 08:12 PM.

    Leave a comment:

  • Patrice Terrier
    Member

  • Patrice Terrier
    replied
    And remove the bicubic resizing that is done again and again at each iteration, with simple HALFTONE, or better do it once for all at startup.

    And remove the variable opacity that is applied again and again at each iteration, or better do it once for all at startup (to see the variable opacity, pickup a sprite in the background and move it in front)

    And switch off the composited mode.

    And then you will come close to the frame rate exposed in some of my other demo availables with the trial version.

    Now using a game loop, like the one exposed on MSDN, is a not a good solution, i have explained this in detail on the GDImage forum, and now many game programmers have been converted to the technic being used in BassBox to run audio and OpenGL plugins altogether.

    IceWalk has been written in a few hours and it was intended to work on VISTA and Windows 7, and certainly not on Emachine, indeed i even didn't think that it could run on it.

    ...
    Patrice Terrier
    Member
    Last edited by Patrice Terrier; 3 Sep 2009, 06:30 PM.

    Leave a comment:

  • Chris Boss
    Member

  • Chris Boss
    replied
    Patrice,

    I downloaded your latest IceWalk demo with the 201 penguin sprites.

    I believe it proves my point about the need to benchmark the speed of animation. Now remember, your sprite engine is designed to do a lot, lot, lot more than mine so in all fairness that has to be taken into consideration.

    On my PC (Emachine with 2.5 ghz Intel Celeron CPU, 768 meg Ram (I previously stated the wrong amount), NVidia Geforce4 MX 4000 video card (replaces onboard video PC came with) 32 bit color at 1680 x 1050 resolution) the results are not what one would have expected.

    First, when all the 201 sprites are displayed the:

    CPU usage of 96% to 99%.

    Frame rate is slow. I estimate 4 frames per second
    (it took 3 seconds for the penguins to move the entire number of frames (12)) NOTE: See Update below!

    Now for comparison, my own sprite engine (albiet not as powerful as yours and no fancy frills) displayed a similiar 200 penguin sprites at:

    CPU usage of 97% to 100%

    Frame rate of 13 (+) frames per second (with anti-aliasing ON)

    Thats 3 times faster.

    Now this does not mean my sprite engine is better, of course. Yours is high end with many, many, many features mine can't come close to. Yours is designed to get the most out of the DWM on Vista and Windows 7. Yours supports openGL, DirectX, 3D, PNG images and the list goes on.

    You do though have to rethink the speed of the engine when comparing it to others, even lowly sprite engines like mine (I should note that my sprite engine was not thrown together just recently, but it is a port of the EZGUI 4.0 Pro sprite engine to a non-EZGUI standalone DLL, so a lot of development went into it).

    Back to my previous point about the choices that go into a graphic engine. Some may choose to support all the advanced features (ie. rotation, world coordinates, etc.) but this has a price in raw speed at times. Some may choose the route if keep is simple, few features, but aim for raw speed. Thats what I took.

    Each product targets different needs.

    Please understand that just because others take a different route than your software, does not mean it is totally inferior. Your graphic engine is a Porshe. Mine is a little Volkswagon bug, but with a backyard mechanic souped up engine.

    Be fair in your comparisons.

    Now that said, I still feel GDimage is an amazing product. If any PB'ers out there are planning on building the next PhotoShop then seriously consider GDImage. There are a lot of years of advanced graphic experience behind it and the price is small compared to its value.

    Update: In all fairness it was best to do some accurate benchmarking and GDImage faired better afterwards.

    I rewrote the message loop on your Icewalk app to:

    Code:
             LOCAL RV&, CT&, T$, TM!
              TM!=TIMER
              DO
                 RV&= PeekMessage(Msg, %NULL, %NULL, 0, %PM_REMOVE)
                 IF msg.message=%WM_QUIT THEN EXIT DO
                 IF IsDialogMessage(gMainWnd, Msg) = %FALSE THEN
                    CALL TranslateMessage(Msg)
                    CALL DispatchMessage(Msg)
                 END IF
                 CALL RenderAnimation()
                 CT&=CT&+1
                 IF CT&>=25 THEN
                      CT&=0
                      TM!=TIMER-TM!
                      TM!=25/TM!
                      T$="Frame rate is "+FORMAT$(TM!, "000.00")+" frames/sec."
                      SetWindowText gMainWnd, BYVAL STRPTR(T$)
                      TM!=TIMER
                 END IF
              LOOP
    I got rid of the timer, used a game loop (peekmessage) with no sleeps.
    This would push the app to use 100% of the CPU for the animation.

    Now with the 201 sprites all running, I got a frame rate of 7 (+) (once hit 9, but usually stayed at about 7) frames per second.

    Thats still about half the speed of my own on the same PC.
    Chris Boss
    Member
    Last edited by Chris Boss; 3 Sep 2009, 04:59 PM.

    Leave a comment:

  • Patrice Terrier
    Member

  • Patrice Terrier
    replied
    Want to see a state of the art sprite animation?

    then try the attached SplashAni demo.

    Note: to shut it down, click on the sprite, then press the escape key.

    ...
    Attached Files
    Patrice Terrier
    Member
    Last edited by Patrice Terrier; 3 Sep 2009, 01:14 PM.

    Leave a comment:

  • Patrice Terrier
    Member

  • Patrice Terrier
    replied
    Chris,

    Try this: move the IceWalk window around, you shoul still see the animation running while doing so. If this is the case, this is because the GDImage animation is cooperative, it means it will use less CPU resource when other appliations needs them, and more if nothing else needs it.

    I should say also that the results are very different when running on Core 2 duo than on a single processor, and on VISTA DWM, that is definitly the best graphic platform i have ever used.

    The version with 201 sprites has been posted on the GDImage forum, it does uses alphablending, that of course slows down the process, i must say also that it works in full 32-bit composited mode. I could have done the same demo in OpenGL, but due to the cooperative animation technic being used the CPU charge should be almost the same.

    I have learned a lot about the animation technic with BassBox, and the BassBox plugins, also with my MovieBox DirectX project (available both in C# and in PowerBASIC).

    There is still a GDImage sprite demo that comes along with the trial version running at 543 FPS, but i always thought that FPS was not meaningfull over cooperative animation, and i am looking forward to the new API that can realy use the multi-processor capabilities.

    ...

    Leave a comment:

  • Chris Boss
    Member

  • Chris Boss
    replied
    It doesn't hog the CPU
    In all fairness Patrice, your Icewalk demo will use more CPU time on the average system that you may think. Remember, you tend to test your demos on your own system which is most likely a "cut above the rest."

    On my PC (EMachine with 2.5 ghz CPU, 784 meg Ram) it uses 60% CPU time with the 1 penguin and on average 85% with all the penguins displayed (which I estimated to be about 100 or so).

    CPU usage also depends upon whether one is purposely giving time back to the CPU for other threads. In my own demos I was "purposely" using all the CPU time (no sleeps) so I can see the maximum frame rate possible.

    In doing a test with 200 penguin sprites animating as fast or better than Icewalk (from the visual appearance of the penguins moving side to side) and also adding a 50 ms sleep to each iteration, I still got a decent 8 fps, with 200 sprites animated using only about 60% CPU time. When I let the app use as much CPU time as possible (100% and no sleeps) then it got a 12 fps frame rate.

    The point is that so called hogging of the CPU has more to do with the app purposely not giving other threads time, rather than the sprite engine itself being a hog.


    Just as a comparison, your Icewalk running with just one sprite animated (100 x 100 pixel penguin) it was using:

    60% to 70% CPU usage on my system (not sure why it used so much for one sprite)

    I created a simple demo which was moving around 4 sprites (140 x 140 pixel balloon) , added a 20 ms sleep in every iteration of the message loop and it was using:

    20% to 30% CPU usage on my system

    with a nice frame rate of 40 frames per second.


    Don't get me wrong, GDImage is an amazing graphic engine, well worth the price.

    Just make sure you do some fair benchmarking when you advertise GDImage.

    One of the things you may not consider when comparing different methods of graphic animation is that some so called "lesser" graphic methods may actually be quite fast because some fancier features are left out on purpose for the sake of speed. A good example of this was the old Sprite engines (hardware based) on the ancient Commodore and Atari computers. The Commodore 64 did some amazing animation for a 1 mhz CPU. The sprites though did things in a way designed for speed, not beauty (ie. no anti-aliasing). They sacrificed fancier features for speed.

    The more complex one makes a graphic engine (ie. rotation, scaling, world coordinates) one sacrifices speed for the sake of beauty (features).

    I chose the route of less features, less beauty for the sake of decent speed (at least for a software based engine).
    Of course it can't compare to hardware based animation and forget 3D.

    This is one reason I don't like comparing what I am working on with GDImage.

    They are "two different animals" made for totally different purposes.

    Its like comparing a Volkswagon Beetle to a Porshe.

    The people who drove a Beetle are quite different than the people who drove a Porshe.
    I would think the Porshe company would look a bit strange trying to compare their products to a Volkswagon Beetle saying how much better it was than a Beetle.

    See my point!

    Two different products for totally different markets.
    Chris Boss
    Member
    Last edited by Chris Boss; 3 Sep 2009, 12:45 PM.

    Leave a comment:

  • Patrice Terrier
    Member

  • Patrice Terrier
    replied
    Barry,

    You already told me, and i have nothing more to answer

    ...

    Leave a comment:

  • Barry Marks
    Member

  • Barry Marks
    replied
    Originally posted by Patrice Terrier View Post
    Yes, because the nag screen shows up, just at startup, like with my demos.
    I'm not sure this applies to others but the nag screen makes it impossible for me to use your library.

    I'm living in a subsidised retirement home where the government pays part of my rent. Most of what I write is to run on their computers in the common area, that the tennants use. The promise I've made to management is that there will be nothing illegal in anything I put on their computer.

    They know nothing about computers and if they see a nag screen they'll get suspicious and begin to mistrust my promise. I won't even install trial versions of software on their computers. They're working for the government and they can't afford to take chances and they're only letting me do it because they trust me and I can't risk eroding that trust or we all lose.

    I have no objection to the price of your program and the nag screen seems reasonable enough. This isn't a complaint. It's just that I can't use it. I wonder if others have similar issues.

    Barry

    Leave a comment:

  • Barry Marks
    Member

  • Barry Marks
    replied
    Originally posted by Patrice Terrier View Post
    Now about the price, i am just curious how much you would charge for one single programming day.

    Here if you ask a plomber to do some work in your house, he will charge you € 75 per hour + VAT (19.6), that means € 600 for height hours work.

    Don't you think that GDImage is worth the price of one day's work of a plomber.

    There is realy something wrong, if you can't invest one plomber's day work in something that tooks years to create, and that will save you weeks or even monthes of work.
    I have the impression that Chris wasn't saying your price was too high, but that he's pointing out that many of us simply can't afford it.

    I can't afford it. I don't doubt that it's worth every penny of it's price but I'm retired and only doing very lightweight hobby programming and I simply don't have that much money. I was only able to afford PB because it went on sale when I'd been saving up for something else.

    Barry

    Leave a comment:

  • Patrice Terrier
    Member

  • Patrice Terrier
    replied
    While the original pinguin, is a GIF animation, it has been converted with the GDImage GIF2PNG.exe utility, then the resulting multi-frame bitmap has been edited with PhotoShop to remove the bottom shadow and better antialias the outline.

    As you can imagine this takes more time, than just cuting/pasting my work.

    The clone feature is a very unique GDImage feature that was introduced several years ago, i am amazed to see that my work is a huge source of inspiration for some people.

    Anyway better to use the original than a clone years behind

    In GDImage a sprite can be anything shown on a Windows screen, it can be 3D based, or pure software animation, and GDImage animation do not hog the CPU resource just for the purpose of showing a high FPS that couldn't be used in real life cooperative applications.

    I could also make a EZ-Sprite only version if there was a real demand for it.
    What about one sold $49.99, or a freeware version (don't be fooled, i am just teasing of course)

    ...
    Patrice Terrier
    Member
    Last edited by Patrice Terrier; 3 Sep 2009, 04:28 AM.

    Leave a comment:

  • Patrice Terrier
    Member

  • Patrice Terrier
    replied
    Back to the competition

    Here is another one, for the fun: IceWalk

    And you know what, with GDImage you could even give the illusion that they are realy walking, by slowly strectching the background, like in the WinScape demo.

    ...
    Attached Files
    Patrice Terrier
    Member
    Last edited by Patrice Terrier; 2 Sep 2009, 11:34 AM.

    Leave a comment:

  • Patrice Terrier
    Member

  • Patrice Terrier
    replied
    is it a Windows standard (as in the gdi32.dll functions themselves specifically target that color as transparent)?
    No it is not a Windows standard, but a very common convention that is recognized by several graphic toolkits and even some programming languages.

    Another convention, is to use the pixel color located at coordinate 0,0.

    ...
    Patrice Terrier
    Member
    Last edited by Patrice Terrier; 30 Aug 2009, 07:27 AM.

    Leave a comment:

  • Wayne Diamond
    Member

  • Wayne Diamond
    replied
    Patrice thankyou for that insight, good info there, but I'm still just a little foggy about the magenta color -- is it a Windows standard (as in the gdi32.dll functions themselves specifically target that color as transparent)? Or can you specify which color you want to make transparent?

    btw I like your trick of converting RGB(255,0,255) to RGB(255,0,254) - simple, effective, fast and easy to accomplish at inline assembly-level, and with minimal (virtually zero) affect on the viewers perception. Is that the usual route? (can you tell I haven't done much gfx coding?)

    Leave a comment:

  • Patrice Terrier
    Member

  • Patrice Terrier
    replied
    Wayne,

    How is the transparent color defined? for example in your demo graphic the transparent color is a specific pink, but perhaps i have a sprite that needs to display that color, so can I define a specific transparent color for each sprite?
    The magenta color RGB(255,0,255) is kind of "standard" to define a transparent color in pictures that do not have an alpha channel.

    The GDImage trial version is provided with several pictures using the magenta for the same purpose.

    This was first introduced in WinLIFT to deal with 8-bit bitmap components, to create a region on the fly.

    The concept is exactly the same with some GIF animation.

    To avoid any potential problem with the use of magenta in GDImage, i remap all RGB(255,0,255) to RGB(255,0,254), just to make sure that this would not cause any confusion with the true magenta color.

    However this technic has many limitations as soon as you want to resize a bitmap on the fly, or when dealing with jpeg pictures.

    But fortunatly there is a solution to this problem.

    ...

    Leave a comment:

  • Joe Byrne
    Member

  • Joe Byrne
    replied
    Originally posted by Patrice Terrier View Post
    Joe,


    Strange, you paid me to create a logo for you, don't you?

    And you can't justify to pay the counterpart of one single day's work, something that would take you years to write, oh! i see you are kidding me

    ...
    Yea, I did for 1/4 the price of your software. I'm not saying your application isn't worth it, what I'm saying is that I can't justify the cost just to add such advanced graphics to my programs. I might consider $100 for a tool that does 25% of what your app does mainly because thats about all the graphics I would ever use.

    I haven't bought Photoshop either, because its too expensive for what I need, but I did buy Photoshop Elements (~ $100) because it DID do what I had need of most.

    BTW, is there any reason you wouldn't do the second logo I asked for? I always wondered if I offended you in some way. Certainly not my intent if I did.

    Leave a comment:

  • Patrice Terrier
    Member

  • Patrice Terrier
    replied
    In fact the dilema is very simple, if you don't need it, don't buy it.

    If you need it, be assured that you will get the best around

    ...

    Leave a comment:

  • Wayne Diamond
    Member

  • Wayne Diamond
    replied
    Originally posted by Patrice Terrier View Post
    Wayne,
    That is a fact PhotoShop CS4 and all the ADOBE products are sold more than three time the US price, here in France by ADOBE itself !!!!
    This is the reason why i bought mine in Canada, as they are also speaking french
    ...
    So in other words it has nothing to do with $ <> € or any other currency conversion, just that it's more expensive in your native France ... thanks for the clarification.

    By the way I thought we were talking about the price of your program, not how much the author of Windev gets paid per day.

    Anyway it's your product, you're free to price it at whatever you wish. While I'm floored at the price of the product I'm also equally floored by quality of it; it is a very high quality product and I don't think anybody can question its quality, and I truly wish you all the success with it.

    Thats my 2c
    Best regards, Wayne

    Leave a comment:

  • Patrice Terrier
    Member

  • Patrice Terrier
    replied
    Some more food for thought:

    Tarif: from 1.250€ / day (excl. VAT) depending on the engineering skills required, not including travelling expenses.
    Participants: max. 3 persons.
    This is the rating of PC-Soft (WinDev), for one single day of their programming engineer.

    More details there:
    http://www.windev.com/ts/assistance.htm

    ...
    Patrice Terrier
    Member
    Last edited by Patrice Terrier; 29 Aug 2009, 07:07 PM.

    Leave a comment:

  • Wayne Diamond
    Member

  • Wayne Diamond
    replied
    Joe,
    Strange, you paid me to create a logo for you, don't you?
    Whatever happened to client privacy?

    More seriously, i wonder how much you guy would charge for one day's work.
    If Adobe sold Photoshop in respect of how many hours it took their teams of programmers to develop it the cost to us as a customer would be $millions per license.

    Leave a comment:

  • Patrice Terrier
    Member

  • Patrice Terrier
    replied
    Wayne,

    That is a fact PhotoShop CS4 and all the ADOBE products are sold more than three time the US price, here in France by ADOBE itself !!!!

    This is the reason why i bought mine in Canada, as they are also speaking french

    ...

    Leave a comment:

Working...
X