Skip to content

Commit

Permalink
better workaround for Intel GPU crash for glDrawBuffer on Linux
Browse files Browse the repository at this point in the history
fix a linux build issue
  • Loading branch information
Erwin Coumans committed Jun 28, 2014
1 parent 771a2e0 commit 063a034
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Demos3/bullet2/RagdollDemo/RagdollDemo.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define RAGDOLL_DEMO_H


#include "../../Demos/CommonRigidBodySetup.h"
#include "../../../Demos/CommonRigidBodySetup.h"
#include "../BasicDemo/BasicDemo.h"

struct BulletDemoInterface;
Expand Down
15 changes: 12 additions & 3 deletions btgui/OpenGLWindow/GLRenderToTexture.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

///See http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-14-render-to-texture/

bool gIntelLinuxglDrawBufferWorkaround=false;

#include "GLRenderToTexture.h"
#include "Bullet3Common/b3Scalar.h" // for b3Assert
GLRenderToTexture::GLRenderToTexture()
Expand Down Expand Up @@ -66,9 +68,16 @@ bool GLRenderToTexture::enable()
}
case RENDERTEXTURE_DEPTH:
{
GLenum drawBuffers[2] = { GL_COLOR_ATTACHMENT0, 0 };// GL_DEPTH_ATTACHMENT, 0};
glDrawBuffers(1, drawBuffers);
// glDrawBuffer(GL_NONE);
//Intel OpenGL driver crashes when using GL_NONE for glDrawBuffer on Linux, so use a workaround
if (gIntelLinuxglDrawBufferWorkaround)
{
GLenum drawBuffers[2] = { GL_DEPTH_ATTACHMENT,0};
glDrawBuffers(1, drawBuffers);

} else
{
glDrawBuffer(GL_NONE);
}
break;
}
default:
Expand Down
7 changes: 7 additions & 0 deletions btgui/OpenGLWindow/X11OpenGLWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <unistd.h>

#include <pthread.h>
extern bool gIntelLinuxglDrawBufferWorkaround;

GLint att[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None };
static bool forceOpenGL3 = true;
Expand Down Expand Up @@ -233,6 +234,12 @@ void X11OpenGLWindow::enableOpenGL()
}
const GLubyte* ven = glGetString(GL_VENDOR);
printf("GL_VENDOR=%s\n", ven);

if (strncmp((const char*)ven,"Intel",5)==0)
{
printf("Workaround for some crash in the Intel OpenGL driver on Linux/Ubuntu\n");
gIntelLinuxglDrawBufferWorkaround=true;
}
const GLubyte* ren = glGetString(GL_RENDERER);
printf("GL_RENDERER=%s\n",ren);
const GLubyte* ver = glGetString(GL_VERSION);
Expand Down

0 comments on commit 063a034

Please sign in to comment.