Esempio n. 1
0
static void* lookupOpenGLFunctionAddress(const char* functionName, bool* success = 0)
{
    if (success && !*success)
        return 0;

    void* target = getProcAddress(functionName);
    if (target)
        return target;

    target = getProcAddress(reinterpret_cast<const char*>(makeString(functionName, "ARB").characters8()));
    if (target)
        return target;

    // FIXME: <https://webkit.org/b/143964> OpenGLShims appears to have a dead store if GLES2
    target = getProcAddress(reinterpret_cast<const char*>(makeString(functionName, "EXT").characters8()));

#if defined(GL_ES_VERSION_2_0)
    target = getProcAddress(reinterpret_cast<const char*>(makeString(functionName, "ANGLE").characters8()));
    if (target)
        return target;

    target = getProcAddress(reinterpret_cast<const char*>(makeString(functionName, "APPLE").characters8()));
#endif

    // A null address is still a failure case.
    if (!target && success)
        *success = false;

    return target;
}
Esempio n. 2
0
static void* lookupOpenGLFunctionAddress(const char* functionName, bool& success)
{
    if (!success)
        return 0;

    void* target = getProcAddress(functionName);
    if (target)
        return target;

    String fullFunctionName(functionName);
    fullFunctionName.append("ARB");
    target = getProcAddress(fullFunctionName.utf8().data());
    if (target)
        return target;

    fullFunctionName = functionName;
    fullFunctionName.append("EXT");
    target = getProcAddress(fullFunctionName.utf8().data());

    // A null address is still a failure case.
    if (!target)
        success = false;

    return target;
}
Esempio n. 3
0
static void* lookupOpenGLFunctionAddress(const char* functionName, bool* success = 0)
{
    if (success && !*success)
        return 0;

    void* target = getProcAddress(functionName);
    if (target)
        return target;

    String fullFunctionName(functionName);
    fullFunctionName.append("ARB");
    target = getProcAddress(fullFunctionName.utf8().data());
    if (target)
        return target;

    fullFunctionName = functionName;
    fullFunctionName.append("EXT");
    target = getProcAddress(fullFunctionName.utf8().data());

#if defined(GL_ES_VERSION_2_0)
    fullFunctionName = functionName;
    fullFunctionName.append("ANGLE");
    target = getProcAddress(fullFunctionName.utf8().data());

    fullFunctionName = functionName;
    fullFunctionName.append("APPLE");
    target = getProcAddress(fullFunctionName.utf8().data());
#endif

    // A null address is still a failure case.
    if (!target && success)
        *success = false;

    return target;
}
Esempio n. 4
0
void    initLinuxExtensions ()
{
                                    // GLX_SGIX_pbuffer
    glXCreateGLXPbufferSGIX  = (PFNGLXCREATEGLXPBUFFERSGIXPROC)  getProcAddress ( "glXCreateGLXPbufferSGIX" );
    glXDestroyGLXPbufferSGIX = (PFNGLXDESTROYGLXPBUFFERSGIXPROC) getProcAddress ( "glXDestroyGLXPbufferSGIX" );
    glXQueryGLXPbufferSGIX   = (PFNGLXQUERYGLXPBUFFERSGIXPROC)   getProcAddress ( "glXQueryGLXPbufferSGIX" );

                                    // GLX_SGIX_fbconfig
    glXChooseFBConfigSGIX          = (PFNGLXCHOOSEFBCONFIGSGIXPROC)          getProcAddress ( "glXChooseFBConfigSGIX" );
    glXCreateContextWithConfigSGIX = (PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) getProcAddress ( "glXCreateContextWithConfigSGIX" );
}
Esempio n. 5
0
// find pointers of OpenGL functions
static bool initGlFunctions()
{
    glGenFramebuffers = (GenFramebuffers)getProcAddress("glGenFramebuffers");
    glBindFramebuffer = (BindFramebuffer)getProcAddress("glBindFramebuffer");
    glFramebufferTexture2D = (FramebufferTexture2D)getProcAddress("glFramebufferTexture2D");
    glDeleteFramebuffers = (DeleteFramebuffers)getProcAddress("glDeleteFramebuffers");
    glGenerateMipmap = (GenerateMipmap)getProcAddress("glGenerateMipmap");

    return glGenFramebuffers && glBindFramebuffer && glFramebufferTexture2D &&
        glDeleteFramebuffers && glGenerateMipmap;
}
Esempio n. 6
0
LibX11exports *LibX11::loadExports()
{
	static void *libX11 = nullptr;
	static void *libXext = nullptr;
	static LibX11exports *libX11exports = nullptr;

	if(!libX11)
	{
		libX11 = loadLibrary("libX11.so");

		if(libX11)
		{
			libXext = loadLibrary("libXext.so");
			libX11exports = new LibX11exports(libX11, libXext);
		}
		else   // Might have failed to load due to sandboxing. Search the global scope for pre-loaded library.
		{
			if(getProcAddress(RTLD_DEFAULT, "XOpenDisplay"))
			{
				libX11exports = new LibX11exports(RTLD_DEFAULT, RTLD_DEFAULT);
			}

			libX11 = (void*)-1;   // Don't attempt loading more than once.
		}
	}

	return libX11exports;
}
Esempio n. 7
0
int vglInit(FILE * out)
{
    vgl_map_table_t * tab = __vgl_map_table;
    int missing = 0;

    while (tab->fname) {
	__extfuncptr * fptr = (__extfuncptr *)tab->fptr;

	*fptr = (__extfuncptr)getProcAddress(tab->fname);

	if (*fptr == 0) {
	    *fptr = (__extfuncptr)__vgl_missing_func;

	    if (out) {
		if (!missing) {
		    fprintf(out, "vglInit: Missing extension functions:\n", tab->fname);
		}
		fprintf(out, "  %s\n", tab->fname);
	    }

	    missing++;
	}

	tab++;
    }

    if (out && missing) {
	fprintf(out, "%d functions are missing\n", missing);
    }

    return -missing;
}
Esempio n. 8
0
void glxResolveFunctions()
{
    if (hasGLExtension(QByteArrayLiteral("GLX_MESA_swap_control")))
        glXSwapIntervalMESA = (glXSwapIntervalMESA_func) getProcAddress("glXSwapIntervalMESA");
    else
        glXSwapIntervalMESA = nullptr;
}
Esempio n. 9
0
void AbstractFunction::resolveAddress()
{
    if (state().initialized)
        return;

    state().address = getProcAddress(m_name);
    state().initialized = true;
}
void AbstractFunction::resolveAddress()
{
    auto & currentState = state();

    if (currentState.initialized)
        return;

    currentState.address = getProcAddress(m_name);
    currentState.initialized = true;
}
Esempio n. 11
0
static void *
find_gl_symbol (void *handle,
                __eglMustCastToProperFunctionPointerType (*getProcAddress) (const char *procname),
                const char *symbol_name)
{
    void *symbol = dlsym (handle, symbol_name);
    if (symbol == NULL)
        symbol = getProcAddress (symbol_name);
    return symbol;
}
Esempio n. 12
0
	template<typename ProcType> bool getProcAddress(const char * name,ProcType &proc)
	{
		void *ptr=getProcAddress(name);
		proc=(ProcType)ptr;
		if(!ptr)
		{
			processError();
			return false;
		}
		return true;
	}
Esempio n. 13
0
GLfunction getFuzzyProcAddress(const char * psz)
{
    GLfunction pProc = getProcAddress(psz);
    if (!pProc) {
        string s = string(psz)+"EXT";
        pProc = getProcAddress(s);
    }
    if (!pProc) {
        string s = string(psz)+"ARB";
        pProc = getProcAddress(s);
    }
    if (!pProc) {
        string s = string(psz)+"OES";
        pProc = getProcAddress(s);
    }
    if (!pProc) {
        pProc = invalidGLCall;
    }
    return pProc;
}
Esempio n. 14
0
	LibEGLexports *loadExports()
	{
		if(!libEGL)
		{
			#if defined(_WIN32)
				#if defined(__LP64__)
					const char *libEGL_lib[] = {"libEGL.dll", "lib64EGL_translator.dll"};
				#else
					const char *libEGL_lib[] = {"libEGL.dll", "libEGL_translator.dll"};
				#endif
			#elif defined(__ANDROID__)
				#if defined(__LP64__)
					const char *libEGL_lib[] = {"/vendor/lib64/egl/libEGL_swiftshader.so"};
				#else
					const char *libEGL_lib[] = {"/vendor/lib/egl/libEGL_swiftshader.so"};
				#endif
			#elif defined(__linux__)
				#if defined(__LP64__)
					const char *libEGL_lib[] = {"lib64EGL_translator.so", "libEGL.so.1", "libEGL.so"};
				#else
					const char *libEGL_lib[] = {"libEGL_translator.so", "libEGL.so.1", "libEGL.so"};
				#endif
			#elif defined(__APPLE__)
				#if defined(__LP64__)
					const char *libEGL_lib[] = {"lib64EGL_translator.dylib", "libEGL.so", "libEGL.dylib"};
				#else
					const char *libEGL_lib[] = {"libEGL_translator.dylib", "libEGL.so", "libEGL.dylib"};
				#endif
			#else
				#error "libEGL::loadExports unimplemented for this platform"
			#endif

			libEGL = loadLibrary(libEGL_lib, "libEGL_swiftshader");

			if(libEGL)
			{
				auto libEGL_swiftshader = (LibEGLexports *(*)())getProcAddress(libEGL, "libEGL_swiftshader");
				libEGLexports = libEGL_swiftshader();
			}
		}

		return libEGLexports;
	}
Esempio n. 15
0
void InitializeExtensions(glProc (*getProcAddress)(const char *)) {
    std::call_once(initializeExtensionsOnce, [getProcAddress] {
        const char * extensionsPtr = reinterpret_cast<const char *>(
            MBGL_CHECK_ERROR(glGetString(GL_EXTENSIONS)));

        if (!extensionsPtr)
            return;

        const std::string extensions = extensionsPtr;
        for (auto fn : ExtensionFunctionBase::functions()) {
            for (auto probe : fn->probes) {
                if (extensions.find(probe.first) != std::string::npos) {
                    fn->ptr = getProcAddress(probe.second);
                    break;
                }
            }
        }
    });
}
Esempio n. 16
0
bool    initWin32Extensions ()
{
    wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC) getProcAddress ( "wglGetExtensionsStringARB" );

    if ( wglGetExtensionsStringARB == NULL )
        return false;

    const char * exts = wglGetExtensionsStringARB ( wglGetCurrentDC () );

    if ( exts == NULL )
        return false;

    if ( strstr ( exts, "WGL_ARB_pbuffer" ) != NULL )
    {
        wglCreatePbufferARB    = (PFNWGLCREATEPBUFFERARBPROC)     wglGetProcAddress ( "wglCreatePbufferARB"    );
        wglGetPbufferDCARB     = (PFNWGLGETPBUFFERDCARBPROC)      wglGetProcAddress ( "wglGetPbufferDCARB"     );
        wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC)  wglGetProcAddress ( "wglReleasePbufferDCARB" );
        wglDestroyPbufferARB   = (PFNWGLDESTROYPBUFFERARBPROC)    wglGetProcAddress ( "wglDestroyPbufferARB"   );
        wglQueryPbufferARB     = (PFNWGLQUERYPBUFFERARBPROC)      wglGetProcAddress ( "wglQueryPbufferARB"     );
    }

    if ( strstr ( exts, "WGL_ARB_pixel_format" ) != NULL )
        wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress ( "wglChoosePixelFormatARB" );

    if ( strstr ( exts, "WGL_ARB_render_texture" ) != NULL )
    {
        wglBindTexImageARB      = (PFNWGLBINDTEXIMAGEARBPROC)     wglGetProcAddress ( "wglBindTexImageARB"     );
        wglReleaseTexImageARB   = (PFNWGLRELEASETEXIMAGEARBPROC)  wglGetProcAddress ( "wglReleaseTexImageARB"  );
        wglSetPbufferAttribARB  = (PFNWGLSETPBUFFERATTRIBARBPROC) wglGetProcAddress ( "wglSetPbufferAttribARB" );
    }

    if ( strstr ( exts, "WGL_EXT_swap_control" ) != NULL )
    {
        wglSwapIntervalEXT      = (PFNWGLSWAPINTERVALEXTPROC)       wglGetProcAddress ( "wglSwapIntervalEXT"    );
        wglGetSwapIntervalEXT   = (PFNWGLGETSWAPINTERVALEXTPROC)    wglGetProcAddress ( "wglGetSwapIntervalEXT" );
    }

    return true;
}
Esempio n. 17
0
void glxResolveFunctions()
{
    // handle OpenGL extensions functions
    glXGetProcAddress = (glXGetProcAddress_func) getProcAddress("glXGetProcAddress");
    if (glXGetProcAddress == nullptr)
        glXGetProcAddress = (glXGetProcAddress_func) getProcAddress("glXGetProcAddressARB");
    glXQueryDrawable = (glXQueryDrawable_func) getProcAddress("glXQueryDrawable");
    if (hasGLExtension(QStringLiteral("GLX_EXT_texture_from_pixmap"))) {
        glXBindTexImageEXT = (glXBindTexImageEXT_func) getProcAddress("glXBindTexImageEXT");
        glXReleaseTexImageEXT = (glXReleaseTexImageEXT_func) getProcAddress("glXReleaseTexImageEXT");
    } else {
        glXBindTexImageEXT = nullptr;
        glXReleaseTexImageEXT = nullptr;
    }
    if (hasGLExtension(QStringLiteral("GLX_MESA_copy_sub_buffer")))
        glXCopySubBuffer = (glXCopySubBuffer_func) getProcAddress("glXCopySubBufferMESA");
    else
        glXCopySubBuffer = nullptr;
    if (hasGLExtension(QStringLiteral("GLX_SGI_video_sync"))) {
        glXGetVideoSync = (glXGetVideoSync_func) getProcAddress("glXGetVideoSyncSGI");
        glXWaitVideoSync = (glXWaitVideoSync_func) getProcAddress("glXWaitVideoSyncSGI");
    } else {
        glXGetVideoSync = nullptr;
        glXWaitVideoSync = nullptr;
    }

    if (hasGLExtension(QStringLiteral("GLX_SGI_swap_control")))
        glXSwapIntervalSGI = (glXSwapIntervalSGI_func) getProcAddress("glXSwapIntervalSGI");
    else
        glXSwapIntervalSGI = nullptr;
    if (hasGLExtension(QStringLiteral("GLX_EXT_swap_control")))
        glXSwapIntervalEXT = (glXSwapIntervalEXT_func) getProcAddress("glXSwapIntervalEXT");
    else
        glXSwapIntervalEXT = nullptr;
    if (hasGLExtension(QStringLiteral("GLX_MESA_swap_control")))
        glXSwapIntervalMESA = (glXSwapIntervalMESA_func) getProcAddress("glXSwapIntervalMESA");
    else
        glXSwapIntervalMESA = nullptr;

    if (hasGLExtension(QStringLiteral("GLX_ARB_create_context")))
        glXCreateContextAttribsARB = (glXCreateContextAttribsARB_func) getProcAddress("glXCreateContextAttribsARB");
    else
        glXCreateContextAttribsARB = nullptr;
}
Esempio n. 18
0
void *Loader::load_driver(const char* kind, const char *tag,
        egl_connection_t* cnx, uint32_t mask)
{
    char driver_absolute_path[PATH_MAX];
    const char* const search1 = "/vendor/lib/egl/lib%s_%s.so";
    const char* const search2 = "/system/lib/egl/lib%s_%s.so";

    snprintf(driver_absolute_path, PATH_MAX, search1, kind, tag);
    if (access(driver_absolute_path, R_OK)) {
        snprintf(driver_absolute_path, PATH_MAX, search2, kind, tag);
        if (access(driver_absolute_path, R_OK)) {
            // this happens often, we don't want to log an error
            return 0;
        }
    }

    void* dso = dlopen(driver_absolute_path, RTLD_NOW | RTLD_LOCAL);
    if (dso == 0) {
        const char* err = dlerror();
        LOGE("load_driver(%s): %s", driver_absolute_path, err?err:"unknown");
        return 0;
    }

    LOGD("loaded %s", driver_absolute_path);

    if (mask & EGL) {
        getProcAddress = (getProcAddressType)dlsym(dso, "eglGetProcAddress");

        LOGE_IF(!getProcAddress, 
                "can't find eglGetProcAddress() in %s", driver_absolute_path);

        egl_t* egl = &cnx->egl;
        __eglMustCastToProperFunctionPointerType* curr =
            (__eglMustCastToProperFunctionPointerType*)egl;
        char const * const * api = egl_names;
        while (*api) {
            char const * name = *api;
            __eglMustCastToProperFunctionPointerType f = 
                (__eglMustCastToProperFunctionPointerType)dlsym(dso, name);
            if (f == NULL) {
                // couldn't find the entry-point, use eglGetProcAddress()
                f = getProcAddress(name);
                if (f == NULL) {
                    f = (__eglMustCastToProperFunctionPointerType)0;
                }
            }
            *curr++ = f;
            api++;
        }
    }
    
    if (mask & GLESv1_CM) {
        void *gl=&cnx->hooks[GLESv1_INDEX]->gl;
        init_api(dso, gl_names,
            (__eglMustCastToProperFunctionPointerType*)
                gl,
            getProcAddress);
    }

    if (mask & GLESv2) {
      void *gl=&cnx->hooks[GLESv2_INDEX]->gl;
      init_api(dso, gl_names,
            (__eglMustCastToProperFunctionPointerType*)
                gl,
            getProcAddress);
    }
    
    return dso;
}
Esempio n. 19
0
void RendererGL::initGLExtensions()
{
	// nullify the pointers
	glBindBufferARB           = NULL;
	glDeleteBuffersARB        = NULL;
	glGenBuffersARB           = NULL;
	glIsBufferARB             = NULL;
	glBufferDataARB           = NULL;
	glBufferSubDataARB        = NULL;
	glGetBufferSubDataARB     = NULL;
	glMapBufferARB            = NULL;
	glUnmapBufferARB          = NULL;
	glGetBufferParameterivARB = NULL;
	glGetBufferPointervARB    = NULL;
	glActiveTextureARB			= NULL;
	glClientActiveTextureARB	= NULL;

	// set the bool query storage to all false
	memset(&m_supported[0], 0, sizeof(bool)*MAX_EXTENSIONS);

	const unsigned char* ext = glGetString (GL_EXTENSIONS);
	std::string ext_str = (char*)ext;
/*
	std::ofstream extensionDump("extensions.txt");
	extensionDump << ext_str;
	extensionDump.close();
*/

	// GL_ARB_multitexture
	if(std::string::npos != ext_str.find("GL_ARB_multitexture") )
	{
		m_supported[XGL_ARB_multitexture] = true;

		/* Obtain the address of the extension entry points. */
		glActiveTextureARB		= (PFNGLACTIVETEXTUREARBPROC)	getProcAddress("glActiveTextureARB");
		glClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC) getProcAddress("glClientActiveTextureARB");
		// Load the rest IF you need them, no need to store unused function pointers, yes I am lazy as well..
/*
		glMultiTexCoord2fARB	= (PFNGLMULTITEXCOORD2FARBPROC)	getProcAddress("glMultiTexCoord2fARB");
		glMultiTexCoord1dARB = (PFNGLMULTITEXCOORD1DARBPROC) getProcAddress("glMultiTexCoord1dARB");
        glMultiTexCoord1dvARB = (PFNGLMULTITEXCOORD1DVARBPROC) getProcAddress("glMultiTexCoord1dvARB");
        glMultiTexCoord1fARB = (PFNGLMULTITEXCOORD1FARBPROC) getProcAddress("glMultiTexCoord1fARB");
        glMultiTexCoord1fvARB = (PFNGLMULTITEXCOORD1FVARBPROC) getProcAddress("glMultiTexCoord1fvARB");
        glMultiTexCoord1iARB = (PFNGLMULTITEXCOORD1IARBPROC) getProcAddress("glMultiTexCoord1iARB");
        glMultiTexCoord1ivARB = (PFNGLMULTITEXCOORD1IVARBPROC) getProcAddress("glMultiTexCoord1ivARB");
        glMultiTexCoord1sARB = (PFNGLMULTITEXCOORD1SARBPROC) getProcAddress("glMultiTexCoord1sARB");
        glMultiTexCoord1svARB = (PFNGLMULTITEXCOORD1SVARBPROC) getProcAddress("glMultiTexCoord1svARB");
        glMultiTexCoord2dARB = (PFNGLMULTITEXCOORD2DARBPROC) getProcAddress("glMultiTexCoord2dARB");
        glMultiTexCoord2dvARB = (PFNGLMULTITEXCOORD2DVARBPROC) getProcAddress("glMultiTexCoord2dvARB");
        glMultiTexCoord2fvARB = (PFNGLMULTITEXCOORD2FVARBPROC) getProcAddress("glMultiTexCoord2fvARB");
        glMultiTexCoord2iARB = (PFNGLMULTITEXCOORD2IARBPROC) getProcAddress("glMultiTexCoord2iARB");
        glMultiTexCoord2ivARB = (PFNGLMULTITEXCOORD2IVARBPROC) getProcAddress("glMultiTexCoord2ivARB");
        glMultiTexCoord2sARB = (PFNGLMULTITEXCOORD2SARBPROC) getProcAddress("glMultiTexCoord2sARB");
        glMultiTexCoord2svARB = (PFNGLMULTITEXCOORD2SVARBPROC) getProcAddress("glMultiTexCoord2svARB");
        glMultiTexCoord3dARB = (PFNGLMULTITEXCOORD3DARBPROC) getProcAddress("glMultiTexCoord3dARB");
        glMultiTexCoord3dvARB = (PFNGLMULTITEXCOORD3DVARBPROC) getProcAddress("glMultiTexCoord3dvARB");
        glMultiTexCoord3fARB = (PFNGLMULTITEXCOORD3FARBPROC) getProcAddress("glMultiTexCoord3fARB");
        glMultiTexCoord3fvARB = (PFNGLMULTITEXCOORD3FVARBPROC) getProcAddress("glMultiTexCoord3fvARB");
        glMultiTexCoord3iARB = (PFNGLMULTITEXCOORD3IARBPROC) getProcAddress("glMultiTexCoord3iARB");
        glMultiTexCoord3ivARB = (PFNGLMULTITEXCOORD3IVARBPROC) getProcAddress("glMultiTexCoord3ivARB");
        glMultiTexCoord3sARB = (PFNGLMULTITEXCOORD3SARBPROC) getProcAddress("glMultiTexCoord3sARB");
        glMultiTexCoord3svARB = (PFNGLMULTITEXCOORD3SVARBPROC) getProcAddress("glMultiTexCoord3svARB");
        glMultiTexCoord4dARB = (PFNGLMULTITEXCOORD4DARBPROC) getProcAddress("glMultiTexCoord4dARB");
        glMultiTexCoord4dvARB = (PFNGLMULTITEXCOORD4DVARBPROC) getProcAddress("glMultiTexCoord4dvARB");
        glMultiTexCoord4fARB = (PFNGLMULTITEXCOORD4FARBPROC) getProcAddress("glMultiTexCoord4fARB");
        glMultiTexCoord4fvARB = (PFNGLMULTITEXCOORD4FVARBPROC) getProcAddress("glMultiTexCoord4fvARB");
        glMultiTexCoord4iARB = (PFNGLMULTITEXCOORD4IARBPROC) getProcAddress("glMultiTexCoord4iARB");
        glMultiTexCoord4ivARB = (PFNGLMULTITEXCOORD4IVARBPROC) getProcAddress("glMultiTexCoord4ivARB");
        glMultiTexCoord4sARB = (PFNGLMULTITEXCOORD4SARBPROC) getProcAddress("glMultiTexCoord4sARB");
        glMultiTexCoord4svARB = (PFNGLMULTITEXCOORD4SVARBPROC) getProcAddress("glMultiTexCoord4svARB");
*/
    }
	
	// GL_ARB_vertex_buffer_object
	if(std::string::npos != ext_str.find("GL_ARB_vertex_buffer_object") )
	{
		m_supported[XGL_ARB_vertex_buffer_object] = true;
		glBindBufferARB           = (PFNGLBINDBUFFERARBPROC)getProcAddress("glBindBufferARB");
        glDeleteBuffersARB        = (PFNGLDELETEBUFFERSARBPROC)getProcAddress("glDeleteBuffersARB");
        glGenBuffersARB           = (PFNGLGENBUFFERSARBPROC)getProcAddress("glGenBuffersARB");
        glIsBufferARB             = (PFNGLISBUFFERARBPROC)getProcAddress("glIsBufferARB");
        glBufferDataARB           = (PFNGLBUFFERDATAARBPROC)getProcAddress("glBufferDataARB");
        glBufferSubDataARB        = (PFNGLBUFFERSUBDATAARBPROC)getProcAddress("glBufferSubDataARB");
        glGetBufferSubDataARB     = (PFNGLGETBUFFERSUBDATAARBPROC)getProcAddress("glGetBufferSubDataARB");
        glMapBufferARB            = (PFNGLMAPBUFFERARBPROC)getProcAddress("glMapBufferARB");
        glUnmapBufferARB          = (PFNGLUNMAPBUFFERARBPROC)getProcAddress("glUnmapBufferARB");
        glGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC)getProcAddress("glGetBufferParameterivARB");
        glGetBufferPointervARB    = (PFNGLGETBUFFERPOINTERVARBPROC)getProcAddress("glGetBufferPointervARB");
	}
}
    void GLESSupport::initialiseExtensions(void)
    {
        // Set version string
        const GLubyte* pcVer = glGetString(GL_VERSION);

        assert(pcVer && "Problems getting GL version string using glGetString");

        String tmpStr = (const char*)pcVer;
        LogManager::getSingleton().logMessage("GL_VERSION = " + tmpStr);
        mVersion = tmpStr.substr(0, tmpStr.find(" "));

        // Get vendor
        const GLubyte* pcVendor = glGetString(GL_VENDOR);
        tmpStr = (const char*)pcVendor;
        LogManager::getSingleton().logMessage("GL_VENDOR = " + tmpStr);
        mVendor = tmpStr.substr(0, tmpStr.find(" "));

        // Get renderer
        const GLubyte* pcRenderer = glGetString(GL_RENDERER);
        tmpStr = (const char*)pcRenderer;
        LogManager::getSingleton().logMessage("GL_RENDERER = " + tmpStr);

        // Set extension list
        std::stringstream ext;
        String str;

        const GLubyte* pcExt = glGetString(GL_EXTENSIONS);
        LogManager::getSingleton().logMessage("GL_EXTENSIONS = " + String((const char*)pcExt));

        assert(pcExt && "Problems getting GL extension string using glGetString");

        ext << pcExt;

        while (ext >> str)
        {
			LogManager::getSingleton().logMessage("EXT:" + str);
            extensionList.insert(str);
        }


		// Get function pointers on platforms that doesn't have prototypes
#ifndef GL_GLEXT_PROTOTYPES

		// define the GL types if they are not defined
#	ifndef PFNGLISRENDERBUFFEROES

		// GL_OES_Framebuffer_object

		typedef GLboolean (GL_APIENTRY *PFNGLISRENDERBUFFEROES)(GLuint renderbuffer);
		typedef void (GL_APIENTRY *PFNGLBINDRENDERBUFFEROES)(GLenum target, GLuint renderbuffer);
		typedef void (GL_APIENTRY *PFNGLDELETERENDERBUFFERSOES)(GLsizei n, const GLuint *renderbuffers);
		typedef void (GL_APIENTRY *PFNGLGENRENDERBUFFERSOES)(GLsizei n, GLuint *renderbuffers);
		typedef void (GL_APIENTRY *PFNGLRENDERBUFFERSTORAGEOES)(GLenum target, GLenum internalformat,GLsizei width, GLsizei height);
		typedef void (GL_APIENTRY *PFNGLGETRENDERBUFFERPARAMETERIVOES)(GLenum target, GLenum pname, GLint* params);
		typedef GLboolean (GL_APIENTRY *PFNGLISFRAMEBUFFEROES)(GLuint framebuffer);
		typedef void (GL_APIENTRY *PFNGLBINDFRAMEBUFFEROES)(GLenum target, GLuint framebuffer);
		typedef void (GL_APIENTRY *PFNGLDELETEFRAMEBUFFERSOES)(GLsizei n, const GLuint *framebuffers);
		typedef void (GL_APIENTRY *PFNGLGENFRAMEBUFFERSOES)(GLsizei n, GLuint *framebuffers);
		typedef GLenum (GL_APIENTRY *PFNGLCHECKFRAMEBUFFERSTATUSOES)(GLenum target);
		typedef void (GL_APIENTRY *PFNGLFRAMEBUFFERTEXTURE2DOES)(GLenum target, GLenum attachment,GLenum textarget, GLuint texture,GLint level);
		typedef void (GL_APIENTRY *PFNGLFRAMEBUFFERRENDERBUFFEROES)(GLenum target, GLenum attachment,GLenum renderbuffertarget, GLuint renderbuffer);
		typedef void (GL_APIENTRY *PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVOES)(GLenum target, GLenum attachment,GLenum pname, GLint *params);
		typedef void (GL_APIENTRY *PFNGLGENERATEMIPMAPOES)(GLenum target);

		typedef void (GL_APIENTRY *PFNGLBLENDEQUATIONOES)(GLenum mode);
		typedef void (GL_APIENTRY *PFNGLBLENDFUNCSEPARATEOES)(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
		typedef void (GL_APIENTRY *PFNGLBLENDEQUATIONSEPARATEOES)(GLenum modeRGB, GLenum modeAlpha);

        typedef void* (GL_APIENTRY *PFNGLMAPBUFFEROES)(GLenum target, GLenum access);
        typedef GLboolean (GL_APIENTRY *PFNGLUNMAPBUFFEROES)(GLenum target);

		// GL_OES_point_size_array
		typedef void (GL_APIENTRY *PFNGLPOINTSIZEPOINTEROES)(GLenum type, GLsizei stride, const void *ptr );
#	endif

        glIsRenderbufferOES = (PFNGLISRENDERBUFFEROES)getProcAddress("glIsRenderbufferOES");
        glBindRenderbufferOES = (PFNGLBINDRENDERBUFFEROES)getProcAddress("glBindRenderbufferOES");
        glDeleteRenderbuffersOES = (PFNGLDELETERENDERBUFFERSOES)getProcAddress("glDeleteRenderbuffersOES");
        glGenRenderbuffersOES = (PFNGLGENRENDERBUFFERSOES)getProcAddress("glGenRenderbuffersOES");
        glRenderbufferStorageOES = (PFNGLRENDERBUFFERSTORAGEOES)getProcAddress("glRenderbufferStorageOES");
        glGetRenderbufferParameterivOES = (PFNGLGETRENDERBUFFERPARAMETERIVOES)getProcAddress("glGetRenderbufferParameterivOES");
        glIsFramebufferOES = (PFNGLISFRAMEBUFFEROES)getProcAddress("glIsFramebufferOES");
        glBindFramebufferOES = (PFNGLBINDFRAMEBUFFEROES)getProcAddress("glBindFramebufferOES");
        glDeleteFramebuffersOES = (PFNGLDELETEFRAMEBUFFERSOES)getProcAddress("glDeleteFramebuffersOES");
        glGenFramebuffersOES = (PFNGLGENFRAMEBUFFERSOES)getProcAddress("glGenFramebuffersOES");
        glCheckFramebufferStatusOES = (PFNGLCHECKFRAMEBUFFERSTATUSOES)getProcAddress("glCheckFramebufferStatusOES");
        glFramebufferRenderbufferOES = (PFNGLFRAMEBUFFERRENDERBUFFEROES)getProcAddress("glFramebufferRenderbufferOES");
        glFramebufferTexture2DOES = (PFNGLFRAMEBUFFERTEXTURE2DOES)getProcAddress("glFramebufferTexture2DOES");
        glGetFramebufferAttachmentParameterivOES = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVOES)getProcAddress("glGetFramebufferAttachmentParameterivOES");
        glGenerateMipmapOES = (PFNGLGENERATEMIPMAPOES)getProcAddress("glGenerateMipmapOES");

		glBlendEquationOES = (PFNGLBLENDEQUATIONOES)getProcAddress("glBlendEquationOES");
		glBlendFuncSeparateOES = (PFNGLBLENDFUNCSEPARATEOES)getProcAddress("glBlendFuncSeparateOES");
		glBlendEquationSeparateOES = (PFNGLBLENDEQUATIONSEPARATEOES)getProcAddress("glBlendEquationSeparateOES");

        glMapBufferOES = (PFNGLMAPBUFFEROES)getProcAddress("glMapBufferOES");
        glUnmapBufferOES = (PFNGLUNMAPBUFFEROES)getProcAddress("glUnmapBufferOES");
#endif
    }
