Skip to content
MrNex edited this page Jun 28, 2015 · 5 revisions

Common Functions

There are a few common functions which you will find reoccuring throughout NGen. We will call these the common 3. These common 3 functions are Allocate, Initialize, and Free. Although pretty self explanatory, let us go over them here & take the time to discuss the finer points of such common functions:

  • Allocate is the malloc of NGen.

    • Effectively, Allocate allocates memory in RAM for a given structure.
    • It will always take no parameters & it will always return a pointer to the structure you are allocating.
    • All members of the struct will be garbage values upon allocation! Allocate does not initialize any members!
    • Everything which is Allocated (and not Initialized) must be manually freed using C's free function in stdlib.h!
    • It is dangerous to use a structures Free function unless the structure has been both Allocated and Initialized.
  • Initialize is the constructor of NGen.

    • Effectively, Initialize initializes an Allocated structure's members to safe or specified values.
    • It will always take at least one parameter, the structure which you want initialized, and will often take many more parameters.
    • Any structure which has been Allocated and Initialized must be Freed using the structure's Free Function.
    • Never Initialize a structure prior to Allocating the structure!
  • Free is the destructor of NGen.

    • Effectively, Free releases memory used by a structure back to the Operating System.
    • It will always take one parameter, the structure which you want to Free.
    • It is dangerous to Free a structure which has not been Initialized
    • Do not Free a structure which has not been Allocated, unless you know what you are doing!

Components

The NGen is divided into various sections:

  • Mathematics

  • Data Structures

  • Rendering

  • Collisions

  • Physics

  • GObjects

  • States

  • Implementation

  • Managers

  • Assets

  • Loaders