Sign in to follow this  
DerTroll

OpenGL Problems getting OpenGL 3 context to work

Recommended Posts

DerTroll    105

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

Share this post


Link to post
Share on other sites
DerTroll    105

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
mhagain    13430

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
DerTroll    105

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
TheChubu    9454

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
DerTroll    105

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
mhagain    13430

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
DerTroll    105

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Partner Spotlight

  • Similar Content

    • By pseudomarvin
      I assumed that if a shader is computationally expensive then the execution is just slower. But running the following GLSL FS instead just crashes
      void main() { float x = 0; float y = 0; int sum = 0; for (float x = 0; x < 10; x += 0.00005) { for (float y = 0; y < 10; y += 0.00005) { sum++; } } fragColor = vec4(1, 1, 1 , 1.0); } with unhandled exception in nvoglv32.dll. Are there any hard limits on the number of steps/time that a shader can take before it is shut down? I was thinking about implementing some time intensive computation in shaders where it would take on the order of seconds to compute a frame, is that possible? Thanks.
    • By Arulbabu Donbosco
      There are studios selling applications which is just copying any 3Dgraphic content and regenerating into another new window. especially for CAVE Virtual reality experience. so that the user opens REvite or CAD or any other 3D applications and opens a model. then when the user selects the rendered window the VR application copies the 3D model information from the OpenGL window. 
      I got the clue that the VR application replaces the windows opengl32.dll file. how this is possible ... how can we copy the 3d content from the current OpenGL window.
      anyone, please help me .. how to go further... to create an application like VR CAVE. 
       
      Thanks
    • By cebugdev
      hi all,

      i am trying to build an OpenGL 2D GUI system, (yeah yeah, i know i should not be re inventing the wheel, but this is for educational and some other purpose only),
      i have built GUI system before using 2D systems such as that of HTML/JS canvas, but in 2D system, i can directly match a mouse coordinates to the actual graphic coordinates with additional computation for screen size/ratio/scale ofcourse.
      now i want to port it to OpenGL, i know that to render a 2D object in OpenGL we specify coordiantes in Clip space or use the orthographic projection, now heres what i need help about.
      1. what is the right way of rendering the GUI? is it thru drawing in clip space or switching to ortho projection?
      2. from screen coordinates (top left is 0,0 nd bottom right is width height), how can i map the mouse coordinates to OpenGL 2D so that mouse events such as button click works? In consideration ofcourse to the current screen/size dimension.
      3. when let say if the screen size/dimension is different, how to handle this? in my previous javascript 2D engine using canvas, i just have my working coordinates and then just perform the bitblk or copying my working canvas to screen canvas and scale the mouse coordinates from there, in OpenGL how to work on a multiple screen sizes (more like an OpenGL ES question).
      lastly, if you guys know any books, resources, links or tutorials that handle or discuss this, i found one with marekknows opengl game engine website but its not free,
      Just let me know. Did not have any luck finding resource in google for writing our own OpenGL GUI framework.
      IF there are no any available online, just let me know, what things do i need to look into for OpenGL and i will study them one by one to make it work.
      thank you, and looking forward to positive replies.
    • By fllwr0491
      I have a few beginner questions about tesselation that I really have no clue.
      The opengl wiki doesn't seem to talk anything about the details.
       
      What is the relationship between TCS layout out and TES layout in?
      How does the tesselator know how control points are organized?
          e.g. If TES input requests triangles, but TCS can output N vertices.
             What happens in this case?
      In this article,
      http://www.informit.com/articles/article.aspx?p=2120983
      the isoline example TCS out=4, but TES in=isoline.
      And gl_TessCoord is only a single one.
      So which ones are the control points?
      How are tesselator building primitives?
    • By Orella
      I've been developing a 2D Engine using SFML + ImGui.
      Here you can see an image
      The editor is rendered using ImGui and the scene window is a sf::RenderTexture where I draw the GameObjects and then is converted to ImGui::Image to render it in the editor.
      Now I need to create a 3D Engine during this year in my Bachelor Degree but using SDL2 + ImGui and I want to recreate what I did with the 2D Engine. 
      I've managed to render the editor like I did in the 2D Engine using this example that comes with ImGui. 
      3D Editor preview
      But I don't know how to create an equivalent of sf::RenderTexture in SDL2, so I can draw the 3D scene there and convert it to ImGui::Image to show it in the editor.
      If you can provide code will be better. And if you want me to provide any specific code tell me.
      Thanks!
  • Popular Now