Jump to content
  • Advertisement

Archived

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

Shadow1234567890

Window shows up, drawing not completed?

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

For some reason anything I try to draw won't show up. Is there something wrong with the following code?
		while(!done) {
			if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
				if(msg.message == WM_QUIT)
					done = true;
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
			else {
				glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
				glLoadIdentity();
				glColor3f(0.0f, 1.0f, 0.0f);
				glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
				glBegin(GL_LINES);
					glVertex3f(0.0f, 0.0f, -1.0f);
					glVertex3f(1.0f, 1.0f, -1.0f);
				glEnd();

				SwapBuffers(hDc);

			}
		}
		return 0;
}
  
The window shows up as white instead of red. I think for some reason the else claus isn't being executed. I am not sure why that is. I am trying not to use global variables, so I created a device context in winmain, and it is warning me that it has been used without being initialized. How are you supposed to correctly initialize a device context? Is it like: HDC hDc = GetDC(hwnd); ? [edited by - Shadow1234567890 on August 13, 2002 10:54:27 AM]

Share this post


Link to post
Share on other sites
Advertisement
I''m not sure exactly what the problem is, maybe it''s because you''re not translating the line far enough into the screen. But glColor3f(0, 1, 0) should create a green line, not red. Right?

But do you think it''s logical to draw the screen only if there''s NOT a message? You shouldn''t hinder drawing to the screen in any way. In other words, the drawing code shouldn''t be in an else.

By your code, it seems I would stall the program just by moving the mouse around on the window, the continuous messages would mean the drawing code never runs.

http://roninmagus.hopto.org
acronymfinder.com - Find any acronym you need!

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!