void GLFirstLayer::draw() { // CCLayer::draw(); //顶点数据 static GLfloat vertex[] = { 0,0,0, 200,0,0, 0,200,0, 200,200,0 }; //纹理坐标 static GLfloat coord[] = { 0,1, 1,1, 0,0, 1,0 }; //颜色数据 static GLfloat color[] = { 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1 }; //初始化纹理 static CCTexture2D* texture2d = NULL; if (!texture2d) { texture2d = CCTextureCache::sharedTextureCache()->addImage("HelloWorld.png"); } //设置着色器 ccGLEnableVertexAttribs(kCCVertexAttribFlag_PosColorTex); texture2d->getShaderProgram()->use(); texture2d->getShaderProgram()->setUniformForModelViewProjectionMatrix(); //绑定纹理 glBindTexture(GL_TEXTURE_2D, texture2d->getName()); //设置顶点数据 glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, 0, vertex); glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, 0, color); glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, coord); //绘图 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); }上面就绘制了一个矩形,直接重写 draw()方法即可