Test

BabECS Progress Showcase

This is a progress showcase of the various components I’ve been working on for my game engine, which utilizes an Entity Component System (ECS) and OpenGL.

The project aims to expand my knowledge of mathematics by developing my own math library and learning OpenGL.

  1. Initial Proof of Concept & Performance Test of Threaded ECS Systems

  2. Implementation of Instanced Uniforms/Shaders

  3. Implementation of Model-View-Projection (MVP)

  4. Implementation of Quaternions in Custom Math Library

  5. Implementation of Custom Model Loading

Current Programming Interface for BabECS Example:

Note: The interface currently feels cumbersome due to the heavy use of macros, and the setup style for the ECS is somewhat awkward. The goal is to improve this by incorporating configuration files and code generation for the systems and ECS setup. This will streamline the process, allowing developers to focus on writing gameplay functions in C++ while core-related configurations can be handled via configuration files or direct implementation (though less preferred).


namespace BabECS
{
	using EXAMPLE_GAME = BabECS::ECS
	<
		PositionData,
		TriangleData,
		MaterialData
	>;

	// Functional Style System Example
	BabeForEach(EXAMPLE_GAME, SystemExample, PositionData)
	{
		where_component(PositionData, is_not_entity_one)
			return;

		// 1 input component
		// 2 predicate / lambda evaluating the query
		// 3 all components in query (Can be multiple)
		where_from_query(PositionData, position_and_material_share_entity, MaterialData)
		{
			auto position_data_transform = [](PositionData position_data) -> PositionData
			{
				position_data.position.x += 1.1f;
				return position_data;
			};

			// Requests to alter this component after system thread memory is unlocked
			// with lambda provided above as transforming function
			request_transform(PositionData, position_data_transform);
		}

		// Local functions used by this system
		bool position_and_material_share_entity(const PositionData& pos, auto query_value)
		{
			const MaterialData& material_data = query_value.get<MaterialData>();
			if (material_data.entity_id == pos.entity_id)
				return true;
	
			return false;
		};
	
		bool is_not_entity_one(const PositionData& pos)
		{
			return pos.entity_id != 1;
		};
	}
}


int main()
{
	// Setup ECS and run!
	EXAMPLE_GAME ecs = EXAMPLE_GAME()
	               .add_pool(EXAMPLE_GAME::Pool()
		               .add_component_blocks(EXAMPLE_GAME::ComponentBlocks(
			               nrOfEntities, //		Position Data (one per entity)
			               nrOfEntities, //		Triangle Data (one per entity)
			               nrOfEntities))) //		Material Data (one per entity)
	               .system(System()
	                     .callback(SystemExample))
	               .add_renderer<Renderer>()
	               .add_app<PerformanceTest>()
	               .run();
}