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.

DarkBASIC Professional Discussion / DBP Pro slow for 2D ?

Author
Message
DrFloyd
3
Years of Service
User Offline
Joined: 12th Feb 2021
Location:
Posted: 26th Jun 2023 11:02
Hi again

There is a rumor : DBP is slow for 2D games ? It that true ?

My last game was using PURE BASIC (very very very fast !)

Thanks
Laurent
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 27th Jun 2023 04:13
It really depends on what you are attempting to do. A lot of 2D functions can be done fairly efficiently however these are more advanced optimizations that a basic read of the commands would overlook.
For example locking and unlocking pixels allows a bulk of 2D commands to be processed much faster. There are things like using DDS file format, which speeds up loading times. Some plugins also help.

One of the ways 2D Dark Basic Professional falls short for me is the sprite scaling appears to be 'nearest neighbor' or at least the filtering is bad. If you take a sprite on screen and make it grow or shrink you will see patterns and distortions as the image changes size. In my case I am scaling font characters and at those smaller sizes the lack of blending makes the fonts look bad. This means having to put extra effort into selecting a font that can scale well under these conditions.

There is a bug with changing Sprite U/V coordinates. If you load an image anywhere in your program it will reset all sprite u/v coordinates you have setup. This is important because if you load all of your sprite animations from a single image for speed (which is an industry standard) you then have to create sprites and manually setup which parts of the image that sprite will use (the U/V coordinates). So if you setup all these sprites, then go to load an image at some point all that stuff gets reset. It basically means using customer sprite u/v coordinates is broken and unusable in DBPro. I don't know how this was overlooked. Look at how many people used this over the years and nobody complained.

Mage's Modular Code - Get awesome UI controls and powerful Bitmap Fonts!
Screen Device Recovery - Stop your apps from crashing when minimized/tabbed/screen locked.
CPU Friendly Frame Limiter - Make your app generate less computer heat + noise, and use less battery life!
DrFloyd
3
Years of Service
User Offline
Joined: 12th Feb 2021
Location:
Posted: 27th Jun 2023 10:08
thank you

Very strange this bug ! Nobody complained !?
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 28th Jun 2023 01:11 Edited at: 28th Jun 2023 01:18
A haven't looked into it in a while, but I'm pretty much the only person who ever mentioned it. It's almost like nobody ever used the Sprite commands beyond basic work.

I got involved because I wrote a bitmap font system. The characters are loaded from a single image. The system would just setup sprites for each character using sections of that image. So the font system would totally reset any time an image was loaded in a program that used it. I got around this by loading font character image, and chopping it up into separate images in memory, so that all of the sprites could point to them with default 1:1 u/v settings. However this introduced a processing delay when the program first loads and the font system needs to be setup and do all this.

Mage's Modular Code - Get awesome UI controls and powerful Bitmap Fonts!
Screen Device Recovery - Stop your apps from crashing when minimized/tabbed/screen locked.
CPU Friendly Frame Limiter - Make your app generate less computer heat + noise, and use less battery life!
Kuper
16
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 28th Jun 2023 21:14
Instead of using build in 2d engine you can use Advanced Sprites plugin which is much faster, as I remember.
As for me, when I was writing my GUI system I decide to switch to screen shaders. It was right decision. For animated sprite characters you have to use moving 3d planes in screen space and it is complicated way, but as a result you will be able
to use different shader effects like lighting, glowing, color changing and so on. If you know shaders well I definitely recomend to use them.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 29th Jun 2023 03:19
Thanks I will give that a look.

Mage's Modular Code - Get awesome UI controls and powerful Bitmap Fonts!
Screen Device Recovery - Stop your apps from crashing when minimized/tabbed/screen locked.
CPU Friendly Frame Limiter - Make your app generate less computer heat + noise, and use less battery life!
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 29th Jun 2023 16:21
Quote: "There is a bug with changing Sprite U/V coordinates. If you load an image anywhere in your program it will reset all sprite u/v coordinates you have setup. This is important because if you load all of your sprite animations from a single image for speed (which is an industry standard) you then have to create sprites and manually setup which parts of the image that sprite will use (the U/V coordinates). So if you setup all these sprites, then go to load an image at some point all that stuff gets reset. It basically means using customer sprite u/v coordinates is broken and unusable in DBPro. I don't know how this was overlooked. Look at how many people used this over the years and nobody complained."


While Virtual Texture _might_ be an Industry Standard today... in 2002 - 2007., it was an uncommon practise to say the least.
Now I'd have to dig into the DBP Source to see why it resets the UV for all Sprites when you Load an Image., but it could be that DBP itself isn't actually storing said information., meaning said "bug" is with DirectX 9 itself.
This wouldn't surprise me, as keep in mind that things such-as associated Draw States are handled by the Graphics Drivers not the API.

What I mean is... are you sure the behaviour is universal to all Hardware and not just, say NVIDIA or ATI?
You will find there are a lot of behaviours in DBP that are Vendor Specific; and this is because quite a fair amount of the "Dark Engine" was just being a DirectX 9 API Wrapper., with minor streamlining to work how you'd expect for a BASIC Language.
Still even IF it's a universal behaviour, you also have to keep in mind that again at the time things were moving to pure Shader Pipelines... and well each Shader has its own State Object that is Zeroed by Default.

