Interface InstanceRenderAPI

All Known Implementing Classes:
AreaLight, BaseIlluminantData, BaseInstanceRenderData, BaseMIRenderData, CommonEntity, CurveEntity, DistortionEntity, FlareEntity, InfiniteLight, LinearLight, PointLight, SpotLight, SpriteEntity

public interface InstanceRenderAPI
  • Method Details

    • resetInstanceData

      void resetInstanceData()
      When call it, will reset data and delete related objects.

      A.K.A. free() for instance data resources.

    • getInstanceData

      List<InstanceDataAPI> getInstanceData()
    • setInstanceData

      byte setInstanceData(@Nullable List<InstanceDataAPI> instanceData)
      For rendering a lots of entities (such as 10k+ entities) at once.

      For all render objects, location/facing/size/color/emissive/alpha data all form InstanceDataAPI, and overlay to RenderDataAPI implements.

      Render count decided by List.size().

      Have size limit, pick smallest from BoxConfigs.getMaxInstanceDataSize().

      This entity attribute, MaterialData.getColor() and MaterialData.getEmissiveColor() both apply to each instance when rendering.

      For model matrix, each instance is also derived from this entity.

      Parameters:
      instanceData - set to 'null' or empty 'List' -> clear, or a 'List' what isn't empty.
      Returns:
      returns BoxEnum.STATE_SUCCESS when success, return BoxEnum.STATE_SUCCESS when null list that set to empty list.
    • setInstanceData

      byte setInstanceData(@Nullable List<InstanceDataAPI> instanceData, float fadeIn, float full, float fadeOut)
      Reset global timer by manual.

      Similar to setInstanceData(List).

      Returns:
      returns BoxEnum.STATE_SUCCESS when success, return BoxEnum.STATE_FAILED when over limit.
    • addInstanceData

      byte addInstanceData(@NotNull InstanceDataAPI instanceData)
      Returns:
      returns BoxEnum.STATE_SUCCESS when success, return BoxEnum.STATE_FAILED when over limit, return BoxEnum.STATE_FAILED_OTHER when added a null object.
    • isMappingInstanceSubmit

      boolean isMappingInstanceSubmit()
      Default value is false.
    • setMappingInstanceSubmit

      void setMappingInstanceSubmit(boolean mappingMode)
      NOTE: Ineffective if device was OpenGL 4.4+ supported, will force updating to persistent mapping buffer.

      For some very slight data, use glBufferSubData() may faster.

      Besides, some devices(some ARM SoC) may slower with glMapBufferRange(), decided by the drive how implements it.

      Parameters:
      mappingMode - to controls whether submit use glMapBufferRange(), else use glBufferSubData().
    • submitInstance

      void submitInstance()
      Use it when you changed the instance data.

      Should have reserved size for it, memory expand is an expensive operation.

      Make sure has call mallocInstance(InstanceType, int) when without valid memory.

    • mallocInstance

      void mallocInstance(InstanceType target, int dataNum)
      Make sure call it before call submitInstance() when without valid memory.
    • isNeedRefreshInstanceData

      boolean isNeedRefreshInstanceData()
    • isAlwaysRefreshInstanceData

      boolean isAlwaysRefreshInstanceData()
    • callRefreshInstanceData

      void callRefreshInstanceData(boolean refresh)
      When changed the instance data(Not fixed instance data), call it.
    • setAlwaysRefreshInstanceData

      void setAlwaysRefreshInstanceData(boolean refresh)
    • haveValidInstanceData

      boolean haveValidInstanceData()
    • getValidInstanceDataCount

      int getValidInstanceDataCount()
    • getInstanceDataRefreshIndex

      int getInstanceDataRefreshIndex()
    • getInstanceDataRefreshOffset

      int getInstanceDataRefreshOffset()
    • getInstanceDataRefreshSize

      int getInstanceDataRefreshSize()
    • setInstanceDataRefreshIndex

      void setInstanceDataRefreshIndex(int index)
      Parameters:
      index - will refresh instance data start from this index.
    • setInstanceDataRefreshOffset

      void setInstanceDataRefreshOffset(int targetIndex)
      Parameters:
      targetIndex - will refresh instance data to instance data index of memory.
    • setInstanceDataRefreshSize

      void setInstanceDataRefreshSize(int size)
      Parameters:
      size - Will refresh instance data count.
    • setInstanceDataRefreshAllFromCurrentIndex

      void setInstanceDataRefreshAllFromCurrentIndex()
    • getRenderingCount

      int getRenderingCount()
    • setRenderingCount

      void setRenderingCount(int num)
    • getRenderingOffset

      int getRenderingOffset()
    • setRenderingOffset

      void setRenderingOffset(int index)
      Should reset the rendering count after that.
    • setRenderingAllInstanceFromCurrentOffset

      void setRenderingAllInstanceFromCurrentOffset()
    • getInstanceDataMemory

      MemoryBlock getInstanceDataMemory()
    • setSharedInstanceData

      void setSharedInstanceData(InstanceRenderAPI renderData)
      Will always computes once for the same memory range.

      And if any rendering entity with not-full-range refresh, will only refresh the minimum range for them.

    • resetMemory

      void resetMemory(MemoryBlock memory)
      Equivalent to:
       
       MemoryBlock old_mem = this->memory;
       if (old_mem) free(old_mem);
       this->memory = new_mem;
       
       
    • resetMemory

      void resetMemory()
    • getInstanceTimerOverride

      float getInstanceTimerOverride()
    • setInstanceTimerOverride

      void setInstanceTimerOverride(float alpha, byte state)
      Override timer of all in-vRAM instance data to this value.
      Parameters:
      alpha - set less than 0 to disable override.
      state - valid state: BoxEnum.TIMER_IN, BoxEnum.TIMER_FULL, BoxEnum.TIMER_OUT.
    • copyInstanceTimerOverride

      void copyInstanceTimerOverride(InstanceRenderAPI renderData)