Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Configure Visual Studio 2010 from ogl 1.1 to ogl 3.x or 4.x


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
8 replies to this topic

#1 Kurt_duncan   Members   -  Reputation: 103

Like
0Likes
Like

Posted 29 July 2012 - 09:02 AM

Hello experts,

I learned a bit opengl on version 1.1 . I want to upgrade my knowledge to actual versions but i am facing the first (stupid) problem on that. I am using Visual Studio C++ 2010 on a Windows 7 x64. My graphics card is a nvidia gt540M with latest driver. Well, on my visual studio i only found version 1.1 of opengl under include/GL/ . The gl.h is from the last century, and i think that libopengl32.lib is too. I spent last day looking for how to configure visual studio to use latest opengl versions, but i wasn't able to achieve it.

Please, could someone explain how to get latest gl.h and opengl libraries and configure visual studio to start with latest versions?

Thanks in advance!

Sponsor:

#2 Brother Bob   Moderators   -  Reputation: 8453

Like
2Likes
Like

Posted 29 July 2012 - 09:16 AM

There are no newer files, but you don't need any either. You can see pretty much any tutorial on OpenGL that has anything to do with version 1.2 or later. It will describe how to access later versions.

#3 Kurt_duncan   Members   -  Reputation: 103

Like
0Likes
Like

Posted 29 July 2012 - 10:45 AM

Thanks for your fast reply Brother Bob!

I was trying to find a tutorial explaining me how to do that, but they seem to be hidden from me. Please, could you paste any resource explaining how to setup visual studio to use opengl 3.x or 4.x ?

Thanks in advance!

#4 beans222   Members   -  Reputation: 1135

Like
1Likes
Like

Posted 29 July 2012 - 10:55 AM

Anything beyond 1.1 you need to query the function pointer through wglGetProcAddress. Using the library called GLEW is a fairly popular choice for gaining access to newer GL functions with minimal work on your part. If you search for GLEW, you'll likely find other libraries that would work just as well.

New C/C++ Build Tool 'Stir' (doesn't just generate Makefiles, it does the build): https://github.com/space222/stir

 


#5 Brother Bob   Moderators   -  Reputation: 8453

Like
0Likes
Like

Posted 29 July 2012 - 11:01 AM

You seem to be talking about two things; using anything beyond version 1.1, and using the features in the modern api (version 3 and later). The former should be in any tutorial (see the first tutorials at nehe.gamedev.net). For tutorials on the modern api you can check the links in the getting started box in the OpenGL subforum. Note that you need the former to do the latter since you will run into the same problems in both cases.

#6 Kurt_duncan   Members   -  Reputation: 103

Like
0Likes
Like

Posted 29 July 2012 - 11:18 AM

Thanks to you too beans222.
I downloaded glew 1.8 and i am trying to see this code:

[source lang="cpp"]#include <gl/glew.h>#include <iostream>#include <stdlib.h>using namespace std; void main(int argc, char** argv) { if(glGetString(GL_VERSION) == NULL){ GLenum glError = glGetError(); cout << glError; } else{ string version( (const char*)glGetString(GL_VERSION) ); cout << version.data(); } }[/source]

But i am getting error 1282, invalid operation. It seems that it is because opengl context it is not setted up. How i can do that?

Brother Bob, the nehe tutorials that i saw, are based on opengl 1.1 and they are, in my opinion, very good but very old. When i ask you before about a tutorial, i was thinking on a tutorial that explains how to configure visual studio to uses latest versions of opengl.

Has Glew an implementation of latest versions of opengl or how it works to get functions work? I told that because although i am getting error 1282, visual studio finds functions that are part of latest versions! Like glDrawElements, for example.

Thanks for everything.

#7 beans222   Members   -  Reputation: 1135

Like
0Likes
Like

Posted 29 July 2012 - 12:32 PM

You need to create a context like you were doing before in order for glew to be able to set up all the function pointers (it just calls wglGetProcAddress *a lot*). Then, you use some of the function pointers glew set up to get a GL3 context.
See this (under "Proper Context Creation"): http://www.opengl.org/wiki/Creating_an_OpenGL_Context

ps. All you need for glew to work is a context and then call glewInit

New C/C++ Build Tool 'Stir' (doesn't just generate Makefiles, it does the build): https://github.com/space222/stir

 


#8 slicer4ever   Crossbones+   -  Reputation: 3948

Like
1Likes
Like

Posted 29 July 2012 - 02:05 PM

I'd recommend using Glee http://www.opengl.org/sdk/libs/GLee/ for extension managment in windows, it'll get everything upto 3.0 standards, and relieves the headache of having to setup correct function pointers when you have a valid openGL context, as well makes it easy to determine what openGL version the system is using, and what extensions are supported.

Edited by slicer4ever, 29 July 2012 - 02:07 PM.

Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

#9 Neilo   Members   -  Reputation: 290

Like
0Likes
Like

Posted 30 July 2012 - 08:19 AM

Thanks to you too beans222.
I downloaded glew 1.8 and i am trying to see this code:

[source lang="cpp"]#include <gl/glew.h>#include <iostream>#include <stdlib.h>using namespace std;void main(int argc, char** argv){ if(glGetString(GL_VERSION) == NULL){ GLenum glError = glGetError(); cout << glError; } else{ string version( (const char*)glGetString(GL_VERSION) ); cout << version.data(); }}[/source]

But i am getting error 1282, invalid operation. It seems that it is because opengl context it is not setted up. How i can do that?

Brother Bob, the nehe tutorials that i saw, are based on opengl 1.1 and they are, in my opinion, very good but very old. When i ask you before about a tutorial, i was thinking on a tutorial that explains how to configure visual studio to uses latest versions of opengl.

Has Glew an implementation of latest versions of opengl or how it works to get functions work? I told that because although i am getting error 1282, visual studio finds functions that are part of latest versions! Like glDrawElements, for example.

Thanks for everything.


You need to init GLEW before you do anything...

int kContextFlags = WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB
#ifdef _DEBUG
   | WGL_CONTEXT_DEBUG_BIT_ARB;
#else
   ;
#endif
bool Device::Initialize(HWND window)
{
   // TODO: assert window is valid, make sure get a valid device context also
	    this->window = window;
	    deviceContext = ::GetDC(this->window);
	    PIXELFORMATDESCRIPTOR pfd = { 0 };
	    pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
	    pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;
	    pfd.iPixelType = PFD_TYPE_RGBA;
	    pfd.cColorBits = 32;
	    pfd.cDepthBits = 32;
	    pfd.iLayerType = PFD_MAIN_PLANE;
	    int pixelFormat = ::ChoosePixelFormat(deviceContext, &pfd);
	    if(pixelFormat == 0)
	    {
			    return false;
	    }
	    if(SetPixelFormat(deviceContext, pixelFormat, &pfd) == FALSE)
	    {
			    return false;
	    }
	    HGLRC tempContext = ::wglCreateContext(deviceContext);
	    ::wglMakeCurrent(deviceContext, tempContext);
   GLenum result = glewInit();
	    if(result != GLEW_OK)
	    {
			    return false;
	    }
	    if(wglewIsSupported("WGL_ARB_create_context") == 1)
	    {
			    renderingContext = ::wglCreateContextAttribsARB(deviceContext, NULL, kOpenGLAttribs);
			    BOOL success = ::wglMakeCurrent(NULL, NULL);
			    ::wglDeleteContext(tempContext);
			    ::wglMakeCurrent(deviceContext, renderingContext);
	  wglSwapIntervalEXT(1);
	  SetupDebugOutput();
	    }
	    else
	    {
			    //renderingContext = tempContext;
	  return false;
	    }
	   GLenum error = glGetError();
	   glGetIntegerv(GL_MAJOR_VERSION, &OpenGLVersion[0]);
	   glGetIntegerv(GL_MINOR_VERSION, &OpenGLVersion[1]);
	    return error == GL_NO_ERROR;
}





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