public interface Engine
This interface is used to create and use the Advanced Graphic Platform (AGP) engine.
| 限定符和类型 | 接口 | 说明 |
|---|---|---|
static class |
Engine.RenderBackend |
Indicates the type of the rendering backend, which can be either OpenGL ES or VULKAN.
|
static class |
Engine.RenderMode |
Indicates the rendering mode.
|
static interface |
Engine.RenderNodeGraph |
Configures a renderer.
|
static class |
Engine.RenderNodeGraphType |
Indicates the type of the rendering node graph.
|
static interface |
Engine.Time |
Provides engine time information.
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
activateContext() |
Activates the rendering context.
|
MeshBuilder |
createMeshBuilder(int primitiveCount) |
Creates a
MeshBuilder for building a 3D mesh. |
ViewHolder |
createViewHolder(SurfaceProvider surfaceView) |
Creates a
ViewHolder using SurfaceProvider. |
void |
deactivateContext() |
Deactivates the OpenGl rendering context.
|
Engine.Time |
getEngineTime() |
Obtains the engine time.
|
GltfExporter |
getGltfExporter() |
Obtains a
GltfExporter instance. |
GltfLoader |
getGltfLoader() |
Obtains a
GltfLoader instance. |
ResourceManager |
getResourceManager() |
Obtains a
ResourceManager instance. |
Scene |
getScene() |
Obtains the default scene.
|
String |
getVersion() |
Obtains the engine version.
|
boolean |
handleDevGuiTouchEvent(TouchEvent event) |
Checks whether a touch event is processed on the GUI control of the engine.
|
boolean |
init(Context context,
Engine.RenderBackend backend,
Map<String,Object> backendExtra,
String systemGraphUri) |
Initializes the engine.
|
boolean |
isDebugBuild() |
Checks whether the engine is of the debugging version (debug build).
|
Engine.RenderNodeGraph |
loadRenderNodeGraph(String renderNodeGraphUri) |
Loads a rendering node graph from the specified URI, which can be used to customize the rendering pipeline.
|
void |
postInRenderThread(Runnable task) |
Releases the task to run in a rendering thread.
|
void |
release() |
Deinitializes the initialized engine.
|
void |
renderFrame(Engine.RenderNodeGraph renderNodeGraph) |
Performs rendering on a frame using the customized rendering node graph.
|
void |
renderFrame(Engine.RenderNodeGraphType renderNodeGraphType) |
Render a frame using a built-in render graph.
|
void |
requestRender() |
Requests rendering on the next frame even if the engine or scene is not changed.
|
void |
requireRenderThread() |
Checks whether the current thread is a rendering thread.
|
void |
reset() |
Deinitializes and then initializes the entity-component system by deleting
all of the loaded entities, components, and resources.
|
void |
resourceCleanup() |
Ensures that all GPU resources have been cleared.
|
void |
runInRenderThread(Runnable task) |
Runs a task in the rendering thread.
|
void |
setDefaultTargetBuffer(TargetBuffer targetBuffer) |
Sets the default rendering buffer for the engine.
|
void |
setDefaultTargetBuffers(TargetBuffer[] targetBuffers) |
Sets the default rendering buffers array for an engine.
|
void |
setRenderMode(Engine.RenderMode renderMode) |
Sets the rendering mode of an engine.
|
boolean |
update() |
Updates the engine state for rendering purposes.
|
boolean init(Context context, Engine.RenderBackend backend, Map<String,Object> backendExtra, String systemGraphUri)
The OpenGL ES extra backend parameters are as follows:
| Key | Type | Default value |
|---|---|---|
| "MSAA_SAMPLE_COUNT" | Integer | 0 |
| "DEPTH_BUFFER_BITS" | Integer | 24 |
| "ALPHA_BITS" | Integer | 0 |
| "STENCIL_BITS" | Integer | 0 |
context - Indicates the rendering context.backend - Indicates the backend rendering type.backendExtra - Indicates extra backend parameters transferred to the engine for initialization.systemGraphUri - Indicates the URI of the system graph file.true if the engine is initialized; returns false otherwise.void reset()
void release()
void resourceCleanup()
GPU resources are usually allocated and released in RenderLoop. If RenderLoop is interrupted
and the engine is not released, this method can be used to process pending resource tasks if any.
String getVersion()
boolean isDebugBuild()
true if the engine is of the debugging version; returns false otherwise.void setDefaultTargetBuffer(TargetBuffer targetBuffer)
targetBuffer - Indicates the rendering buffer of the engine.void setDefaultTargetBuffers(TargetBuffer[] targetBuffers)
targetBuffers - Indicates the rendering buffers array of the engine.Engine.Time getEngineTime()
ResourceManager getResourceManager()
ResourceManager instance.ResourceManager instance.Scene getScene()
GltfLoader getGltfLoader()
GltfLoader instance.GltfLoader instance.GltfExporter getGltfExporter()
GltfExporter instance.GltfExporter instance.MeshBuilder createMeshBuilder(int primitiveCount)
MeshBuilder for building a 3D mesh.primitiveCount - Indicates the number of primitives in the mesh.MeshBuilder.ViewHolder createViewHolder(SurfaceProvider surfaceView)
ViewHolder using SurfaceProvider.surfaceView - Indicates the SurfaceProvider.ViewHolder.Engine.RenderNodeGraph loadRenderNodeGraph(String renderNodeGraphUri)
renderNodeGraphUri - Indicates the URI of the rendering node graph.void setRenderMode(Engine.RenderMode renderMode)
renderMode - Indicates the rendering mode of the engine.boolean update()
RenderLoop for the same purpose.true if rendering is required by the updated engine; returns false otherwise.void requestRender()
RenderMode#RENDER_IF_DIRTY is used.void renderFrame(Engine.RenderNodeGraph renderNodeGraph)
Engine#update() before calling this method.renderNodeGraph - Indicates the customized rendering node graph.void renderFrame(Engine.RenderNodeGraphType renderNodeGraphType)
Engine#update() before calling this to see if
rendering is actually required. Instead of calling this a RenderLoop can be used to simplify rendering.renderNodeGraphType - render node graph to use when rendering.void activateContext()
void deactivateContext()
boolean handleDevGuiTouchEvent(TouchEvent event)
event - Indicates the touch event.true if the touch event is processed; returns false otherwise.void requireRenderThread()
IllegalStateException - Throws this exception if the current thread is not a rendering thread.void postInRenderThread(Runnable task)
task - Indicates the task to run.void runInRenderThread(Runnable task)
If the rendering thread has already been called, the task runs immediately. Otherwise, the task is passed to the corresponding handle to run.
task - Indicates the task to run.