HTC VIVE need help

hi,I am writing a interface to HTC VIVE, it need panda to submit left eye image and right eye image

vr::VRCompositor()->Submit(vr::Eye_Left, &leftEyeTexture );

leftEyeTexture is texture id in opengl mode, or texture pointer in dx mode

I write base.cam buffer to a texture, how can i get texture id ?

You should use a multiview texture by using set_num_views(2) on the texture. This will make it effectively two textures with the same properties.

If you render to it with a stereo buffer and a stereo lens, Panda will automatically render the left side to the first view and the right side to the second view.

To get the texture IDs you can do something like this: (untested)

#include "glgsg.h"

...

PreparedGraphicsObjects *pgo = gsg->get_prepared_objects();

GLTextureContext *left = (GLTextureContext *)tex->prepare_now(0, pgo, gsg);
GLTextureContext *right = (GLTextureContext *)tex->prepare_now(1, pgo, gsg);

GLuint left_id = left->_index;
GLuint right_id = right->_index;

Note that for this to succeed, either the textures must have already previously been prepared on the GSG, or you must be calling this while the GL context is currently bound (like in a draw callback).

thanks!

in graphicsOutpput.cxx

bool GraphicsOutput::init_hTC_vive()
{
if(_htc_texture==NULL)
{
_htc_texture=new Texture();
_htc_texture->set_num_views(2);
add_render_texture(_htc_texture, RTM_copy_ram);
}

return InitHTCVive();

}

when submit image,in wglGraphicsWindow.cxx

void wglGraphicsWindow::SubmitImage()
{

UpdateHMDMatrixPose();

int num_views = _htc_texture->get_num_views();
if(num_views>1)
{
PreparedGraphicsObjects *pgo = _gsg->get_prepared_objects();

GLTextureContext *left = (GLTextureContext *)_htc_texture->prepare_now(0, pgo, _gsg);
GLTextureContext *right = (GLTextureContext *)_htc_texture->prepare_now(1, pgo, _gsg);

Submit(vr::Eye_Left,(void*)(left->_index));
Submit(vr::Eye_Right,(void*)(right->_index))

}
}

i draw texture[left->_index] in the screen, the image is total white

i try submit image before begin_frame,after begin_frame,and after end_frame

it is ok now! , it seems set_num_views is not work!

add : _htc_texture->set_textures_power_2(ATS_none);

bool GraphicsOutput::init_hTC_vive()
{
if(_htc_texture==NULL)
{
_htc_texture=new Texture();
//_htc_texture->set_num_views(2);
_htc_texture->set_textures_power_2(ATS_none);
add_render_texture(_htc_texture, RTM_bind_or_copy);
}

return InitHTCVive();

}

SubmitImage before begin_frame

void wglGraphicsWindow::SubmitImage()
{

PreparedGraphicsObjects *pgo = _gsg->get_prepared_objects();
GLTextureContext *screentex = (GLTextureContext )_htc_texture->prepare_now(0, pgo, _gsg);
Submit((void
)(screentex->_index));
}

void CHTCVive::Submit(void* iTextureID)
{
if (m_pHMD)
{
vr::Texture_t eyeTexture = { iTextureID, vr::API_OpenGL, vr::ColorSpace_Gamma };
vr::VRCompositor()->Submit(vr::Eye_Left, &eyeTexture,&m_leftBound);
vr::VRCompositor()->Submit(vr::Eye_Right, &eyeTexture,&m_rightBound);
}
}