我正在尝试将我的代码提升到一个新的水平.遵循Apple的一些最佳实践,我试图在我的顶点缓冲对象(VBO)周围实现顶点数组对象.我设置我的VBO和VAO像这样:
- (void)setupVBOs {
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindVertexArrayOES(0);
{
glGenVertexArraysOES(1, &directArrayObject);
glBindVertexArrayOES(directArrayObject);
// GLuint texCoordBuffer;
glGenBuffers(1, &texCoordBuffer);
glBindBuffer(GL_ARRAY_BUFFER, texCoordBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(DirectVertices), DirectVertices, GL_STATIC_DRAW);
glVertexAttribPointer(directPositionSlot, 2, GL_FLOAT, GL_FALSE, sizeof(DirectVertex), (GLvoid*)offsetof(DirectVertex, position));
glEnableVertexAttribArray(directPositionSlot);
glVertexAttribPointer(texCoordSlot, 2, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(DirectVertex), (GLvoid*)offsetof(DirectVertex, texCoord));
glEnableVertexAttribArray(texCoordSlot);
glGenVertexArraysOES(1, &arrayObject);
glBindVertexArrayOES(arrayObject);
// GLuint vertexBuffer;
glGenBuffers(1, &vertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(Vertices), Vertices, GL_STATIC_DRAW);
glVertexAttribPointer(positionSlot, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), 0);
glEnableVertexAttribArray(positionSlot);
glVertexAttribPointer(colorSlot, 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(Vertex), (GLvoid*)offsetof(Vertex, Color));
glEnableVertexAttribArray(colorSlot);
// GLuint indexBuffer;
glGenBuffers(1, &indexBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(Indices), Indices, GL_STATIC_DRAW); …Run Code Online (Sandbox Code Playgroud) 我在AVAssetWriterInputPixelBufferAdaptor中使用pixelBufferPool来创建像素缓冲区以与append方法一起使用.创建4个缓冲区后,pixelBufferPool属性变为NULL;
我设置了我的编写器,输入和适配器,如下所示:
- (BOOL) setupRecorder {
NSError *error = nil;
if([[NSFileManager defaultManager] fileExistsAtPath:[[self tempFileURL] path]])
[[NSFileManager defaultManager] removeItemAtURL:[self tempFileURL] error:&error];
assetWriter = [[AVAssetWriter alloc] initWithURL: [self tempFileURL]
fileType:AVFileTypeQuickTimeMovie
error:&error];
if (error) {
NSLog(@"Error creating asset writer: %@", error);
[assetWriter release];
return NO;
}
// writer
NSDictionary *videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:
AVVideoCodecH264, AVVideoCodecKey,
[NSNumber numberWithInt:videoWidth], AVVideoWidthKey,
[NSNumber numberWithInt:videoHeight], AVVideoHeightKey,
nil];
assetWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo
outputSettings:videoSettings];
NSDictionary *bufferAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:kCVPixelFormatType_32BGRA], kCVPixelBufferPixelFormatTypeKey,
nil];
adaptor = [[AVAssetWriterInputPixelBufferAdaptor alloc] initWithAssetWriterInput:assetWriterInput sourcePixelBufferAttributes:bufferAttributes];
[adaptor …Run Code Online (Sandbox Code Playgroud) 我正试图在iPhone 4上的iOS 4.3中将原生平面图像渲染为OpenGL ES 2.0纹理.然而,纹理全部变黑.我的相机配置如下:
[videoOutput setVideoSettings:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange]
forKey:(id)kCVPixelBufferPixelFormatTypeKey]];
Run Code Online (Sandbox Code Playgroud)
我将像素数据传递给我的纹理,如下所示:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, bufferWidth, bufferHeight, 0, GL_RGB_422_APPLE, GL_UNSIGNED_SHORT_8_8_REV_APPLE, CVPixelBufferGetBaseAddress(cameraFrame));
Run Code Online (Sandbox Code Playgroud)
我的fragement着色器是:
varying highp vec2 textureCoordinate;
uniform sampler2D videoFrame;
void main() {
lowp vec4 color;
color = texture2D(videoFrame, textureCoordinate);
lowp vec3 convertedColor = vec3(-0.87075, 0.52975, -1.08175);
convertedColor += 1.164 * color.g; // Y
convertedColor += vec3(0.0, -0.391, 2.018) * color.b; // U
convertedColor += vec3(1.596, -0.813, 0.0) * color.r; // V
gl_FragColor = vec4(convertedColor, 1.0);
}
Run Code Online (Sandbox Code Playgroud)
我的顶点着色器是
attribute vec4 position;
attribute …Run Code Online (Sandbox Code Playgroud) 我有两个成功的概念,我想现在合并.我成功地将相位框架分层CATextLayer到CVImageBufferRef相机框架上,然后通过AVAssetWriter使用a来保存它AVAssetWriterInputPixelBufferAdaptor.我这样做:
- (void) processNewBuffer:(CVImageBufferRef)cameraFrame {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
//
// //update CALayer on main queue
// //UIKit is not thread safe
dispatch_sync(dispatch_get_main_queue(), ^{
[self updateCALayer];
});
if(recorder.recording) {
CVPixelBufferLockBaseAddress(cameraFrame,0);
// do stuff with buffer here
uint8_t *baseAddress = (uint8_t *)CVPixelBufferGetBaseAddress(cameraFrame);
size_t bytesPerRow = CVPixelBufferGetBytesPerRow(cameraFrame);
width = CVPixelBufferGetWidth(cameraFrame);
height = CVPixelBufferGetHeight(cameraFrame);
/*Create a CGImageRef from the CVImageBufferRef*/
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef newContext = CGBitmapContextCreate(baseAddress, width, height, 8, bytesPerRow, …Run Code Online (Sandbox Code Playgroud) 我需要确定用户是否只是销售人员.我的ASP.NET MVC 4控制器中有以下内容:
public ActionResult Index() {
string salespersonCode = null;
var roles = Roles.GetRolesForUser();
if(roles.Count() == 1 && roles.Contains(UserRoles.Salesperson.ToString()))
salespersonCode = User.Name();
return View(new ProspectIndexViewModel { Prospects = _crmService.GetActiveProspects(salespersonCode) });
}
Run Code Online (Sandbox Code Playgroud)
用户可能有多个角色.如果用户只有该角色,我想将返回的数据限制为仅属于销售人员的数据.其他三个角色(Manager,Admin和SalesAdministrator)将接收整个列表.谢谢!