Forum Discussion
DoZo1971
11 years agoExplorer
Simple, one page, OpenGL example (0.4.2 beta)
Hi,
Has anyone got a simple example of OpenGL (SDK) rendering working yet with DK2?
This is what I've got so far, based on the earlier example of the spinning cube using GLFW. It seems to work without the Oculus plugged in but gives an exception in ovrHmd_EndFrame() when it is. The exception is thrown in glBindFramebuffer(GL_FRAMEBUFFER, FrameBuffer) in HSWDisplay::RenderInternal(...).
I have no idea how to solve it.
EDIT Updated to 0.4.2 beta, it now works in extended mode on both Windows and OSX. Lots of @TODOs: Positional tracking, strange difference in translation over either X or Z between Windows and OSX version. Multisampling.
EDIT Difference in translation is nonsense, just do a ovrHmd_RecenterPose() at the start.
Thanks,
Daniel Dekkers
Has anyone got a simple example of OpenGL (SDK) rendering working yet with DK2?
This is what I've got so far, based on the earlier example of the spinning cube using GLFW. It seems to work without the Oculus plugged in but gives an exception in ovrHmd_EndFrame() when it is. The exception is thrown in glBindFramebuffer(GL_FRAMEBUFFER, FrameBuffer) in HSWDisplay::RenderInternal(...).
I have no idea how to solve it.
EDIT Updated to 0.4.2 beta, it now works in extended mode on both Windows and OSX. Lots of @TODOs: Positional tracking, strange difference in translation over either X or Z between Windows and OSX version. Multisampling.
EDIT Difference in translation is nonsense, just do a ovrHmd_RecenterPose() at the start.
// GLFWOculusRiftTest
// (c) cThrough 2014 (Daniel Dekkers)
// Version 2014090601 Based on DK2, OculusSDK 4.0.2 beta
// Windows and OSX, Linux not yet supported by OculusSDK 4.0.2 beta
#include <GL/glew.h>
#if defined(_WIN32)
#include <Windows.h>
#define GLFW_EXPOSE_NATIVE_WIN32
#define GLFW_EXPOSE_NATIVE_WGL
#elif defined(__linux__)
#include <X11/X.h>
#include <X11/extensions/Xrandr.h>
#define GLFW_EXPOSE_NATIVE_X11
#define GLFW_EXPOSE_NATIVE_GLX
#endif
#include <GLFW/glfw3.h>
#if !defined(__APPLE__)
#include <GLFW/glfw3native.h>
#endif
#include <OVR.h>
#include <OVR_CAPI.h>
#include <OVR_CAPI_GL.h>
const bool l_FullScreen = true;
const bool l_MultiSampling = false;
const bool l_Spin = true;
ovrHmd g_Hmd;
ovrGLConfig g_Cfg;
ovrEyeRenderDesc g_EyeRenderDesc[2];
GLfloat l_VAPoints[] =
{
0.5f, 0.5f, 0.5f,
-0.5f, 0.5f, 0.5f,
-0.5f,-0.5f, 0.5f,
0.5f,-0.5f, 0.5f,
-0.5f,-0.5f,-0.5f,
-0.5f, 0.5f,-0.5f,
0.5f, 0.5f,-0.5f,
0.5f,-0.5f,-0.5f,
0.5f, 0.5f, 0.5f,
0.5f, 0.5f,-0.5f,
-0.5f, 0.5f,-0.5f,
-0.5f, 0.5f, 0.5f,
-0.5f,-0.5f,-0.5f,
0.5f,-0.5f,-0.5f,
0.5f,-0.5f, 0.5f,
-0.5f,-0.5f, 0.5f,
0.5f, 0.5f, 0.5f,
0.5f,-0.5f, 0.5f,
0.5f,-0.5f,-0.5f,
0.5f, 0.5f,-0.5f,
-0.5f,-0.5f,-0.5f,
-0.5f,-0.5f, 0.5f,
-0.5f, 0.5f, 0.5f,
-0.5f, 0.5f,-0.5f
};
GLfloat l_VANormals[] =
{
0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f,
0.0f, 0.0f,-1.0f,
0.0f, 0.0f,-1.0f,
0.0f, 0.0f,-1.0f,
0.0f, 0.0f,-1.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f,-1.0f, 0.0f,
0.0f,-1.0f, 0.0f,
0.0f,-1.0f, 0.0f,
0.0f,-1.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
-1.0f, 0.0f, 0.0f,
-1.0f, 0.0f, 0.0f,
-1.0f, 0.0f, 0.0f,
-1.0f, 0.0f, 0.0f
};
GLuint l_VAIndici[] =
{
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15,
16, 17, 18, 19,
20, 21, 22, 23
};
// =============================================================================
static void ErrorCallback(int p_Error, const char* p_Description)
{
fputs(p_Description, stderr);
}
// =============================================================================
static void KeyCallback(GLFWwindow* p_Window, int p_Key, int p_Scancode, int p_Action, int p_Mods)
{
if (p_Action==GLFW_PRESS)
{
if (p_Key==GLFW_KEY_ESCAPE)
{
glfwSetWindowShouldClose(p_Window, GL_TRUE);
}
else
if (p_Key==GLFW_KEY_R)
{
ovrHmd_RecenterPose(g_Hmd);
}
ovrHSWDisplayState l_HasWarningState;
ovrHmd_GetHSWDisplayState(g_Hmd, &l_HasWarningState);
if (l_HasWarningState.Displayed) ovrHmd_DismissHSWDisplay(g_Hmd);
}
}
// =============================================================================
static void WindowSizeCallback(GLFWwindow* p_Window, int p_Width, int p_Height)
{
g_Cfg.OGL.Header.RTSize.w = p_Width;
g_Cfg.OGL.Header.RTSize.h = p_Height;
ovrHmd_ConfigureRendering(g_Hmd, &g_Cfg.Config, g_Hmd->DistortionCaps & ~ovrDistortionCap_FlipInput, g_Hmd->DefaultEyeFov, g_EyeRenderDesc);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
// ============================================================================
void RenderCubeVertexArrays(void)
{
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, l_VAPoints);
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, 0, l_VANormals);
glDrawElements(GL_QUADS, 6*4, GL_UNSIGNED_INT, l_VAIndici);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
}
// ============================================================================
void RenderCubeFixedFunction(void)
{
// Obsolete, remains as a fall back for the vertex arrays version...
glBegin(GL_QUADS);
glNormal3f( 0.0f, 0.0f, 1.0f);
glVertex3f( 0.5f, 0.5f, 0.5f);
glVertex3f(-0.5f, 0.5f, 0.5f);
glVertex3f(-0.5f,-0.5f, 0.5f);
glVertex3f( 0.5f,-0.5f, 0.5f);
glNormal3f( 0.0f, 0.0f,-1.0f);
glVertex3f(-0.5f,-0.5f,-0.5f);
glVertex3f(-0.5f, 0.5f,-0.5f);
glVertex3f( 0.5f, 0.5f,-0.5f);
glVertex3f( 0.5f,-0.5f,-0.5f);
glNormal3f( 0.0f, 1.0f, 0.0f);
glVertex3f( 0.5f, 0.5f, 0.5f);
glVertex3f( 0.5f, 0.5f,-0.5f);
glVertex3f(-0.5f, 0.5f,-0.5f);
glVertex3f(-0.5f, 0.5f, 0.5f);
glNormal3f( 0.0f,-1.0f, 0.0f);
glVertex3f(-0.5f,-0.5f,-0.5f);
glVertex3f( 0.5f,-0.5f,-0.5f);
glVertex3f( 0.5f,-0.5f, 0.5f);
glVertex3f(-0.5f,-0.5f, 0.5f);
glNormal3f( 1.0f, 0.0f, 0.0f);
glVertex3f( 0.5f, 0.5f, 0.5f);
glVertex3f( 0.5f,-0.5f, 0.5f);
glVertex3f( 0.5f,-0.5f,-0.5f);
glVertex3f( 0.5f, 0.5f,-0.5f);
glNormal3f(-1.0f, 0.0f, 0.0f);
glVertex3f(-0.5f,-0.5f,-0.5f);
glVertex3f(-0.5f,-0.5f, 0.5f);
glVertex3f(-0.5f, 0.5f, 0.5f);
glVertex3f(-0.5f, 0.5f,-0.5f);
glEnd();
}
// ============================================================================
static void SetOpenGLState(void)
{
// Some state...
glEnable(GL_CULL_FACE);
glEnable(GL_LIGHTING);
glDisable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (l_MultiSampling) glEnable(GL_MULTISAMPLE);
glClearColor(0.2f, 0.3f, 0.4f, 1.0f);
// Some (stationary) lights...
GLfloat l_Light0Position[] = { 5.0f, 6.0f, 3.0f, 0.0f };
GLfloat l_Light0Diffuse[] = { 1.0f, 0.8f, 0.6f, 1.0f };
glLightfv(GL_LIGHT0, GL_POSITION, l_Light0Position);
glLightfv(GL_LIGHT0, GL_DIFFUSE, l_Light0Diffuse);
glEnable(GL_LIGHT0);
GLfloat l_Light1Position[] = { -5.0f, -6.0f, 5.0f, 0.0f };
GLfloat l_Light1Diffuse[] = { 0.6f, 0.8f, 1.0f, 1.0f };
glLightfv(GL_LIGHT1, GL_POSITION, l_Light1Position);
glLightfv(GL_LIGHT1, GL_DIFFUSE, l_Light1Diffuse);
glEnable(GL_LIGHT1);
// Material...
GLfloat l_MaterialSpecular[] = { 0.3f, 0.3f, 0.3f, 1.0f };
GLfloat l_MaterialShininess[] = { 10.0f };
glMaterialfv(GL_FRONT, GL_SPECULAR, l_MaterialSpecular);
glMaterialfv(GL_FRONT, GL_SHININESS, l_MaterialShininess);
}
// =============================================================================
int main(void)
{
// Initialize LibOVR...
ovr_Initialize();
g_Hmd = ovrHmd_Create(0);
if (!g_Hmd) g_Hmd = ovrHmd_CreateDebug(ovrHmd_DK2);
uint32_t l_SupportedSensorCaps = ovrTrackingCap_Orientation | ovrTrackingCap_MagYawCorrection | ovrTrackingCap_Position;
uint32_t l_RequiredTrackingCaps = 0;
ovrHmd_ConfigureTracking(g_Hmd, l_SupportedSensorCaps, l_RequiredTrackingCaps);
GLFWwindow* l_Window;
glfwSetErrorCallback(ErrorCallback);
if (!glfwInit()) exit(EXIT_FAILURE);
if (l_MultiSampling) glfwWindowHint(GLFW_SAMPLES, 4); else glfwWindowHint(GLFW_SAMPLES, 0);
// Get the proper monitor, when either in "Extended" or "Direct" mode...
GLFWmonitor* l_Monitor;
if (g_Hmd->HmdCaps & ovrHmdCap_ExtendDesktop)
{
printf("Running in \"Extended Desktop\" mode...\n");
int l_Count;
GLFWmonitor** l_Monitors = glfwGetMonitors(&l_Count);
switch (l_Count)
{
case 0:
printf("No monitors found, exiting.\n");
exit(EXIT_FAILURE);
break;
case 1:
printf("Two monitors expected, found only one, using primary...\n");
l_Monitor = glfwGetPrimaryMonitor();
break;
case 2:
printf("Two monitors found, using second monitor\n");
l_Monitor = l_Monitors[1];
break;
default:
printf("More than two monitors found, using second monitor\n");
l_Monitor = l_Monitors[1];
}
}
else
{
printf("Running in \"Direct\" mode, this might cause problems with OculusSDK 0.4.2 (beta)...\n");
l_Monitor = glfwGetPrimaryMonitor();
}
ovrSizei l_ClientSize;
if (l_FullScreen)
{
l_ClientSize.w = g_Hmd->Resolution.w; // 1920 for DK2...
l_ClientSize.h = g_Hmd->Resolution.h; // 1080 for DK2...
// Create a fullscreen window with the Oculus Rift resolution...
l_Window = glfwCreateWindow(l_ClientSize.w, l_ClientSize.h, "GLFW Oculus Rift Test", l_Monitor, NULL);
}
else
{
l_ClientSize.w = 640;
l_ClientSize.h = 480;
l_Window = glfwCreateWindow(l_ClientSize.w, l_ClientSize.h, "GLFW Oculus Rift Test", l_Monitor, NULL);
}
// Check if window creation was succesfull...
if (!l_Window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
// Make the context current for this window...
glfwMakeContextCurrent(l_Window);
// @TODO When OpenGL "Direct" mode will be supported attach the window...
if (g_Hmd->HmdCaps & ovrHmdCap_ExtendDesktop)
{
// ...
}
else
{
#if defined(_WIN32)
ovrHmd_AttachToWindow(g_Hmd, glfwGetWin32Window(l_Window), NULL, NULL);
#endif
}
// Don't forget to initialize Glew, turn glewExperimental on to avoid problem fetching function pointers...
glewExperimental = GL_TRUE;
GLenum l_Result = glewInit();
if (l_Result!=GLEW_OK)
{
printf("glewInit() error.\n");
exit(EXIT_FAILURE);
}
// Print some info about the OpenGL context...
int l_Major = glfwGetWindowAttrib(l_Window, GLFW_CONTEXT_VERSION_MAJOR);
int l_Minor = glfwGetWindowAttrib(l_Window, GLFW_CONTEXT_VERSION_MINOR);
int l_Profile = glfwGetWindowAttrib(l_Window, GLFW_OPENGL_PROFILE);
printf("OpenGL: %d.%d ", l_Major, l_Minor);
if (l_Major>=3) // Profiles introduced in OpenGL 3.0...
{
if (l_Profile==GLFW_OPENGL_COMPAT_PROFILE) printf("GLFW_OPENGL_COMPAT_PROFILE\n"); else printf("GLFW_OPENGL_CORE_PROFILE\n");
}
printf("Vendor: %s\n", (char*)glGetString(GL_VENDOR));
printf("Renderer: %s\n", (char*)glGetString(GL_RENDERER));
// Create some lights, materials, etc...
SetOpenGLState();
// We will do some offscreen rendering, setup FBO...
ovrSizei l_TextureSizeLeft = ovrHmd_GetFovTextureSize(g_Hmd, ovrEye_Left, g_Hmd->DefaultEyeFov[0], 1.0f);
ovrSizei l_TextureSizeRight = ovrHmd_GetFovTextureSize(g_Hmd, ovrEye_Right, g_Hmd->DefaultEyeFov[1], 1.0f);
ovrSizei l_TextureSize;
l_TextureSize.w = l_TextureSizeLeft.w + l_TextureSizeRight.w;
l_TextureSize.h = (l_TextureSizeLeft.h>l_TextureSizeRight.h ? l_TextureSizeLeft.h : l_TextureSizeRight.h);
// Create FBO...
GLuint l_FBOId;
glGenFramebuffers(1, &l_FBOId);
glBindFramebuffer(GL_FRAMEBUFFER, l_FBOId);
// The texture we're going to render to...
GLuint l_TextureId;
glGenTextures(1, &l_TextureId);
// "Bind" the newly created texture : all future texture functions will modify this texture...
glBindTexture(GL_TEXTURE_2D, l_TextureId);
// Give an empty image to OpenGL (the last "0")
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, l_TextureSize.w, l_TextureSize.h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
// Linear filtering...
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
// Create Depth Buffer...
GLuint l_DepthBufferId;
glGenRenderbuffers(1, &l_DepthBufferId);
glBindRenderbuffer(GL_RENDERBUFFER, l_DepthBufferId);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, l_TextureSize.w, l_TextureSize.h);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, l_DepthBufferId);
// Set the texture as our colour attachment #0...
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, l_TextureId, 0);
// Set the list of draw buffers...
GLenum l_GLDrawBuffers[1] = { GL_COLOR_ATTACHMENT0 };
glDrawBuffers(1, l_GLDrawBuffers); // "1" is the size of DrawBuffers
// Check if everything is OK...
GLenum l_Check = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
if (l_Check!=GL_FRAMEBUFFER_COMPLETE)
{
printf("There is a problem with the FBO.\n");
exit(EXIT_FAILURE);
}
// Unbind...
glBindRenderbuffer(GL_RENDERBUFFER, 0);
glBindTexture(GL_TEXTURE_2D, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
// Oculus Rift eye configurations...
g_Cfg.OGL.Header.API = ovrRenderAPI_OpenGL;
g_Cfg.OGL.Header.RTSize.w = l_ClientSize.w;
g_Cfg.OGL.Header.RTSize.h = l_ClientSize.h;
g_Cfg.OGL.Header.Multisample = (l_MultiSampling ? 1 : 0);
#if defined(_WIN32)
g_Cfg.OGL.Window = glfwGetWin32Window(l_Window);
g_Cfg.OGL.DC = GetDC(g_Cfg.OGL.Window);
#elif defined(__linux__)
l_Cfg.OGL.Win = glfwGetX11Window(l_Window);
l_Cfg.OGL.Disp = glfwGetX11Display();
#endif
ovrHmd_ConfigureRendering(g_Hmd, &g_Cfg.Config, g_Hmd->DistortionCaps & ~ovrDistortionCap_FlipInput, g_Hmd->DefaultEyeFov, g_EyeRenderDesc);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
ovrTexture l_EyeTexture[2];
l_EyeTexture[0].Header.API = ovrRenderAPI_OpenGL;
l_EyeTexture[0].Header.TextureSize.w = l_TextureSize.w;
l_EyeTexture[0].Header.TextureSize.h = l_TextureSize.h;
l_EyeTexture[0].Header.RenderViewport.Pos.x = 0;
l_EyeTexture[0].Header.RenderViewport.Pos.y = 0;
l_EyeTexture[0].Header.RenderViewport.Size.w = l_TextureSize.w/2;
l_EyeTexture[0].Header.RenderViewport.Size.h = l_TextureSize.h;
((ovrGLTexture*)(&l_EyeTexture[0]))->OGL.TexId = l_TextureId;
// Right eye the same, except for the x-position in the texture...
l_EyeTexture[1] = l_EyeTexture[0];
l_EyeTexture[1].Header.RenderViewport.Pos.x = (l_TextureSize.w+1)/2;
glfwSetKeyCallback(l_Window, KeyCallback);
glfwSetWindowSizeCallback(l_Window, WindowSizeCallback);
GLfloat l_SpinX;
GLfloat l_SpinY;
// Do a single recenter to calibrate orientation to current state of the Rift...
ovrHmd_RecenterPose(g_Hmd);
// Main loop...
while (!glfwWindowShouldClose(l_Window))
{
if (l_Spin)
{
l_SpinX = (GLfloat) fmod(glfwGetTime()*17.0, 360.0);
l_SpinY = (GLfloat) fmod(glfwGetTime()*23.0, 360.0);
}
else
{
l_SpinX = 30.0f;
l_SpinY = 40.0f;
}
ovrFrameTiming l_HmdFrameTiming = ovrHmd_BeginFrame(g_Hmd, 0);
// Bind the FBO...
glBindFramebuffer(GL_FRAMEBUFFER, l_FBOId);
// Clear...
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
ovrPosef l_HeadPose[2];
for (int l_EyeIndex=0; l_EyeIndex<ovrEye_Count; l_EyeIndex++)
{
ovrEyeType l_Eye = g_Hmd->EyeRenderOrder[l_EyeIndex];
l_HeadPose[l_Eye] = ovrHmd_GetEyePose(g_Hmd, l_Eye);
glViewport(
l_EyeTexture[l_Eye].Header.RenderViewport.Pos.x,
l_EyeTexture[l_Eye].Header.RenderViewport.Pos.y,
l_EyeTexture[l_Eye].Header.RenderViewport.Size.w,
l_EyeTexture[l_Eye].Header.RenderViewport.Size.h
);
// Get Projection and ModelView matrici from the device...
OVR::Matrix4f l_ProjectionMatrix = ovrMatrix4f_Projection(g_EyeRenderDesc[l_Eye].Fov, 0.3f, 100.0f, true);
OVR::Quatf l_Orientation = OVR::Quatf(l_HeadPose[l_Eye].Orientation);
OVR::Matrix4f l_ModelViewMatrix = OVR::Matrix4f(l_Orientation.Inverted());
// Pass matrici on to OpenGL...
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMultMatrixf(&(l_ProjectionMatrix.Transposed().M[0][0]));
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// Translate for specific eye based on IPD...
glTranslatef(g_EyeRenderDesc[l_Eye].ViewAdjust.x,
g_EyeRenderDesc[l_Eye].ViewAdjust.y,
g_EyeRenderDesc[l_Eye].ViewAdjust.z);
// Multiply with orientation retrieved from sensor...
glMultMatrixf(&(l_ModelViewMatrix.Transposed().M[0][0]));
// Move back a bit to show scene in front of us...
glTranslatef(0.0f, 0.0f, -2.0f);
// Make the cube spin...
glRotatef(l_SpinX, 1.0f, 0.0f, 0.0f);
glRotatef(l_SpinY, 0.0f, 1.0f, 0.0f);
// Render...
// RenderCubeFixedFunction();
RenderCubeVertexArrays();
}
ovrHmd_EndFrame(g_Hmd, l_HeadPose, l_EyeTexture);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glfwPollEvents();
}
glfwDestroyWindow(l_Window);
glfwTerminate();
ovrHmd_Destroy(g_Hmd);
ovr_Shutdown();
exit(EXIT_SUCCESS);
}
Thanks,
Daniel Dekkers
8 Replies
- DiConHonored GuestCould be the OpenGL Profile incompatibility mentioned in another thread. (Sorry, just a quick guess - don't have the time to look closely right now).
LibOVR breaks with some core profiles and OpenGL versions as deprecated function trigger a warning, which are not treated correctly - Try to tell GLFW to explicitly use a compat profile (I had success with OpenGL 3.3 and compat). - gplourdeHonored GuestIs this using direct to rift? I think that the error you get when doing that. Use extended mode.
- nuclearExplorerHere is my very simple OpenGL test program: http://nuclear.mutantstargoat.com/hg/oculus2 (mercurial repo).
Uses SDL2 and GLEW, and extremely simple traditional fixed function OpenGL. - DoZo1971ExplorerHi,
Thanks for the tips. Yes, I am trying to use "direct mode" but looking at nuclears code this doesn't seem to work?
/* to sucessfully draw to the HMD display in "direct-hmd" mode, we have to
* call ovrHmd_AttachToWindow
* XXX: this doesn't work properly yet due to bugs in the oculus 0.4.1 sdk/driver
*/
This is officially broken?
The examples work because they are DirectX based?
Annoying. If I turn on extended mode my desktop (dimensions/orientation) looks like garbage. The desktop becomes narrow (black bars on the sides) and the Rift shows that same image but rotated 90 degrees.
But ok, i'll see if I can fix that first.
Thanks,
Daniel - japes98Honored GuestOn the Mac, this mostly works for me.
I was initially getting a segfault on glfwInit(), but this turned out to be related to a bug in glfw-3.0.4 related to rotated screens like the DK2 in OSX (https://github.com/glfw/glfw/issues/221). Updating src/cocoa_monitor.m to the latest version allows this to run on the OR (extended mode for me).
One thing that appears odd is that while the position of the cube tracks correctly with yaw, it seems to "follow" the orientation with respect to pitch (i.e., I'm expecting the cube to be rotating in a stationary position, but it isn't stationary). - gplourdeHonored GuestNot sure what is the "Official word" but yes its broken. If you for exemple change the World sample to GL is will also crash. I believe on OSX you also run in extended and not direct. All the sample are directX on windows.
Sure hope they fix this ASAP. - malcolmbHonored GuestI don't get a crash when I try to use Direct to HMD with OpenGL, but nothing shows up on the HMD displays either. Any official word on this?
- DoZo1971ExplorerHi,
Updated to 0.4.2 beta. Now works on my systems on Windows and OSX in "extended" mode. GLFW correctly gives two monitors so you can just use the second monitor, which would be the Rift, to create your window in. I'll try next to see if I can get "direct" mode working, at least on Windows.One thing that appears odd is that while the position of the cube tracks correctly with yaw, it seems to "follow" the orientation with respect to pitch (i.e., I'm expecting the cube to be rotating in a stationary position, but it isn't stationary).
Yes, there is a "ovrDistortionCap_FlipInput"-flag that you can set with ovrHmd_ConfigureRendering() that I use now. But once they make up their mind it is probably better to modify your matrix calculations instead of using the flip.Strange thing that came up is that I have to translate the world over different axes (X-axis on Windows, Z-axis on OSX) to get the scene appear in front of me. But maybe that is because of how the rift calibrates the initial orientation. I thought that it just took the orientation during startup as "zero" but maybe that has changed (real north?). This would then be broke or at least different on Windows/OSX.
EDIT Nonsense, just ovrHmd_Recenter() as the start.
Still have to look at positional tracking, multisampling, ...
Thanks,
Daniel
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 9 months ago
- 11 years ago