Source for open GL

783058842956ab1b8f495cab05f64a37
0
sujay 101 May 05, 2012 at 06:17

HI,
This may be a silly question.But I want to know where to obtain the openGL libraries.
I visited the opengl.org site, but could not find downloadable libararies(GL,GLU and GLUT) for Windows.
Please help.

Regards,
Sujay

4 Replies

Please log in or register to post a reply.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 May 05, 2012 at 06:24

There is no single source code for OpenGL. OpenGL is not really a library, just a standardized interface to let applications talk to the graphics driver. Its implementation is provided by the graphics driver for the particular GPU and operating system you’re using. These drivers are typically closed-source, though you might be able to find an open-source Linux driver somewhere out there, or look at Mesa, which is a software renderer implementation of OpenGL.

783058842956ab1b8f495cab05f64a37
0
sujay 101 May 05, 2012 at 06:36

@Reedbeta

There is no single source code for OpenGL. OpenGL is not really a library, just a standardized interface to let applications talk to the graphics driver. Its implementation is provided by the graphics driver for the particular GPU and operating system you’re using. These drivers are typically closed-source, though you might be able to find an open-source Linux driver somewhere out there, or look at Mesa, which is a software renderer implementation of OpenGL.

ok.So I want to write programs using OPENGL in C++>I have Windows 7 OS and Intel HD Graphics Card.Will they provide support for OPENGL?

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 May 05, 2012 at 06:46

As long as you have an up-to-date graphics driver installed, it should. You just have to write your code and link with the OpenGL .lib or .a files, which should be in your compiler distribution. For instance if you use Visual Studio, just add opengl32.lib and glu32.lib to the additional linker dependencies in your project. You may also want to use an extension library like GLEW or GLEE, which simplify the process of getting access to OpenGL extensions (necessary to use any of the interesting features, like shaders).

6837d514b487de395be51432d9cdd078
0
TheNut 179 May 05, 2012 at 10:42

Visual Studio will install the core OpenGL header and library files. This would be enough for you to compile and run OpenGL 1.x with a fixed function graphics pipeline (not that good nowadays). If your users have their video card drivers properly installed, the hardware will automatically execute the OpenGL commands instead of your CPU, otherwise OpenGL will fallback to software rendering on the CPU (only for OpenGL 1.X commands, will not work with any extensions you use). You will need to download the latest OpenGL Extension headers here and install them to your C++ include folder (eg: c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Include\gl). glext.h contains all the new APIs. As Reed mentioned, you need this for doing any OpenGL 2.X and newer stuff such as shader development. You should stick to the vanilla functions (eg: glDeleteRenderbuffers) instead of the “ARB” or “EXT” variants (eg: glDeleteRenderbuffersEXT). wglext.h is necessary for Windows-only specific OpenGL extensions. For example, you need this to enable MSAA. glxext.h is the same thing, but for X11 (*nix) based machines. The new APIs are not automatically linked for you with the library that gets installed with Visual Studio. Microsoft stopped supporting OpenGL long ago, but left in support for version 1.X. You need to define all the methods you want to use or use a 3rd party library like GLEW to assist you with this. If you wish to manually link the functions yourself, you can do something like this.

void *GetGLExtension (const char name[])
{
#ifdef WIN32
    return wglGetProcAddress(name);
#elif __linux__
    return (void *)glXGetProcAddress((const GLubyte *)name);
#endif

    return 0;
}


#ifdef WIN32
    PFNGLBINDBUFFERPROC _glBindBuffer;
    void APIENTRY glBindBuffer (GLenum target, GLuint buffer)
    {
        if ( !_glBindBuffer )
            _glBindBuffer = (PFNGLBINDBUFFERPROC)GetGLExtension("glBindBuffer");

        if ( _glBindBuffer )
            _glBindBuffer(target, buffer);
       // else throw an error if you like
    }
#endif

This allows you to call glBindBuffer(…) and the code will automatically fetch and run the function if it’s available. More advance solutions would check what level of support is available from the user’s video card and decide how to render content based on that. Also note that this workaround is only really necessary for Windows based computers. Linux, Mac, iOS, and Android all use an up-to-date OpenGL library with these functions defined for you.