Problem displaying rendered texture on window in second display, second graphics card


On a machine with two display outputs, I am trying to create a window that appears on the second
display and render some OpenGL texture on the window.
For the purpose of explaining my problem, I created the window such that left half of the window
appeared on the first display and the right half appeared on the second display with this code :

// Note : this CreateWindowEX is taken from NeHe tutorial 1
hwnd=CreateWindowEx( dwExStyle, // Extended Style For The Window
“OpenGL”, // Class Name
title, // Window Title
dwStyle | // Defined Window Style
WS_CLIPSIBLINGS | // Required Window Style
WS_CLIPCHILDREN, // Required Window Style
WindowRect.right / 2, 0, // Window Position
WindowRect.right-WindowRect.left, // Calculate Window Width, // Calculate Window Height
NULL, // No Parent Window
NULL, // No Menu
hInstance, // Instance
NULL))) // Dont Pass Anything To WM_CREATE

HDC hdc = GetDC(hwnd);
GLuint PixelFormat = ChoosePixelFormat(hdc,&pfd);
HGLRC hrc = wglCreateContext(hdc);

for(;; )

When I used only 1 graphics card with 2 display outputs, I could see the left half of the rendered texture on the first display
and the other half on the second display. In this case, it worked fine.

However, when I used 2 graphics card (1 output from 1 card), I could see the left half of the rendered texture on the first display,
but nothing other than the window borders on the second display.
Seeing the window borders on the second display, I am pretty convinced that the HDC spans across the 2 displays.
The problem is most likely the OpenGL rendering context, HGLRC.
I am beginning to think that when I did all the OpenGL rendering, the rendered texture data went only to the first graphics card
and not the second card, which explained this behavior.
Please correct me if you think I am wrong.

Ultimately I want to create the window and render only on the second display.
When I tried to create window only on the second display and do all the GetDC stuff,
I could see only window borders on the second display.

Can anybody please tell me how you would solve this problem ?
I have tried CreateDC with \.\DISPLAY2 as device name.
Successfully created HDC and HGLRC but wglMakeCurrent(hDC,hRC) returned error.

Thank you,

You should not expect the DC/RC to be the same across different cards. Especially if they are of different brands, Windows only provide GL acceleration for the primary card. What is your hardware setup ?

To use an analogy, run a video player using overlay, and move it from one screen to the other. You will see the video disapearing when crossing the ‘barrier’.
Try running it directly from screen 2 also.

I have an nVidia GeForce MX200 with 32 MB VRAM and an nVidia Quadro FX3000G with 256 MB VRAM.
The MX200 is the current primary display (for BIOS and also Windows).
The Quadro is the secondary display.
All this time I have been trying to display the window and OpenGL rendered texture on the Quadro output.

The two cards are not hardware compatible. So, if your window is half way it will not render to the secondary card.

dimensionX, thanks for the clarification.

Unfortunately, even if my window is completely on the second display (on second card), still it does not render the texture to the window.

Ultimately, I only want my window to be completely on the second display (on the second card).
I have a feeling that all my OpenGL calls go to the first card only. I want to make my calls only to the second card, not the first card.
Can anybody please show me how to do that ?

Can anybody please show me how to do that ?
No. There is no mechanism to choose which graphics card you get when you ask for a GL context. It simply gives you the “primary” graphics card.

The only info from Nvidia I found on the subject is for linux systems, I guess their win32 drivers do the same :

There is a notion of “hardware compatible” GPUs as said dimensionX. It would be great to have a compatibility matrix though … :smiley:

Thanks for all the replies.
I have decided to use 1 card to output 2 displays instead of using 2 cards.
Have spent too much time on this.


This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.