Data Fields
| int32_t(* | GetAttribMaxValue )(PP_Resource instance, int32_t attribute, int32_t *value) |
| PP_Resource(* | Create )(PP_Instance instance, PP_Resource share_context, const int32_t attrib_list[]) |
| PP_Bool(* | IsGraphics3D )(PP_Resource resource) |
| int32_t(* | GetAttribs )(PP_Resource context, int32_t attrib_list[]) |
| int32_t(* | SetAttribs )(PP_Resource context, const int32_t attrib_list[]) |
| int32_t(* | GetError )(PP_Resource context) |
| int32_t(* | ResizeBuffers )(PP_Resource context, int32_t width, int32_t height) |
| int32_t(* | SwapBuffers )(PP_Resource context, struct PP_CompletionCallback callback) |
Detailed Description
PPB_Graphics3D defines the interface for a 3D graphics context.
Example usage from plugin code:
Setup:
PP_Resource context; int32_t attribs[] = {PP_GRAPHICS3DATTRIB_WIDTH, 800, PP_GRAPHICS3DATTRIB_HEIGHT, 800, PP_GRAPHICS3DATTRIB_NONE}; context = g3d->Create(instance, 0, attribs); inst->BindGraphics(instance, context);
Present one frame:
PP_CompletionCallback callback = { DidFinishSwappingBuffers, 0, PP_COMPLETIONCALLBACK_FLAG_NONE, }; gles2->Clear(context, GL_COLOR_BUFFER_BIT); g3d->SwapBuffers(context, callback);
Shutdown:
core->ReleaseResource(context);
Field Documentation
| PP_Resource(* PPB_Graphics3D::Create)(PP_Instance instance, PP_Resource share_context, const int32_t attrib_list[]) |
Create() creates and initializes a 3D rendering context.
The returned context is off-screen to start with. It must be attached to a plugin instance using PPB_Instance::BindGraphics to draw on the web page.
- Parameters:
[in] instance The module instance. [in] share_context The 3D context with which the created context would share resources. If share_contextis not 0, then all shareable data, as defined by the client API (note that for OpenGL and OpenGL ES, shareable data excludes texture objects named 0) will be shared byshare_context, all other contextsshare_contextalready shares with, and the newly created context. An arbitrary number ofPPB_Graphics3Dcan share data in this fashion.[in] attrib_list specifies a list of attributes for the context. It is a list of attribute name-value pairs in which each attribute is immediately followed by the corresponding desired value. The list is terminated withPP_GRAPHICS3DATTRIB_NONE. Theattrib_listmay be 0 or empty (first attribute isPP_GRAPHICS3DATTRIB_NONE). If an attribute is not specified inattrib_list, then the default value is used (it is said to be specified implicitly). Attributes for the context are chosen according to an attribute-specific criteria. Attributes can be classified into two categories:- AtLeast: The attribute value in the returned context meets or exceeds the value specified in
attrib_list. - Exact: The attribute value in the returned context is equal to the value specified in
attrib_list.
- AtLeast: The attribute value in the returned context meets or exceeds the value specified in
Attributes that can be specified in attrib_list include:
PP_GRAPHICS3DATTRIB_ALPHA_SIZE: Category: AtLeast Default: 0.PP_GRAPHICS3DATTRIB_BLUE_SIZE: Category: AtLeast Default: 0.PP_GRAPHICS3DATTRIB_GREEN_SIZE: Category: AtLeast Default: 0.PP_GRAPHICS3DATTRIB_RED_SIZE: Category: AtLeast Default: 0.PP_GRAPHICS3DATTRIB_DEPTH_SIZE: Category: AtLeast Default: 0.PP_GRAPHICS3DATTRIB_STENCIL_SIZE: Category: AtLeast Default: 0.PP_GRAPHICS3DATTRIB_SAMPLES: Category: AtLeast Default: 0.PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS: Category: AtLeast Default: 0.PP_GRAPHICS3DATTRIB_WIDTH: Category: Exact Default: 0.PP_GRAPHICS3DATTRIB_HEIGHT: Category: Exact Default: 0.PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR: Category: Exact Default: Implementation defined.
- Returns:
- A
PP_Resourcecontaining the 3D graphics context if successful or 0 if unsuccessful.
| int32_t(* PPB_Graphics3D::GetAttribMaxValue)(PP_Resource instance, int32_t attribute, int32_t *value) |
GetAttribMaxValue() retrieves the maximum supported value for the given attribute.
This function may be used to check if a particular attribute value is supported before attempting to create a context.
- Parameters:
[in] instance The module instance. [in] attribute The attribute for which maximum value is queried. Attributes that can be queried for include: PP_GRAPHICS3DATTRIB_ALPHA_SIZEPP_GRAPHICS3DATTRIB_BLUE_SIZEPP_GRAPHICS3DATTRIB_GREEN_SIZEPP_GRAPHICS3DATTRIB_RED_SIZEPP_GRAPHICS3DATTRIB_DEPTH_SIZEPP_GRAPHICS3DATTRIB_STENCIL_SIZEPP_GRAPHICS3DATTRIB_SAMPLESPP_GRAPHICS3DATTRIB_SAMPLE_BUFFERSPP_GRAPHICS3DATTRIB_WIDTHPP_GRAPHICS3DATTRIB_HEIGHT
[out] value The maximum supported value for attribute
- Returns:
- Returns
PP_TRUEon success or the following on error:PP_ERROR_BADRESOURCEifinstanceis invalidPP_ERROR_BADARGUMENTifattributeis invalid orvalueis 0
| int32_t(* PPB_Graphics3D::GetAttribs)(PP_Resource context, int32_t attrib_list[]) |
GetAttribs() retrieves the value for each attribute in attrib_list.
- Parameters:
[in] context The 3D graphics context. [in,out] attrib_list The list of attributes that are queried. attrib_listhas the same structure as described forPPB_Graphics3D::Create. It is both input and output structure for this function. All attributes specified inPPB_Graphics3D::Createcan be queried for.
- Returns:
- Returns
PP_OKon success or:PP_ERROR_BADRESOURCEif context is invalidPP_ERROR_BADARGUMENTif attrib_list is 0 or any attribute in theattrib_listis not a valid attribute.
Example usage: To get the values for rgb bits in the color buffer, this function must be called as following:
int attrib_list[] = {PP_GRAPHICS3DATTRIB_RED_SIZE, 0, PP_GRAPHICS3DATTRIB_GREEN_SIZE, 0, PP_GRAPHICS3DATTRIB_BLUE_SIZE, 0, PP_GRAPHICS3DATTRIB_NONE}; GetAttribs(context, attrib_list); int red_bits = attrib_list[1]; int green_bits = attrib_list[3]; int blue_bits = attrib_list[5];
| int32_t(* PPB_Graphics3D::GetError)(PP_Resource context) |
GetError() returns the current state of the given 3D context.
The recoverable error conditions that have no side effect are detected and returned immediately by all functions in this interface. In addition the implementation may get into a fatal state while processing a command. In this case the application must destroy the context and reinitialize client API state and objects to continue rendering.
Note that the same error code is also returned in the SwapBuffers callback. It is recommended to handle error in the SwapBuffers callback because GetError is synchronous. This function may be useful in rare cases where drawing a frame is expensive and you want to verify the result of ResizeBuffers before attempting to draw a frame.
- Parameters:
[in] The 3D graphics context.
- Returns:
- Returns:
PP_OKif no errorPP_ERROR_NOMEMORYPP_ERROR_CONTEXT_LOST
| PP_Bool(* PPB_Graphics3D::IsGraphics3D)(PP_Resource resource) |
IsGraphics3D() determines if the given resource is a valid Graphics3D context.
- Parameters:
[in] resource A Graphics3Dcontext resource.
- Returns:
- PP_TRUE if the given resource is a valid
Graphics3D,PP_FALSEif it is an invalid resource or is a resource of another type.
| int32_t(* PPB_Graphics3D::ResizeBuffers)(PP_Resource context, int32_t width, int32_t height) |
ResizeBuffers() resizes the backing surface for context.
If the surface could not be resized due to insufficient resources, PP_ERROR_NOMEMORY error is returned on the next SwapBuffers callback.
- Parameters:
[in] context The 3D graphics context. [in] width The width of the backing surface. [in] height The height of the backing surface.
- Returns:
- Returns
PP_OKon success or:PP_ERROR_BADRESOURCEif context is invalid.PP_ERROR_BADARGUMENTif the value specified forwidthorheightis less than zero.
| int32_t(* PPB_Graphics3D::SetAttribs)(PP_Resource context, const int32_t attrib_list[]) |
SetAttribs() sets the values for each attribute in attrib_list.
- Parameters:
[in] context The 3D graphics context. [in] attrib_list The list of attributes whose values need to be set. attrib_listhas the same structure as described forPPB_Graphics3D::Create. Attributes that can be specified are:PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR
- Returns:
- Returns
PP_OKon success or:PP_ERROR_BADRESOURCEifcontextis invalid.PP_ERROR_BADARGUMENTifattrib_listis 0 or any attribute in theattrib_listis not a valid attribute.
| int32_t(* PPB_Graphics3D::SwapBuffers)(PP_Resource context, struct PP_CompletionCallback callback) |
SwapBuffers() makes the contents of the color buffer available for compositing.
This function has no effect on off-screen surfaces - ones not bound to any plugin instance. The contents of ancillary buffers are always undefined after calling SwapBuffers. The contents of the color buffer are undefined if the value of the PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR attribute of context is not PP_GRAPHICS3DATTRIB_BUFFER_PRESERVED.
SwapBuffers runs in asynchronous mode. Specify a callback function and the argument for that callback function. The callback function will be executed on the calling thread after the color buffer has been composited with rest of the html page. While you are waiting for a SwapBuffers callback, additional calls to SwapBuffers will fail.
Because the callback is executed (or thread unblocked) only when the plugin's current state is actually on the screen, this function provides a way to rate limit animations. By waiting until the image is on the screen before painting the next frame, you can ensure you're not generating updates faster than the screen can be updated.
SwapBuffers performs an implicit flush operation on context. If the context gets into an unrecoverable error condition while processing a command, the error code will be returned as the argument for the callback. The callback may return the following error codes:
PP_ERROR_NOMEMORYPP_ERROR_CONTEXT_LOSTNote that the same error code may also be obtained by calling GetError.
- Parameters:
[in] context The 3D graphics context. [in] callback The callback that will executed when SwapBufferscompletes.
- Returns:
- Returns PP_OK on success or:
PP_ERROR_BADRESOURCEif context is invalid.PP_ERROR_BADARGUMENTif callback is invalid.
The documentation for this struct was generated from the following file: