All pastes #458511 Raw Edit

Miscellany

public text v1 · immutable
#458511 ·published 2007-04-25 22:41 UTC
rendered paste body
@implementation VideoView

-(void) drawQuad
{
	glBegin(GL_QUADS);
		glTexCoord2f(0.0f, 0.0f); glVertex2f(-1.0f,-1.0f);
		glTexCoord2f(0.0f, 0.0f); glVertex2f( 1.0f,-1.0f);
		glTexCoord2f(1.0f, 1.0f); glVertex2f( 1.0f, 1.0f);
		glTexCoord2f(0.0f, 1.0f); glVertex2f(-1.0f, 1.0f);
	glEnd();
}

-(void) drawRect: (NSRect) bounds
{
	glClearColor(0, 0, 0, 0);
	glClear(GL_COLOR_BUFFER_BIT);

	glGenTextures(1, &texture[0]);
	glBindTexture(GL_TEXTURE_2D, texture[0]);
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 300, 225,
				0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
	/* Draw our quad and load a black texture */
	[self drawQuad];
}

-(void) DrawFrame: (CFrame *)pFrame
{
	U8 *pBuffer;
	U32 ulBufferSize;
	
	pFrame->GetBuffer(&pBuffer, &ulBufferSize);
	
	glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 300, 225, GL_RGB,
		GL_UNSIGNED_BYTE, pBuffer);
	[self drawQuad];
}

@end