I need to render opengl output to a 2nd monitor. I need control over the width and height of the monitor can’t rely on duplicating my primary display. I’ve read that the way to do this is to render to a frame buffer and then I guess send that out to the 2nd monitor. Can anyone direct me to some simple code to do this? Right now, I’m creating a window and linking that to a device context using code as follows:
hWnd = CreateWindowEx( WS_EX_APPWINDOW,
WNDCLASSNAME,
TEXT("title"),
WS_POPUP |
WS_CLIPSIBLINGS |
WS_CLIPCHILDREN,
WINPOS_DELTA_X,
WINPOS_DELTA_Y,
WINDOW_WIDTH,
WINDOW_HEIGHT,
NULL,
NULL,
hInstance,
NULL);
HDC hDC = GetDC(hWnd);
And then render to this device context directly with commands like this (to create a simple triangle)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glVertex3f(-1.0f, -0.5f, 1.0f);
glVertex3f(1.0f, -0.5f, 1.0f);
glVertex3f(0.0f, 0.5f, 1.0f);
glEnd();
SwapBuffers(hDC);
This renders fine to my primary screen - but if I locate the window onto my secondary display it fails. I think the way to accomplish what I’m trying to do is to set up a framebuffer and render to that. I think I know how to get that part working. But how do I then take the frame buffer and tell OpenGL to display the framebuffer to my (off-primary-screen) display?