-(void) drawRect: (NSRect) bounds { U8 *pBuffer = NULL; U32 ulBufferSize = 0; U32 width = 300; U32 height = 225; if(!isInitialized) { // pBuffer could be anything here, but I don't care, just want to see some color pBuffer = (U8 *)malloc(300 * 255 * 3); for(int i = 0; i < 300 * 25; i++) pBuffer[i] = 55; glEnable(GL_TEXTURE_2D); glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glGenTextures(1, &texture[0]); glBindTexture(GL_TEXTURE_2D, texture[0]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // Linear Filtering glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 300, 225, 0, GL_RGB8, GL_UNSIGNED_BYTE, pBuffer); free(pBuffer); isInitialized = YES; [self drawQuad]; glFlush(); } if(m_pFrame) { m_pFrame->GetBuffer(&pBuffer, &ulBufferSize); width = m_pFrame->GetWidth(); height = m_pFrame->GetHeight(); for(int i = 0; i < 300 * 25; i++) pBuffer[i] = 55; glBindTexture(GL_TEXTURE_2D, texture[0]); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGB8, GL_UNSIGNED_BYTE, pBuffer); printf("Displaying frame %d\n", frameNum++); [self drawQuad]; m_pFrame = NULL; glFlush(); } }