Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Work in Progress / Sprite Drawing Libary

Author
Message
General Reed
18
Years of Service
User Offline
Joined: 24th Feb 2006
Location:
Posted: 4th Oct 2008 16:43 Edited at: 4th Oct 2008 16:46
Hi all. I finaly grew fed up with the slugishness of what could be a set of very useful commands. The draw and text commands. So i spent about 8 hours creating a set of functions, to draw simple lines and boxes, to images, and in turn displayed as sprites. Obviously sprites are a lot faster, and there is the advantage.

The main problem with the draw command, is that you have to redraw the box, line etc every frame. Now with one box or line, its faster than sprites, however when you try rendering 100 boxes per frame, the program crawls to a halt.

I created a test scene. A line of text, a drawn line, and 100 randomly coloured, and placed boxes.
When i used the standard draw and text commands, i got 80fps for this scene.
When i used my new set of functions, i got 1450fps for the same scene. This is 15 times faster!
The text system in the libary is basicly a bitmap font system. Ive used scraggles lcd text font for testing, and is included in the attached example.

To follow, is a list of commands, and how to use them:
spriteDrawManager_Initilize() - Initilizes the libary, must be called before any other commands


spriteDrawManager_CreateNewCanvas(positionX, positionY, width, height, depth, red, green, blue, alpha) - Creates a canvas, on which to draw. You must create a canvas before you can start drawing.

spriteDrawManager_LoadFont(fontFilename, numberOfCharactersX, numberOfCharactersY, spaceDistance) - This loads in a bitmap font ready for use with the sprite text system.

spriteDrawManager_StartCanvasModify(canvasId) - This specifies the current canvas to be drawn to. Must be called before trying to perform any drawing operations, including text.

spriteDrawManager_EndCanvasModify - This stops the modification of the current canvas. Must be called before you switch to another canvas, with "SpriteDrawManager_StartCanvasModify"

spriteDrawManager_DrawText(caption, fontId, alignment(not yet implemented), offsetX, offsetY) - This draws text to the current canvas, set by "spriteDrawManager_startCanvasModify". Note that offsetX and offsetY are offsets from the current canvas.

spriteDrawManager_Box(offsetX, offsetY, offsetX2, offsetY2, red, green blue, alpha) - Draws a box to the current canvas. Note the offsets, are offset positions from the position of the canvas.

spriteDrawManager_Line(offsetX, offsetY, offsetX2, offsetY2, red, green, blue, alpha) - Draws a line to the current canvas. Note the offsets, are offset positions from the position of the current canvas.

spriteDrawManager_Dot(offsetX, offsetY, red, green, blue, alpha) - Draws a dot to the current canvas. Note hte offsets are offset positions from the position of the current canvas.

spriteDrawManager_DrawImage(imageId, offsetX, offsetY, width, height, transparency) - Draws an image to the current canvas. Transparency when set to 1, will make parts of the image with no alpha, not display, but when set to 0, everything will display.

spriteDrawManager_PositionCanvas(positionX, positionY) - Positions the current canvas.

Remember that all commands that edit a canvas in some way, including position, need to be called between a "SpriteDrawManager_StartCanvasModify" and "spriteDrawManager_EndCanvasModify" command.

Attached is the libary, with the lcdtext bitmap font, and an example.

Enjoy.

-General Reed

CPU: AMD X2 6000+ 3.0ghz GFX: NVIDIA BFG Geforce 8800GTS 640MB OC-550mhz core RAM: 2048mb

Attachments

Login to view attachments
General Reed
18
Years of Service
User Offline
Joined: 24th Feb 2006
Location:
Posted: 4th Oct 2008 17:08 Edited at: 4th Oct 2008 17:09
Here are the comparison screenshots

Using dark basics draw commands:



Using my sprite draw libary:



FPS is in the bottom right hand corner

CPU: AMD X2 6000+ 3.0ghz GFX: NVIDIA BFG Geforce 8800GTS 640MB OC-550mhz core RAM: 2048mb

