From 861226e1afaa2b82daee1e0f37088f28d6c19402 Mon Sep 17 00:00:00 2001 From: Bergmann89 Date: Tue, 17 Mar 2015 20:23:08 +0100 Subject: [PATCH] * [glcContext] check return value from wglShareLists * [glcFrameBufferObject] fixed bug with glDrawBuffer/glReadBuffer --- uglcContextWGL.pas | 3 ++- uglcFrameBufferObject.pas | 11 ++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/uglcContextWGL.pas b/uglcContextWGL.pas index 16fc885..58b35de 100644 --- a/uglcContextWGL.pas +++ b/uglcContextWGL.pas @@ -399,7 +399,8 @@ end; procedure TglcContextWGL.Share(const aContext: TglcContext); begin - wglShareLists(FRC, (aContext as TglcContextWGL).FRC); + if not wglShareLists(FRC, (aContext as TglcContextWGL).FRC) then + raise EGLError.Create('wglShareLists failed: ' + IntToStr(GetLastError())); end; class function TglcContextWGL.ChangeDisplaySettings(const aWidth, aHeight, diff --git a/uglcFrameBufferObject.pas b/uglcFrameBufferObject.pas index a0d75e0..0b98e4a 100644 --- a/uglcFrameBufferObject.pas +++ b/uglcFrameBufferObject.pas @@ -322,7 +322,6 @@ constructor TglcTextureBuffer.Create(const aFormat: TglcFormat; const aInternalF begin inherited Create; fBufferType := btTextureBuffer; - glGenTextures(1, @fID); Bind(false); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, {$IFNDEF OPENGL_ES}GL_CLAMP{$ELSE}GL_CLAMP_TO_EDGE{$ENDIF}); @@ -330,7 +329,6 @@ begin glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); Unbind(false); - fFormat := aFormat; fInternalFormat := aInternalFormat; SetSize(64, 64); @@ -495,11 +493,11 @@ procedure TglcFrameBufferObject.UpdateAndCheckFBO; var buff: array of GLenum; -{$IFNDEF OPENGL_ES} - b: GLboolean; -{$ENDIF} i: Integer; + {$IFNDEF OPENGL_ES}DoubleBuffered: GLboolean;{$ENDIF} begin + {$IFNDEF OPENGL_ES}glGetBooleanv(GL_DOUBLEBUFFER, @DoubleBuffered);{$ENDIF} + if (fBuffers.Count = 0) then exit; Bind(false); @@ -525,8 +523,7 @@ begin end else begin glDrawBuffers(Length(buff), @buff[0]); {$IFNDEF OPENGL_ES} - glGetBooleanv(GL_DOUBLEBUFFER, @b); - if b then + if DoubleBuffered then glReadBuffer(GL_BACK) else glReadBuffer(GL_FRONT);