4
\$\begingroup\$

I have an LCD monitor display and Oculus Rift attached to my PC. I have an Nvidia 820M dedicated GPU. How does the GPU know to which display device it has to render (or to send rendered information)? Are there any OpenGL/DirectX calls to bind display with the GPU?

\$\endgroup\$
0
7
\$\begingroup\$

The GPU doesn't, the programmer does.

The initialization of the graphics API will typically involve optional specification of which display device to use; not explicitly specifying this generally results in the default of whatever the OS thinks the "primary monitor" is.

OpenGL and D3D handle this decision differently. D3D has the concept of "adapters" modeled in to its API, and you can query the available number and figure out the the properties of each and then automatically decide or present a choice to the user.

OpenGL doesn't actually concern itself with formally specifying the creation of its context object for every OS; the OS itself handles that. You generally need to use the OS-level display-enumeration features (EnumDisplayDevices or NSScreen on OS X) to find the set of available displays and give them to the appropriate OS-level functions used to create the OpenGL context.

Usually this only matters if you're trying to use exclusive full-screen on a specific monitor, or render to a device that the system doesn't necessarily normally consider a "screen" (in that case getting the appropriate handle may involve the use of APIs specific to that hardware; this may be the case with the Rift, I'm not sure).

Generally if you're just doing windowed rendering, you don't need to worry about which monitor you are on.

\$\endgroup\$
5
  • \$\begingroup\$ For the Oculus Rift in particular the SDK just gives you a rectangle (position + size) with which you create a window in "desktop space". \$\endgroup\$ – jmegaffin May 28 '15 at 19:50
  • \$\begingroup\$ Thanks @Josh&Boreal. In my case I'm using GLFW 3.1 on windows 7 machine. Are you saying that to render into my default monitor I've to use windows API to get opengl context and to render into oculus rift I've to use Oculus SDK API to get opengl context. Am I right? correct me if not. \$\endgroup\$ – veerendra May 28 '15 at 20:48
  • \$\begingroup\$ and one more thing. while compiling my glfw c++ application, It is show ing "No windows API selected". what should I do to correct this? please let me know if you know.. \$\endgroup\$ – veerendra May 28 '15 at 20:59
  • \$\begingroup\$ No, the Oculus SDK will give you the position and size and all you have to do is create a GLFW (or Win32, or SDL, or whatever) window in that area. And GLFW will give you the OpenGL context either way automatically with the creation of your window. \$\endgroup\$ – jmegaffin May 29 '15 at 1:29
  • 1
    \$\begingroup\$ @Boreal that's only the case with 0.5.x of the Oculus API. With 0.6 the SDK completely handles creation of the Rift surface. Also, with 0.5, technically the SDK only gave you the position and the native resolution of the Rift. It was still up to the developer to query the platform API to determine what in which resolution the Rift was actually running. \$\endgroup\$ – Jherico May 29 '15 at 19:50
2
\$\begingroup\$

If you're running on a Windows platform with the latest version of the Oculus SDK (0.6) and you're trying to figure out how to create a window and a rendering context to target the Rift, then this question is kind of meaningless. As of 0.6 the SDK now completely handles creation of the onscreen window to target the Rift display, regardless of whether the Rift is running in extended or direct mode.

Your responsibility as a developer is just to create a new D3D or OpenGL rendering context for creating the content that will be sent to the SDK. You can either create an onscreen window or an offscreen surface for this, and it doesn't really matter where you put the window, so it's simplest just to let the underlying system use a default location. The only caveat is that if you're running in extended mode, you don't want the window you create to end up on the Rift display, but since there's no way (in 0.6) to determine whether you're running in extended mode or which display belongs to the Rift, that's not possible, so just target the primary monitor on the assumption that it's probably not the Rift display.

\$\endgroup\$
2
  • \$\begingroup\$ Thanks @jherico. I'm using oculus SDK 0.4 with oculus runtime 0.4. What has to be done for upgrading to 0.6. Is it possible to run oculus SDK 0.6 with runtime 0.4? Or do I have to upgrade runtime also? \$\endgroup\$ – veerendra May 30 '15 at 19:02
  • \$\begingroup\$ 0.6 changes the SDK so that it now manages window creation and destruction of the window and all the textures used for framebuffer targets. It reduces the number of calls you have to make at startup, as well as the number of calls on each frame. You do need to be running the 0.6 runtime to use it though. \$\endgroup\$ – Jherico May 31 '15 at 0:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.