Esempio n. 21
0
void
OSGLContext_x11::initGLXData(OSGLContext_glx_data* glxInfo)
{
    //Sets all bits to 0
    memset( glxInfo->_imp.get(), 0, sizeof(OSGLContext_glx_dataPrivate) );

    XInitThreads();
    glxInfo->_imp->x11.display = XOpenDisplay(NULL);
    if (!glxInfo->_imp->x11.display) {
        throw std::runtime_error("X11: Failed to open display");
    }
    glxInfo->_imp->x11.screen = DefaultScreen(glxInfo->_imp->x11.display);
    glxInfo->_imp->x11.root = RootWindow(glxInfo->_imp->x11.display, glxInfo->_imp->x11.screen);
    glxInfo->_imp->x11.context = XUniqueContext();


    const char* sonames[] =
    {
#if defined(__CYGWIN__)
        "libGL-1.so",
#else
        "libGL.so.1",
        "libGL.so",
#endif
        NULL
    };

    for (int i = 0; sonames[i]; ++i) {
        glxInfo->_imp->handle = dlopen(sonames[i], RTLD_LAZY | RTLD_GLOBAL);
        if (glxInfo->_imp->handle) {
            break;
        }
    }

    if (!glxInfo->_imp->handle) {
        throw std::runtime_error("GLX: Failed to load GLX");
    }

    glxInfo->_imp->GetFBConfigs = (PFNGLXGETFBCONFIGSPROC)dlsym(glxInfo->_imp->handle, "glXGetFBConfigs");
    glxInfo->_imp->GetFBConfigAttrib = (PFNGLXGETFBCONFIGATTRIBPROC)dlsym(glxInfo->_imp->handle, "glXGetFBConfigAttrib");
    glxInfo->_imp->GetClientString = (PFNGLXGETCLIENTSTRINGPROC)dlsym(glxInfo->_imp->handle, "glXGetClientString");
    glxInfo->_imp->QueryExtension = (PFNGLXQUERYEXTENSIONPROC)dlsym(glxInfo->_imp->handle, "glXQueryExtension");
    glxInfo->_imp->QueryVersion = (PFNGLXQUERYVERSIONPROC)dlsym(glxInfo->_imp->handle, "glXQueryVersion");
    glxInfo->_imp->DestroyContext = (PFNGLXDESTROYCONTEXTPROC)dlsym(glxInfo->_imp->handle, "glXDestroyContext");
    glxInfo->_imp->MakeCurrent = (PFNGLXMAKECURRENTPROC)dlsym(glxInfo->_imp->handle, "glXMakeCurrent");
    glxInfo->_imp->SwapBuffers = (PFNGLXSWAPBUFFERSPROC)dlsym(glxInfo->_imp->handle, "glXSwapBuffers");
    glxInfo->_imp->QueryExtensionsString = (PFNGLXQUERYEXTENSIONSSTRINGPROC)dlsym(glxInfo->_imp->handle, "glXQueryExtensionsString");
    glxInfo->_imp->CreateNewContext = (PFNGLXCREATENEWCONTEXTPROC)dlsym(glxInfo->_imp->handle, "glXCreateNewContext");
    glxInfo->_imp->CreateWindow = (PFNGLXCREATEWINDOWPROC)dlsym(glxInfo->_imp->handle, "glXCreateWindow");
    glxInfo->_imp->DestroyWindow = (PFNGLXDESTROYWINDOWPROC)dlsym(glxInfo->_imp->handle, "glXDestroyWindow");
    glxInfo->_imp->GetProcAddress = (PFNGLXGETPROCADDRESSPROC)dlsym(glxInfo->_imp->handle, "glXGetProcAddress");
    glxInfo->_imp->GetProcAddressARB = (PFNGLXGETPROCADDRESSPROC)dlsym(glxInfo->_imp->handle, "glXGetProcAddressARB");
    glxInfo->_imp->GetVisualFromFBConfig = (PFNGLXGETVISUALFROMFBCONFIGPROC)dlsym(glxInfo->_imp->handle, "glXGetVisualFromFBConfig");
    glxInfo->_imp->MakeContextCurrent = (PFNGLXMAKECONTEXTCURRENTPROC)dlsym(glxInfo->_imp->handle, "glXMakeContextCurrent");
    glxInfo->_imp->IsDirect = (PFNGLXISDIRECT)dlsym(glxInfo->_imp->handle, "glXIsDirect");

    if ( !glxInfo->_imp->QueryExtension(glxInfo->_imp->x11.display, &glxInfo->_imp->errorBase, &glxInfo->_imp->eventBase) ) {
        throw std::runtime_error("GLX: GLX extension not found");
    }

    if ( !glxInfo->_imp->QueryVersion(glxInfo->_imp->x11.display, &glxInfo->_imp->major, &glxInfo->_imp->minor) ) {
        throw std::runtime_error("GLX: Failed to query GLX version");
    }

    if ( (glxInfo->_imp->major == 1) && (glxInfo->_imp->minor < 3) ) {
        throw std::runtime_error("GLX: GLX version 1.3 is required");
    }

    if ( extensionSupported(glxInfo, "GLX_EXT_swap_control") ) {
        glxInfo->_imp->SwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)getProcAddress(glxInfo, "glXSwapIntervalEXT");
        if (glxInfo->_imp->SwapIntervalEXT) {
            glxInfo->_imp->EXT_swap_control = GL_TRUE;
        }
    }

    if ( extensionSupported(glxInfo, "GLX_SGI_swap_control") ) {
        glxInfo->_imp->SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)getProcAddress(glxInfo, "glXSwapIntervalSGI");

        if (glxInfo->_imp->SwapIntervalSGI) {
            glxInfo->_imp->SGI_swap_control = GL_TRUE;
        }
    }

    if ( extensionSupported(glxInfo, "GLX_MESA_swap_control") ) {
        glxInfo->_imp->SwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)getProcAddress(glxInfo, "glXSwapIntervalMESA");

        if (glxInfo->_imp->SwapIntervalMESA) {
            glxInfo->_imp->MESA_swap_control = GL_TRUE;
        }
    }

    if ( extensionSupported(glxInfo, "GLX_MESA_query_renderer") ) {
        glxInfo->_imp->QueryRendererIntegerMESA = (PFNGLXQUERYRENDERERINTEGERMESA)getProcAddress(glxInfo, "glXQueryRendererIntegerMESA");
        glxInfo->_imp->QueryCurrentRendererIntegerMESA = (PFNGLXQUERYCURRENTRENDERERINTEGERMESA)getProcAddress(glxInfo, "glXQueryCurrentRendererIntegerMESA");
        glxInfo->_imp->QueryRendererStringMesa = (PFNGLXQUERYRENDERERSTRINGMESA)getProcAddress(glxInfo, "glXQueryRendererStringMESA");
        glxInfo->_imp->QueryCurrentRendererStringMesa = (PFNGLXQUERYCURRENTRENDERERSTRINGMESA)getProcAddress(glxInfo, "glXQueryCurrentRendererStringMESA");
        if (glxInfo->_imp->QueryRendererIntegerMESA) {
            glxInfo->_imp->MESA_query_renderer = GL_TRUE;
        }
    }

    if ( extensionSupported(glxInfo, "GLX_ARB_multisample") ) {
        glxInfo->_imp->ARB_multisample = GL_TRUE;
    }

    if ( extensionSupported(glxInfo, "GLX_ARB_framebuffer_sRGB") ) {
        glxInfo->_imp->ARB_framebuffer_sRGB = GL_TRUE;
    }

    if ( extensionSupported(glxInfo, "GLX_EXT_framebuffer_sRGB") ) {
        glxInfo->_imp->EXT_framebuffer_sRGB = GL_TRUE;
    }

    if ( extensionSupported(glxInfo, "GLX_ARB_create_context") ) {
        glxInfo->_imp->CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)getProcAddress(glxInfo, "glXCreateContextAttribsARB");

        if (glxInfo->_imp->CreateContextAttribsARB) {
            glxInfo->_imp->ARB_create_context = GL_TRUE;
        }
    }

    if ( extensionSupported(glxInfo, "GLX_ARB_create_context_robustness") ) {
        glxInfo->_imp->ARB_create_context_robustness = GL_TRUE;
    }

    if ( extensionSupported(glxInfo, "GLX_ARB_create_context_profile") ) {
        glxInfo->_imp->ARB_create_context_profile = GL_TRUE;
    }

    if ( extensionSupported(glxInfo, "GLX_EXT_create_context_es2_profile") ) {
        glxInfo->_imp->EXT_create_context_es2_profile = GL_TRUE;
    }

    if ( extensionSupported(glxInfo, "GLX_ARB_context_flush_control") ) {
        glxInfo->_imp->ARB_context_flush_control = GL_TRUE;
    }
} // initGLXData
Esempio n. 22
0
	void GL::init()
	{
		static bool init = false;
		const GLubyte* str;
		if( init )
			return;
		init = true;

		/* version check */
		str = glGetString( GL_VERSION );
		parseVersion( ( const char* ) str, &_glmajor, &_glminor );
		str = glGetString( GL_SHADING_LANGUAGE_VERSION );
		parseVersion( ( const char* ) str, &_glslmajor, &_glslminor );

		if( _glmajor < 2  || ( _glmajor == 2 && _glminor == 0 ) ) {
			std::cerr << "GL Version too old, at least GL 2.1 is needed" << std::endl;
			std::exit( EXIT_FAILURE );
		}

		if( _glslmajor == 1 && _glslminor < 20 ) {
			std::cerr << "GLSL Version too old, at least GLSL 1.20 is needed" << std::endl;
			std::exit( EXIT_FAILURE );
		}

		/* extensions check */
		if( _glmajor > 2 ) {
			int numext;
			glGetIntegerv( GL_NUM_EXTENSIONS, &numext );
			for( int i = 0; i < numext; i++ ) {
				_extensions.push_back( ( const char* ) glGetStringi( GL_EXTENSIONS, i ) );
			}
		} else {
			String cvtstr( ( const char* ) glGetString( GL_EXTENSIONS ) );
			cvtstr.tokenize( _extensions, ' ' );
		}

		if( existsExtension( "GL_ARB_vertex_array_object" ) || ( _glmajor > 2 || ( _glmajor == 2 && _glminor >= 1 ) ) ) {
			glGenVertexArrays = ( void (*)( GLsizei, GLuint* ) ) getProcAddress( "glGenVertexArrays" );
			glDeleteVertexArrays = ( void (*)( GLsizei, const GLuint* ) ) getProcAddress( "glDeleteVertexArrays" );
			glBindVertexArray = ( void (*)( GLuint ) ) getProcAddress( "glBindVertexArray" );
			glIsVertexArray = ( GLboolean (*)( GLuint ) ) getProcAddress( "glIsVertexArray" );
		} else if( existsExtension( "GL_APPLE_vertex_array_object" ) ) {
			glGenVertexArrays = ( void (*)( GLsizei, GLuint* ) ) getProcAddress( "glGenVertexArraysAPPLE" );
			glDeleteVertexArrays = ( void (*)( GLsizei, const GLuint* ) ) getProcAddress( "glDeleteVertexArraysAPPLE" );
			glBindVertexArray = ( void (*)( GLuint ) ) getProcAddress( "glBindVertexArrayAPPLE" );
			glIsVertexArray = ( GLboolean (*)( GLuint ) ) getProcAddress( "glIsVertexArrayAPPLE" );
		} else {
			std::cerr << "GL vertex array object extension missing" << std::endl;
			std::exit( EXIT_FAILURE );
		}

		if( !existsExtension( "GL_ARB_texture_non_power_of_two" ) && _glmajor <= 2 ) {
			std::cerr << "GL texture non power of two extension missing" << std::endl;
			std::exit( EXIT_FAILURE );
		}

		if( existsExtension( "GL_EXT_framebuffer_object" ) || existsExtension( "GL_ARB_framebuffer_object" ) || _glmajor > 2 ) {
			glBindRenderbuffer = ( void (*)( GLenum target, GLuint renderbuffer) ) getProcAddress( "glBindRenderbuffer" );
			glDeleteRenderbuffers = ( void (*)( GLsizei n, const GLuint *renderbuffers) ) getProcAddress( "glDeleteRenderbuffers" );
			glGenRenderbuffers = ( void (*)( GLsizei n, GLuint *renderbuffers) ) getProcAddress( "glGenRenderbuffers" );
			glRenderbufferStorage = ( void (*)( GLenum target, GLenum internalformat, GLsizei width, GLsizei height) ) getProcAddress( "glRenderbufferStorage" );

			glBindFramebuffer = ( void (*)( GLenum target, GLuint framebuffer ) ) getProcAddress( "glBindFramebuffer" );
			glDeleteFramebuffers = ( void (*)( GLsizei n, const GLuint *framebuffers ) ) getProcAddress( "glDeleteFramebuffers" );
			glGenFramebuffers = ( void (*)( GLsizei n, GLuint *framebuffers ) ) getProcAddress( "glGenFramebuffers" );

			glFramebufferTexture1D = ( void (*)( GLenum target,  GLenum attachment,  GLenum textarget, GLuint texture, GLint level ) ) getProcAddress( "glFramebufferTexture1D" );
			glFramebufferTexture2D = ( void (*)( GLenum target,  GLenum attachment,  GLenum textarget, GLuint texture, GLint level ) ) getProcAddress( "glFramebufferTexture2D" );
			glFramebufferTexture3D = ( void (*)( GLenum target,  GLenum attachment,  GLenum textarget, GLuint texture, GLint level, GLint zoffset ) ) getProcAddress( "glFramebufferTexture3D" );

			glFramebufferRenderbuffer = ( void (*)( GLenum target,  GLenum attachment,  GLenum renderbuffertarget, GLuint renderbuffer) ) getProcAddress( "glFramebufferRenderbuffer" );
		} else {
			std::cerr << "GL framebuffer extension missing" << std::endl;
			std::exit( EXIT_FAILURE );
		}

	}
