- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我目前正在将立方体贴图加载到我的应用程序中,但它显示为红色。编辑: channel 问题在使用 2D 纹理时也存在,似乎 channel 的顺序不正确。有什么方法可以使用 iOS 方法更改 channel 的顺序吗?
这是纹理加载的代码:
public TextureCube (Generic3DView device, UIImage right, UIImage left, UIImage top, UIImage bottom, UIImage front, UIImage back)
: base(device)
{
_Device = device;
GL.GenTextures (1, ref _Handle);
GL.BindTexture (TextureType, _Handle);
LoadTexture(All.TextureCubeMapPositiveX, right);
LoadTexture(All.TextureCubeMapNegativeX, left);
LoadTexture(All.TextureCubeMapPositiveY, top);
LoadTexture(All.TextureCubeMapNegativeY, bottom);
LoadTexture(All.TextureCubeMapPositiveZ, front);
LoadTexture(All.TextureCubeMapNegativeZ, back);
GL.TexParameter(All.TextureCubeMap, All.TextureMinFilter, (Int32)All.LinearMipmapLinear);
GL.TexParameter(All.TextureCubeMap, All.TextureMagFilter, (Int32)All.Linear);
GL.GenerateMipmap(All.TextureCubeMap);
}
private void LoadTexture(All usage, UIImage image)
{
GL.TexImage2D(usage, 0, (Int32)All.Rgba, (Int32)image.Size.Width,
(Int32)image.Size.Height, 0, All.Rgba, All.UnsignedByte, RequestImagePixelData(image));
}
protected CGBitmapContext CreateARGBBitmapContext (CGImage inImage)
{
var pixelsWide = inImage.Width;
var pixelsHigh = inImage.Height;
var bitmapBytesPerRow = pixelsWide * 4;
var bitmapByteCount = bitmapBytesPerRow * pixelsHigh;
//Note implicit colorSpace.Dispose()
using (var colorSpace = CGColorSpace.CreateDeviceRGB()) {
//Allocate the bitmap and create context
var bitmapData = Marshal.AllocHGlobal (bitmapByteCount);
if (bitmapData == IntPtr.Zero) {
throw new Exception ("Memory not allocated.");
}
var context = new CGBitmapContext (bitmapData, pixelsWide, pixelsHigh, 8,
bitmapBytesPerRow, colorSpace, CGImageAlphaInfo.PremultipliedFirst);
if (context == null) {
throw new Exception ("Context not created");
}
return context;
}
}
//Store pixel data as an ARGB Bitmap
protected IntPtr RequestImagePixelData (UIImage inImage)
{
var imageSize = inImage.Size;
CGBitmapContext ctxt = CreateARGBBitmapContext (inImage.CGImage);
var rect = new RectangleF (0.0f, 0.0f, imageSize.Width, imageSize.Height);
ctxt.DrawImage (rect, inImage.CGImage);
var data = ctxt.Data;
return data;
}
我认为 channel 是反转的,但也许有一种方法可以在没有一些自定义代码的情况下反转位图。
这是渲染的图像(忽略它前面的精美模型):
以及预期的图像:
GL_INVALID_OPERATION 问题已修复,但并未解决红色纹理的问题。
顶点着色器:
attribute vec3 position;
uniform mat4 modelViewMatrix;
varying mediump vec3 texture;
void main()
{
texture = position.xyz;
gl_Position = modelViewMatrix * vec4(position.xyz, 1.0);
}
片段着色器:
varying mediump vec3 texture;
uniform samplerCube cubeMap;
void main()
{
mediump vec3 cube = vec3(textureCube(cubeMap, texture));
gl_FragColor = vec4(cube.xyz, 1.0);
}
最佳答案
问题是你的函数CreateARGBBitmapContext这一行
var context = new CGBitmapContext (bitmapData, pixelsWide, pixelsHigh, 8, bitmapBytesPerRow, colorSpace, CGImageAlphaInfo.PremultipliedFirst);
如果你改变
CGImageAlphaInfo.PremultipliedFirst
到
CGImageAlphaInfo.PremultipliedLast
这应该可以修复您的代码。
关于c# - OpenGL ES 2.0/MonoTouch : Texture is colorized red,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7986153/
在我输入的 javascript 控制台中/(red|green)/g.exec('红绿红绿') 它返回一个包含两个结果的数组:[“红色”,“红色”] 它不应该返回一个包含 4 个结果的数组吗?如:[
所以我目前正在将一个下降大小的程序从 Rebol 3 迁移到 Red。所述程序依赖于与 C 库 (clang) 的大型绑定(bind)。我已经重写了 Red/System 中的绑定(bind)部分,并
是否可以在节点集群上水平扩展 Node-RED? 找不到任何文档。我的场景是每秒处理数百万个事件并使用 Node-RED 实时处理它们。 最佳答案 我在 Google Groups Node-RED
因此,在尝试在 Red 和 Red/System 之间来回编码值时出现了问题。我想访问传递给例程的对象的内脏。 我注意到 Red Runtime 中有一些函数可以在对象上下文中处理诸如此类、get-v
假设我正在使用 MQTT 协议(protocol)从许多设备接收信息,下图是一个设备 block 的简化版本: 因此,我们还假设所有其他设备具有完全相同的图表,除了将更改为 device2 的主题名称
想象一下我已经连接了一个流程,如下所示: 现在希望重新连接到: 看来我的选择是删除现有的电线,然后重新连接它们。我的问题是: 问题 是否可以将连线从一个节点移动到另一个节点,而不是删除和重新创建? 最
有没有办法将现有的 Node-RED 流文件 myflow.json 部署到运行 Node-RED 的远程计算机? 经过多次谷歌搜索,我偶然发现了this discussion在相关的Google群组
我想了解下例中WPF是如何将字符串值(Red)转换成对应的SolidColorBrush的? 我们如何对自定义 DependencyProperty 做同样的事情? 最佳答案 从字符串到 Brush
我想了解下例中WPF是如何将字符串值(Red)转换成对应的SolidColorBrush的? 我们如何对自定义 DependencyProperty 做同样的事情? 最佳答案 从字符串到 Brush
我想合并来自 3 个不同来源的数据(来自 HTTP msg.payload)。 但是,这些 HTTP 请求可能会被多次调用,因此可以多次接收来自同一源的数据。 [{"id":"7ed13b41.131
我需要 Accel 对象作为有效负载对象的一部分: msg.payload.Accel.x : 1 msg.payload.Accel.y : 2 msg.payload.Accel.z : 3 如何
我正在尝试在 Node-RED 中执行简单的 http get 请求。根据在线文档,我必须传递函数中的参数作为 http 请求节点的输入。我的函数如下所示; msg.url = "https://ap
我有一个简单的 php 页面,它输出一个表(已动态创建)。 页面上的文本都是红色标记的,除非你专门放置一个font color元素并强制它变成黑色。 我使用的是 FF 并安装了 Firebug,所以我
setXxx(Color.red) 和 setXxx(Color.RED) 的定义之间的真正区别是什么? 我在网上找到了以下解释。都是关于命名约定的吗? Java originally defined
我正在使用具有以下内容的 Dockerfile,我在树莓派上使用 resin.io 进行部署。 FROM nodered/node-red-docker:rpi-v8 USER root RUN su
这个问题已经有答案了: Difference between Color.red and Color.RED (3 个回答) 已关闭 9 年前。 Color.RED 之间有什么区别吗?变量和 Colo
我可能是盲人,但我找不到我在许多节点实现中看到的功能的文档,因为有: RED.nodes.createNode() RED.nodes.getNode() RED.nodes.eachNode() R
$('#toggle-linecolor').click(function () { chart.yAxis[0].update({ lineColor: li
我用了this GitHub 存储库,用于使用 Electron 创建 Node-Red 桌面应用程序。 现在我想使用 node-red-admin 向这个应用程序添加身份验证。我怎样才能做到这一点?
两种方法都有效吗?两者都一样。 border:2px solid red; 和 border:2px red solid; 最佳答案 W3.org (官方规范)说 border 简写属性的值是这样的:
我是一名优秀的程序员,十分优秀!