• Create Account

## Problems getting OpenGL 3 context to work

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.

8 replies to this topic

### #1DerTroll  Members

Posted 12 April 2013 - 09:29 AM

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[] = {
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
WGL_CONTEXT_MINOR_VERSION_ARB, 2,
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
0
};

if (wglewIsSupported("WGL_ARB_create_context") == 1) {
hrc = wglCreateContextAttribsARB(hdc, NULL, attributes);
wglMakeCurrent(NULL, NULL);
wglDeleteContext(tempOpenGLContext);
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...

### #2DerTroll  Members

Posted 12 April 2013 - 04:14 PM

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

### #3mhagain  Members

Posted 12 April 2013 - 04:32 PM

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.

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.

### #4DerTroll  Members

Posted 12 April 2013 - 05:03 PM

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.

### #5TheChubu  Members

Posted 12 April 2013 - 06:57 PM

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.

"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"

My journals: dustArtemis ECS framework and Making a Terrain Generator

### #6mhagain  Members

Posted 12 April 2013 - 07:20 PM

The other possibility is that the laptop is on the list of models for which NV drivers are not supported: http://www.nvidia.com/object/notebook-win8-win7-64bit-314.22-whql-driver.html (bottom of "Supported Products" tab).

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.

### #7DerTroll  Members

Posted 12 April 2013 - 07:29 PM

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

### #8mhagain  Members

Posted 12 April 2013 - 07:47 PM

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

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.

### #9DerTroll  Members

Posted 12 April 2013 - 07:54 PM

thx a lot...

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

1. while (stupid == true)
2. {