Problem using GLUT

Started by
4 comments, last by Promit 20 years, 8 months ago
  
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.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
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.
-------------------------- - Alexey. (IGD = Independent Game Developer)
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.
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?
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
See this. Google is your friend.

Use this one...

void main()
{
glutInit(int argc,char *argv[]);
----------------
----------------
}

This topic is closed to new replies.

Advertisement