我的应用程序(ios8.0)是使用Opengl-es在GLKViewController中呈现流式视频
我遇到横向模式时视频被剪切的问题
也许..我需要缩放纹理,使用顶点着色器。
typedef struct {
float Position[3];
float Color[4];
float TexCoordp[2];
} Vertex;
const Vertex Vertices[] = {
{{1, -1, 0}, {1, 1, 1, 1}, {1, 1}},
{{1, 1, 0}, {1, 1, 1, 1}, {1, 0}},
{{-1, 1, 0}, {1, 1, 1, 1}, {0, 0}},
{{-1, -1, 0}, {1, 1, 1, 1}, {0, 1}}
};
const GLubyte Indices[] = {
0, 1, 2,
2, 3, 0
};
#pragma mark - shaders
#define STRINGIZE(x) #x
#define STRINGIZE2(x) STRINGIZE(x)
#define SHADER_STRING(text) @ STRINGIZE2(text)
NSString *const vertexShaderString = SHADER_STRING
(
attribute vec4 Position; // 1
attribute vec4 SourceColor; // 2
varying vec4 DestinationColor; // 3
attribute vec2 TexCoordIn;
varying vec2 TexCoordOut;
void main(void) { // 4
DestinationColor = SourceColor; // 5
gl_Position = Position; // 6
TexCoordOut = TexCoordIn; // New
}
);
设置GL代码
- (void)setupGL
{
[EAGLContext setCurrentContext:self.context];
glGenBuffers(1, &_vertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(Vertices), Vertices, GL_STATIC_DRAW);
glGenBuffers(1, &_indexBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _indexBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(Indices), Indices, GL_STATIC_DRAW);
// init the update render semaphore
_textureUpdateRenderSemaphore = dispatch_semaphore_create((long)1);
}
也许我需要改变“顶点”,但我无法得到任何线索。
非常感谢你的帮助