Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 xXxRosexXxEE   Members   -  Reputation: 112

Like
0Likes
Like

Posted 08 February 2014 - 01:08 PM

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???...... 
 

 


Edited by xXxRosexXxEE, 08 February 2014 - 01:13 PM.


Sponsor:

#2 mhagain   Crossbones+   -  Reputation: 8134

Like
2Likes
Like

Posted 08 February 2014 - 01:19 PM

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.


It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#3 xXxRosexXxEE   Members   -  Reputation: 112

Like
0Likes
Like

Posted 08 February 2014 - 01:21 PM

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.


Edited by xXxRosexXxEE, 08 February 2014 - 01:23 PM.


#4 empirical2   Members   -  Reputation: 567

Like
1Likes
Like

Posted 08 February 2014 - 01:26 PM

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



#5 Sponji   Members   -  Reputation: 1308

Like
1Likes
Like

Posted 08 February 2014 - 01:30 PM

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


Derp

#6 mark ds   Members   -  Reputation: 1384

Like
1Likes
Like

Posted 08 February 2014 - 01:32 PM

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!!!


Edited by mark ds, 08 February 2014 - 01:47 PM.


#7 xXxRosexXxEE   Members   -  Reputation: 112

Like
0Likes
Like

Posted 08 February 2014 - 01:50 PM

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...



#8 empirical2   Members   -  Reputation: 567

Like
1Likes
Like

Posted 08 February 2014 - 02:03 PM

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


Edited by empirical2, 08 February 2014 - 02:06 PM.


#9 xXxRosexXxEE   Members   -  Reputation: 112

Like
0Likes
Like

Posted 08 February 2014 - 02:15 PM

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


Edited by xXxRosexXxEE, 08 February 2014 - 02:17 PM.


#10 empirical2   Members   -  Reputation: 567

Like
2Likes
Like

Posted 08 February 2014 - 02:28 PM

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?



#11 xXxRosexXxEE   Members   -  Reputation: 112

Like
0Likes
Like

Posted 08 February 2014 - 02:43 PM

Yes!!!! Who ever says getting a singular image onto the framebuffer is easy suck on it <3

 

4ZWszv8.png

 

Thank you so much I need to learn more of the mathematics behind projections do you have any good sources?


Edited by xXxRosexXxEE, 08 February 2014 - 02:44 PM.


#12 mark ds   Members   -  Reputation: 1384

Like
2Likes
Like

Posted 08 February 2014 - 02:58 PM

If this if any consolation...

 

John Carmack on twitter "Beginning gfx programmers take heart--even an expert can sometimes spend two hours trying to figure out WTF no triangles are being drawn."

 

This is a pretty good resource for modern Open GL - http://www.arcsynthesis.org/gltut/index.html, as is this - http://antongerdelan.net/opengl/


Edited by mark ds, 08 February 2014 - 02:59 PM.


#13 tom_mai78101   Members   -  Reputation: 575

Like
0Likes
Like

Posted 13 February 2014 - 06:37 AM

Unrelated, but your title is misleading. I don't see any OpenGL 3.3 in your code.

 

It's actually OpenGL 1.1.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS