WVR_SubmitFrameLayers¶
-
WVR_EXPORT WVR_SubmitError WVR_SubmitFrameLayers(const WVR_LayerParams_t * param, uint32_t layerCount, WVR_SubmitExtend extendMethod = WVR_SubmitExtend_Default)
Update multiple texture layers to display.
Besides submitting the right and left scenes, developers can submit a frame with separate texture layers and different behavior. Runtime will compose the layers into the final frame.
This function must be called after WVR_RenderInit.
- Return
- WVR_SubmitError. The error status of the WVR_SubmitFrame interface. Refer to WVR_RenderError for the different statuses.
- Version
- API Level 6
- Parameters
param
: Pointer to struct WVR_LayerParams_t to aggregate texture layers for this frame.layerCount
: Number of layers provided in param.extendMethod
: enum WVR_SubmitExtend. Flag to specify the invoking path.
Struct and enumeration¶
The type WVR_LayerParams_t is defined as:
-
struct
WVR_LayerParams
¶ Layer parameters.
Aggregate the related texture layers information that needs to be updated to runtime. The texture parameters can be obtained via WVR_GetTexture or directly assigned a valid texture. The WVR_SubmitFrameLayers needs this struct as an argument to pass the current texture identity to runtime.
Public Members
-
WVR_Texture_t
id
¶ The name of the texture to identify the texture entity in the graphics library such as OpenGL.
-
WVR_TextureTarget
target
¶ Specifies the target to which the texture is bound. The parameter corresponds to the texture target in the graphics library such as OpenGL. it must be WVR_TextureTarget_2D if the layer type is WVR_TextureLayerType_Overlay or WVR_TextureLayerType_Underlay
-
WVR_TextureLayout_t
layout
¶ The lower-left and upper-right UV coordinates pair that specifies the presenting region of the submitted texture.
-
WVR_TextureOptions
opts
¶ Specify the additional flag of the corresponding texture layer.
-
WVR_TextureShape
shape
¶ Assign the shape of the texture layer.
-
WVR_TextureLayerType
type
¶ Specify the type of layer. Only one layer of WVR_TextureLayerType_Content in one frame is allowed.
-
uint32_t
compositionDepth
¶ Composition order. The smaller value is composited first; the larger value means closer to the eye (0 ~ 15).
-
WVR_PoseState_t *
pose
¶ The pose used for rendering this frame.
-
WVR_Pose_t *
poseTransform
¶ Specify the position and orientation of this layer corresponding to the scene.
-
WVR_Vector3f *
size
¶ The size of this layer, measured in meters.
-
uint32_t
width
¶ The texture width.
-
uint32_t
height
¶ The texture height.
-
float
cylinderRadius
¶ The radius of the cylinder.
-
WVR_Texture_t
depth
¶ The name of the texture to identify the texture entity in the graphics library such as OpenGL.
-
WVR_Matrix4f_t *
projectionMatrix
¶ Projection matrix of the content.
-
WVR_Texture_t
The type WVR_Texture_t is defined as:
-
typedef void *
WVR_Texture_t
¶ WVR_Texture_t: type define the name of texture.
The srtuct WVR_TextureLayout_t is defined as:
-
struct
WVR_TextureLayout
¶ Texture layout.
Store the lower and upper UV coordinates to specify the region of the submitting texture. The lower-left coordinates are kept in lowerLeftUVs. The upper-right coordinates are kept in upperRightUVs.
Public Members
-
WVR_Vector2f
leftLowUVs
¶ Component 0 and 1 are lower-left UV coordinates of the texture.
-
WVR_Vector2f
rightUpUVs
¶ Component 0 and 1 are upper-right UV coordinates of the texture.
-
WVR_Vector2f
-
enum
WVR_TextureOptions
¶ Enumerate to specify the flag of the corresponding texture layer.
WVR_LayerParams_t This flag is needed to specify the invoking path.
Values:
-
WVR_TextureOption_None
= 0¶ WVR_TextureOption_None: The default option. The current layer is worldlock and treated as transparent.
-
WVR_TextureOption_HeadLocked
= 1 << 0¶ WVR_TextureOption_HeadLocked: Texture layer is headlock. Avoid runtime to apply reprojection on this layer.
-
WVR_TextureOption_Opaque
= 1 << 1¶ WVR_TextureOption_Opaque: The texture layer is opaque.
-
-
enum
WVR_TextureShape
¶ The shape of the texture.
Enumerate the shape of the texture.
Values:
-
WVR_TextureShape_Quad
= 0¶ WVR_TextureShape_Quad: Quad shape
-
WVR_TextureShape_Cylinder
= 1¶ WVR_TextureShape_Cylinder: [Experimental feature] Cylindrical shape
-
-
enum
WVR_TextureLayerType
¶ The type of the texture.
Enumerate the type of texture.
Values:
-
WVR_TextureLayerType_Content
= 0¶ WVR_TextureLayerType_Content: Content type
-
WVR_TextureLayerType_Overlay
= 1¶ WVR_TextureLayerType_Overlay: Overlay type
-
WVR_TextureLayerType_Underlay
= 2¶ WVR_TextureLayerType_Underlay: Underlay type
-
The struct WVR_PoseState_t is defined as:
-
struct
WVR_PoseState
¶ Describes a single pose in the rotation matrix form for a tracked object.
Public Members
-
bool
isValidPose
¶ The label of valid(true) or invalid(false) pose.
-
WVR_Matrix4f_t
poseMatrix
¶ The pose data (rotation, position) in matrix form (refer to WVR_Matrix4f).
-
WVR_Vector3f_t
velocity
¶ The velocity of the pose (refer to WVR_Vector3f).
-
WVR_Vector3f_t
angularVelocity
¶ The angular velocity of the pose.
-
bool
is6DoFPose
¶ The label of 6 DoF(true) or 3 DoF(false) pose.
-
int64_t
timestamp
¶ Absolute time (in nanosecond) of the pose.
-
WVR_Vector3f_t
acceleration
¶ The acceleration of the pose.
-
WVR_Vector3f_t
angularAcceleration
¶ The angular acceleration of the pose.
-
float
predictedMilliSec
¶ Number of milliseconds from now to predict poses.
-
WVR_PoseOriginModel
originModel
¶ The origin model of the pose.
-
WVR_Pose_t
rawPose
¶ The raw data of the pose from the device.
-
bool
The type WVR_Pose_t is defined as below.
-
struct
WVR_Pose
¶ Describes a single pose in quaternion form for a tracked object.
Public Members
-
WVR_Vector3f_t
position
¶ Position (x, y, z) part of the Pose (refer to WVR_Vector3f).
-
WVR_Vector3f_t
-
enum
WVR_SubmitExtend
¶ Extend the add-on functionality for WVR_SubmitFrame.
WVR_SubmitFrame needs this flag to specify the invoking path. Currently, the default functionality is available for the runtime to submit the texture target process. To do distortion correction, apply the flag WVR_SubmitExtend_DisableDistortion in this invoking path. The flag WVR_SubmitExtend_PartialTexture should be applied when presenting a cropped texture. The cropped range of the texture is determined by the WVR_TextureLayout struct in WVR_TextureParams.
Values:
-
WVR_SubmitExtend_Default
= 0x0000¶ WVR_SubmitExtend_Default: The default process to submit the texture to the display.
-
WVR_SubmitExtend_DisableDistortion
= 0x0001¶ WVR_SubmitExtend_DisableDistortion: The render runtime doesn’t correct distortion for this submit.
-
WVR_SubmitExtend_PartialTexture
= 0x0010¶ WVR_SubmitExtend_Partial: Present the partial texture.
-
WVR_SubmitExtend_SystemReserved1
= 1 << 30¶ **Reserved for the system.
-
How to use¶
Here is an example for the function:
// Must initialize render runtime once before calling all rendering-related APIs.
WVR_RenderInitParams_t param = {WVR_GraphicsApiType_OpenGL, WVR_RenderConfig_Default};
WVR_RenderError pError = WVR_RenderInit(¶m);
if (pError != WVR_RenderError_None) {
LOGE("Render init failed - Error[%d]", pError);
}
uint32_t maxSupportCount = WVR_GetMaxFrameLayerCount();
std::vector<WVR_LayerParams_t> frameParams;
frameParams.reserve(maxSupportCount);
std::vector<FrameBufferObject*> LeftEyeFBO;
std::vector<FrameBufferObject*> RightEyeFBO;
FrameBufferObject* fbo;
uint32_t RenderWidth = 0, RenderHeight = 0;
WVR_GetRenderTargetSize(&RenderWidth, &RenderHeight);
void* mLeftEyeQ = WVR_ObtainTextureQueue(WVR_TextureTarget_2D, WVR_TextureFormat_RGBA, WVR_TextureType_UnsignedByte, RenderWidth, RenderHeight, 0);
void* mRightEyeQ = WVR_ObtainTextureQueue(WVR_TextureTarget_2D, WVR_TextureFormat_RGBA, WVR_TextureType_UnsignedByte, RenderWidth, RenderHeight, 0);
for (int i = 0; i < WVR_GetTextureQueueLength(mLeftEyeQ); i++) {
fbo = new FrameBufferObject((int)WVR_GetTexture(mLeftEyeQ, i).id, RenderWidth, RenderHeight);
LeftEyeFBO.push_back(fbo);
}
for (int j = 0; j < WVR_GetTextureQueueLength(mRightEyeQ); j++) {
fbo = new FrameBufferObject((int)WVR_GetTexture(mRightEyeQ, j).id, RenderWidth, RenderHeight);
RightEyeFBO.push_back(fbo);
}
// Left Eye
LeftEyeFBO.at(mIndex)->bindFrameBuffer();
LeftEyeFBO.at(mIndex)->glViewportFull();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderScene(WVR_Eye_Left);
LeftEyeFBO.at(mIndex)->unbindFrameBuffer();
WVR_TextureParams_t leftEyeTexture = WVR_GetTexture(mLeftEyeQ, mIndex);
frameParams.emplace_back(
WVR_LayerParams_t {
WVR_Eye_Left,
leftEyeTexture.id,
leftEyeTexture.target,
leftEyeTexture.layout,
WVR_TextureOption_Opaque,
WVR_TextureShape_Quad,
WVR_TextureLayerType_Content,
0,
&mVRDevicePairs[WVR_DEVICE_HMD].pose,
0,
0,
RenderWidth,
RenderHeight,
0,
0,
0
}
);
// Right Eye
RightEyeFBO.at(mIndex)->bindFrameBuffer();
RightEyeFBO.at(mIndex)->glViewportFull();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
renderScene(WVR_Eye_Right);
RightEyeFBO.at(mIndex)->unbindFrameBuffer();
WVR_TextureParams_t rightEyeTexture = WVR_GetTexture(mRightEyeQ, mIndex);
frameParams.emplace_back(
WVR_LayerParams_t {
WVR_Eye_Right,
rightEyeTexture.id,
rightEyeTexture.target,
rightEyeTexture.layout,
WVR_TextureOption_Opaque,
WVR_TextureShape_Quad,
WVR_TextureLayerType_Content,
0,
&mVRDevicePairs[WVR_DEVICE_HMD].pose,
0,
0,
RenderWidth,
RenderHeight,
0,
0,
0
}
);
mPicTexture = Texture::loadTexture("quality_picture.png");
mPicTexture->bindTexture();
mPicTexture->bindBitmap(GL_RGB5_A1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
mPicTexture->unbindTexture();
mPicTexture->cleanBitmap();
WVR_TextureLayout_t picLayout = { { 0.0f, 0.0f }, { 1.0f, 1.0f } };
WVR_Pose_t picTransform = { { 0.0f, 0.0f, -2.0f }, { 1.0f, 0.0f, 0.0f, 0.0f } };
WVR_Vector3f picScale = { 1.0f, 1.0f, 1.0f };
// Check if device supports multi-layers
if (maxSupportCount > 1) {
frameParams.emplace_back(
WVR_LayerParams_t {
WVR_Eye_Left,
(WVR_Texture_t)mPicTexture->getTextureId(),
WVR_TextureTarget_2D,
picLayout,
WVR_TextureOption_None,
WVR_TextureShape_Quad,
WVR_TextureLayerType_Overlay,
7,
&mVRDevicePairs[WVR_DEVICE_HMD].pose,
&picTransform,
&picScale,
pictureWidth,
pictureHeight,
0,
0,
0
}
);
frameParams.emplace_back(
WVR_LayerParams_t {
WVR_Eye_Right,
(WVR_Texture_t)mPicTexture->getTextureId(),
WVR_TextureTarget_2D,
picLayout,
WVR_TextureOption_None,
WVR_TextureShape_Quad,
WVR_TextureLayerType_Overlay,
7,
&mVRDevicePairs[WVR_DEVICE_HMD].pose,
&picTransform,
&picScale,
pictureWidth,
pictureHeight,
0,
0,
0
}
);
}
e = WVR_SubmitFrameLayers(frameParams.data(), frameParams.size());