wildbill
18
Years of Service
User Offline
Joined: 14th Apr 2006
Location:
Posted: 5th Oct 2008 06:35
Really impressive. Of coarse any sprite manager program is going to need to be able to handle animated sprites though.
General Reed
18
Years of Service
User Offline
Joined: 24th Feb 2006
Location:
Posted: 5th Oct 2008 14:03
Quote: "Really impressive"
- Thanks XD

Quote: "Of coarse any sprite manager program is going to need to be able to handle animated sprites though. "
- As WindowKiller mentioned, it is only to replace the sluggish dbpro draw and text commands. You are able to position the canvas on which the shapes etc are drawn.

CPU: AMD X2 6000+ 3.0ghz GFX: NVIDIA BFG Geforce 8800GTS 640MB OC-550mhz core RAM: 2048mb

C0wbox
18
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 5th Oct 2008 14:16
@ General Reed
This is pretty good, but:
Quote: "This is 15 times faster!"

1450 / 80 = 18.125 (not 15)
General Reed
18
Years of Service
User Offline
Joined: 24th Feb 2006
Location:
Posted: 5th Oct 2008 14:57
@C0wbox - Lol oops, thanks.

CPU: AMD X2 6000+ 3.0ghz GFX: NVIDIA BFG Geforce 8800GTS 640MB OC-550mhz core RAM: 2048mb

Mr Kohlenstoff
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 5th Oct 2008 15:41
It looks quite cool so far and if it really is that much faster (did not test it yet) I'm probably going to use it for a sideproject. However, do you think it would be possible to add boxes with different colors in each corner like the ones dbp can draw (optional parameters of box-command)? I actually planned using them in my game but drawing 20 of them reduces my fps from 500 to 30. Apart from that functions for drawing rectangles or circles would be cool, even if hard to solve with sprites... just suggestions, good work anyway.

General Reed
18
Years of Service
User Offline
Joined: 24th Feb 2006
Location:
Posted: 5th Oct 2008 17:24
@Mr Kohlenstoff - Thanks.

Quote: "However, do you think it would be possible to add boxes with different colors in each corner like the ones dbp can draw "
- Yes that would be relativly easy to implement. I will do that and give a new link.

CPU: AMD X2 6000+ 3.0ghz GFX: NVIDIA BFG Geforce 8800GTS 640MB OC-550mhz core RAM: 2048mb

AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 7th Oct 2008 02:43
Looks cool so far! Just one thing...

I'm not sure about others but I am not a big fan of typing out long prefixes on commands. You might wanna shorten spriteDrawManager to SDM or something. Just a suggestion.

C0wbox
18
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 7th Oct 2008 19:44
@ General Reed
Yeh I agree with AndrewT, having to type out an extra 3 words for a faster command is a pain in the neck. xD
General Reed
18
Years of Service
User Offline
Joined: 24th Feb 2006
Location:
Posted: 7th Oct 2008 20:04
Quote: "Yeh I agree with AndrewT, having to type out an extra 3 words for a faster command is a pain in the neck. xD "
Ok i can change that now.

CPU: AMD X2 6000+ 3.0ghz GFX: NVIDIA BFG Geforce 8800GTS 640MB OC-550mhz core RAM: 2048mb

General Reed
18
Years of Service
User Offline
Joined: 24th Feb 2006
Location:
Posted: 7th Oct 2008 20:07 Edited at: 7th Oct 2008 20:08
Here you go, the prefix is now SDM XD



I havent had much time lately, and im still working on other features such as multiple box colours, filled circles, sperate label function - which will enable fast editing of text.

CPU: AMD X2 6000+ 3.0ghz GFX: NVIDIA BFG Geforce 8800GTS 640MB OC-550mhz core RAM: 2048mb

C0wbox
18
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 8th Oct 2008 03:13 Edited at: 8th Oct 2008 03:15
Quote: "the prefix is now SDM"

Good good.

I may actually consider utilizing this plugin, when it's done, now it has a short prefix.

Login to post a reply

Server time is: 2024-09-30 02:32:54
Your offset time is: 2024-09-30 02:32:54