-1
我要在同一时间绘制2个纹理。 (来自不同的视频,实时获得不同的帧纹理...) 它运行良好,代码如下。多个GL纹理(实时)渲染速度太慢
// module 1---------------
{
CVPixelBufferLockBaseAddress(cameraFrame, 0);
int bufferHeight = CVPixelBufferGetHeight(cameraFrame);
int bufferWidth = CVPixelBufferGetWidth(cameraFrame);
// Create a new texture from the camera frame data, display that using the shaders
glGenTextures(1, &videoFrameTexture);
glBindTexture(GL_TEXTURE_2D, videoFrameTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// This is necessary for non-power-of-two textures
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// Using BGRA extension to pull in video frame data directly
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bufferWidth, bufferHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, CVPixelBufferGetBaseAddress(cameraFrame));
}
{
CVPixelBufferLockBaseAddress(buf2, 0);
int bufferHeight = CVPixelBufferGetHeight(buf2);
int bufferWidth = CVPixelBufferGetWidth(buf2);
// Create a new texture from the camera frame data, display that using the shaders
glGenTextures(1, &videoFrameTexture2);
glBindTexture(GL_TEXTURE_2D, videoFrameTexture2);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// This is necessary for non-power-of-two textures
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// Using BGRA extension to pull in video frame data directly
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bufferWidth, bufferHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, CVPixelBufferGetBaseAddress(buf2));
}
[self drawFrame]; // module2---------
{
glDeleteTextures(1, &videoFrameTexture);
CVPixelBufferUnlockBaseAddress(cameraFrame, 0);
glDeleteTextures(1, &videoFrameTexture2);
CVPixelBufferUnlockBaseAddress(buf2, 0);
}
但是它的速度太慢了。主要是module2很慢。 我检查了glTexSubImage2D而不是glTexImage2D,但没有好的结果。
有什么解决方案加快速度?
你是否真的在每一帧都做了这个纹理对象的创建/销毁? –
我知道它不好,所以请让我知道解决方案。为什么人们在没有正确答案的情况下倒退? – sky1224