From 36b1b84216343fd31661ea49991a52187975dc8a Mon Sep 17 00:00:00 2001 From: torque Date: Sat, 23 May 2015 09:06:57 -0700 Subject: DOCS/client_api_examples/cocoa-openglcb: do initial flush correctly. --- DOCS/client_api_examples/cocoa-openglcb/cocoa-openglcb.m | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'DOCS') diff --git a/DOCS/client_api_examples/cocoa-openglcb/cocoa-openglcb.m b/DOCS/client_api_examples/cocoa-openglcb/cocoa-openglcb.m index f65c6a3664..4a4e8aa533 100644 --- a/DOCS/client_api_examples/cocoa-openglcb/cocoa-openglcb.m +++ b/DOCS/client_api_examples/cocoa-openglcb/cocoa-openglcb.m @@ -34,7 +34,7 @@ static void glupdate(void *ctx); @property mpv_opengl_cb_context *mpvGL; - (instancetype)initWithFrame:(NSRect)frame; - (void)drawRect; -- (void)flushBlack; +- (void)fillBlack; @end @implementation MpvClientOGLView @@ -55,29 +55,23 @@ static void glupdate(void *ctx); GLint swapInt = 1; [[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; [[self openGLContext] makeCurrentContext]; + self.mpvGL = nil; } return self; } -- (void)flushBlack +- (void)fillBlack { glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); - [[self openGLContext] flushBuffer]; - [[self openGLContext] flushBuffer]; -} - -- (void)prepareOpenGL -{ - [super prepareOpenGL]; - [self flushBlack]; - self.mpvGL = nil; } - (void)drawRect { if (self.mpvGL) mpv_opengl_cb_draw(self.mpvGL, 0, self.bounds.size.width, -self.bounds.size.height); + else + [self fillBlack]; [[self openGLContext] flushBuffer]; } -- cgit v1.2.3