i am a beginner on cad by opengl,who can give me some useful code?

Hi !

Could you be a bit more specific here, do you want to implement a cad application ?, please do remember that OpenGL is just a rendering engine, there is no support for anything else, no complex geometry functions or anything like that.

If that is what you need, then you should look for a geometry library of some sort and then use OpenGL to do the final rendering, take a look at for example Open Cascade