Hello,
I've been working on some test OpenGL programs in C++ using SDL to manage sound, window management, events... etc
Today I plugged in my external monitor into my laptop and found that no openGL program I had written would work with it plugged in, all I get is the window frame with nothing it (you can see what window is behind it). It's quite an odd problem as it works fine just using my laptop screen, any suggestions?
Thanks in advance.

Dani AI

Generated

This often comes down to how the OS/driver maps displays and GPUs rather than a bug in SDL or your drawing code. As @ktsangob pointed toward, adding a second monitor can change which GPU or display pipeline actually drives the window. Below is a focused, practical checklist and a tiny test you can drop into your app to pinpoint the problem.

  • Reproduce with a known-good GL app (a simple SDL/GL sample or any GPU demo). If that fails too, it is almost certainly a driver/OS/display issue.
  • Log every return value: SDL_CreateWindow, SDL_GL_CreateContext, SDL_GL_MakeCurrent. Print SDL_GetError() if any fail.
  • Immediately after creating the context, print the GL strings (glGetString(GL_VENDOR), GL_RENDERER, GL_VERSION) so you can see which GPU/driver is being used. Different strings on laptop vs external monitor point to GPU routing/switching.
  • Try forcing “external-only” or mirrored display and rebooting the machine; also try a different port (HDMI vs VGA/DisplayPort) to rule out connector routing. (This is the practical follow-up to ’s hardware hint.)
  • If your app uses FBOs or multisampling, check FBO completeness and glGetError() after setup; some drivers expose different extensions per display.
  • Update GPU drivers and, if present, check vendor control panel or Windows Graphics settings to force the app onto the high-performance GPU.

A tiny test to print renderer and draw a clear (drop this into a minimal SDL+GL setup):

SDL_Window* w = SDL_CreateWindow("GLtest", 100,100,640,480, SDL_WINDOW_OPENGL);
SDL_GLContext ctx = SDL_GL_CreateContext(w);
printf("SDL_GL_CreateContext: %s\n", ctx ? "OK" : SDL_GetError());
SDL_GL_MakeCurrent(w, ctx);
printf("GL VENDOR: %s\nGL RENDERER: %s\nGL VERSION: %s\n",
       glGetString(GL_VENDOR), glGetString(GL_RENDERER), glGetString(GL_VERSION));
glClearColor(1,0,0,1); glClear(GL_COLOR_BUFFER_BIT); SDL_GL_SwapWindow(w);

If the renderer string switches when you plug the monitor in, focus on GPU/driver settings; if it stays the same but nothing draws, add glGetError() checks and test a minimal triangle or clear to isolate whether the context or your rendering code is at fault.

I have no idea of OpenGL but i think you should consider that adding an external monitor changes the hardware capabilities of your platform, thus changing the way that OpenGl "accesses" it.
Which might mean that either your OpenGl initialization is incorrect, or your hardware is not capable of handling the opengl settings you provide.
Of course that's what might happen in DirectX so this is just a shot in the dark...

Debug your application step by step and watch for any warnings when initalizing the opengl components.

Good luck!

p.s. If you plug your monitor and use "extended desktop mode" (you can see output on both monitors), try to change it to external monitor mode only, to see if that helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.