Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)
- awakeFromNib
- {
- [super awakeFromNib];
- // Create a sample VBO…
- GLfloat vertices[] =
- {
- -0.8f, -0.8f, 0.0f, 1.0f,
- 0.0f, 0.8f, 0.0f, 1.0f,
- 0.8f, -0.8f, 0.0f, 1.0f,
- };
- GLfloat colors[] =
- {
- 1.0f, 0.0f, 0.0f, 1.0f,
- 0.0f, 1.0f, 0.0f, 1.0f,
- 0.0f, 0.0f, 1.0f, 1.0f,
- };
- glGenVertexArraysAPPLE(1, &mVAO);
- glBindVertexArrayAPPLE(mVAO);
- glGenBuffers(1, &mVBO);
- glBindBuffer(GL_ARRAY_BUFFER, mVBO);
- glBufferData(GL_ARRAY_BUFFER, sizeof (vertices), vertices, GL_STATIC_DRAW);
- glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0);
- glEnableVertexAttribArray(0);
- glGenBuffers(1, &mColorBuffer);
- glBindBuffer(GL_ARRAY_BUFFER, mColorBuffer);
- glBufferData(GL_ARRAY_BUFFER, sizeof(colors), colors, GL_STATIC_DRAW);
- glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, 0);
- glEnableVertexAttribArray(1);
- GLenum err = glGetError();
- if (err != GL_NO_ERROR)
- {
- NSLog(@"Error creating VBO");
- }
- // Create the display link timer…
- GLint syncToVerticalRetrace = 1;
- [self.openGLContext setValues: &syncToVerticalRetrace forParameter: NSOpenGLCPSwapInterval];
- CVDisplayLinkCreateWithActiveCGDisplays(&mDisplayLink);
- CVDisplayLinkSetOutputCallback(mDisplayLink, RenderCVDisplay, (__bridge void*) self);
- CGLContextObj cglContext = self.openGLContext.CGLContextObj;
- CGLPixelFormatObj cglPixelFormat = self.pixelFormat.CGLPixelFormatObj;
- CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(mDisplayLink, cglContext, cglPixelFormat);
- CVDisplayLinkStart(mDisplayLink);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement