Skip to main content
Participant
September 18, 2014

Win32/GL ovrHmd_ConfigureRendering crash


#define SDK_RENDER 1

HDC dc;
HWND WndHandle;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
ovr_Initialize();
hmd = ovrHmd_Create(0);

//... creating window/context, it working itself

ovrGLConfig cfg;
cfg.OGL.Header.API = ovrRenderAPI_OpenGL;
cfg.OGL.Header.RTSize = OVR::Sizei(hmd->Resolution.w,hmd->Resolution.h);
cfg.OGL.Header.Multisample = 0;
cfg.OGL.Window = WndHandle;
cfg.OGL.DC = dc;

ovrFovPort eyeFov[2] = {hmd->DefaultEyeFov[0],hmd->DefaultEyeFov[1]};
ovrEyeRenderDesc EyeRenderDesc[2];
ovrHmd_ConfigureRendering(hmd,&cfg.Config,
ovrDistortionCap_Chromatic|ovrDistortionCap_TimeWarp|ovrDistortionCap_Overdrive,
eyeFov,EyeRenderDesc); //<--------- crash, stack fault, C000005 (access violation)
...
}

What am I doing wrong?
Can't find solution neither in 'oculus_developer_guide.pdf' nor in samples (they for D3D11 mostly).
ovrHmd_AttachToWindow(hmd,WndHandle,0,0) - not helping.

    14 replies

    Up and Coming
    September 21, 2014
    "Vic3Dexe" wrote:

    Thanks but I prefer to get it to work with raw code first (as low level as possible). Tried fasm :) but static libraries linking was harder than I expected...


    That's exactly what it is :) wglarb is not a framework like GLUT or GLFW. It's indended use is in programs making direct use of the Win32 GDI to initialize OpenGL. The purpose of the library is to cover all the hoop jumping you have to do, before you can use the wglCreateContextAttribs function, which you must use to obtain core profile contexts.
    Vic3DexeAuthor
    Participant
    September 22, 2014
    "nuclear" wrote:
    And what about ovr_Initialize?

    It's result is ok too (true/1).
    "nuclear" wrote:

    You missunderstood me. It's not up to you to give the function pointers to libovr. It's doing that itself. I was just pointing out that if this libovr initialization failed (which you're not checking, and have no idea if it did or not) and left their own internal opengl function pointers null, that might be what's causing the null pointer indirection and crash.

    I think that if ovr_Initialize() failed in some reason, calling ovrHmd_Create() would fail too.

    Rebuild libovr.a from another src - still crashing...

    Am I missing something? Can somebody create simple prog with working ovrHmd_ConfigureRendering call? It would be great if both src and exe will present. Don't need it to actually draw something, just call with no crash.
    If .exe will fail - something wrong with my machine, if compiled src will fail - something wrong with my lib/compiler/etc. If both will be ok - something wrong with DNA :)
    Up and Coming
    September 22, 2014
    "Vic3Dexe" wrote:
    "nuclear" wrote:
    And what about ovr_Initialize?

    It's result is ok too (true/1).


    OMFG, I just looked at the function in the SDKs sources. That thing always returns 1. WTF?!


    OVR_EXPORT ovrBool ovr_Initialize()
    {
    if (OVR::CAPI::GlobalState::pInstance)
    return 1;

    // We must set up the system for the plugin to work
    if (!OVR::System::IsInitialized())
    {
    OVR::System::Init(OVR::Log::ConfigureDefaultLog(OVR::LogMask_All));
    CAPI_SystemInitCalled = 1;
    }

    // Constructor detects devices
    GlobalState::pInstance = new GlobalState;
    return 1;
    }


    BTW: Booleans are terrible return values for error conditions. There's exactly one case for "everthing is allright, we completed everything sucessfully". But there a countless ways thing can fail. The numeric error code value for a function to report success should be 0. Nonzero is for errors. You can for example return the number of errorneous conditions you tripped over through initialization there.
    Vic3DexeAuthor
    Participant
    September 22, 2014
    "datenwolf" wrote:
    OMFG, I just looked at the function in the SDKs sources. That thing always returns 1. WTF?!

    Hmm... Have different code for ovr_Initialize()

    OVR_EXPORT ovrBool ovr_Initialize()
    {
    if (CAPI_ovrInitializeCalled)
    return 1;

    // We must set up the system for the plugin to work
    if (!OVR::System::IsInitialized())
    {
    OVR::System::Init(OVR::Log::ConfigureDefaultLog(OVR::LogMask_All));
    CAPI_SystemInitCalled = 1;
    }

    CAPI_pNetClient = NetClient::GetInstance();

    #ifdef OVR_SINGLE_PROCESS

    // If the server could not start running,
    if (Service::NetServer::GetInstance()->IsInitialized())
    {
    CAPI_pNetClient->Connect(true);
    }
    else
    {
    // This normally will happen if the OVRService is running in the background,
    // or another SingleProcess-mode app is running in the background.
    // In this case, it's using the hardware and we should not also attempt to use
    // the hardware.
    LogError("{ERR-079} [LibOVR] Server is already running");
    }
    #else
    CAPI_pNetClient->Connect(true);
    #endif

    CAPI_ovrInitializeCalled = 1;

    return 1;
    }

    And it can't fail too.
    SDK 0.4.2