How to draw a triangles in buffers

Hello ,

I am beginner to the OpenGL . I want to write code to draw triangles and fill these triangles using color values set at the vertices.
I know the call to draw triangles using glDrawArrays(GL_TRIANGLES,0,NumVertices); or glDrawElements( GL_TRIANGLES, NumIndices,GL_UNSIGNED_INT,Indices).

Could you please help me to know if there is any API which do the same thing and write into the openGL buffer/image which i would like to read in OpenCL.