From e6057b765f480a4caba0a0e7f0d44b70e17c7824 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Sat, 10 Dec 2011 11:56:34 +0000 Subject: [PATCH] gsdx-ogl: LINUX-ONLY * Fix context creation. Get opengl working with nvidia graphics cards. git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl@4984 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSDeviceOGL.cpp | 13 ++++++++++--- plugins/GSdx/GSWnd.cpp | 32 +++++++++++++++++++++----------- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 591aafd6a7..950c83ff86 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -52,7 +52,7 @@ // glBindBufferBase(GL_UNIFORM_BUFFER, block_binding_point, some_buffer_object); // glUniformBlockBinding(program, block_index, block_binding_point); - +//#define LOUD_DEBUGGING GSDeviceOGL::GSDeviceOGL() : m_free_window(false) , m_window(NULL) @@ -179,6 +179,11 @@ bool GSDeviceOGL::Create(GSWnd* wnd) // **************************************************************** // convert // **************************************************************** + + // There isn't a default VAO in newer versions of OpenGL, so create one. + unsigned int vao = 0; + glGenVertexArrays(1,&vao); + glBindVertexArray(vao); GSInputLayout il_convert[2] = { @@ -1206,7 +1211,7 @@ void GSDeviceOGL::DebugOutputToFile(unsigned int source, unsigned int type, unsi else if(type == GL_DEBUG_TYPE_OTHER_ARB) strcpy(debType, "Other"); else - strcpy(debType, "UNKNOW"); + strcpy(debType, "UNKNOWN"); if(severity == GL_DEBUG_SEVERITY_HIGH_ARB) strcpy(debSev, "High"); @@ -1215,7 +1220,9 @@ void GSDeviceOGL::DebugOutputToFile(unsigned int source, unsigned int type, unsi else if(severity == GL_DEBUG_SEVERITY_LOW_ARB) strcpy(debSev, "Low"); - //fprintf(stderr,"Type:%s\tID:%d\tSeverity:%s\tMessage:%s\n", debType,id,debSev,message); + #ifdef LOUD_DEBUGGING + fprintf(stderr,"Type:%s\tID:%d\tSeverity:%s\tMessage:%s\n", debType,id,debSev,message); + #endif FILE* f = fopen("Debug.txt","a"); if(f) diff --git a/plugins/GSdx/GSWnd.cpp b/plugins/GSdx/GSWnd.cpp index 27aedd894a..8873ac2bcb 100644 --- a/plugins/GSdx/GSWnd.cpp +++ b/plugins/GSdx/GSWnd.cpp @@ -338,15 +338,26 @@ bool GSWnd::Attach(void* handle, bool managed) if (m_renderer != 2) { m_XDisplay = XOpenDisplay(NULL); - // Get visual information - int attrListDbl[] = { GLX_RGBA, GLX_DOUBLEBUFFER, - GLX_RED_SIZE, 8, - GLX_GREEN_SIZE, 8, - GLX_BLUE_SIZE, 8, - GLX_DEPTH_SIZE, 24, - None - }; - + if ( !m_XDisplay ) + { + fprintf( stderr, "Failed to open X display\n" ); + exit(1); + } + + // Get visual information + static int attrListDbl[] = + { + GLX_X_RENDERABLE , True, + GLX_DRAWABLE_TYPE , GLX_WINDOW_BIT, + GLX_RENDER_TYPE , GLX_RGBA_BIT, + GLX_RED_SIZE , 8, + GLX_GREEN_SIZE , 8, + GLX_BLUE_SIZE , 8, + GLX_DEPTH_SIZE , 24, + GLX_DOUBLEBUFFER , True, + None + }; + PFNGLXCHOOSEFBCONFIGPROC glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC) glXGetProcAddress((GLubyte *) "glXChooseFBConfig"); int fbcount = 0; GLXFBConfig *fbc = glXChooseFBConfig(m_XDisplay, DefaultScreen(m_XDisplay), attrListDbl, &fbcount); @@ -364,7 +375,7 @@ bool GSWnd::Attach(void* handle, bool managed) // FIXME : Request a debug context to ease opengl development // Note: don't support deprecated feature (pre openg 3.1) GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB | GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, - 0 + None }; m_context = glXCreateContextAttribsARB(m_XDisplay, fbc[0], 0, true, context_attribs); XSync( m_XDisplay, false); @@ -382,7 +393,6 @@ bool GSWnd::Attach(void* handle, bool managed) } - return true; }