Esempio n. 23
0
// Initialize GLX
//
GLFWbool _glfwInitGLX(void)
{
    int i;
    const char* sonames[] =
    {
#if defined(__CYGWIN__)
        "libGL-1.so",
#else
        "libGL.so.1",
        "libGL.so",
#endif
        NULL
    };

    for (i = 0;  sonames[i];  i++)
    {
        _glfw.glx.handle = dlopen(sonames[i], RTLD_LAZY | RTLD_GLOBAL);
        if (_glfw.glx.handle)
            break;
    }

    if (!_glfw.glx.handle)
    {
        _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: Failed to load GLX");
        return GLFW_FALSE;
    }

    _glfw.glx.GetFBConfigs =
        dlsym(_glfw.glx.handle, "glXGetFBConfigs");
    _glfw.glx.GetFBConfigAttrib =
        dlsym(_glfw.glx.handle, "glXGetFBConfigAttrib");
    _glfw.glx.GetClientString =
        dlsym(_glfw.glx.handle, "glXGetClientString");
    _glfw.glx.QueryExtension =
        dlsym(_glfw.glx.handle, "glXQueryExtension");
    _glfw.glx.QueryVersion =
        dlsym(_glfw.glx.handle, "glXQueryVersion");
    _glfw.glx.DestroyContext =
        dlsym(_glfw.glx.handle, "glXDestroyContext");
    _glfw.glx.MakeCurrent =
        dlsym(_glfw.glx.handle, "glXMakeCurrent");
    _glfw.glx.SwapBuffers =
        dlsym(_glfw.glx.handle, "glXSwapBuffers");
    _glfw.glx.QueryExtensionsString =
        dlsym(_glfw.glx.handle, "glXQueryExtensionsString");
    _glfw.glx.CreateNewContext =
        dlsym(_glfw.glx.handle, "glXCreateNewContext");
    _glfw.glx.CreateWindow =
        dlsym(_glfw.glx.handle, "glXCreateWindow");
    _glfw.glx.DestroyWindow =
        dlsym(_glfw.glx.handle, "glXDestroyWindow");
    _glfw.glx.GetProcAddress =
        dlsym(_glfw.glx.handle, "glXGetProcAddress");
    _glfw.glx.GetProcAddressARB =
        dlsym(_glfw.glx.handle, "glXGetProcAddressARB");
    _glfw.glx.GetVisualFromFBConfig =
        dlsym(_glfw.glx.handle, "glXGetVisualFromFBConfig");

    if (!glXQueryExtension(_glfw.x11.display,
                           &_glfw.glx.errorBase,
                           &_glfw.glx.eventBase))
    {
        _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: GLX extension not found");
        return GLFW_FALSE;
    }

    if (!glXQueryVersion(_glfw.x11.display, &_glfw.glx.major, &_glfw.glx.minor))
    {
        _glfwInputError(GLFW_API_UNAVAILABLE,
                        "GLX: Failed to query GLX version");
        return GLFW_FALSE;
    }

    if (_glfw.glx.major == 1 && _glfw.glx.minor < 3)
    {
        _glfwInputError(GLFW_API_UNAVAILABLE,
                        "GLX: GLX version 1.3 is required");
        return GLFW_FALSE;
    }

    if (extensionSupported("GLX_EXT_swap_control"))
    {
        _glfw.glx.SwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)
            getProcAddress("glXSwapIntervalEXT");

        if (_glfw.glx.SwapIntervalEXT)
            _glfw.glx.EXT_swap_control = GLFW_TRUE;
    }

    if (extensionSupported("GLX_SGI_swap_control"))
    {
        _glfw.glx.SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)
            getProcAddress("glXSwapIntervalSGI");

        if (_glfw.glx.SwapIntervalSGI)
            _glfw.glx.SGI_swap_control = GLFW_TRUE;
    }

    if (extensionSupported("GLX_MESA_swap_control"))
    {
        _glfw.glx.SwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)
            getProcAddress("glXSwapIntervalMESA");

        if (_glfw.glx.SwapIntervalMESA)
            _glfw.glx.MESA_swap_control = GLFW_TRUE;
    }

    if (extensionSupported("GLX_ARB_multisample"))
        _glfw.glx.ARB_multisample = GLFW_TRUE;

    if (extensionSupported("GLX_ARB_framebuffer_sRGB"))
        _glfw.glx.ARB_framebuffer_sRGB = GLFW_TRUE;

    if (extensionSupported("GLX_EXT_framebuffer_sRGB"))
        _glfw.glx.EXT_framebuffer_sRGB = GLFW_TRUE;

    if (extensionSupported("GLX_ARB_create_context"))
    {
        _glfw.glx.CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)
            getProcAddress("glXCreateContextAttribsARB");

        if (_glfw.glx.CreateContextAttribsARB)
            _glfw.glx.ARB_create_context = GLFW_TRUE;
    }

    if (extensionSupported("GLX_ARB_create_context_robustness"))
        _glfw.glx.ARB_create_context_robustness = GLFW_TRUE;

    if (extensionSupported("GLX_ARB_create_context_profile"))
        _glfw.glx.ARB_create_context_profile = GLFW_TRUE;

    if (extensionSupported("GLX_EXT_create_context_es2_profile"))
        _glfw.glx.EXT_create_context_es2_profile = GLFW_TRUE;

    if (extensionSupported("GLX_ARB_context_flush_control"))
        _glfw.glx.ARB_context_flush_control = GLFW_TRUE;

    return GLFW_TRUE;
}
void *Loader::load_driver(const char* kind, const char *tag,
        egl_connection_t* cnx, uint32_t mask)
{
    char driver_absolute_path[PATH_MAX];
    const char* const search1 = "/vendor/lib/egl/lib%s_%s.so";
    const char* const search2 = "/system/lib/egl/lib%s_%s.so";

    snprintf(driver_absolute_path, PATH_MAX, search1, kind, tag);
    if (access(driver_absolute_path, R_OK)) {
        snprintf(driver_absolute_path, PATH_MAX, search2, kind, tag);
        if (access(driver_absolute_path, R_OK)) {
            // this happens often, we don't want to log an error
            return 0;
        }
    }

    void* dso = dlopen(driver_absolute_path, RTLD_NOW | RTLD_LOCAL);
    if (dso == 0) {
        const char* err = dlerror();
        ALOGE("load_driver(%s): %s", driver_absolute_path, err?err:"unknown");
        return 0;
    }

    ALOGD("loaded %s", driver_absolute_path);

    if (mask & EGL) {
        getProcAddress = (getProcAddressType)dlsym(dso, "eglGetProcAddress");

        ALOGE_IF(!getProcAddress, 
                "can't find eglGetProcAddress() in %s", driver_absolute_path);

#ifdef SYSTEMUI_PBSIZE_HACK
#warning "SYSTEMUI_PBSIZE_HACK enabled"
        /*
         * TODO: replace SYSTEMUI_PBSIZE_HACK by something less hackish
         *
         * Here we adjust the PB size from its default value to 512KB which
         * is the minimum acceptable for the systemui process.
         * We do this on low-end devices only because it allows us to enable
         * h/w acceleration in the systemui process while keeping the
         * memory usage down.
         *
         * Obviously, this is the wrong place and wrong way to make this
         * adjustment, but at the time of this writing this was the safest
         * solution.
         */
        const char *cmdline = getProcessCmdline();
        if (strstr(cmdline, "systemui")) {
            void *imgegl = dlopen("/vendor/lib/libIMGegl.so", RTLD_LAZY);
            if (imgegl) {
                unsigned int *PVRDefaultPBS =
                        (unsigned int *)dlsym(imgegl, "PVRDefaultPBS");
                if (PVRDefaultPBS) {
                    ALOGD("setting default PBS to 512KB, was %d KB", *PVRDefaultPBS / 1024);
                    *PVRDefaultPBS = 512*1024;
                }
            }
        }
#endif

        egl_t* egl = &cnx->egl;
        __eglMustCastToProperFunctionPointerType* curr =
            (__eglMustCastToProperFunctionPointerType*)egl;
        char const * const * api = egl_names;
        while (*api) {
            char const * name = *api;
            __eglMustCastToProperFunctionPointerType f = 
                (__eglMustCastToProperFunctionPointerType)dlsym(dso, name);
            if (f == NULL) {
                // couldn't find the entry-point, use eglGetProcAddress()
                f = getProcAddress(name);
                if (f == NULL) {
                    f = (__eglMustCastToProperFunctionPointerType)0;
                }
            }
            *curr++ = f;
            api++;
        }
    }
    
    if (mask & GLESv1_CM) {
        init_api(dso, gl_names,
            (__eglMustCastToProperFunctionPointerType*)
                &cnx->hooks[egl_connection_t::GLESv1_INDEX]->gl,
            getProcAddress);
    }

    if (mask & GLESv2) {
      init_api(dso, gl_names,
            (__eglMustCastToProperFunctionPointerType*)
                &cnx->hooks[egl_connection_t::GLESv2_INDEX]->gl,
            getProcAddress);
    }
    
    return dso;
}
Esempio n. 25
0
bool S60EglExtensions::initialize()
{
    const bool endpoint =
                getProcAddress("eglCreateEndpointNOK", m_eglCreateEndpointNOK)
             && getProcAddress("eglDestroyEndpointNOK", m_eglDestroyEndpointNOK)
             && getProcAddress("eglGetEndpointAttribNOK", m_eglGetEndpointAttribNOK)
             && getProcAddress("eglSetEndpointAttribNOK", m_eglSetEndpointAttribNOK)
             && getProcAddress("eglAcquireImageNOK", m_eglAcquireImageNOK)
             && getProcAddress("eglReleaseImageNOK", m_eglReleaseImageNOK)
             && getProcAddress("eglGetEndpointDirtyAreaNOK", m_eglGetEndpointDirtyAreaNOK)
             && getProcAddress("eglEndpointRequestNotificationNOK", m_eglEndpointRequestNotificationNOK)
             && getProcAddress("eglEndpointCancelNotificationNOK", m_eglEndpointCancelNotificationNOK)
             && getProcAddress("eglDestroyImageKHR", m_eglDestroyImageKHR);

    bool gl = true;
#ifndef QT_NO_OPENGL
    gl = getProcAddress("glEGLImageTargetTexture2DOES", m_glEGLImageTargetTexture2DOES);
#endif

    bool vg = true;
#ifndef QT_NO_OPENVG
    vg = getProcAddress("vgCreateEGLImageTargetKHR", m_vgCreateEGLImageTargetKHR);
#endif

    return (endpoint && gl && vg);
}
Esempio n. 26
0
LibX11exports::LibX11exports(void *libX11, void *libXext)
{
	XOpenDisplay = (Display *(*)(char*))getProcAddress(libX11, "XOpenDisplay");
	XGetWindowAttributes = (Status (*)(Display*, Window, XWindowAttributes*))getProcAddress(libX11, "XGetWindowAttributes");
	XDefaultScreenOfDisplay = (Screen *(*)(Display*))getProcAddress(libX11, "XDefaultScreenOfDisplay");
	XWidthOfScreen = (int (*)(Screen*))getProcAddress(libX11, "XWidthOfScreen");
	XHeightOfScreen = (int (*)(Screen*))getProcAddress(libX11, "XHeightOfScreen");
	XPlanesOfScreen = (int (*)(Screen*))getProcAddress(libX11, "XPlanesOfScreen");
	XDefaultGC = (GC (*)(Display*, int))getProcAddress(libX11, "XDefaultGC");
	XDefaultDepth = (int (*)(Display*, int))getProcAddress(libX11, "XDefaultDepth");
	XMatchVisualInfo = (Status (*)(Display*, int, int, int, XVisualInfo*))getProcAddress(libX11, "XMatchVisualInfo");
	XDefaultVisual = (Visual *(*)(Display*, int screen_number))getProcAddress(libX11, "XDefaultVisual");
	XSetErrorHandler = (int (*(*)(int (*)(Display*, XErrorEvent*)))(Display*, XErrorEvent*))getProcAddress(libX11, "XSetErrorHandler");
	XSync = (int (*)(Display*, Bool))getProcAddress(libX11, "XSync");
	XCreateImage = (XImage *(*)(Display*, Visual*, unsigned int, int, int, char*, unsigned int, unsigned int, int, int))getProcAddress(libX11, "XCreateImage");
	XCloseDisplay = (int (*)(Display*))getProcAddress(libX11, "XCloseDisplay");
	XPutImage = (int (*)(Display*, Drawable, GC, XImage*, int, int, int, int, unsigned int, unsigned int))getProcAddress(libX11, "XPutImage");

	XShmQueryExtension = (Bool (*)(Display*))getProcAddress(libXext, "XShmQueryExtension");
	XShmCreateImage = (XImage *(*)(Display*, Visual*, unsigned int, int, char*, XShmSegmentInfo*, unsigned int, unsigned int))getProcAddress(libXext, "XShmCreateImage");
	XShmAttach = (Bool (*)(Display*, XShmSegmentInfo*))getProcAddress(libXext, "XShmAttach");
	XShmDetach = (Bool (*)(Display*, XShmSegmentInfo*))getProcAddress(libXext, "XShmDetach");
	XShmPutImage = (int (*)(Display*, Drawable, GC, XImage*, int, int, int, int, unsigned int, unsigned int, bool))getProcAddress(libXext, "XShmPutImage");
}
Bool
addScreen (CompDisplay *display,
	   int	       screenNum)
{
    CompScreen   *s;
    Display	 *dpy = display->display;
    static char  data = 0;
    XColor	 black, dummy;
    Pixmap	 bitmap;
    XVisualInfo  templ;
    XVisualInfo  *visinfo;
    VisualID     visualIDs[MAX_DEPTH + 1];
    Window	 rootReturn, parentReturn;
    Window	 *children;
    unsigned int nchildren;
    int		 defaultDepth, nvisinfo, value, i;
    const char   *glxExtensions, *glExtensions;
    GLint	 stencilBits;

    s = malloc (sizeof (CompScreen));
    if (!s)
	return FALSE;

    s->windowPrivateIndices = 0;
    s->windowPrivateLen     = 0;

    if (display->screenPrivateLen)
    {
	s->privates = malloc (display->screenPrivateLen *
			      sizeof (CompPrivate));
	if (!s->privates)
	{
	    free (s);
	    return FALSE;
	}
    }
    else
	s->privates = 0;

    compScreenInitOptions (s);

    s->redrawTime = 1000 / s->opt[COMP_SCREEN_OPTION_REFRESH_RATE].value.i;

    s->display = display;

    s->damage = XCreateRegion ();
    if (!s->damage)
	return FALSE;

    s->buttonGrab  = 0;
    s->nButtonGrab = 0;
    s->keyGrab     = 0;
    s->nKeyGrab    = 0;

    s->grabs    = 0;
    s->grabSize = 0;
    s->maxGrab  = 0;

    s->pendingDestroys = 0;

    s->screenNum = screenNum;
    s->colormap  = DefaultColormap (dpy, screenNum);
    s->root	 = XRootWindow (dpy, screenNum);

    if (testMode)
    {
	XSetWindowAttributes attrib;
	XWMHints	     *wmHints;
	XSizeHints	     *normalHints;
	XClassHint	     *classHint;
	int		     glx_attrib[] = {
	    GLX_RGBA,
	    GLX_RED_SIZE, 1,
	    GLX_STENCIL_SIZE, 2,
	    GLX_DOUBLEBUFFER,
	    None
	};

	visinfo = glXChooseVisual (dpy, screenNum, glx_attrib);
	if (!visinfo)
	{
	    int glx_attrib2[] = {
		GLX_RGBA,
		GLX_RED_SIZE, 1,
		GLX_DOUBLEBUFFER,
		None
	    };

	    visinfo = glXChooseVisual (dpy, screenNum, glx_attrib2);
	    if (!visinfo)
	    {
		fprintf (stderr, "%s: Couldn't find a double buffered "
			 "RGB visual.\n", programName);
		return FALSE;
	    }
	}

	attrib.colormap = XCreateColormap (dpy, s->root, visinfo->visual,
					   AllocNone);

	normalHints = XAllocSizeHints ();
	normalHints->flags = 0;
	normalHints->x = 0;
	normalHints->y = 0;
	normalHints->width = 800;
	normalHints->height = 600;

	classHint = XAllocClassHint ();
	classHint->res_name = "glxcompmgr";
	classHint->res_class = "Glxcompmgr";

	wmHints = XAllocWMHints ();
	wmHints->flags = InputHint;
	wmHints->input = TRUE;

	s->root = XCreateWindow (dpy, s->root, 0, 0,
				 normalHints->width, normalHints->height, 0,
				 visinfo->depth, InputOutput, visinfo->visual,
				 CWColormap, &attrib);

	XSetWMProtocols (dpy, s->root, &display->wmDeleteWindowAtom, 1);

	XmbSetWMProperties (dpy, s->root,
			    "glxcompmgr - Test mode", "glxcompmgr",
			    programArgv, programArgc,
			    normalHints, wmHints, classHint);

	s->fake[0] = XCreateWindow (dpy, s->root, 64, 32, 1, 1, 0,
				    visinfo->depth, InputOutput,
				    visinfo->visual,
				    CWColormap, &attrib);

	s->fake[1] = XCreateWindow (dpy, s->root, 256, 256, 1, 1, 0,
				    visinfo->depth, InputOutput,
				    visinfo->visual,
				    CWColormap, &attrib);

	XMapWindow (dpy, s->root);

	XFree (wmHints);
	XFree (classHint);
	XFree (normalHints);
    }
    else
	s->fake[0] = s->fake[1] = 0;

    s->escapeKeyCode = XKeysymToKeycode (display->display,
					 XStringToKeysym ("Escape"));

    s->allDamaged  = TRUE;
    s->next	   = 0;
    s->exposeRects = 0;
    s->sizeExpose  = 0;
    s->nExpose     = 0;

    s->rasterX = 0;
    s->rasterY = 0;

    s->windows = 0;
    s->reverseWindows = 0;

    s->stencilRef = 0x1;

    s->nextRedraw = 0;

    gettimeofday (&s->lastRedraw, 0);

    s->setScreenOption	        = setScreenOption;
    s->setScreenOptionForPlugin = setScreenOptionForPlugin;

    s->initPluginForScreen = initPluginForScreen;
    s->finiPluginForScreen = finiPluginForScreen;

    s->preparePaintScreen     = preparePaintScreen;
    s->donePaintScreen        = donePaintScreen;
    s->paintScreen	      = paintScreen;
    s->paintTransformedScreen = paintTransformedScreen;
    s->paintBackground        = paintBackground;
    s->paintWindow            = paintWindow;
    s->addWindowGeometry      = addWindowGeometry;
    s->drawWindowGeometry     = drawWindowGeometry;
    s->invisibleWindowMove    = invisibleWindowMove;
    s->damageWindowRect       = damageWindowRect;
    s->damageWindowRegion     = damageWindowRegion;

    s->getProcAddress = 0;

    if (s->root)
    {
	XSetWindowAttributes attrib;

	attrib.override_redirect = 1;
	s->grabWindow = XCreateWindow (dpy, s->root, -100, -100, 1, 1, 0,
				       CopyFromParent, CopyFromParent,
				       CopyFromParent, CWOverrideRedirect,
				       &attrib);

	XMapWindow (dpy, s->grabWindow);
    }

    if (!XGetWindowAttributes (dpy, s->root, &s->attrib))
	return FALSE;

    s->activeWindow = None;

    templ.visualid = XVisualIDFromVisual (s->attrib.visual);

    visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo);
    if (!nvisinfo)
    {
	fprintf (stderr, "%s: Couldn't get visual info for default visual\n",
		 programName);
	return FALSE;
    }

    defaultDepth = visinfo->depth;

    if (!XAllocNamedColor (dpy, s->colormap, "black", &black, &dummy))
    {
	fprintf (stderr, "%s: Couldn't allocate color\n", programName);
	return FALSE;
    }

    bitmap = XCreateBitmapFromData (dpy, s->root, &data, 1, 1);
    if (!bitmap)
    {
	fprintf (stderr, "%s: Couldn't create bitmap\n", programName);
	return FALSE;
    }

    s->invisibleCursor = XCreatePixmapCursor (dpy, bitmap, bitmap,
					      &black, &black, 0, 0);
    if (!s->invisibleCursor)
    {
	fprintf (stderr, "%s: Couldn't create invisible cursor\n",
		 programName);
	return FALSE;
    }

    XFreePixmap (dpy, bitmap);
    XFreeColors (dpy, s->colormap, &black.pixel, 1, 0);

    glXGetConfig (dpy, visinfo, GLX_USE_GL, &value);
    if (!value)
    {
	fprintf (stderr, "%s: Root visual is not a GL visual\n",
		 programName);
	return FALSE;
    }

    glXGetConfig (dpy, visinfo, GLX_DOUBLEBUFFER, &value);
    if (!value)
    {
	fprintf (stderr,
		 "%s: Root visual is not a double buffered GL visual\n",
		 programName);
	return FALSE;
    }

    s->ctx = glXCreateContext (dpy, visinfo, NULL, TRUE);
    if (!s->ctx)
    {
	fprintf (stderr, "%s: glXCreateContext failed\n", programName);
	return FALSE;
    }

    XFree (visinfo);

    /* we don't want to allocate back, stencil or depth buffers for pixmaps
       so lets see if we can find an approriate visual without these buffers */
    for (i = 0; i <= MAX_DEPTH; i++)
    {
	int j, db, stencil, depth;

	visualIDs[i] = 0;

	db	= MAXSHORT;
	stencil = MAXSHORT;
	depth	= MAXSHORT;

	templ.depth = i;

	visinfo = XGetVisualInfo (dpy, VisualDepthMask, &templ, &nvisinfo);
	for (j = 0; j < nvisinfo; j++)
	{
	    glXGetConfig (dpy, &visinfo[j], GLX_USE_GL, &value);
	    if (!value)
		continue;

	    glXGetConfig (dpy, &visinfo[j], GLX_DOUBLEBUFFER, &value);
	    if (value > db)
		continue;

	    db = value;
	    glXGetConfig (dpy, &visinfo[j], GLX_STENCIL_SIZE, &value);
	    if (value > stencil)
		continue;

	    stencil = value;
	    glXGetConfig (dpy, &visinfo[j], GLX_DEPTH_SIZE, &value);
	    if (value > depth)
		continue;

	    depth = value;
	    visualIDs[i] = visinfo[j].visualid;
	}

	if (nvisinfo)
	    XFree (visinfo);
    }

    /* create contexts for supported depths */
    for (i = 0; i <= MAX_DEPTH; i++)
    {
	templ.visualid = visualIDs[i];
	s->glxPixmapVisuals[i] = XGetVisualInfo (dpy,
						 VisualIDMask,
						 &templ,
						 &nvisinfo);
    }

    if (!s->glxPixmapVisuals[defaultDepth])
    {
	fprintf (stderr, "%s: No GL visual for default depth, "
		 "this isn't going to work.\n", programName);
	return FALSE;
    }

    glXMakeCurrent (dpy, s->root, s->ctx);
    currentRoot = s->root;

    glxExtensions = glXQueryExtensionsString (s->display->display, screenNum);
    if (!testMode && !strstr (glxExtensions, "GLX_MESA_render_texture")
        && !strstr(glxExtensions, "GLX_EXT_texture_from_drawable")
        && !strstr(glxExtensions, "GLX_EXT_texture_from_pixmap"))
    {
	fprintf (stderr, "%s: GLX_MESA_render_texture is missing\n",
		 programName);
	return FALSE;
    }

    s->getProcAddress = (GLXGetProcAddressProc)
	getProcAddress (s, "glXGetProcAddressARB");
    s->bindTexImageExt = (GLXBindTexImageExtProc)
        getProcAddress (s, "glXBindTexImageEXT");
    s->bindTexImageMesa = (GLXBindTexImageMesaProc)
	getProcAddress (s, "glXBindTexImageMESA");
    s->releaseTexImage = (GLXReleaseTexImageProc)
	getProcAddress (s, "glXReleaseTexImageEXT");
    if (!s->releaseTexImage)
        s->releaseTexImage = (GLXReleaseTexImageProc)
            getProcAddress (s, "glXReleaseTexImageMESA");
    s->queryDrawable = (GLXQueryDrawableProc)
	getProcAddress (s, "glXQueryDrawable");

    if (!testMode && !s->bindTexImageExt && !s->bindTexImageMesa)
    {
	fprintf (stderr, "%s: glXBindTexImage{EXT,MESA} are missing\n",
                 programName);
	return FALSE;
    }

    if (!testMode && !s->releaseTexImage)
    {
	fprintf (stderr, "%s: glXReleaseTexImage{EXT,MESA} are missing\n",
		 programName);
	return FALSE;
    }

    if (!testMode && !s->queryDrawable)
    {
	fprintf (stderr, "%s: glXQueryDrawable is missing\n", programName);
	return FALSE;
    }

    s->textureRectangle = 0;
    glExtensions = (const char *) glGetString (GL_EXTENSIONS);
    if (strstr (glExtensions, "GL_NV_texture_rectangle")  ||
	strstr (glExtensions, "GL_EXT_texture_rectangle") ||
	strstr (glExtensions, "GL_ARB_texture_rectangle"))
	s->textureRectangle = 1;

    s->textureNonPowerOfTwo = 0;
    if (strstr (glExtensions, "GL_ARB_texture_non_power_of_two"))
	s->textureNonPowerOfTwo = 1;

    if (!(s->textureRectangle || s->textureNonPowerOfTwo))
    {
	fprintf (stderr, "%s: Support for non power of two textures missing\n",
		 programName);
	return FALSE;
    }

    s->textureEnvCombine = 0;
    if (strstr (glExtensions, "GL_ARB_texture_env_combine"))
	s->textureEnvCombine = 1;

    s->maxTextureUnits = 1;
    if (strstr (glExtensions, "GL_ARB_multitexture"))
    {
	s->activeTexture = (GLActiveTextureProc)
	    getProcAddress (s, "glActiveTexture");
	s->clientActiveTexture = (GLClientActiveTextureProc)
	    getProcAddress (s, "glClientActiveTexture");

	if (s->activeTexture && s->clientActiveTexture)
	    glGetIntegerv (GL_MAX_TEXTURE_UNITS_ARB, &s->maxTextureUnits);
    }

    initTexture (s, &s->backgroundTexture);

    s->desktopWindowCount = 0;

    glGetIntegerv (GL_STENCIL_BITS, &stencilBits);
    if (!stencilBits)
    {
	fprintf (stderr, "%s: No stencil buffer. Clipping of transformed "
		 "windows is not going to be correct when screen is "
		 "transformed.\n", programName);
    }

    glClearColor (0.0, 0.0, 0.0, 1.0);
    glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
    glEnable (GL_CULL_FACE);
    glDisable (GL_BLEND);
    glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    glColor4usv (defaultColor);
    glEnableClientState (GL_VERTEX_ARRAY);
    glEnableClientState (GL_TEXTURE_COORD_ARRAY);

    for (i = 1; i < s->maxTextureUnits; i++)
    {
	s->clientActiveTexture (GL_TEXTURE0_ARB + i);
	glEnableClientState (GL_TEXTURE_COORD_ARRAY);
    }

    if (s->maxTextureUnits > 1)
	s->clientActiveTexture (GL_TEXTURE0_ARB);

    s->activeWindow = getActiveWindow (display, s->root);

    reshape (s, s->attrib.width, s->attrib.height);

    s->next = display->screens;
    display->screens = s;

    screenInitPlugins (s);

    XSelectInput (dpy, s->root,
		  SubstructureNotifyMask |
		  StructureNotifyMask	 |
		  PropertyChangeMask	 |
		  ExposureMask		 |
		  ButtonPressMask	 |
		  ButtonReleaseMask	 |
		  ButtonMotionMask);

    XQueryTree (dpy, s->root,
		&rootReturn, &parentReturn,
		&children, &nchildren);

    for (i = 0; i < nchildren; i++)
    {
	if (children[i] == s->grabWindow)
	    continue;

	addWindow (s, children[i], i ? children[i - 1] : 0);
    }

    XFree (children);

    return TRUE;
}
Esempio n. 28
0
void *Loader::load_driver(const char* kind,
        egl_connection_t* cnx, uint32_t mask)
{
    class MatchFile {
    public:
        static String8 find(const char* kind) {
            String8 result;
            String8 pattern;
            pattern.appendFormat("lib%s", kind);
            const char* const searchPaths[] = {
#if defined(__LP64__)
                    "/vendor/lib64/egl",
                    "/system/lib64/egl"
#else
                    "/vendor/lib/egl",
                    "/system/lib/egl"
#endif
            };

            // first, we search for the exact name of the GLES userspace
            // driver in both locations.
            // i.e.:
            //      libGLES.so, or:
            //      libEGL.so, libGLESv1_CM.so, libGLESv2.so

            for (size_t i=0 ; i<NELEM(searchPaths) ; i++) {
                if (find(result, pattern, searchPaths[i], true)) {
                    return result;
                }
            }

            // for compatibility with the old "egl.cfg" naming convention
            // we look for files that match:
            //      libGLES_*.so, or:
            //      libEGL_*.so, libGLESv1_CM_*.so, libGLESv2_*.so

            pattern.append("_");
            for (size_t i=0 ; i<NELEM(searchPaths) ; i++) {
                if (find(result, pattern, searchPaths[i], false)) {
                    return result;
                }
            }

            // we didn't find the driver. gah.
            result.clear();
            return result;
        }

    private:
        static bool find(String8& result,
                const String8& pattern, const char* const search, bool exact) {

            // in the emulator case, we just return the hardcoded name
            // of the software renderer.
            if (checkGlesEmulationStatus() == 0) {
                ALOGD("Emulator without GPU support detected. "
                      "Fallback to software renderer.");
#if defined(__LP64__)
                result.setTo("/system/lib64/egl/libGLES_android.so");
#else
                result.setTo("/system/lib/egl/libGLES_android.so");
#endif
                return true;
            }

            if (exact) {
                String8 absolutePath;
                absolutePath.appendFormat("%s/%s.so", search, pattern.string());
                if (!access(absolutePath.string(), R_OK)) {
                    result = absolutePath;
                    return true;
                }
                return false;
            }

            DIR* d = opendir(search);
            if (d != NULL) {
                struct dirent cur;
                struct dirent* e;
                while (readdir_r(d, &cur, &e) == 0 && e) {
                    if (e->d_type == DT_DIR) {
                        continue;
                    }
                    if (!strcmp(e->d_name, "libGLES_android.so")) {
                        // always skip the software renderer
                        continue;
                    }
                    if (strstr(e->d_name, pattern.string()) == e->d_name) {
                        if (!strcmp(e->d_name + strlen(e->d_name) - 3, ".so")) {
                            result.clear();
                            result.appendFormat("%s/%s", search, e->d_name);
                            closedir(d);
                            return true;
                        }
                    }
                }
                closedir(d);
            }
            return false;
        }
    };


    String8 absolutePath = MatchFile::find(kind);
    if (absolutePath.isEmpty()) {
        // this happens often, we don't want to log an error
        return 0;
    }
    const char* const driver_absolute_path = absolutePath.string();

    void* dso = dlopen(driver_absolute_path, RTLD_NOW | RTLD_LOCAL);
    if (dso == 0) {
        const char* err = dlerror();
        ALOGE("load_driver(%s): %s", driver_absolute_path, err?err:"unknown");
        return 0;
    }

    ALOGD("loaded %s", driver_absolute_path);

    if (mask & EGL) {
        getProcAddress = (getProcAddressType)dlsym(dso, "eglGetProcAddress");

        ALOGE_IF(!getProcAddress,
                "can't find eglGetProcAddress() in %s", driver_absolute_path);

        egl_t* egl = &cnx->egl;
        __eglMustCastToProperFunctionPointerType* curr =
            (__eglMustCastToProperFunctionPointerType*)egl;
        char const * const * api = egl_names;
        while (*api) {
            char const * name = *api;
            __eglMustCastToProperFunctionPointerType f =
                (__eglMustCastToProperFunctionPointerType)dlsym(dso, name);
            if (f == NULL) {
                // couldn't find the entry-point, use eglGetProcAddress()
                f = getProcAddress(name);
                if (f == NULL) {
                    f = (__eglMustCastToProperFunctionPointerType)0;
                }
            }
            *curr++ = f;
            api++;
        }
    }

    if (mask & GLESv1_CM) {
        init_api(dso, gl_names,
            (__eglMustCastToProperFunctionPointerType*)
                &cnx->hooks[egl_connection_t::GLESv1_INDEX]->gl,
            getProcAddress);
    }

    if (mask & GLESv2) {
      init_api(dso, gl_names,
            (__eglMustCastToProperFunctionPointerType*)
                &cnx->hooks[egl_connection_t::GLESv2_INDEX]->gl,
            getProcAddress);
    }

    return dso;
}
Esempio n. 29
0
void    initExtensions ()
{
    static  bool    initialized = false;                    // whether initExtensions has already been called

    if ( initialized )
        return;

#ifdef  _WIN32
    glActiveTextureARB       = (PFNGLACTIVETEXTUREARBPROC)         getProcAddress ( "glActiveTextureARB"       );
    glClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC)   getProcAddress ( "glClientActiveTextureARB" );
    glMultiTexCoord1f        = (PFNGLMULTITEXCOORD1FARBPROC)       getProcAddress ( "glMultiTexCoord1fARB"     );
    glMultiTexCoord1fv       = (PFNGLMULTITEXCOORD1FVARBPROC)      getProcAddress ( "glMultiTexCoord1fvARB"    );
    glMultiTexCoord2f        = (PFNGLMULTITEXCOORD2FARBPROC)       getProcAddress ( "glMultiTexCoord2fARB"     );
    glMultiTexCoord2fv       = (PFNGLMULTITEXCOORD2FVARBPROC)      getProcAddress ( "glMultiTexCoord2fvARB"    );
    glMultiTexCoord3f        = (PFNGLMULTITEXCOORD3FARBPROC)       getProcAddress ( "glMultiTexCoord3fARB"     );
    glMultiTexCoord3fv       = (PFNGLMULTITEXCOORD3FVARBPROC)      getProcAddress ( "glMultiTexCoord3fvARB"    );
    glMultiTexCoord4f        = (PFNGLMULTITEXCOORD4FARBPROC)       getProcAddress ( "glMultiTexCoord4fARB"     );
    glMultiTexCoord4fv       = (PFNGLMULTITEXCOORD4FVARBPROC)      getProcAddress ( "glMultiTexCoord4fvARB"    );
