[SDL] Window Centering?

William Petiot william at exoide.com
Sat Jan 1 15:51:32 PST 2005

Under windows, with vc standard library, putenv() and getenv() should work
try #include <stdlib.h>. They work for the CURRENT process only. And only if 
one uses consistently putenv() getenv() (ie: doesn't try to query 
environment without using getenv() )

- Quoted from msdn : 

"That is, these functions operate only on data structures accessible to the 
run-time library and not on the environment "segment" created for a process 
by the operating system". 

If they are unresolved, try using _putenv() _getenv(), but this should not 
be necessary.

The important thing is to have this putenv("SDL_WINDOWsomething"..) done 
BEFORE SDL needs it.

btw, If someone wanted to know : 

There are 2 functions in win32 api to set or query an environment variable 
for the *current* process, provided by the win32 kernel :

DWORD GetEnvironmentVariable( 
	LPCTSTR lpName,  
	LPTSTR lpBuffer,  
	DWORD nSize);

BOOL SetEnvironmentVariable(
	LPCTSTR lpName,
	LPCTSTR lpValue);

Le samedi 1 Janvier 2005 21:59, David Olsen a écrit :
> > How is one supposed to use SDL_VIDEO_CENETERED in Win32?
> > I have seen examplesof it using things like putenv and setenv.
> > But i get "unresolved external" no matter which of these 2 i use.
>  I don't think that there is an "internal" way yet(specifying it within
> your SDL program, I mean) for Win32. Please someone correct me if I'm
> wrong. I do believe it will be coming up in a near release (SDL 1.3,
> perhaps?). The only way I could get it to work was to set an environment
> variable in the windows system itself. If you're on XP, right-click My
> Computer->properties. Clicked "Adavanced" tab. At bottom is button -
> "Evironment variables". click it- then click new(either under "user" or
> "system", I don't think it matters, mine's under "user"), then give
> variable name SDL_VIDEO_CENTERED and value of 1. That'll do. I don't know
> if you need to reboot at this point, but knowing windows like I do, you
> probably need to. Other than XP, or if I'm wrong on any point, someone
> else help!
> -Dave

More information about the SDL mailing list