Don't get me wrong here, I agree it isn't working as you expect thus a bug., but it could also be DirectX 9 working "as-intended", so using these things in this way; because it wasn't a common practise then, could easily have been an oversight to not write a work around for.
If you have some Sample Code that showcases the issue; that would be useful to track down the issue.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 30th Jun 2023 01:19
Kuper:
I usually over share a little just so people might jump in with helpful information that I don't know about. Thanks!
I will need to check Advanced Sprites plugin as it no doubt has it's own details to deal with.

Raven:
It's subjective when this (storing anims all on one texture) became popular. So feel free to decide that one for yourself. In my case however with regards to Fonts, this has been common since the 90's or earlier. If I recall correctly this is how windows fonts are stored, in their file format. I have vague childhood memories of editing fonts in MSPaint.

As far as testing this with all hardware, etc. Nope haven't tested this widely. I should also point out that between AMD and Intel hardware I have had some real trouble getting DBP to operate consistently. I have an AMD APU (pre ryzen) which refuses to execute DBP programs properly even adding simple numbers together produces erroneous values.

It's interesting if this is a quirk of directx 9 or not causing this. Maybe. However I am talking to DBP and the system as is isn't working as intended in that case. It basically makes setting custom texture u/v coordinates for sprites useless in DBP. You can't reasonably use that feature then be expected to not load an image anywhere in the program thereafter. This also may have been introduced in one of the patches, I didn't check that so it might not be originally an issue from the DBP launch.

As far as examples go you should just be able to set the sprite u/v, then load an image, and see it get reset. I do have to remember back about 4 or 5 years now on this issue. I will check it again and post back later today if I determine anything interesting to add. Here I am complaining about it in 2017 with a work around:
https://forum.thegamecreators.com/thread/220759#msg2612628

Mage's Modular Code - Get awesome UI controls and powerful Bitmap Fonts!
Screen Device Recovery - Stop your apps from crashing when minimized/tabbed/screen locked.
CPU Friendly Frame Limiter - Make your app generate less computer heat + noise, and use less battery life!
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 30th Jun 2023 09:02
I was correct.








Mage's Modular Code - Get awesome UI controls and powerful Bitmap Fonts!
Screen Device Recovery - Stop your apps from crashing when minimized/tabbed/screen locked.
CPU Friendly Frame Limiter - Make your app generate less computer heat + noise, and use less battery life!
Kuper
16
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 30th Jun 2023 21:48 Edited at: 30th Jun 2023 21:49
Quote: "I usually over share a little just so people might jump in with helpful information that I don't know about. Thanks!"

You mean I should make a post with working demo? Some of functions may be usefull IMHO ( position plane in front of screen with correct rendered pixel size, for example )
The code is little heavy and messed up because for example I add kind of script system ( based on FPSC script syntax ) to make buttons and scrollbars affect variables. Also lot of other functions were added like debug and shader loading.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 1st Jul 2023 01:12 Edited at: 1st Jul 2023 01:26
I would read it. However I would probably not use your shader/screen plane solution since it would be a lot of work, especially since the existing codebase, and apps that use it would need a rewrite. Either way I will check out the plugin. I have some specific needs since I would be interested in adapting my bitmap font system to use it. So specific things like being able to paste the sprite to a background bitmap and using the Get Image command would be needed. This is because the system converts text to image for performance optimizations, and generally as a feature. Also I'd need to confirm the u/v coordinates can be set. So I'll need to investigate further on that.

I did some quick reading of the authors plugin announcement page and there was some mention of not using index numbers and instead using pointers or some other object handler. I'm sure that will make for another hurdle when attempting to drop it in on top of the existing sprite code.

Image Kit plugin can't do a few of these things so I am aware there could be some hang-ups attempting to use Advanced Sprites plugin if it's a similar situation.

Mage's Modular Code - Get awesome UI controls and powerful Bitmap Fonts!
Screen Device Recovery - Stop your apps from crashing when minimized/tabbed/screen locked.
CPU Friendly Frame Limiter - Make your app generate less computer heat + noise, and use less battery life!
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 3rd Jul 2023 21:59
I've had a look at the Source., and it does appear to be an issue with how Images are being loaded into memory... as they reset the Sprite Manager UV to "always use the full image" i.e. 0.0, 0.0, 1.0, 1.0
It does this with a "Test" Sprite, but it propagates with the manager to ALL Sprites.

As for how to fix this though... will have a look to see if I can't hack something together.
Problem is, I'm not so sure it is a "Simple" Fix; as the Test Sprite shouldn't be affecting all the others; that it is suggests an inheritance going on that might need a complete rewrite of the Sprite Manager., and I'm also curious if the same issue is present in Objects as well.

I mean I will stand by my original point... Virtual Textures simply weren't commonplace in the Mid-2000s.
Sure., packing multiple images within a Texture would be used; these would typically be divided up into discreet images (as you said you had to do) rather than be used as a singular image source for virtual images defined only by the texture space coordinates.

Login to post a reply

Server time is: 2024-05-01 07:22:57
Your offset time is: 2024-05-01 07:22:57