#endif

    glFogCoordf              = (PFNGLFOGCOORDFEXTPROC)             getProcAddress ( "glFogCoordfEXT"         );

    glSecondaryColor3f       = (PFNGLSECONDARYCOLOR3FPROC)         getProcAddress ( "glSecondaryColor3fEXT"      );
    glSecondaryColor3fv      = (PFNGLSECONDARYCOLOR3FVPROC)        getProcAddress ( "glSecondaryColor3fvEXT"     );
    glSecondaryColorPointer  = (PFNGLSECONDARYCOLORPOINTERPROC)    getProcAddress ( "glSecondaryColorPointerEXT" );

    glCombinerParameterfvNV  = (PFNGLCOMBINERPARAMETERFVNVPROC)    getProcAddress ( "glCombinerParameterfvNV"  );
    glCombinerParameterivNV  = (PFNGLCOMBINERPARAMETERIVNVPROC)    getProcAddress ( "glCombinerParameterivNV"  );
    glCombinerParameterfNV   = (PFNGLCOMBINERPARAMETERFNVPROC)     getProcAddress ( "glCombinerParameterfNV"   );
    glCombinerParameteriNV   = (PFNGLCOMBINERPARAMETERINVPROC)     getProcAddress ( "glCombinerParameteriNV"   );
    glCombinerInputNV        = (PFNGLCOMBINERINPUTNVPROC)          getProcAddress ( "glCombinerInputNV"        );
    glCombinerOutputNV       = (PFNGLCOMBINEROUTPUTNVPROC)         getProcAddress ( "glCombinerOutputNV"       );
    glFinalCombinerInputNV   = (PFNGLFINALCOMBINERINPUTNVPROC)     getProcAddress ( "glFinalCombinerInputNV"   );

    glBindBufferARB           = (PFNGLBINDBUFFERARBPROC)           getProcAddress ( "glBindBufferARB"           );
    glDeleteBuffersARB        = (PFNGLDELETEBUFFERSARBPROC)        getProcAddress ( "glDeleteBuffersARB"        );
    glGenBuffersARB           = (PFNGLGENBUFFERSARBPROC)           getProcAddress ( "glGenBuffersARB"           );
    glIsBufferARB             = (PFNGLISBUFFERARBPROC)             getProcAddress ( "glIsBufferARB"             );
    glBufferDataARB           = (PFNGLBUFFERDATAARBPROC)           getProcAddress ( "glBufferDataARB"           );
    glBufferSubDataARB        = (PFNGLBUFFERSUBDATAARBPROC)        getProcAddress ( "glBufferSubDataARB"        );
    glGetBufferSubDataARB     = (PFNGLGETBUFFERSUBDATAARBPROC)     getProcAddress ( "glGetBufferSubDataARB"     );
    glMapBufferARB            = (PFNGLMAPBUFFERARBPROC)            getProcAddress ( "glMapBufferARB"            );
    glUnmapBufferARB          = (PFNGLUNMAPBUFFERARBPROC)          getProcAddress ( "glUnmapBufferARB"          );
    glGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC) getProcAddress ( "glGetBufferParameterivARB" );
    glGetBufferPointervARB    = (PFNGLGETBUFFERPOINTERVARBPROC)    getProcAddress ( "glGetBufferPointervARB"    );

                                    // NV-occlusion query extension
    glGenOcclusionQueriesNV = (PFNGLGENOCCLUSIONQUERIESNVPROC) getProcAddress ( "glGenOcclusionQueriesNV" );
    glBeginOcclusionQueryNV = (PFNGLBEGINOCCLUSIONQUERYNVPROC) getProcAddress ( "glBeginOcclusionQueryNV" );
    glEndOcclusionQueryNV   = (PFNGLENDOCCLUSIONQUERYNVPROC)   getProcAddress ( "glEndOcclusionQueryNV"   );
    glGetOcclusionQueryivNV = (PFNGLGETOCCLUSIONQUERYIVNVPROC) getProcAddress ( "glGetOcclusionQueryivNV" );

                                    // ARB_vertex_program extension
    glGenProgramsARB                = (PFNGLGENPROGRAMSARBPROC)               getProcAddress ( "glGenProgramsARB" );
    glDeleteProgramsARB             = (PFNGLDELETEPROGRAMSARBPROC)            getProcAddress ( "glDeleteProgramsARB" );
    glBindProgramARB                = (PFNGLBINDPROGRAMARBPROC)               getProcAddress ( "glBindProgramARB" );
    glIsProgramARB                  = (PFNGLISPROGRAMARBPROC)                 getProcAddress ( "glIsProgramARB" );
    glProgramStringARB              = (PFNGLPROGRAMSTRINGARBPROC)             getProcAddress ( "glProgramStringARB" );
    glGetProgramivARB               = (PFNGLGETPROGRAMIVARBPROC)              getProcAddress ( "glGetProgramivARB" );
    glVertexAttrib4fARB             = (PFNGLVERTEXATTRIB4FARBPROC)            getProcAddress ( "glVertexAttrib4fARB" );
    glVertexAttrib4fvARB            = (PFNGLVERTEXATTRIB4FVARBPROC)           getProcAddress ( "glVertexAttrib4fvARB" );
    glVertexAttrib3fARB             = (PFNGLVERTEXATTRIB3FARBPROC)            getProcAddress ( "glVertexAttrib3fARB" );
    glVertexAttrib3fvARB            = (PFNGLVERTEXATTRIB3FVARBPROC)           getProcAddress ( "glVertexAttrib3fvARB" );
    glVertexAttribPointerARB        = (PFNGLVERTEXATTRIBPOINTERARBPROC)       getProcAddress ( "glVertexAttribPointerARB" );
    glEnableVertexAttribArrayARB    = (PFNGLENABLEVERTEXATTRIBARRAYARBPROC)   getProcAddress ( "glEnableVertexAttribArrayARB" );
    glDisableVertexAttribArrayARB   = (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)  getProcAddress ( "glDisableVertexAttribArrayARB" );
    glProgramLocalParameter4fARB    = (PFNGLPROGRAMLOCALPARAMETER4FARBPROC)   getProcAddress ( "glProgramLocalParameter4fARB" );
    glProgramLocalParameter4fvARB   = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC)  getProcAddress ( "glProgramLocalParameter4fvARB" );
    glGetProgramLocalParameterfvARB = (PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC)getProcAddress ( "glGetProgramLocalParameterfvARB" );
    glProgramEnvParameter4fARB      = (PFNGLPROGRAMENVPARAMETER4FARBPROC)     getProcAddress ( "glProgramEnvParameter4fARB" );
    glProgramEnvParameter4fvARB     = (PFNGLPROGRAMENVPARAMETER4FVARBPROC)    getProcAddress ( "glProgramEnvParameter4fvARB" );
    glGetProgramEnvParameterfvARB   = (PFNGLGETPROGRAMENVPARAMETERFVARBPROC)  getProcAddress ( "glGetProgramEnvParameterfvARB" );

                                    // GL_EXT_texture3D
    glTexImage3DEXT                 =(PFNGLTEXIMAGE3DEXTPROC)                 getProcAddress ( "glTexImage3DEXT" );

                                    // ARB_texture_compression
    glCompressedTexImage3DARB       = (PFNGLCOMPRESSEDTEXIMAGE3DARBPROC)      getProcAddress ( "glCompressedTexImage3DARB"    );
    glCompressedTexImage2DARB       = (PFNGLCOMPRESSEDTEXIMAGE2DARBPROC)      getProcAddress ( "glCompressedTexImage2DARB"    );
    glCompressedTexImage1DARB       = (PFNGLCOMPRESSEDTEXIMAGE1DARBPROC)      getProcAddress ( "glCompressedTexImage1DARB"    );
    glCompressedTexSubImage3DARB    = (PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC)   getProcAddress ( "glCompressedTexSubImage3DARB" );
    glCompressedTexSubImage2DARB    = (PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC)   getProcAddress ( "glCompressedTexSubImage2DARB" );
    glCompressedTexSubImage1DARB    = (PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC)   getProcAddress ( "glCompressedTexSubImage1DARB" );
    glGetCompressedTexImageARB      = (PFNGLGETCOMPRESSEDTEXIMAGEARBPROC)     getProcAddress ( "glGetCompressedTexImageARB"   );

                                    // ARB_point_parameters
    glPointParameterfARB             = (PFNGLPOINTPARAMETERFARBPROC)          getProcAddress ( "glPointParameterfARB" );
    glPointParameterfvARB            = (PFNGLPOINTPARAMETERFVARBPROC)         getProcAddress ( "glPointParameterfvARB" );

                                    // ARB_occlusion_query
    glGenQueriesARB        = (PFNGLGENQUERIESARBPROC)        getProcAddress ( "glGenQueriesARB"        );
    glDeleteQueriesARB     = (PFNGLDELETEQUERIESARBPROC)     getProcAddress ( "glDeleteQueriesARB"     );
    glIsQueryARB           = (PFNGLISQUERYARBPROC)           getProcAddress ( "glIsQueryARB"           );
    glBeginQueryARB        = (PFNGLBEGINQUERYARBPROC)        getProcAddress ( "glBeginQueryARB"        );
    glEndQueryARB          = (PFNGLENDQUERYARBPROC)          getProcAddress ( "glEndQueryARB"          );
    glGetQueryivARB        = (PFNGLGETQUERYIVARBPROC)        getProcAddress ( "glGetQueryivARB"        );
    glGetQueryObjectivARB  = (PFNGLGETQUERYOBJECTIVARBPROC)  getProcAddress ( "glGetQueryObjectivARB"  );
    glGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC) getProcAddress ( "glGetQueryObjectuivARB" );

                                    // GLSL-specific extensions
                                    // GL_ARB_shader_object
    glDeleteObjectARB         = (PFNGLDELETEOBJECTARBPROC)         getProcAddress ( "glDeleteObjectARB" );
    glGetHandleARB            = (PFNGLGETHANDLEARBPROC)            getProcAddress ( "glGetHandleARB" );
    glDetachObjectARB         = (PFNGLDETACHOBJECTARBPROC)         getProcAddress ( "glDetachObjectARB" );
    glCreateShaderObjectARB   = (PFNGLCREATESHADEROBJECTARBPROC)   getProcAddress ( "glCreateShaderObjectARB" );
    glShaderSourceARB         = (PFNGLSHADERSOURCEARBPROC)         getProcAddress ( "glShaderSourceARB" );
    glCompileShaderARB        = (PFNGLCOMPILESHADERARBPROC)        getProcAddress ( "glCompileShaderARB" );
    glCreateProgramObjectARB  = (PFNGLCREATEPROGRAMOBJECTARBPROC)  getProcAddress ( "glCreateProgramObjectARB" );
    glAttachObjectARB         = (PFNGLATTACHOBJECTARBPROC)         getProcAddress ( "glAttachObjectARB" );
    glLinkProgramARB          = (PFNGLLINKPROGRAMARBPROC)          getProcAddress ( "glLinkProgramARB" );
    glUseProgramObjectARB     = (PFNGLUSEPROGRAMOBJECTARBPROC)     getProcAddress ( "glUseProgramObjectARB" );
    glValidateProgramARB      = (PFNGLVALIDATEPROGRAMARBPROC)      getProcAddress ( "glValidateProgramARB" );
    glUniform1fARB            = (PFNGLUNIFORM1FARBPROC)            getProcAddress ( "glUniform1fARB" );
    glUniform2fARB            = (PFNGLUNIFORM2FARBPROC)            getProcAddress ( "glUniform2fARB" );
    glUniform3fARB            = (PFNGLUNIFORM3FARBPROC)            getProcAddress ( "glUniform3fARB" );
    glUniform4fARB            = (PFNGLUNIFORM4FARBPROC)            getProcAddress ( "glUniform4fARB" );
    glUniform1iARB            = (PFNGLUNIFORM1IARBPROC)            getProcAddress ( "glUniform1iARB" );
    glUniform2iARB            = (PFNGLUNIFORM2IARBPROC)            getProcAddress ( "glUniform2iARB" );
    glUniform3iARB            = (PFNGLUNIFORM3IARBPROC)            getProcAddress ( "glUniform3iARB" );
    glUniform4iARB            = (PFNGLUNIFORM4IARBPROC)            getProcAddress ( "glUniform4iARB" );
    glUniform1fvARB           = (PFNGLUNIFORM1FVARBPROC)           getProcAddress ( "glUniform1fvARB" );
    glUniform2fvARB           = (PFNGLUNIFORM2FVARBPROC)           getProcAddress ( "glUniform2fvARB" );
    glUniform3fvARB           = (PFNGLUNIFORM3FVARBPROC)           getProcAddress ( "glUniform3fvARB" );
    glUniform4fvARB           = (PFNGLUNIFORM4FVARBPROC)           getProcAddress ( "glUniform4fvARB" );
    glUniform1ivARB           = (PFNGLUNIFORM1IVARBPROC)           getProcAddress ( "glUniform1ivARB" );
    glUniform2ivARB           = (PFNGLUNIFORM2IVARBPROC)           getProcAddress ( "glUniform2ivARB" );
    glUniform3ivARB           = (PFNGLUNIFORM3IVARBPROC)           getProcAddress ( "glUniform3ivARB" );
    glUniform4ivARB           = (PFNGLUNIFORM4IVARBPROC)           getProcAddress ( "glUniform4ivARB" );
    glUniformMatrix2fvARB     = (PFNGLUNIFORMMATRIX2FVARBPROC)     getProcAddress ( "glUniformMatrix2fvARB" );
    glUniformMatrix3fvARB     = (PFNGLUNIFORMMATRIX3FVARBPROC)     getProcAddress ( "glUniformMatrix3fvARB" );
    glUniformMatrix4fvARB     = (PFNGLUNIFORMMATRIX4FVARBPROC)     getProcAddress ( "glUniformMatrix4fvARB" );
    glGetObjectParameterfvARB = (PFNGLGETOBJECTPARAMETERFVARBPROC) getProcAddress ( "glGetObjectParameterfvARB" );
    glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) getProcAddress ( "glGetObjectParameterivARB" );
    glGetInfoLogARB           = (PFNGLGETINFOLOGARBPROC)           getProcAddress ( "glGetInfoLogARB" );
    glGetAttachedObjectsARB   = (PFNGLGETATTACHEDOBJECTSARBPROC)   getProcAddress ( "glGetAttachedObjectsARB" );
    glGetUniformLocationARB   = (PFNGLGETUNIFORMLOCATIONARBPROC)   getProcAddress ( "glGetUniformLocationARB" );
    glGetActiveUniformARB     = (PFNGLGETACTIVEUNIFORMARBPROC)     getProcAddress ( "glGetActiveUniformARB" );
    glGetUniformfvARB         = (PFNGLGETUNIFORMFVARBPROC)         getProcAddress ( "glGetUniformfvARB" );
    glGetUniformivARB         = (PFNGLGETUNIFORMIVARBPROC)         getProcAddress ( "glGetUniformivARB" );
    glGetShaderSourceARB      = (PFNGLGETSHADERSOURCEARBPROC)      getProcAddress ( "glGetShaderSourceARB" );

                                        // GL_ARB_vertex_shader
    glBindAttribLocationARB   = (PFNGLBINDATTRIBLOCATIONARBPROC)   getProcAddress ( "glBindAttribLocationARB" );
    glGetActiveAttribARB      = (PFNGLGETACTIVEATTRIBARBPROC)      getProcAddress ( "glGetActiveAttribARB"    );
    glGetAttribLocationARB    = (PFNGLGETATTRIBLOCATIONARBPROC)    getProcAddress ( "glGetAttribLocationARB"  );
    glGetVertexAttribfvARB    = (PFNGLGETVERTEXATTRIBFVARBPROC)    getProcAddress ( "glGetVertexAttribfvARB"  );

                                        // EXT_stencil_two_side
    glActiveStencilFaceEXT    = (PFNGLACTIVESTENCILFACEEXTPROC)    getProcAddress ( "glActiveStencilFaceEXT" );

										// EXT_depth_bounds_test
	glDepthBoundsEXT      = (PFNGLDEPTHBOUNDSEXTPROC)          getProcAddress ( "glDepthBoundsEXT" );

										// EXT_framebuffer_object
	glIsRenderbufferEXT                      = (PFNGLISRENDERBUFFEREXTPROC                     ) getProcAddress ( "glIsRenderbufferEXT" );
	glBindRenderbufferEXT                    = (PFNGLBINDRENDERBUFFEREXTPROC                   ) getProcAddress ( "glBindRenderbufferEXT" );
	glDeleteRenderbuffersEXT                 = (PFNGLDELETERENDERBUFFERSEXTPROC                ) getProcAddress ( "glDeleteRenderbuffersEXT" );
	glGenRenderbuffersEXT                    = (PFNGLGENRENDERBUFFERSEXTPROC                   ) getProcAddress ( "glGenRenderbuffersEXT" );
	glRenderbufferStorageEXT                 = (PFNGLRENDERBUFFERSTORAGEEXTPROC                ) getProcAddress ( "glRenderbufferStorageEXT" );
	glGetRenderbufferParameterivEXT          = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC         ) getProcAddress ( "glGetRenderbufferParameterivEXT" );
	glIsFramebufferEXT                       = (PFNGLISFRAMEBUFFEREXTPROC                      ) getProcAddress ( "glIsFramebufferEXT" );
	glBindFramebufferEXT                     = (PFNGLBINDFRAMEBUFFEREXTPROC                    ) getProcAddress ( "glBindFramebufferEXT" );
	glDeleteFramebuffersEXT                  = (PFNGLDELETEFRAMEBUFFERSEXTPROC                 ) getProcAddress ( "glDeleteFramebuffersEXT" );
	glGenFramebuffersEXT                     = (PFNGLGENFRAMEBUFFERSEXTPROC                    ) getProcAddress ( "glGenFramebuffersEXT" );
	glCheckFramebufferStatusEXT              = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC             ) getProcAddress ( "glCheckFramebufferStatusEXT" );
	glFramebufferTexture1DEXT                = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC               ) getProcAddress ( "glFramebufferTexture1DEXT" );
	glFramebufferTexture2DEXT                = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC               ) getProcAddress ( "glFramebufferTexture2DEXT" );
	glFramebufferTexture3DEXT                = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC               ) getProcAddress ( "glFramebufferTexture3DEXT" );
	glFramebufferRenderbufferEXT             = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC			   ) getProcAddress ( "glFramebufferRenderbufferEXT" );
	glGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) getProcAddress ( "glGetFramebufferAttachmentParameterivEXT" );
	glGenerateMipmapEXT                      = (PFNGLGENERATEMIPMAPEXTPROC					   ) getProcAddress ( "glGenerateMipmapEXT" );

