cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to map image to oculus rift through openGL

Martti
Honored Guest
Hi I am trying to map image through openGL texture, but it only becomes a background image? I am doing following:

eyeRenderViewport[0].Pos = OVR::Vector2i(0, 0);
eyeRenderViewport[0].Size = OVR::Sizei(renderTargetSize.w / 2, renderTargetSize.h);
eyeRenderViewport[1].Pos = OVR::Vector2i((renderTargetSize.w + 1) / 2, 0);
eyeRenderViewport[1].Size = eyeRenderViewport[0].Size;

//ovrGLTexture eyeTexture[2];
eyeTexture[0].OGL.Header.API = ovrRenderAPI_OpenGL;
eyeTexture[0].OGL.Header.TextureSize = renderTargetSize;
eyeTexture[0].OGL.Header.RenderViewport = eyeRenderViewport[0];
eyeTexture[0].OGL.TexId = video_texture[0];

eyeTexture[1] = eyeTexture[0];
if(settings == 2){
eyeTexture[1].OGL.TexId = video_texture[1];
}
eyeTexture[1].OGL.Header.RenderViewport = eyeRenderViewport[1];

glBindTexture( GL_TEXTURE_2D, video_texture[0] );
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width,height,0, GL_RGB, GL_UNSIGNED_BYTE, image);

I am using shaders as in openGL 3.x but still image stays as upsidedown background image. Any suggestions why I cant control the image. Why cant I just use simple glBegin() and glEnd() as in openGL 1.x. I want to be able to map 2 images by
glPushMatrix();
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f((GLfloat)0.0f, 0.0f, -1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f((GLfloat)width, 0.0f, -1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f((GLfloat)width,(GLfloat)height , -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f((GLfloat)0.0f, (GLfloat)height , -1.0f);
glEnd();
glPopMatrix();

I am currently using vertex shaders and fragment shaders because I am little bit unsure if glBegin works on oculus SDK 0.3.2 linux
2 REPLIES 2

cybereality
Grand Champion
Have you not updated to SDK 0.4.3 for Linux? There should be example code included.
AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV

Martti
Honored Guest
I am trying to run oculus with allied stingray cameras using dc1394 library. I having problem just rendering with:

glPushMatrix();
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f((GLfloat)0.0f, 0.0f, -1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f((GLfloat)width, 0.0f, -1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f((GLfloat)width,(GLfloat)height , -1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f((GLfloat)0.0f, (GLfloat)height , -1.0f);
glEnd();
glPopMatrix();

see file attachments for example code. The image becomes as background image when I mapp it with:

glBindTexture( GL_TEXTURE_2D, video_texture[0] );
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width,height,0, GL_RGB, GL_UNSIGNED_BYTE, image);

I have used SDK 0.4.3 but I use SDK 0.3.2 since I think glBegin() and glEnd() still works on this. I am not sure if the mapping glTexCoord2f works?