Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Problems getting OpenGL 3 context to work

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

Hi guys,


actually i try to get an OpenGL 3+ context to work. I ve downloaded the tutorials from swiftless and compiled them. Compilation worked fine but all i got to see is a white screen. I figured out, that it seems to be a problem with the creation of the new context:


The following Code is from swiftless. I didn't change anything, just deleted the comments in this post:


	int attributes[] = {

	if (wglewIsSupported("WGL_ARB_create_context") == 1) { 
		hrc = wglCreateContextAttribsARB(hdc, NULL, attributes); 
		wglMakeCurrent(NULL, NULL); 
		wglMakeCurrent(hdc, hrc); 
	else {
		hrc = tempOpenGLContext; 

	const GLubyte *glVersionString = glGetString(GL_VERSION); 
	int glVersion[2] = {-1, -1}; 
	glGetIntegerv(GL_MAJOR_VERSION, &glVersion[0]); 
	glGetIntegerv(GL_MINOR_VERSION, &glVersion[1]); 


If I set a holding point in Visual Studio10 I can read the version Numbers contained in glVersion. It says -1,-1.  I guess that means the context creation has failed, but why? I also get the Version Number of the temporary context. Its 3.0. I exspected 2.0. If I am using the temporary context, everything works fine, i can render objects the old way, but the new context shows just a blank white screen. When resizing the window to a larger size, the new areas are black, the old still white.


I ve Got a Nvidea GeForce 540M. Actual drivers are installed. As mentioned I am using VS2010 with GLEW 1.9.


Hope you can help me getting this to work.


Der Troll


PS: Sorry for my bad english...

Share this post

Link to post
Share on other sites

After trying a few things I am now able to give you some more information after Updating to VS2012.


First I tried another Tutorial Program which uses FreeGLUT. Now what happens is, that it only works, if i tell glut to crate an OpenGl 3.0 Context. Then I restarted the swiftless Tutorial and tried some Version Numbers. Only if I tell him to build a 3.0 version the program shows the selected backgroundcolor. As I mentioned before, 3.0 is the version of the context when I am initializing OpenGL "the old way".


So here are my suggestions:

- maybe the glew version isnt correct fpr my setup

- maybe the graphic drivers are incompatible

- maybe the VS2012 Settings are wrong


You see, there are a lot of maybe's. I really dont know what's the Problem. I ll try some other glew builds. If that doesnt work, i ll search for other display drivers...


Hope someone knows the solution, i m getting mad...

Share this post

Link to post
Share on other sites

As this is a laptop video card, can you confirm if you have drivers from your laptop manufacturer or from NVIDIA themselves?  Laptop-manufacturer-provided drivers are often woefully out of date (and sometimes may not include OpenGL support at all).  You can also run the OpenGL extensions viewer (link) and cross-check what GL version it tells you you've got.


I'd consider this the most likely cause of your problem.  The GL version is entirely dependent on your driver; there's nothing in VS that can affect it, and bypassing GLEW gives you 3.0; with a 540M you should be getting 4.3 (even with the old way of initializing a context) so that rules out GLEW as a possible cause.  So it's definitely driver-related.

Share this post

Link to post
Share on other sites

Thx for the hint with the extension viewer and it seems you re 100% right. It says:

3.0 100%

3.1 37%


rest 0%


I ve got the driver from the nvidea homepage and the discription said its Open-GL 4.3 compatible :/ So i ve to try some other drivers, but I don't know where to find them... I ll Check my Card and Driver specifications again to be sure its really 4.3 compatible... I ll also try to reinstall the drivers in advanced mode. Maybe you ve another hint what to do while i am searching for other drivers?


Thx by the way. Now  I know what exactly is the problem, just have to find a solution.

Share this post

Link to post
Share on other sites

GeForce 540M you say? Its a GF108 chip. From the GeForce GT 420. It should work up to 4.3 with latest drivers.


For reference, I have an ION 2 (aka 305M, GT218 chip, lowest of the GeForce 2xx series) and I can create OpenGL 3.3 contexts both on Windows 7 x64 and Linux 32 bit.


Go to nVidia's site, download latest drivers for your card and try with those (clean install).

Share this post

Link to post
Share on other sites

I ve got the solution... finally...


I used the OpenGL extensions viewer and clicked on the "search Update" Button. It directed me to the Intel Site... didn't think about that (and the big Intel Logo in the Extention Viewer)... searched for new drivers, found them and was able to get to OpenGl 3.1. Somehow I realized, that the drivers are for my onboard-Graphics... I started the NVidea Center and forced it to use the Graphic Accellerator on the OpenGL extensions viewer. Restarted the Program and I got what i wanted... OpenGL 4.3. Repeated that on Visual Studio and compiled my Project... and it worked!!!


So somehow there must be Setting in my System that tells the Computer to use onboard-Graphics instead of the Nvidea Chipset... -.- Problem is now solved, but if somebody knows where to find this Setting to kick it out of my System configuration... that would be nice



Special Thanks to mhagain... without the OpenGL extensions viewer I wouldn t have been able to get this far. Thanks a lot!!!

Share this post

Link to post
Share on other sites

In the main 3D settings page of the control panel you can select which GPU to use; you should have something similar to this: http://www.studio1productions.com/Articles/VideoCards/NVidia-2.jpg


Be aware that this is a global setting that will affect everything and you won't get the power-saving benefits of Optimus.  If you're OK with that, go for it.


See the following PDF for other methods of enabling it for specific programs: http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf

Share this post

Link to post
Share on other sites

thx a lot...


at the moment i try to get out of this Program:

  1. while (stupid == true)
  2. {
  3. Hit_Table(&Head);
  4. }
somehow the stupid=false; is missing -.-
I think I wont change it to save power. Now I know whats the Problem and I am pretty sure I wont forget it.

Share this post

Link to post
Share on other sites
Sign in to follow this  

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