#ifndef	GL_VERSION_1_3										// ARB_transpose matrix
	glLoadTransposeMatrixfARB	              = (PFNGLLOADTRANSPOSEMATRIXFPROC                 ) getProcAddress ( "glLoadTransposeMatrixfARB" );
	glLoadTransposeMatrixdARB	              = (PFNGLLOADTRANSPOSEMATRIXDPROC                 ) getProcAddress ( "glLoadTransposeMatrixdARB" );
	glMultTransposeMatrixfARB	              = (PFNGLMULTTRANSPOSEMATRIXFPROC                 ) getProcAddress ( "glMultTransposeMatrixfARB" );
	glMultTransposeMatrixdARB	              = (PFNGLMULTTRANSPOSEMATRIXDPROC                 ) getProcAddress ( "glMultTransposeMatrixdARB" );
#endif	

															// ARB_color_buffer_float
	glClampColorARB         = (PFNGLCLAMPCOLORARBPROC)      getProcAddress ( "glClampColorARB" );

#ifdef	_WIN32											// fresh Linux already has 2.0
														// stencil ops from OpenGL 2.0
	glStencilFuncSeparate  = (PFNGLSTENCILFUNCSEPARATEPROC) getProcAddress ( "glStencilFuncSeparate" );
	glStencilOpSeparate    = (PFNGLSTENCILOPSEPARATEPROC)   getProcAddress ( "glStencilOpSeparate" );
	glStencilMaskSeparate  = (PFNGLSTENCILMASKSEPARATEPROC) getProcAddress ( "glStencilMaskSeparate" );

															// blend ops from OPenGL 2.0
	glBlendEquation         = (PFNGLBLENDEQUATIONPROC)         getProcAddress ( "glBlendEquation" );
	glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC) getProcAddress ( "glBlendEquationSeparate" );
	glBlendFuncSeparate     = (PFNGLBLENDFUNCSEPARATEPROC)     getProcAddress ( "glBlendFuncSeparate" );
	glBlendColor            = (PFNGLBLENDCOLORPROC)            getProcAddress ( "glBlendColor" );
