Skip to content

Engine API

Drew Wibbenmeyer edited this page Aug 31, 2021 · 1 revision

Engine API

Namespace bde

Enum class ResultType

Represents the success or failure of an operation.

Values

  • Success
  • Failure

Type ptr<Type>

Alias for a raw pointer.

Type sptr<Type>

Alias for a shared_ptr.

Type uptr<Type>

Alias for a unique_ptr.

Type error

Represents a some error that doesn't trigger an exception.

Struct Result

Represents success or failure of an operation with a possible message.

Data ResultType Type

The type of result.

Data error Message

The associated error message if Type is Failure.

Method operator int() const

Returns a simple integer representation of the Result. Useful for returning from main.

Method int HandleError(std::ostream & out = std::cerr)

If there was an error, output error message. Return result regardless.

Parameters
  • out The std::ostream to output the error message to.

NOTE: This method will most likely change to not use std::ostream but Raylib's TraceLog function.

Method operator bool() const

Returns true if Type is Success and false if Type is Failure.

Class BDEException

derives from std::runtime_error

Parent class of all Engine exceptions.

Constructor BDEException(std::string const & what)

Construct BDEException with a message.

Parameters
  • what The message to pass.

Class Object

Parent class of "managed" Engine classes.

Subtype ptr

Raw pointer wrapper.

Subtype sptr

Shared pointer wrapper.

Subtype uptr

Unique pointer wrapper.

Destructor virtual ~Object

Overridable destructor for Objects.

Method virtual void OnConstruct

Overridable method called when the Object is constructed.

Method virtual void OnDestruct

Overridable method called when the Object is destructed.

Class Engine

Parent class of the BlueDragonEngine.

Data toml::table Config

Holds the current Engine configuration data.

See Also: toml++

Data nk_context * NuklearGUI

The Engine's Nuklear context.

See Also: Nuklear

Data sol::state Lua

The Engine's Lua interpreter state.

See Also: Sol

Destructor virtual ~Engine

Engine destructor. Can be extended.

Method Result operator() (int argc, char * argv[])

Run the Engine with the given command-line arguments.

Parameters
  • argc Argument count (argc from main)
  • argv Argument values (argv from main)
Returns
  • A Success if no errors occurred in the execution of the Engine.
  • A Failure if an error occurred in the execution of the Engine.

Method virtual Result OnStartup(std::vector<std::string> const & args)

Overridable method called before Engine is setup. Used for processing command-line arguments.

Parameters
  • args Command-line arguments
Returns
  • A Success if no errors occurred in the function.
  • A Failure if an error occurred in the execution of the Engine.

Method virtual void OnLoad()

Overridable method called after the Engine is setup, but before the game loop starts.

Method virtual void OnUpdate()

Overridable method called at the beginning of each frame, used for updating game state.

Method virtual void OnRender()

Overridable method called each frame, used for drawing game graphics.

Method virtual void OnShutdown()

Overridable method called as the Engine is shutting down, but Engine facilities are still available.