954,535 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

SDL_Event and Visual Studio

Hello all,
My question is, when using Visual Studio, and compiling this piece of code:

int main(int argc, char *argv[])
{
	SDL_Init(SDL_INIT_EVERYTHING);
	SDL_SetVideoMode(640, 480, 32, SDL_OPENGL);
	SDL_WM_SetCaption("OpenGL Awesomeness", NULL);

        //run time error here
	SDL_Event event;

	while(event.type != SDL_QUIT)
	{
		SDL_PollEvent(&event);
		RenderScene();
		SetupRC();
		SDL_GL_SwapBuffers();
		SDL_Delay(60);
	}
	SDL_Quit();
	return 0;
}


I get a runtime error saying that I'm using a variable that is being used and not initialized. I know that SDL_Events cannot be initialized, and am wondering how to fix this problem. I have before, but the soultion has currently escaped me. Thank you for your help in advance,

~Asian

epicasian
Junior Poster in Training
53 posts since Nov 2009
Reputation Points: 12
Solved Threads: 0
 

Try using a do...while statement. The PollEvent function is more than likely initializing the event object, so when you try to use the event object before it's been assigned anything.

Sodabread
Posting Whiz in Training
290 posts since Nov 2009
Reputation Points: 103
Solved Threads: 42
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: