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


Window shows up, drawing not completed?

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;
			else {
				glColor3f(0.0f, 1.0f, 0.0f);
				glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
					glVertex3f(0.0f, 0.0f, -1.0f);
					glVertex3f(1.0f, 1.0f, -1.0f);


		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
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. - Find any acronym you need!

Share this post

Link to post
Share on other sites