Jump to content
  • Advertisement
Sign in to follow this  

SDL Window Location

This topic is 4660 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

You can only do it in a platform specific way. Here's an example of how to do it on Windows:

#include <sdl_syswm.h>
void SetWindowPosition(int sX, int sY)
RECT sRect;
static SDL_SysWMinfo sInfo;
GetWindowRect(sInfo.window, &sRect);
MoveWindow(sInfo.window, sX, sY, sRect.right, sRect.top, true);

Also note how I get and use the actual window dimensions rather than use the known resolution of the main screen. Just something to keep in mind. You need that header file to be able to use most of that code, it automatically includes windows.h for you.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!