Inheritance diagram for pp::Graphics3D:

List of all members.

Public Member Functions

 Graphics3D ()
 Graphics3D (const InstanceHandle &instance, const int32_t attrib_list[])
 Graphics3D (const InstanceHandle &instance, const Graphics3D &share_context, const int32_t attrib_list[])
 ~Graphics3D ()
int32_t GetAttribs (int32_t attrib_list[]) const
int32_t SetAttribs (const int32_t attrib_list[])
int32_t ResizeBuffers (int32_t width, int32_t height)
int32_t SwapBuffers (const CompletionCallback &cc)

Detailed Description

This class represents a 3D rendering context in the browser.


Constructor & Destructor Documentation

Default constructor for creating an is_null() Graphics3D object.

pp::Graphics3D::Graphics3D(const InstanceHandleinstance,
const int32_t attrib_list[] 
)

A constructor for creating and initializing a 3D rendering context.

The returned context is created off-screen and must be attached to a module instance using Instance::BindGraphics to draw on the web page.

Parameters:
[in]instanceThe instance with which this resource will be associated.
[in]attrib_listThe list of attributes (name=value pairs) for the context. The list is terminated with PP_GRAPHICS3DATTRIB_NONE. The attrib_list may be NULL or empty (first attribute is PP_GRAPHICS3DATTRIB_NONE). If an attribute is not specified in attrib_list, then the default value is used.

Attributes are classified into two categories:

1. AtLeast: The attribute value in the returned context will meet or exceed the value requested when creating the object. 2. Exact: The attribute value in the returned context is equal to the value requested when creating the object.

AtLeast attributes are (all have default values of 0):

PP_GRAPHICS3DATTRIB_ALPHA_SIZE PP_GRAPHICS3DATTRIB_BLUE_SIZE PP_GRAPHICS3DATTRIB_GREEN_SIZE PP_GRAPHICS3DATTRIB_RED_SIZE PP_GRAPHICS3DATTRIB_DEPTH_SIZE PP_GRAPHICS3DATTRIB_STENCIL_SIZE PP_GRAPHICS3DATTRIB_SAMPLES PP_GRAPHICS3DATTRIB_SAMPLE_BUFFERS

Exact attributes are:

PP_GRAPHICS3DATTRIB_WIDTH Default 0 PP_GRAPHICS3DATTRIB_HEIGHT Default 0 PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR Default: Implementation defined.

On failure, the object will be is_null().

pp::Graphics3D::Graphics3D(const InstanceHandleinstance,
const Graphics3Dshare_context,
const int32_t attrib_list[] 
)

A constructor for creating and initializing a 3D rendering context.

The returned context is created off-screen. It must be attached to a module instance using Instance::BindGraphics to draw on the web page.

This constructor is identical to the 2-argument version except that this version allows sharing of resources with another context.

Parameters:
[in]instanceThe instance that will own the new Graphics3D.
[in]share_contextSpecifies the context with which all shareable data will be shared. The shareable data is defined by the client API (note that for OpenGL and OpenGL ES, shareable data excludes texture objects named 0). An arbitrary number of Graphics3D resources can share data in this fashion.
[in]attrib_listThe list of attributes for the context. See the 2-argument version of this constructor for more information.

On failure, the object will be is_null().


Member Function Documentation

int32_t pp::Graphics3D::GetAttribs(int32_t attrib_list[])const

GetAttribs() retrieves the value for each attribute in attrib_list.

The list has the same structure as described for the constructor. All attribute values specified in pp_graphics_3d.h can be retrieved.

Parameters:
[in,out]attrib_listThe list of attributes (name=value pairs) for the context. The list is terminated with PP_GRAPHICS3DATTRIB_NONE.

The following error codes may be returned on failure:

PP_ERROR_BADRESOURCE if context is invalid. PP_ERROR_BADARGUMENT if attrib_list is NULL or any attribute in the attrib_list is not a valid attribute.

Example:

 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];

This example retrieves the values for rgb bits in the color buffer.

int32_t pp::Graphics3D::ResizeBuffers(int32_t width,
int32_t height 
)

ResizeBuffers() resizes the backing surface for the context.

Parameters:
[in]widthThe width of the backing surface.
[in]heightThe height of the backing surface.
Returns:
An int32_t containing PP_ERROR_BADRESOURCE if context is invalid or PP_ERROR_BADARGUMENT if the value specified for width or height is less than zero. PP_ERROR_NOMEMORY might be returned on the next SwapBuffers() callback if the surface could not be resized due to insufficient resources.
int32_t pp::Graphics3D::SetAttribs(const int32_t attrib_list[])

SetAttribs() sets the values for each attribute in attrib_list.

The list has the same structure as the list used in the constructors.

Attributes that can be specified are:

  • PP_GRAPHICS3DATTRIB_SWAP_BEHAVIOR

On failure the following error codes may be returned:

  • PP_ERROR_BADRESOURCE if context is invalid.
  • PP_ERROR_BADARGUMENT if attrib_list is NULL or any attribute in the attrib_list is not a valid attribute.

SwapBuffers() makes the contents of the color buffer available for compositing.

This function has no effect on off-screen surfaces: surfaces not bound to any module 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 instance'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_NOMEMORY PP_ERROR_CONTEXT_LOST

Note that the same error code may also be obtained by calling GetError().

param[in] cc A CompletionCallback to be called upon completion of SwapBuffers().

Returns:
An int32_t containing PP_ERROR_BADRESOURCE if context is invalid or PP_ERROR_BADARGUMENT if callback is invalid.

The documentation for this class was generated from the following file:
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.