View Full Version : OpenGL 3.3 sample code

Brandon J. Van Every
03-25-2010, 01:34 PM
Where can I find some working sample code for OpenGL 3.3? I would prefer working Windows WGL code, but I will conjure a Linux box if I must. I didn't see anything apropos under "Coding Resources". I did download all the specs, but I would like to see something actually working.

03-25-2010, 08:59 PM
Have a look at this:


Ehsan Kamrani
03-26-2010, 04:24 AM
I have not created that new OpenGL context.So Wha'ts my OpenGL version?!
I'm also able to work with shader #version 110.So why do we need to create a new context for OpenGL 3?

Dan Bartlett
03-26-2010, 05:06 AM
From http://www.opengl.org/registry/specs/ARB/wgl_create_context.txt :

Legacy Context Creation

When this extension is supported, calling


is equivalent to calling




is equivalent to calling

wglCreateContextAttribs(hdc, 0,
{ WGL_CONTEXT_LAYER_PLANE, layer, 0 }) .

The legacy context creation routines can only return OpenGL
contexts if the GL_ARB_compatibility extension is supported, and can
only return OpenGL 3.2 or greater contexts implementing the
compatibility profile. This ensures compatibility for existing
applications. However, 3.0-aware applications are encouraged to use
wglCreateContextAttribsARB instead of the legacy routines.


The default values for WGL_CONTEXT_MAJOR_VERSION_ARB and
WGL_CONTEXT_MINOR_VERSION_ARB are 1 and 0 respectively. In this
case, implementations will typically return the most recent version
of OpenGL they support which is backwards compatible with OpenGL 1.0
(e.g. 3.0, 3.1 + GL_ARB_compatibility, or 3.2 compatibility profile)

So if you use wglCreateContext, you'll need to query to see what was actually created. NVidia drivers currently return a 3.3 compatibility profile.

Ehsan Kamrani
03-26-2010, 05:46 AM
here's the information of my implementation returned by glGetString():

OpenGL Vendor: NVIDIA Corporation
OpenGL Renderer: GeForce 9600 GT/PCI/SSE2
OpenGL Version: 3.0.0
OpenGL Shading Language Version: 1.30 NVIDIA via Cg compiler

Does it mean that my GPU can support OpenGL 3.3 if I create a compatible context?

03-26-2010, 05:49 AM
No, until you update your drivers! ;)
But, yes! Your card supports GL 3.3.