javascript - pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);

标签 javascript ios objective-c xcode webgl

如果使用 OpenGL ES,我一直在尝试找出与 UNPACK_FLIP_Y_WEBGL 行等效的内容。我一直找不到解决方案。

谁能帮我找到一个等价物?

问候

最佳答案

它在 ES 2.0 中不存在。

解决方案从好到坏排序

  1. 在编译时翻转图像。

    这就是专业人士所做的。为什么要浪费内存和代码,如果不需要,为什么要让用户等待翻转图像?

  2. 上下颠倒加载图像(libpng 有该选项)

  3. 加载后翻转。

    假设每 channel RGBA 8 位图像,翻转代码类似于

     void flipInPlace(unsigned char* data, int width, int height) {
       size_t line_size = width * 4;
       unsigned char* line_buffer = new unsigned char[line_size];
       int half_height = height / 2
       for (int y = 0; y < halfHeight) {
         void* top_line = data + y * line_size;
         void* bottom_line = data + (height - y - 1) * line_size;
         memcpy(line_buffer, top_line, line_size);
         memcpy(top_line, bottom_line, line_size);
         memcpy(bottom_line, line_buffer, line_size);
       }
       delete [] line_buffer;
     }
    

关于javascript - pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15364517/

相关文章:

javascript - 选择列表项的前半部分和后半部分

javascript - 使用 JavaScript/Jquery 在 Ruby 中显示具有相同 id/class 的表单

ios - 如何查看ControllerWithRestorationIdentifierPath :coder: find an existing instance?

objective-c - 帮助诊断 Cocoa 框架中的崩溃 - 可能的内存泄漏?

javascript - 我的 html 文件不会链接到位于父目录中的样式表和 javascript

javascript - 如何根据页面位置实现 ng-show

ios - iOS 上的 IOBluetooth/使用其 Mac 地址连接到设备?

ios - 从 xc10 > xc11 迁移 SceneKit 应用程序,我遇到 "xcrun: error: unable to find utility "scntool",不是开发人员工具或在 PATH 中"

ios - 重写 UITextField 委托(delegate)方法

iphone - SQLite 中的 BLOB?