#endif

															// draw buffers from OpenGL 2.0
	glDrawBuffers           = (PFNGLDRAWBUFFERSPROC)           getProcAddress ( "glDrawBuffers" );
															// ATI_draw_buffers
	glDrawBuffersATI        = (PFNGLDRAWBUFFERSATIPROC)        getProcAddress ( "glDrawBuffersATI" );
	
#ifdef  _WIN32
    initWin32Extensions ();
#else
    initLinuxExtensions ();
#endif

    initialized = true;
}
Esempio n. 30
0
void
agl_get_extensions()
{
   glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC) getProcAddress("glBlendFuncSeparate");

   /* OpenGL 2.0 */
   glAttachShader = (PFNGLATTACHSHADERPROC) getProcAddress("glAttachShader");
#if 0
   glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) getProcAddress("glBindAttribLocation");
#endif
   glCompileShader = (PFNGLCOMPILESHADERPROC) getProcAddress("glCompileShader");
   glCreateProgram = (PFNGLCREATEPROGRAMPROC) getProcAddress("glCreateProgram");
   glCreateShader = (PFNGLCREATESHADERPROC) getProcAddress("glCreateShader");
   glDeleteProgram = (PFNGLDELETEPROGRAMPROC) getProcAddress("glDeleteProgram");
   glDeleteShader = (PFNGLDELETESHADERPROC) getProcAddress("glDeleteShader");
