Jump to content
  • Advertisement


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


Problem using GLUT

This topic is 5446 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
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.


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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!