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 / Wierd Behaviour (Code Included)

Author
Message
Raven
14
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 26th Mar 2019 01:26
It could be that I'm overlooking something simple... but the code below has a weird behaviour when run, where instead of "Smooth" Scrolling through the Colour Palette Raster Bars., they do a little "Skip" at random intervals.
While it does smooth out (albeit not disappear) at Lower Update Commits., it would be good to have a second set of eyes to see if it's something that I'm overlooking that isn't related to the manual Buffer System... or if this is just inherent behaviour (say as a result of DirectX 9.0c / DBP U77) that will need to be resolved via a fix to the DBP Source Code.

Raven
14
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 26th Mar 2019 04:10
Alright, so I've expanded the example here with a set of 2D Drawing Commands
The Animated Circles perhaps better showcases the issue in the original Code

Derek Darkly
7
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 27th Mar 2019 00:05

Sorry, I'm useless. The code won't compile for me. It highlights a blank line (243) right above this section:

If Fill
For Y = AY To BY
FnLine( AX, Y, BX, Y, Colour )
Next
Else
FnLine( AX, AY, BX, AY, Colour )
FnLine( BX, AY, BX, BY, Colour )
FnLine( BX, BY, AX, BY, Colour )
FnLine( AX, BY, AX, AY, Colour )
EndIf


I've never really used the Fill command, I assume it's M1Utils.
Maybe someone else can try. Are you using the synergy editor?

Send your parents to noisy sprite demo hell... enter the D-Zone
Raven
14
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 27th Mar 2019 11:56
You can grab a copy of the Clean Install (60MB Zip., 120MB Decompressed) … just update the compiler path to point to wherever you decompress it.
It's simply a built "as-is" from the GitHub Source on Visual Studio 2019. No Expansion Libraries (well beyond the TGC ones packaged with the GitHub Source.

The Project source is also provided, in the "Prototype" directory.
I think the Editor is Synergy., but not 100% sure on that... as I didn't really check, but I don't think I'm using any "Special" features of it; rather it's whatever the default options are, well except some colour highlight changes.
It could be that one of the Expansion Libraries you have doesn't like the Variable names being used.
Derek Darkly
7
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 27th Mar 2019 18:46

Hmm... I know this isn't really related to your problem, but I don't think FILL is a native DBP command, is it? Or at least I don't see it in the regular help files.

Since you're saying IF FILL..... what is FILL supposed to return as a value?
Send your parents to noisy sprite demo hell... enter the D-Zone
Raven
14
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 27th Mar 2019 18:53
Function FnBox( AX As Integer , AY As Integer , BX As Integer , BY As Integer , Colour As Dword, Fill As Boolean )
Local Y As Integer

If Fill
For Y = AY To BY
FnLine( AX, Y, BX, Y, Colour )
Next
Else
FnLine( AX, AY, BX, AY, Colour )
FnLine( BX, AY, BX, BY, Colour )
FnLine( BX, BY, AX, BY, Colour )
FnLine( AX, BY, AX, AY, Colour )
EndIf

EndFunction
Raven
14
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 29th Mar 2019 20:03
Alright, so I feel like this just needs a fresh pair of eyes...
Was having an issue with "As" and Custom Types., so stripped it out in favour of DBC Compatible Code (aside from the Timer; which is easily replaced)
Also stripped out the BackBuffer approach (at least for now) to focus instead on the actual Draw Commands.

There are two issues I'm having with this particular code.
1) The Anti-Aliased Colours within certain Hues are "Off" … I'm probably just tired and missing something obvious
2) When you enable the Anti-Aliased Line Drawing., the Triangle has one of it's sides do something funky... it looks like it's being incorrectly flipping the X/Y but not sure... again a little tired after trying to work around some odd language behaviour

Anyway here's the code


I think what I might do is create 2 SKU of the Codebase., one that's DBC Compatible and another that's DBP Compatible.
Not sure about AGK... we'll see.
What I'll likely do next, is combine both Line Routines., while also adding in a Bypass for Straight Lines (which can be highly optimised) into a Single "FnLine" Command then work on Circles / Semi-Circles … before then moving on to Space Filling Polygons as well as adapting the Colour Functions to support the Palette Colours that I originally intended.

Probably require some CLUT for "Nearest" Colour and such.
Raven
14
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 29th Mar 2019 22:29
Well I feel like I'm taking 1 Step Forward and 2 Steps Back...



So, now regardless of the Line Angle it'll Render "Properly" … so the Triangles are remaining together BUT (and here's the Super-Special-Awesome element) they Edges seem like they're being offset by 33 Degrees CCW; while the Vertex Points are being Plotted correctly.
At first I just thought this was an issue with my implementation but actually I've been checking a few other Xu Line (Fast AA) implementations in different Languages and ALL of them are suffering from the same issue that my original code had., which actually is something that has me a bit baffled to be honest.

Now... I'm strictly speaking I think what I need to do is always ensure the Start X / Y are the Smallest Points (i.e. Closest to View Space 0,0) with a Flip depending on if the X or Y Axis is the Major Axis at Play., this way the Line Function is always Incrementing toward the End-Point.
As a note a Simple corrected to the previous post code, is to comment out the If Abs(DX) / Abs(DY) … EndIf., to prevent the Axis Swap; as this will render the Line Steps Correctly but just won't Render the Gradient between them.

This code does render the line correctly., it's just transposed from origin for all points.
I'll figure out what I'm doing wrong eventually but help would be appreciated.
Raven
14
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 29th Mar 2019 23:03
It's [i]almost[/I] working properly now... check out the screenshot (2 instances running side by side)
The only flaw are some of the Vertex are being Plotted at the Top of the Screen... trying to figure out what 'special case' is causing it to hack in a fix., but other than that... it works



Next step is to handle a Fill Routine (for the Shape Areas) … this will be for handling Polygon (Triangle / Quad) Rendering.
Oh., and I still need to sort out the Colour Displacement with the Anti-Aliased Edges but the code is still in there (just need to uncomment) to cycle through a Foreground and a Negative Background., it's a crass approach but eh, was just for testing purposes.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2019-06-19 11:07:29
Your offset time is: 2019-06-19 11:07:29