【问题标题】:Core Graphics and Open GL Drawing核心图形和 Open GL 绘图
【发布时间】:2013-10-26 17:25:40
【问题描述】:

我有一个绘图应用程序,我在其中使用 openGL 绘图代码来绘制笔触,但想在笔触完成后将其传输到另一个图像,然后清除 OpenGL 视图。为此,我正在使用 CoreGraphics。然而,我遇到了一个问题,在图像通过 CG 传输之前,OpenGL 视图被清除(即使我之后清除它)

(我希望它是另一种方式,即先绘制图像然后擦除绘画图像,以避免任何闪烁)

(paintingView是openGL视图)

代码如下:

// Save the previous line drawn to the "main image"

UIImage *paintingViewImage = [[UIImage alloc] init];
paintingViewImage = [_paintingView snapshot];

UIGraphicsBeginImageContext(self.mainImage.frame.size);
[self.mainImage.image drawInRect:CGRectMake(0, 0, self.mainImage.frame.size.width, self.mainImage.frame.size.height) blendMode:kCGBlendModeNormal alpha:1.0];

// Get the image from the painting view

[paintingViewImage drawInRect:CGRectMake(0, 0, self.mainImage.frame.size.width, self.mainImage.frame.size.height) blendMode:kCGBlendModeNormal alpha:1.0];
self.mainImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

[self.paintingView erase];

所以在 mainImage.image 变量被设置为 CurrentImage 上下文之前,paintingView 被擦除了。

我只是这些方面的初学者,所以任何想法都有帮助。

谢谢

【问题讨论】:

    标签: ios opengl-es uiimageview core-graphics


    【解决方案1】:

    您可能最好使用FBOs(OpenGL 帧缓冲区对象)。您绘制到一个FBO,然后在保存前一个的同时将绘图切换到新的 FBO。您可以在 2 个 FBO 之间来回切换。 Here are the docs 在 iOS 上使用 FBOs。

    【讨论】:

    • 谢谢,但出于好奇,有没有办法强制擦除命令仅在 mainImage.image 变量设置并绘制到屏幕后发生?跨度>
    • 抱歉,我不确定。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-18
    • 1970-01-01
    • 1970-01-01
    • 2012-03-23
    • 1970-01-01
    相关资源
    最近更新 更多