more X11/Linux debug-graphics fixes
This commit is contained in:
@@ -68,8 +68,8 @@ void MyMouseButtonCallback(int button, int state, float x, float y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int sWidth = 1050;
|
int sWidth = 800;//1050;
|
||||||
int sHeight = 768;
|
int sHeight = 600;//768;
|
||||||
GLPrimitiveRenderer* primRenderer=0;
|
GLPrimitiveRenderer* primRenderer=0;
|
||||||
//GwenOpenGL3CoreRenderer* gwenRenderer=0;
|
//GwenOpenGL3CoreRenderer* gwenRenderer=0;
|
||||||
Gwen::Renderer::Base* gwenRenderer =0;
|
Gwen::Renderer::Base* gwenRenderer =0;
|
||||||
@@ -308,7 +308,7 @@ int main()
|
|||||||
b3gDefaultOpenGLWindow* window = new b3gDefaultOpenGLWindow();
|
b3gDefaultOpenGLWindow* window = new b3gDefaultOpenGLWindow();
|
||||||
window->setKeyboardCallback(keyCallback);
|
window->setKeyboardCallback(keyCallback);
|
||||||
b3gWindowConstructionInfo wci;
|
b3gWindowConstructionInfo wci;
|
||||||
wci.m_openglVersion = 2;
|
wci.m_openglVersion = 3;
|
||||||
wci.m_width = sWidth;
|
wci.m_width = sWidth;
|
||||||
wci.m_height = sHeight;
|
wci.m_height = sHeight;
|
||||||
// wci.m_resizeCallback = MyResizeCallback;
|
// wci.m_resizeCallback = MyResizeCallback;
|
||||||
@@ -324,14 +324,25 @@ int main()
|
|||||||
printf("Exit: Error cannot extract OpenGL version from GL_VERSION string\n");
|
printf("Exit: Error cannot extract OpenGL version from GL_VERSION string\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
if (majorGlVersion>=3)
|
if (majorGlVersion>=3 && wci.m_openglVersion>=3)
|
||||||
{
|
{
|
||||||
float retinaScale = 1.f;
|
float retinaScale = 1.f;
|
||||||
|
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
|
#ifndef _WIN32
|
||||||
|
//we need glewExperimental on Linux
|
||||||
|
glewExperimental = GL_TRUE;
|
||||||
|
#endif // _WIN32
|
||||||
glewInit();
|
glewInit();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//we ned to call glGetError twice, because of some Ubuntu/Intel/OpenGL issue
|
||||||
|
|
||||||
|
GLuint err = glGetError();
|
||||||
|
err = glGetError();
|
||||||
|
assert(err==GL_NO_ERROR);
|
||||||
|
|
||||||
|
|
||||||
retinaScale = window->getRetinaScale();
|
retinaScale = window->getRetinaScale();
|
||||||
|
|
||||||
primRenderer = new GLPrimitiveRenderer(sWidth,sHeight);
|
primRenderer = new GLPrimitiveRenderer(sWidth,sHeight);
|
||||||
@@ -410,7 +421,7 @@ int main()
|
|||||||
// MSG msg;
|
// MSG msg;
|
||||||
while( !window->requestedExit() )
|
while( !window->requestedExit() )
|
||||||
{
|
{
|
||||||
if (majorGlVersion<3)
|
if (majorGlVersion<3 || wci.m_openglVersion<3)
|
||||||
{
|
{
|
||||||
saveOpenGLState(sWidth,sHeight);
|
saveOpenGLState(sWidth,sHeight);
|
||||||
}
|
}
|
||||||
@@ -503,7 +514,7 @@ int main()
|
|||||||
}
|
}
|
||||||
window->endRendering();
|
window->endRendering();
|
||||||
|
|
||||||
if (majorGlVersion<3)
|
if (majorGlVersion<3 || wci.m_openglVersion<3)
|
||||||
{
|
{
|
||||||
restoreOpenGLState();
|
restoreOpenGLState();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,26 @@
|
|||||||
|
|
||||||
///See http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-14-render-to-texture/
|
///See http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-14-render-to-texture/
|
||||||
|
|
||||||
bool gIntelLinuxglDrawBufferWorkaround=false;
|
|
||||||
|
|
||||||
#include "GLRenderToTexture.h"
|
#include "GLRenderToTexture.h"
|
||||||
#include "Bullet3Common/b3Scalar.h" // for b3Assert
|
#include "Bullet3Common/b3Scalar.h" // for b3Assert
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
bool gIntelLinuxglDrawBufferWorkaround=false;
|
||||||
|
|
||||||
GLRenderToTexture::GLRenderToTexture()
|
GLRenderToTexture::GLRenderToTexture()
|
||||||
:m_framebufferName(0)
|
:m_framebufferName(0)
|
||||||
{
|
{
|
||||||
|
const GLubyte* ven = glGetString(GL_VENDOR);
|
||||||
|
printf("ven = %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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLRenderToTexture::init(int width, int height, GLuint textureId, int renderTextureType)
|
void GLRenderToTexture::init(int width, int height, GLuint textureId, int renderTextureType)
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ struct GLRenderToTexture
|
|||||||
bool m_initialized;
|
bool m_initialized;
|
||||||
int m_renderTextureType;
|
int m_renderTextureType;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GLRenderToTexture();
|
GLRenderToTexture();
|
||||||
|
|
||||||
void init(int width, int height, GLuint textureId, int renderTextureType=RENDERTEXTURE_COLOR);
|
void init(int width, int height, GLuint textureId, int renderTextureType=RENDERTEXTURE_COLOR);
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
extern bool gIntelLinuxglDrawBufferWorkaround;
|
|
||||||
|
|
||||||
GLint att[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None };
|
GLint att[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None };
|
||||||
static bool forceOpenGL3 = true;
|
static bool forceOpenGL3 = true;
|
||||||
@@ -235,11 +234,6 @@ void X11OpenGLWindow::enableOpenGL()
|
|||||||
const GLubyte* ven = glGetString(GL_VENDOR);
|
const GLubyte* ven = glGetString(GL_VENDOR);
|
||||||
printf("GL_VENDOR=%s\n", ven);
|
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);
|
const GLubyte* ren = glGetString(GL_RENDERER);
|
||||||
printf("GL_RENDERER=%s\n",ren);
|
printf("GL_RENDERER=%s\n",ren);
|
||||||
const GLubyte* ver = glGetString(GL_VERSION);
|
const GLubyte* ver = glGetString(GL_VERSION);
|
||||||
@@ -276,7 +270,10 @@ printf("createWindow\n");
|
|||||||
|
|
||||||
m_data->m_root = DefaultRootWindow(m_data->m_dpy);
|
m_data->m_root = DefaultRootWindow(m_data->m_dpy);
|
||||||
|
|
||||||
|
if (ci.m_openglVersion < 3)
|
||||||
|
{
|
||||||
|
forceOpenGL3 = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (forceOpenGL3)
|
if (forceOpenGL3)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user