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.

AppGameKit/AppGameKit Studio Showcase / Software 3D Graphics Engine Tutorial Source (JavidX) - AppGameKit v2 & Studio

Author
Message
Raven
15
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 17th Mar 2020 03:20 Edited at: 17th Mar 2020 03:24
For anyone looking to get into the Nuts & Bolts of 3D Graphics, then building a Software 3D Renderer is an excellent way to learn.
As with most things today, a lot of the fundamental ideas end up a bit of a Black Box because these are such common things that most Graphics APIs come with this stuff built-in...
I'd further argue that while there are typically a lot of Tutorials Online that go over what and the Algebraic Mathematics to do various things., converting Algebraic Terms into Working Code isn't always the easiest thing, especially for those who haven't actually done Higher Level Mathematics (which things like Quadratics, Matrices, etc.) are.

This is where I'd say JavidX' "Code it Yourself! 3D Graphics Engine" Tutorial Series comes in.
Because he walks you through how and why something is being done, typically with a cutaway to a Whiteboard to Visualise it.

Now in his tutorials he uses his Console Game Engine, which is a basic interface for Creating Graphics, Getting Input and Outputting Audio., but this is written in C/C++
I thought that it might be cool to convert all of his Tutorial Source (which is freely available) into an AppGameKit Compatible Format... so you can watch the tutorials, and see how you'd do some of the things he does in AppGameKit.

---------------------------

agkCommon.agc


AppGameKit Common Framework, will eventually echo all of the same features as the olcConsoleEngine ... so that you can use it identically as in JavidX's Tutorials.
Now I still don't know why after 21 Years, TheGameCreators BASIC doesn't have built-in True and False.
These however are predefined as AGK_TRUE and AGK_FALSE in the agkCommon.agc

Function OnCreate( )
// This is called only at Creation
EndFunction AGK_TRUE

Function OnUpdate( fElapsedTime As Float )
// This is called every Frame
EndFunction AGK_TRUE

These are not defined in agkCommon.agc because these are specifically for you to Override; and as AppGameKit doesn't have a "Virtual" (i.e. Placeholder) ... this does mean you have to make these yourself.

In order to Begin the Runtime you want to use the agc_Create( )
So a basic Hello World would be:



fElapsedTime is the time in milliseconds between each Update.
So if you want to have Updates based upon the Framerate, then just Multiply any "Per Frame" Update by the fElapsedTime and every Second that's how many Units said Object will have Transformed / Rotated / Scaled.

--------------------------------------------------------------------

3DGraphicsEngine_Part_1.agc / Part 1 - Triangles & Projection


This is the AppGameKit Version of Part 1 ... and here's the Video for it.



As a side note., I've included at the end a Cube Mesh Function (I'll be adding more primitives with each Part) but it isn't part of the Tutorial.
These will just be to see how to create such things in Code.

I hope you all enjoy. I will be posting the other 3 Parts over this week, so keep an eye out.
DannyD
2
Years of Service
User Offline
Joined: 29th Aug 2017
Location:
Posted: 17th Mar 2020 16:50
Thanks Raven.... Very interesting..
Raven
15
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 19th Mar 2020 10:19
So as a quick preface here... my Fill Triangle Routines for some reason is a little "Janky" in AppGameKit and I've been scratching my head over why exactly.
It's good enough for now, and I'll try to fix it later.

3DGraphicsEngine_Part_2.agc / Part 2 - Normals, Culling and Object Files


This covers everything that's in the next part of the series



As noted I'll see about improving the Triangle Fill Routine to work better (hopefully by the next part)
And the Source will get cleaned up a bit with better comments, as I think it might be useful to know how (and why) I've changed certain aspects to work in AGK.

Now as a further note, the ObjectFile has been attached to the post and you'll have to manually set the path, because for some reason my AppGameKit Studio just doesn't like doing Relative Reads as it always claims the File doesn't Exist.
Now idea if that's an issue with how I'm trying to use it or what... just irritates the heck out of me though.

Cliff Mellangard 3DEGS
Developer
14
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Raven
15
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 26th Mar 2020 02:08
I'll get the next part up hopefully Monday... work has me doing an insane amount of extra hours that I wasn't expecting.
In the mean time, I did resolve the Triangle Rasterisation issue.



Add that to the DrawTriangle() Function after the Local Declarations., as it seems that AppGameKits' Integer > Float Rounding can be a bit "twitchy" ... so simply removing the Decimal without rounding resolves the issue.
c0d3r9
2
Years of Service
User Offline
Joined: 2nd Oct 2017
Location:
Posted: 27th Mar 2020 03:33
awesome.i will take a look at that all on the weekend.
Laptop: Win10@64bit - i3 2x2Ghz - 8GB Ram - 1TB HDD
Desktop: Win10@64bit - AMD Ryzen 5 2400G - MSI B450 Tomahawk - 8GB Ram - 240GB SSD
janbo
11
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 27th Mar 2020 22:21 Edited at: 27th Mar 2020 23:54
Nice I made a software renderer too back before I dived into shaders.
It defenately helped me in the process of understanding them.
I'm totaly nitpicking here, but those redundant calculations made me itchy somehow.
This:

To this:

There is more but the tidiness outweighs the performance I think.

Also the second part didn't work for me but I found your VertexCounter a bit slow so I just did this:

[Edit]
And you dont want to run the triangle filling if the vertices are on the same line:

[/Edit]
Raven
15
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 27th Mar 2020 23:40
The tutorial isn't mine... rather an AppGameKit Version of the C++ Code from the linked Tutorial Videos.
I'm not sure what I'll do afterwards.
Have a few ideas, but might keep with the "Retro" theme.
janbo
11
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 27th Mar 2020 23:57 Edited at: 28th Mar 2020 00:00
I know, but you did a good and tidy job converting it.
I just having fun optimizing it here and there, don't mind me if you want ^^

But you should put everything into a package so it's more accesible for others if you want more feedback i guess.
Software 3D Renderer Demo with my changes

Attachments

Login to view attachments

Login to post a reply

Server time is: 2020-03-30 15:29:48
Your offset time is: 2020-03-30 15:29:48