Archived

This topic is now archived and is closed to further replies.

Promit

Problem using GLUT

Recommended Posts

  
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrev, LPSTR lpCmdLine, int nShowCmd )
{
	char** argv = NULL;
	int argc = 0;

	//Parse the command line

	CommandLineToArgvW( (LPCWSTR)lpCmdLine, &argc );

	//Initialize GLUT and create a GLUT window

	glutInit( &argc, argv );
}
  
The program melts at the last line, the glutInit one. It causes an access violation, and i have no clue why. I dont think any params are actually being passed in th command line.

Share this post


Link to post
Share on other sites
Not TOO sure right now, but i''d say you''re using Wide character function (2 bytes per char) to convert the cmd line
this function will only work on windows XP and after and relies on unicode but you get passed an ASCII string which uses one byte per char as lpCmdLine.
i suggest you write your own tokenizer for the command line. Or you could convert the string to unicode by making every other byte 0. simply casting to LPCWSTR is what causes wrong parcing.
Trace it, you''ll see what I mean.

-Alexey.

Share this post


Link to post
Share on other sites
He''s probably right about the crash.

My question is, why are you using WinMain for a GLUT appication? It''s really intended to be used in a console application, since one of its strengths is in allowing you to write cross-platform code.

Share this post


Link to post
Share on other sites
Well i changed to a console project, and it works, with one catch. There''s a console window in the background which I dont want. Thats what I was trying to avoid in the first place. FreeConsole() didn''t do anything. How do I get rid of the console?

Share this post


Link to post
Share on other sites