目录

CGKitInterface

Class Info

class CGKitInterface

CG Kit接口类,可设置、获取应用程序,获取屏幕宽高比及宽度、高度等。

Public Method Summary

Qualifier and Type

Method Name and Description

void

SetApplication(BaseApplication* application)

设置应用程序。

const BaseApplication*

GetApplication() const

获取当前应用程序。

f32

GetAspectRatio() const

获取屏幕宽高比。

u32

GetScreenWidth() const

获取屏幕宽度。

u32

GetScreenHeight() const

获取屏幕高度。

bool

IsPlatformSupported() const

判断CG Kit是否支持当前平台。目前支持Android 8.0及其以上版本。

String

GetProgramDirectory()const

获取工程目录。

static CGKitInterface&

GetInstance()

获取CG Kit接口实例。

bool

SetMultiThreadRendering(bool isOpen)

设置多线程渲染开关,适用于CPU侧重负载场景,建议模型数在5000以上再开启。

u32

SetThreadCount(u32 count)

设置多线程数,需在多线程开启前设置,开启后设置无效,可设置的区间为[2, 手机的核数];该方法为非必须调用,系统会默认设置线程数为手机核数的一半减一。

void

SetSceneManagerType(SceneManagerType sceneManagerType)

设置场景管理器类型,不设置时默认使用四叉树场景管理器。

void

SetRenderingSortType(RenderingSortType sortType)

设置渲染排序类型。

void

SetMSAA(bool enable)

设置MSAA。

void

SetSampleCount(SampleCountFlagBits sampleCount)

设置采样数。

void

SetSampleShading(bool enable)

设置Sample Shading。

void

SetMinSampleShading(f32 minSampleShading)

设置最小着色率。

Public Methods

[h2]SetApplication

Method

void SetApplication(BaseApplication* application)

设置应用程序。

Parameters

Name

Description

application

指向当前使用应用程序的指针。

[h2]GetApplication

Method

const BaseApplication* GetApplication() const

获取当前应用程序。

Returns

Type

Description

const BaseApplication*

返回指向当前应用程序的指针。

[h2]GetAspectRatio

Method

f32 GetAspectRatio() const

获取屏幕宽高比。

Returns

Type

Description

f32

返回浮点类型屏幕宽高比。

[h2]GetScreenWidth

Method

u32 GetScreenWidth() const

获取屏幕宽度。

Returns

Type

Description

u32

返回32位无符号整数类型屏幕宽度。

[h2]GetScreenHeight

Method

u32 GetScreenHeight() const

获取屏幕高度。

Returns

Type

Description

u32

返回32位无符号整数类型屏幕高度。

[h2]IsPlatformSupported

Method

bool IsPlatformSupported() const

判断CG Kit是否支持当前平台。目前支持Android 8.0及其以上版本。

Returns

Type

Description

bool

  • true:支持当前平台。
  • false:不支持当前平台。

[h2]GetProgramDirectory

Method

String GetProgramDirectory() const

获取工程目录。

Returns

Type

Description

String

工程目录。

[h2]GetInstance

Method

static CGKitInterface& GetInstance()

获取CG Kit接口实例。

Returns

Type

Description

static CGKitInterface&

返回CG Kit接口实例的引用。

[h2]SetMultiThreadRendering

Method

bool SetMultiThreadRendering(bool isOpen)

多线程渲染开关接口,默认为false,关闭。

Parameters

Name

Description

isOpen

关闭或者开启,true为开启,false为关闭。

Returns

Type

Description

bool

  • true:接口调用成功。
  • false:接口调用失败。

[h2]SetThreadCount

Method

u32 SetThreadCount(u32 count)

设置多线程数,需在多线程开启前设置,开启后设置无效,可设置的区间为[2, 手机的核数];该方法为非必须调用,系统会默认设置线程数为手机核数的一半减一。

Parameters

Name

Description

u32

设置开启的线程数,可设置的区间为[2, 手机的核数]。

Returns

Type

Description

u32

返回成功设置的线程数。

[h2]SetSceneManagerType

Method

void SetSceneManagerType(SceneManagerType sceneManagerType)

设置场景管理器类型,不设置时默认使用四叉树场景管理器。

Parameters

Name

Description

sceneManagerType

场景管理器类型。

  • SCENE_MANAGER_TYPE_QUADTREE:四叉树场景管理器。
  • SCENE_MANAGER_TYPE_COMMON :普通场景管理器。

[h2]SetRenderingSortType

Method

void SetRenderingSortType(RenderingSortType sortType)

设置渲染排序类型。

Parameters

Name

Description

sortType

排序类型。默认值为RENDERING_SORT_TYPE_DISTANCE。

[h2]SetMSAA

Method

void SetMSAA(bool enable)

设置MSAA。

Parameters

Name

Description

enable

  • true:使能。
  • false:不使能,为默认值。

[h2]SetSampleCount

Method

void SetSampleCount(SampleCountFlagBits sampleCount)

设置采样数。

Parameters

Name

Description

sampleCount

采样数类型。默认值为SAMPLE_COUNT_1_BIT。

具体请参见SampleCountFlagBits。

[h2]SetSampleShading

Method

void SetSampleShading(bool enable)

设置Sample Shading。

Parameters

Name

Description

enable

  • true:使能。
  • false:不使能,为默认值。

[h2]SetMinSampleShading

Method

void SetMinSampleShading(f32 minSampleShading)

设置最小着色率。

Parameters

Name

Description

minSampleShading

最小着色率。默认值为0.0f。

取值范围为[0.0f, 1.0f],其值越接近1,图像越平滑。