#if 0
   glGetActiveAttrib_func = (PFNGLGETACTIVEATTRIBPROC) getProcAddress("glGetActiveAttrib");
   glGetActiveUniform_func = (PFNGLGETACTIVEUNIFORMPROC) getProcAddress("glGetActiveUniform");
   glGetAttachedShaders_func = (PFNGLGETATTACHEDSHADERSPROC) getProcAddress("glGetAttachedShaders");
   glGetAttribLocation_func = (PFNGLGETATTRIBLOCATIONPROC) getProcAddress("glGetAttribLocation");
#endif
   glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) getProcAddress("glGetProgramInfoLog");
   glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) getProcAddress("glGetShaderInfoLog");
   glGetProgramiv = (PFNGLGETPROGRAMIVPROC) getProcAddress("glGetProgramiv");
   glGetShaderiv = (PFNGLGETSHADERIVPROC) getProcAddress("glGetShaderiv");
#if 0
   glGetShaderSource_func = (PFNGLGETSHADERSOURCEPROC) getProcAddress("glGetShaderSource");
#endif
   glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) getProcAddress("glGetUniformLocation");
#if 0
   glGetUniformfv_func = (PFNGLGETUNIFORMFVPROC) getProcAddress("glGetUniformfv");
#endif
   glIsProgram = (PFNGLISPROGRAMPROC) getProcAddress("glIsProgram");
   glIsShader = (PFNGLISSHADERPROC) getProcAddress("glIsShader");
   glLinkProgram = (PFNGLLINKPROGRAMPROC) getProcAddress("glLinkProgram");
   glShaderSource = (PFNGLSHADERSOURCEPROC) getProcAddress("glShaderSource");
   glUniform1i = (PFNGLUNIFORM1IPROC) getProcAddress("glUniform1i");
   glUniform2i_func = (PFNGLUNIFORM2IPROC) getProcAddress("glUniform2i");
   glUniform3i_func = (PFNGLUNIFORM3IPROC) getProcAddress("glUniform3i");
   glUniform4i_func = (PFNGLUNIFORM4IPROC) getProcAddress("glUniform3i");
   glUniform1f = (PFNGLUNIFORM1FPROC) getProcAddress("glUniform1f");
   glUniform2f_func = (PFNGLUNIFORM2FPROC) getProcAddress("glUniform2f");
   glUniform3f_func = (PFNGLUNIFORM3FPROC) getProcAddress("glUniform3f");
   glUniform4f = (PFNGLUNIFORM4FPROC) getProcAddress("glUniform4f");
   glUniform1fv = (PFNGLUNIFORM1FVPROC) getProcAddress("glUniform1fv");
   glUniform2fv = (PFNGLUNIFORM2FVPROC) getProcAddress("glUniform2fv");
   glUniform3fv = (PFNGLUNIFORM3FVPROC) getProcAddress("glUniform3fv");
   glUniform4fv = (PFNGLUNIFORM3FVPROC) getProcAddress("glUniform4fv");
   glUniform1iv = (PFNGLUNIFORM1IVPROC) getProcAddress("glUniform1iv");
#if 0
   glUniformMatrix2fv_func = (PFNGLUNIFORMMATRIX2FVPROC) getProcAddress("glUniformMatrix2fv");
   glUniformMatrix3fv_func = (PFNGLUNIFORMMATRIX3FVPROC) getProcAddress("glUniformMatrix3fv");
#endif
   glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) getProcAddress("glUniformMatrix4fv");
   glUseProgram = (PFNGLUSEPROGRAMPROC) glXGetProcAddress((GLubyte*)"glUseProgram");
#if 0
   glVertexAttrib1f_func = (PFNGLVERTEXATTRIB1FPROC) getProcAddress("glVertexAttrib1f");
   glVertexAttrib2f_func = (PFNGLVERTEXATTRIB2FPROC) getProcAddress("glVertexAttrib2f");
   glVertexAttrib3f_func = (PFNGLVERTEXATTRIB3FPROC) getProcAddress("glVertexAttrib3f");
   glVertexAttrib4f_func = (PFNGLVERTEXATTRIB4FPROC) getProcAddress("glVertexAttrib4f");
   glVertexAttrib1fv_func = (PFNGLVERTEXATTRIB1FVPROC) getProcAddress("glVertexAttrib1fv");
   glVertexAttrib2fv_func = (PFNGLVERTEXATTRIB2FVPROC) getProcAddress("glVertexAttrib2fv");
   glVertexAttrib3fv_func = (PFNGLVERTEXATTRIB3FVPROC) getProcAddress("glVertexAttrib3fv");
   glVertexAttrib4fv_func = (PFNGLVERTEXATTRIB4FVPROC) getProcAddress("glVertexAttrib4fv");

   glVertexAttribPointer_func = (PFNGLVERTEXATTRIBPOINTERPROC) getProcAddress("glVertexAttribPointer");
#endif
   glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) getProcAddress("glEnableVertexAttribArray");
#if 0
   glDisableVertexAttribArray_func = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) getProcAddress("glDisableVertexAttribArray");

   /* OpenGL 2.1 */
   glUniformMatrix2x3fv_func = (PFNGLUNIFORMMATRIX2X3FVPROC) getProcAddress("glUniformMatrix2x3fv");
   glUniformMatrix3x2fv_func = (PFNGLUNIFORMMATRIX3X2FVPROC) getProcAddress("glUniformMatrix3x2fv");
   glUniformMatrix2x4fv_func = (PFNGLUNIFORMMATRIX2X4FVPROC) getProcAddress("glUniformMatrix2x4fv");
   glUniformMatrix4x2fv_func = (PFNGLUNIFORMMATRIX4X2FVPROC) getProcAddress("glUniformMatrix4x2fv");
   glUniformMatrix3x4fv_func = (PFNGLUNIFORMMATRIX3X4FVPROC) getProcAddress("glUniformMatrix3x4fv");
   glUniformMatrix4x3fv_func = (PFNGLUNIFORMMATRIX4X3FVPROC) getProcAddress("glUniformMatrix4x3fv");

   /* OpenGL 1.4 */
   glPointParameterfv_func = (PFNGLPOINTPARAMETERFVPROC) getProcAddress("glPointParameterfv");
   glSecondaryColor3fv_func = (PFNGLSECONDARYCOLOR3FVPROC) getProcAddress("glSecondaryColor3fv");

   /* GL_ARB_vertex/fragment_program */
   glBindProgramARB_func = (PFNGLBINDPROGRAMARBPROC) getProcAddress("glBindProgramARB");
   glDeleteProgramsARB_func = (PFNGLDELETEPROGRAMSARBPROC) getProcAddress("glDeleteProgramsARB");
   glGenProgramsARB_func = (PFNGLGENPROGRAMSARBPROC) getProcAddress("glGenProgramsARB");
   glGetProgramLocalParameterdvARB_func = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) getProcAddress("glGetProgramLocalParameterdvARB");
   glIsProgramARB_func = (PFNGLISPROGRAMARBPROC) getProcAddress("glIsProgramARB");
   glProgramLocalParameter4dARB_func = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC) getProcAddress("glProgramLocalParameter4dARB");
   glProgramLocalParameter4fvARB_func = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) getProcAddress("glProgramLocalParameter4fvARB");
   glProgramStringARB_func = (PFNGLPROGRAMSTRINGARBPROC) getProcAddress("glProgramStringARB");
   glVertexAttrib1fARB_func = (PFNGLVERTEXATTRIB1FARBPROC) getProcAddress("glVertexAttrib1fARB");

   /* GL_APPLE_vertex_array_object */
#endif
   glBindVertexArrayAPPLE = (PFNGLBINDVERTEXARRAYAPPLEPROC) getProcAddress("glBindVertexArrayAPPLE");
#if 0
   glDeleteVertexArraysAPPLE_func = (PFNGLDELETEVERTEXARRAYSAPPLEPROC) getProcAddress("glDeleteVertexArraysAPPLE");
   glGenVertexArraysAPPLE_func = (PFNGLGENVERTEXARRAYSAPPLEPROC) getProcAddress("glGenVertexArraysAPPLE");
   glIsVertexArrayAPPLE_func = (PFNGLISVERTEXARRAYAPPLEPROC) getProcAddress("glIsVertexArrayAPPLE");

   /* GL_EXT_stencil_two_side */
   glActiveStencilFaceEXT_func = (PFNGLACTIVESTENCILFACEEXTPROC) getProcAddress("glActiveStencilFaceEXT");

   /* GL_ARB_vertex_buffer_object */
#endif
   glGenBuffersARB = (PFNGLGENBUFFERSARBPROC) getProcAddress("glGenBuffersARB");
   glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) getProcAddress("glDeleteBuffersARB");
   glBindBufferARB = (PFNGLBINDBUFFERARBPROC) getProcAddress("glBindBufferARB");
   glBufferDataARB = (PFNGLBUFFERDATAARBPROC) getProcAddress("glBufferDataARB");
#if 0
   glBufferSubDataARB_func = (PFNGLBUFFERSUBDATAARBPROC) getProcAddress("glBufferSubDataARB");
   glMapBufferARB_func = (PFNGLMAPBUFFERARBPROC) getProcAddress("glMapBufferARB");
   glUnmapBufferARB_func = (PFNGLUNMAPBUFFERARBPROC) getProcAddress("glUnmapBufferARB");

   /* GL_EXT_framebuffer_object */
   glIsRenderbufferEXT_func = (PFNGLISRENDERBUFFEREXTPROC) getProcAddress("glIsRenderbufferEXT");
   glBindRenderbufferEXT_func = (PFNGLBINDRENDERBUFFEREXTPROC) getProcAddress("glBindRenderbufferEXT");
   glDeleteRenderbuffersEXT_func = (PFNGLDELETERENDERBUFFERSEXTPROC) getProcAddress("glDeleteRenderbuffersEXT");
   glGenRenderbuffersEXT_func = (PFNGLGENRENDERBUFFERSEXTPROC) getProcAddress("glGenRenderbuffersEXT");
   glRenderbufferStorageEXT_func = (PFNGLRENDERBUFFERSTORAGEEXTPROC) getProcAddress("glRenderbufferStorageEXT");
   glGetRenderbufferParameterivEXT_func = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) getProcAddress("glGetRenderbufferParameterivEXT");
   glIsFramebufferEXT_func = (PFNGLISFRAMEBUFFEREXTPROC) getProcAddress("glIsFramebufferEXT");
   glBindFramebufferEXT_func = (PFNGLBINDFRAMEBUFFEREXTPROC) getProcAddress("glBindFramebufferEXT");
   glDeleteFramebuffersEXT_func = (PFNGLDELETEFRAMEBUFFERSEXTPROC) getProcAddress("glDeleteFramebuffersEXT");
   glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) getProcAddress("glGenFramebuffersEXT");
   glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) getProcAddress("glCheckFramebufferStatusEXT");
   glFramebufferTexture1DEXT_func = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) getProcAddress("glFramebufferTexture1DEXT");
   glFramebufferTexture2DEXT_func = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) getProcAddress("glFramebufferTexture2DEXT");
   glFramebufferTexture3DEXT_func = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) getProcAddress("glFramebufferTexture3DEXT");
   glFramebufferRenderbufferEXT_func = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) getProcAddress("glFramebufferRenderbufferEXT");
   glGetFramebufferAttachmentParameterivEXT_func = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) getProcAddress("glGetFramebufferAttachmentParameterivEXT");
   glGenerateMipmapEXT_func = (PFNGLGENERATEMIPMAPEXTPROC) getProcAddress("glGenerateMipmapEXT");

   /* GL_ARB_framebuffer_object */
   glIsRenderbuffer_func = (PFNGLISRENDERBUFFERPROC) getProcAddress("glIsRenderbuffer");
#endif
   glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) getProcAddress("glBindRenderbuffer");
   glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) getProcAddress("glDeleteRenderbuffers");
   glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) getProcAddress("glGenRenderbuffers");
   glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) getProcAddress("glRenderbufferStorage");
   glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) getProcAddress("glGetRenderbufferParameteriv");
#if 0
   glIsFramebuffer_func = (PFNGLISFRAMEBUFFERPROC) getProcAddress("glIsFramebuffer");
#endif
   glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) getProcAddress("glBindFramebuffer");
   glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) getProcAddress("glDeleteFramebuffers");
   glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) getProcAddress("glGenFramebuffers");
   glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) getProcAddress("glCheckFramebufferStatus");
#if 0
   glFramebufferTexture1D_func = (PFNGLFRAMEBUFFERTEXTURE1DPROC) getProcAddress("glFramebufferTexture1D");
#endif
   glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) getProcAddress("glFramebufferTexture2D");
#if 0
   glFramebufferTexture3D_func = (PFNGLFRAMEBUFFERTEXTURE3DPROC) getProcAddress("glFramebufferTexture3D");
#endif
   glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) getProcAddress("glFramebufferRenderbuffer");
   glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) getProcAddress("glGetFramebufferAttachmentParameteriv");
#if 0
   glGenerateMipmap_func = (PFNGLGENERATEMIPMAPPROC) getProcAddress("glGenerateMipmap");
   glBlitFramebuffer_func = (PFNGLBLITFRAMEBUFFERPROC) getProcAddress("glBlitFramebuffer");
   glRenderbufferStorageMultisample_func = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) getProcAddress("glRenderbufferStorageMultisample");
   glFramebufferTextureLayer_func = (PFNGLFRAMEBUFFERTEXTURELAYERPROC) getProcAddress("glFramebufferTextureLayer");
#endif
   glStringMarkerGREMEDY = (PFNGLSTRINGMARKERGREMEDYPROC) getProcAddress("glStringMarkerGREMEDY");
}