Iphone 从UIView子类中使用OpenGL绘制UIImage

Iphone 从UIView子类中使用OpenGL绘制UIImage,iphone,objective-c,uiview,opengl-es,uiimage,Iphone,Objective C,Uiview,Opengl Es,Uiimage,我只是想用OpenGL在整个视图中绘制背景图片.png。请帮忙!我是OpenGL的新手,我正在尝试制作一个photoshop ish应用程序,我正在学习OpenGL来完成图像绘制 我的代码到目前为止 [EAGLContext setCurrentContext:context]; CGContextRef imageContext; GLubyte *imageData; size_t width, height; CGImageRef bac

我只是想用OpenGL在整个视图中绘制
背景图片.png
。请帮忙!我是OpenGL的新手,我正在尝试制作一个photoshop ish应用程序,我正在学习OpenGL来完成图像绘制

我的代码到目前为止

[EAGLContext setCurrentContext:context];

CGContextRef    imageContext;
GLubyte         *imageData;
size_t          width, height;
CGImageRef      backgroundImage;

backgroundImage = [UIImage imageNamed:@"background_pic.png"].CGImage;

// Get the width and height of the image
width = CGImageGetWidth(backgroundImage);
height = CGImageGetHeight(backgroundImage);

// Make sure the image exists
if(backgroundImage) {
    // Allocate  memory needed for the bitmap context
    imageData = (GLubyte *) calloc(width * height * 4, sizeof(GLubyte));
    // Use  the bitmatp creation function provided by the Core Graphics framework. 
    imageContext = CGBitmapContextCreate(imageData, width, height, 8, width * 4, CGImageGetColorSpace(backgroundImage), kCGImageAlphaPremultipliedLast);
    // After you create the context, you can draw the  image to the context.
    CGContextDrawImage(imageContext, CGRectMake(0.0, 0.0, (CGFloat)width, (CGFloat)height), backgroundImage);
    // You don't need the context at this point, so you need to release it to avoid memory leaks.
    CGContextRelease(imageContext);

    //I'm thinking the drawing goes in here

    free(imageData);
}

// Display the buffer
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];