• Advertisement

Archived

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

Problem using GLUT

This topic is 5271 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

  
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
Advertisement
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
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

  • Advertisement