C++ Win32 && OpenGL 3.3 Not Updating FrameBuffer and or Device Context?

Started by
11 comments, last by tom_mai78101 10 years, 2 months ago
Could someone tell me why the backbuffer or frontbuffer will not update the device context I've been stuck on this problem for 3days and It's driving me crazy!?
- Win7 64bit
- OpenGL 3.311672 Compatibility Profile Context
- Microsoft Visual Studio 2012 C++
The Pixel format is being assigned properly.
I've created the projections correctly,set the opengl clear color,swapped the buffers on the devicecontext in the "correct place".
What more does it want???......

Advertisement

In your DRAW_OPENGL routine, your glTranslatef call is a bug. The first frame you'll translate by {3, 0, 0}, the second frame by {6, 0, 0}, the third frame by {9, 0, 0}, and so on. This is because you don't load identity on your modelview matrix at the start of each frame, so each frame's translation is going to be in addition to the total translations for all previous frames.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

I was aware of the glTranslatef(); being on a constant loop , I was more concerned about the actual device context not updating unless your implicating that glTranslatef(); is the reason for the lack of data rasterized on the device context? .

Upon testing my theory with glTranslatef(); causing the lack of device context updating is false so you must have been implicating one of the already known bugs in my code I thank you for telling me atleast.

Try handling the WM_PAINT message, re-enable both the BeginPaint and EndPaint calls, even if you don't use the hDC

Your triangle is also really small compared to your projection matrix.

Derp

Try:


hdc = GetDC( WindowHandle );

 
while( Running == true )
{
	while( PeekMessage( &Messages, NULL, 0, 0, PM_REMOVE ) )
	{
		TranslateMessage( &Messages );
		DispatchMessage( &Messages );
	}

	if( Messages.message == WM_QUIT )
	{
		Running = false;
	}
	else
	{
		DRAW_OPENGL();
		SwapBuffers( hdc );
	}
}

Your hdc was invalid, glClearColor requires floats in the range 0.0-1.0, and note PM_REMOVE in PeekMessage, and the removal of GetMessage.

Edit - I totally give up with the code formatting!!!

NEWS IN!

I just got the clear screen color to show so at least that portion of the code works to fix it I just put the SwapBuffer and DRAW_OPENGL function within the begin paint and end paint function and it worked.

The question now becomes how do I see the triangle hmmm...

If you do that you will have no frame rate. You had it right the first time except:

-You must handle WM_PAINT even if you dont actually do anything other than GetDC/ReelaseDC

-You have two LOCAL hdc variables and you assign the hdc is your window proc function so the copy in your Main function is still null when you try to SwapBuffers with it. Declare the hdc as a global (at the top) (this is considered bad practice but for now it will give a quick result.) Then remove the local declarations to it.

-Also I could not get your message pump to work so I replaced it with one along the lines as the FM above did. Using that one should be just fine.

My bad created a bug whilst fiddling with your code, your pump seems to work ok

Thank you empirical2!

So now my context is created , my projection is fine "for now" and I've drawn the vertex positions then why hasn't the rasterization occurred

I see no triangle even with glTranslate3f(); commented out....???? also I'm able to make it so I can see GDI textout function which is funny lol.

eTLw1fk.png

Your triangle is tiny and off screen.

In orthro mode the coods are pixel coords.

Use glLoadIdentity() at the start of draw.

Use a big glTranslate (like 10,10,0)

and you should see a dot.

Alsoif you can use TextOut then its becuase your screen is not being redrawn by OGL on a continuous bases because you have your swapbuffers function in your WM_PAINT case still?

This topic is closed to new replies.

Advertisement