Howdy,
All example code I’ve seen so far, and all of the SDL Xcode templates seem to create a window 640 x 480 centered, but I’d like it to be 640 x 480 upper left corner. SDL_SetVideoMode() only has size (height and width) parameters, and no position parameters.
Is there a way to get the initial window positioned in the upper left hand corner?
Adios,
Cactus Dan
Howdy,
OK, found the answer:
Code:
putenv(strdup(“SDL_VIDEO_WINDOW_POS=0,0”));
… and to switch back to centered:
Code:
putenv(strdup(“SDL_VIDEO_WINDOW_POS=center”));
Adios,
Cactus Dan
Code:
putenv(strdup(“SDL_VIDEO_WINDOW_POS=0,0”));
… and to switch back to centered:
Code:
putenv(strdup(“SDL_VIDEO_WINDOW_POS=center”));
Why are you leaking a string? There is no need of strdup() it.
Also, putenv() is not portable, if you want to work on all platforms it’s
better to use the SDL version of putenv:
SDL_putenv(“SDL_VIDEO_WINDOW_POS=center”);–
Bye,
Gabry
Howdy,
Gabriele Greco wrote:
Why are you leaking a string? There is no need of strdup() it.
Also, putenv() is not portable, if you want to work on all platforms it’s better to use the SDL version of putenv:
SDL_putenv(“SDL_VIDEO_WINDOW_POS=center”);
–
Bye, ?Gabry
Well, to be honest, I really don’t know because I’m just grasping at straws. I was simply following another example I found here on the forum. [Embarassed]
When I use your example I get this warning in Xcode:
warning: deprecated conversion from string constant to ‘char*’
I can get rid of that warning by adding this:
Code:
SDL_putenv(const_cast<char*>(“SDL_VIDEO_WINDOW_POS=0,0”));
Is that the correct way to handle it?
Adios,
Cactus Dan
SDL_putenv(const_cast(“SDL_VIDEO_WINDOW_POS=0,0”));
Is that the correct way to handle it?
What version of SDL are you using?
Recent versions of SDL, on both 1.2 and 1.3 branches, declare the argument
of SDL_putenv constant:
SDL 1.2 packaged with ubuntu:
/usr/include/SDL/SDL_stdinc.h:extern DECLSPEC int SDLCALL SDL_putenv(const
char *variable);
SDL 1.3 hg/head:
/home/gabry/no-backup/SDL/include/SDL_compat.h:extern DECLSPEC int SDLCALL
SDL_putenv(const char *variable);
I suggest you to use at least SDL 1.2.14 if you want to use the stable
branch!
Anyway for the version of SDL you are using the “const_cast” is probably the
correct workaround.On Wed, May 18, 2011 at 5:20 PM, Cactus Dan wrote:
–
Bye,
Gabry