I am using SDL 1.2 with FFmpeg on MAC. I am trying to build a video player using both FFmpeg and SDL. I am viewing my video on SDL_Surface. My player is working fine. Now my problem is, i want to move SDL window without dragging it from title bar. Is there any function/method in SDL 1.2 framework for moving SDL_Surface.
Asked
Active
Viewed 2,544 times
1
-
*i want to move SDL window*... with keyboard? Programatically? randomly? – Thomas Ayoub May 05 '15 at 08:31
-
programatically..do u have any idea..?? – Dev Sam May 05 '15 at 08:36
-
1when my sdl window pops up i want to make it centralized according to my desktop screen. do u have any idea..?? – Dev Sam May 05 '15 at 08:47
-
Show us your code :) – Thomas Ayoub May 05 '15 at 09:09
-
i am doing this: `SDL_BlitSurface(Bmpsrc,NULL,screen,&rect); SDL_Flip(screen);` where Bmpsrc and screen are SDL_Surfaces – Dev Sam May 05 '15 at 10:11
2 Answers
3
SDL 1.2 does not have an API for moving windows. SDL 2.0 has better support for multiple windows and window management in general.
See http://wiki.libsdl.org/SDL_SetWindowPosition
To do this with SDL 1.2, you'll need to use platform-specific calls using the window handle. You can get that with SDL_GetWMInfo()
.
If you just need to set the initial position of the window so it is centered, then try this before SDL_SetVideoMode()
:
SDL_putenv("SDL_VIDEO_WINDOW_POS=center");

Jonny D
- 2,244
- 15
- 22
0
The function you are looking for is:
void SDL_SetWindowPosition(SDL_Window* window,
int x,
int y)
Which set the position of the window for you.

Thomas Ayoub
- 29,063
- 15
- 95
- 142
-
1this function is defined in SDL 2.0 but i am using SDL 1.2. Is there any other way for SDL 1.2 ? – Dev Sam May 06 '15 at 06:31
-
@DevSam do you've got something like `SetWindowPos` to use it like so : `SetWindowPos(pInfo.window, 0, r.left, r.top, 0, 0, SWP_NOMOVE | SWP_NOSIZE);` – Thomas Ayoub May 06 '15 at 08:11