
############################
A3DGlobalInsertGraphMaterial
############################

.. c:function:: A3DStatus A3DGlobalInsertGraphMaterial(const A3DGraphMaterialData *pData, A3DUns32 *puiIndexMaterial)

   .. rst-class:: sig-pretty-signature
   
      | :c:enum:`~A3DStatus` A3DGlobalInsertGraphMaterial(*const* :c:struct:`~A3DGraphMaterialData`\ \* **pData**\ , :c:type:`~A3DUns32`\ \* **puiIndexMaterial**\ )
   
   Creates a new material, returning its index.
   
   
      2.0
   
   
   When given an ``A3DGraphMaterialData``\ , the function searches for an already existing material data of the same value and returns its index. If the material does not exist, it is created and a new index is returned. In case of failure ``*puiIndexMaterial`` is unchanged.
   
   .. code-block:: c
   
      A3DGraphMaterialData material_data = A3D_MAKE_DATA(A3DGraphMaterialData);
      A3DUns32 idx_0 = A3D_DEFAULT_MATERIAL_INDEX;
      
      A3DStatus result = A3DGlobalInsertGraphMaterial(&material_data, &idx_0);
      assert(result == A3D_SUCCESS);
      
      Second insertion with the same data, expect index to be the same.
      A3DUns32 idx_1 = A3D_DEFAULT_MATERIAL_INDEX;
      result = A3DGlobalInsertGraphMaterial(&material_data, &idx_1);
      assert(result == A3D_SUCCESS);
      assert(idx_0 == idx_1);
   
   **Return Values**
   
   
      **A3D_SUCCESS**\ : in case of success.
   
      **A3D_INITIALIZE_NOT_CALLED**\ : if the library is not initialized.
   
      **A3D_INVALID_DATA_STRUCT_SIZE**\ : if ``pData`` is incorrectly initialized
   
      **A3D_INVALID_DATA_STRUCT_NULL**\ : if ``pData`` is null.
   
   
   
      :c:func:`~A3DGlobalGetGraphMaterialData`
   
   
   
      :c:struct:`~A3DGraphMaterialData`
   
   
   **Parameters**
   
   
      **pData**\ : The material data to insert.
   
      **puiIndexMaterial**\ : The resulting index for the input color.
   
   
   **Returns**
   
   
      A3D_SUCCESS or an error code.
   
   




