OpenGL 3.3 sample code

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.

Have a look at this:

http://www.opengl.org/wiki/Tutorial:OpenGL_3.1_The_First_Triangle(C%2B%2B/Win)

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?

From http://www.opengl.org/registry/specs/ARB/wgl_create_context.txt :

Legacy Context Creation
-----------------------

When this extension is supported, calling

wglCreateContext(hdc)

is equivalent to calling

wglCreateContextAttribs(hdc,0,NULL).

Calling

wglCreateLayerContext(hdc,layer)

is equivalent to calling

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

The legacy context creation routines can only return OpenGL 

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

and

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.

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?

No, until you update your drivers! :wink:
But, yes! Your card supports GL 3.3.