//
    // Constructor
    //
    CRegistry::CRegistry( 
                         bool WindowSystem 
                         ):
        m_VersionStr( NULL ),
        m_ExtensionsStr( NULL )
    {
        if (WindowSystem)
        {
	#ifdef _WIN32
            if (!wglGetExtensionsStringARB)
                throw Sys::CException( this, "::CRegistry() : Failed to obtain wglGetExtensionsStringARB entry point." );
                
            HDC DC = wglGetCurrentDC();
            if (!DC)
                throw Sys::CException( this, "::CRegistry() : Invalid current DC." );
       
            m_ExtensionsStr = wglGetExtensionsStringARB( DC );
	#elif defined (__linux__)
            Display *Dpy = glXGetCurrentDisplay();
            if (!Dpy)
                throw Sys::CException( this, "::CRegistry() : Invalid current Display." );
                
            m_ExtensionsString = glXGetClientString( Dpy, GLX_EXTENSIONS );
	#endif // _WIN32
        }
		else
        {
            m_VersionStr = reinterpret_cast<const char *>( glGetString( GL_VERSION ) );
            m_ExtensionsStr = reinterpret_cast<const char *>( glGetString( GL_EXTENSIONS ) );
        }

        TokenizeString();
    }
Esempio n. 2
0
static int has_ext(const char *ext) {
    const char *terminator;
    const char *loc;
    const char *extensions;

    if(wglGetExtensionsStringEXT == NULL && wglGetExtensionsStringARB == NULL)
        return 0;

    if(wglGetExtensionsStringARB == NULL || GLADWGLhdc == INVALID_HANDLE_VALUE)
        extensions = wglGetExtensionsStringEXT();
    else
        extensions = wglGetExtensionsStringARB(GLADWGLhdc);

    if(extensions == NULL || ext == NULL)
        return 0;

    while(1) {
        loc = strstr(extensions, ext);
        if(loc == NULL)
            break;

        terminator = loc + strlen(ext);
        if((loc == extensions || *(loc - 1) == ' ') &&
            (*terminator == ' ' || *terminator == '\0'))
        {
            return 1;
        }
        extensions = terminator;
    }

    return 0;
}
Esempio n. 3
0
/* static */
bool wxGLCanvasBase::IsExtensionSupported(const char *extension)
{
    static const char *s_extensionsList = (char *)wxUIntPtr(-1);
    if ( s_extensionsList == (char *)wxUIntPtr(-1) )
    {
        typedef const char * (WINAPI *wglGetExtensionsStringARB_t)(HDC hdc);

        wxDEFINE_WGL_FUNC(wglGetExtensionsStringARB);
        if ( wglGetExtensionsStringARB )
        {
            s_extensionsList = wglGetExtensionsStringARB(wglGetCurrentDC());
        }
        else
        {
            typedef const char * (WINAPI * wglGetExtensionsStringEXT_t)();

            wxDEFINE_WGL_FUNC(wglGetExtensionsStringEXT);
            if ( wglGetExtensionsStringEXT )
            {
                s_extensionsList = wglGetExtensionsStringEXT();
            }
            else
            {
                s_extensionsList = NULL;
            }
        }
    }

    return s_extensionsList && IsExtensionInList(s_extensionsList, extension);
}
Esempio n. 4
0
void CSDLSupport::InitWGLExtensions()
{
	nova::stl<nstring>::vector exten;


	HDC hdc = wglGetCurrentDC();
	if(!hdc)
		throw NOVA_EXP("CWGLSupport::InitWGLExtensions - Couldn't take device context!", BAD_OPERATION);

	if(WGL_ARB_extensions_string)
	{
		nstring temp(wglGetExtensionsStringARB(hdc));
		exten = nova::CStringUtils::Split( temp );

		CLog::GetInstance().PrintMessage("WGL Extensions\n", CLog::LG_NO_TIME);

		nstring fullext;
		nova::uint i, j;
		for(i = 0, j = 0; i < exten.size(); ++i, ++j)
		{
			fullext += exten[i] + " ";
			if(j > 6)
				fullext += "\n";

			mExtensionsList.push_back(exten[i]);
		}

		CLog::GetInstance().PrintMessage(fullext, CLog::LG_NO_TIME);
	}
	else
		throw NOVA_EXP("CWGLSupport::InitWGLExtensions - \
		WGL_ARB_extensions_string not supported...", BAD_OPERATION);
}
Esempio n. 5
0
static void Init_WGL_ARB_extensions(_THIS)
{
	HWND hwnd;
	HDC hdc;
	HGLRC hglrc;
	int pformat;
	const char * (WINAPI *wglGetExtensionsStringARB)(HDC) = 0;
	const char *extensions;
	
	hwnd = CreateWindow(SDL_Appname, SDL_Appname, WS_POPUP | WS_DISABLED,
	                    0, 0, 10, 10,
	                    NULL, NULL, SDL_Instance, NULL);
	WIN_FlushMessageQueue();

	hdc = GetDC(hwnd);

	pformat = ChoosePixelFormat(hdc, &GL_pfd);
	SetPixelFormat(hdc, pformat, &GL_pfd);

	hglrc = this->gl_data->wglCreateContext(hdc);
	if ( hglrc ) {
		this->gl_data->wglMakeCurrent(hdc, hglrc);
	}

	wglGetExtensionsStringARB = (const char * (WINAPI *)(HDC))
		this->gl_data->wglGetProcAddress("wglGetExtensionsStringARB");

	if( wglGetExtensionsStringARB ) {
		extensions = wglGetExtensionsStringARB(hdc);
	} else {
		extensions = NULL;
	}

	this->gl_data->WGL_ARB_pixel_format = 0;
	if( ExtensionSupported("WGL_ARB_pixel_format", extensions) ) {
		this->gl_data->wglChoosePixelFormatARB =
			(BOOL (WINAPI *)(HDC, const int *, const FLOAT *, UINT, int *, UINT *))
			this->gl_data->wglGetProcAddress("wglChoosePixelFormatARB");
		this->gl_data->wglGetPixelFormatAttribivARB =
			(BOOL (WINAPI *)(HDC, int, int, UINT, const int *, int *))
			this->gl_data->wglGetProcAddress("wglGetPixelFormatAttribivARB");

		if( (this->gl_data->wglChoosePixelFormatARB != NULL) &&
		    (this->gl_data->wglGetPixelFormatAttribivARB != NULL) ) {
			this->gl_data->WGL_ARB_pixel_format = 1;
		}
	}
	
	if ( hglrc ) {
		this->gl_data->wglMakeCurrent(NULL, NULL);
		this->gl_data->wglDeleteContext(hglrc);
	}
	ReleaseDC(hwnd, hdc);
	DestroyWindow(hwnd);
	WIN_FlushMessageQueue();
}
char * COpenGLExtentions::GetWGLExtensions(HDC winhdc)
{
	if(winhdc)
	{
		InitExtention(WGL_ARB_extensions_string);
		return const_cast<char *>(wglGetExtensionsStringARB(winhdc));
	}

	return NULL;
}
Esempio n. 7
0
    void investigate_swapcontrol_support() {

      if (has_checked_extensions) return; // Already calculated, no need to calculate it more.

      const char *wgl_extensions = wglGetExtensionsStringARB(window_hDC);

      ext_swapcontrol_supported = strstr(wgl_extensions, "WGL_EXT_swap_control");

      has_checked_extensions = true;
    }
Esempio n. 8
0
static int ChoosePixelFormatARB(_THIS, const int *iAttribs, const FLOAT *fAttribs)
{
	HWND hwnd;
	HDC hdc;
	HGLRC hglrc;
	const char * (WINAPI *wglGetExtensionsStringARB)(HDC) = 0;
	const char *extensions;
	int pformat = 0;
	UINT matches = 0;

	hwnd = CreateWindow(SDL_Appname, SDL_Appname, WS_POPUP | WS_DISABLED,
	                    0, 0, 10, 10,
	                    NULL, NULL, SDL_Instance, NULL);
	WIN_FlushMessageQueue();

	hdc = GetDC(hwnd);

	SetPixelFormat(hdc, ChoosePixelFormat(hdc, &GL_pfd), &GL_pfd);

	hglrc = this->gl_data->wglCreateContext(hdc);
	if ( hglrc ) {
		this->gl_data->wglMakeCurrent(hdc, hglrc);
	}

	wglGetExtensionsStringARB = (const char * (WINAPI *)(HDC))
		this->gl_data->wglGetProcAddress("wglGetExtensionsStringARB");

	if( wglGetExtensionsStringARB ) {
		extensions = wglGetExtensionsStringARB(hdc);
	} else {
		extensions = NULL;
	}

	this->gl_data->WGL_ARB_pixel_format = 0;
	if( ExtensionSupported("WGL_ARB_pixel_format", extensions) ) {
		BOOL (WINAPI *wglChoosePixelFormatARB)(HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
		wglChoosePixelFormatARB =
			(BOOL (WINAPI *)(HDC, const int *, const FLOAT *, UINT, int *, UINT *))
			this->gl_data->wglGetProcAddress("wglChoosePixelFormatARB");
		if( wglChoosePixelFormatARB &&
		    wglChoosePixelFormatARB(hdc, iAttribs, fAttribs, 1, &pformat, &matches) && pformat ) {
			this->gl_data->WGL_ARB_pixel_format = 1;
		}
	}
	
	if ( hglrc ) {
		this->gl_data->wglMakeCurrent(NULL, NULL);
		this->gl_data->wglDeleteContext(hglrc);
	}
	ReleaseDC(hwnd, hdc);
	DestroyWindow(hwnd);
	WIN_FlushMessageQueue();

	return pformat;
}
Esempio n. 9
0
	int LoadWinFunctions(void *hdc)
	{
		HDC hDC = (HDC)hdc;

		wgleIntClear();
		wgleIntLoadBaseFuncs();

		gleIntLoadBaseFuncs();

		if(!wglGetExtensionsStringARB) return LS_LOAD_FAILED;

		ProcExtFromExtString(wglGetExtensionsStringARB(hDC), wgleIntExtensionMap, wgleIntExtensionMapSize);

		return LS_LOAD_FUNCTIONS_ALL;
	}
static void
WIN_GL_InitExtensions(_THIS, HDC hdc)
{
    const char *(WINAPI * wglGetExtensionsStringARB) (HDC) = 0;
    const char *extensions;

    wglGetExtensionsStringARB = (const char *(WINAPI *) (HDC))
        _this->gl_data->wglGetProcAddress("wglGetExtensionsStringARB");
    if (wglGetExtensionsStringARB) {
        extensions = wglGetExtensionsStringARB(hdc);
    } else {
        extensions = NULL;
    }

    /* Check for WGL_ARB_pixel_format */
    _this->gl_data->HAS_WGL_ARB_pixel_format = SDL_FALSE;
    if (HasExtension("WGL_ARB_pixel_format", extensions)) {
        _this->gl_data->wglChoosePixelFormatARB = (BOOL(WINAPI *)
                                                   (HDC, const int *,
                                                    const FLOAT *, UINT,
                                                    int *, UINT *))
            WIN_GL_GetProcAddress(_this, "wglChoosePixelFormatARB");
        _this->gl_data->wglGetPixelFormatAttribivARB =
            (BOOL(WINAPI *) (HDC, int, int, UINT, const int *, int *))
            WIN_GL_GetProcAddress(_this, "wglGetPixelFormatAttribivARB");

        if ((_this->gl_data->wglChoosePixelFormatARB != NULL) &&
            (_this->gl_data->wglGetPixelFormatAttribivARB != NULL)) {
            _this->gl_data->HAS_WGL_ARB_pixel_format = SDL_TRUE;
        }
    }

    /* Check for WGL_EXT_swap_control */
    _this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_FALSE;
    if (HasExtension("WGL_EXT_swap_control", extensions)) {
        _this->gl_data->wglSwapIntervalEXT =
            WIN_GL_GetProcAddress(_this, "wglSwapIntervalEXT");
        _this->gl_data->wglGetSwapIntervalEXT =
            WIN_GL_GetProcAddress(_this, "wglGetSwapIntervalEXT");
        if (HasExtension("WGL_EXT_swap_control_tear", extensions)) {
            _this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_TRUE;
        }
    } else {
        _this->gl_data->wglSwapIntervalEXT = NULL;
        _this->gl_data->wglGetSwapIntervalEXT = NULL;
    }
}
Esempio n. 11
0
	bool checkAvailable(const char* extension)
	{
		// Check windows extensions
		if(wglGetExtensionsStringARB == 0)
		{
			wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");

			HWND hWnd = GetActiveWindow();
			HDC hDC = GetDC(hWnd);
			wext = wglGetExtensionsStringARB(hDC);
		}

		if(findExtension(extension, (char*)glGetString(GL_EXTENSIONS)))
			return true;

		if (findExtension(extension, (char*)wext))
			return true;

		return false;
	}
Esempio n. 12
0
		void wgl_features()
		{
#ifdef GLLOADER_WGL
			std::string exts_str;

			LOAD_FUNC1(wglGetExtensionsStringARB);
			if (wglGetExtensionsStringARB != NULL)
			{
				exts_str = wglGetExtensionsStringARB(::wglGetCurrentDC());
			}
			else
			{
				LOAD_FUNC1(wglGetExtensionsStringEXT);
				if (wglGetExtensionsStringEXT != NULL)
				{
					exts_str = wglGetExtensionsStringEXT();
				}
			}

			std::vector<std::string> wgl_exts = split(exts_str);
			wgl_exts.erase(std::remove(wgl_exts.begin(), wgl_exts.end(), ""), wgl_exts.end());
			features_.insert(features_.end(), wgl_exts.begin(), wgl_exts.end());
#endif		// GLLOADER_WGL
		}
Esempio n. 13
0
static bool create_context_w32_gl3(struct MPGLContext *ctx)
{
    struct w32_context *w32_ctx = ctx->priv;

    HDC windc = w32_ctx->hdc;
    HGLRC context = 0;

    // A legacy context is needed to get access to the new functions.
    HGLRC legacy_context = wglCreateContext(windc);
    if (!legacy_context) {
        MP_FATAL(ctx->vo, "Could not create GL context!\n");
        return false;
    }

    // set context
    if (!wglMakeCurrent(windc, legacy_context)) {
        MP_FATAL(ctx->vo, "Could not set GL context!\n");
        goto out;
    }

    const char *(GLAPIENTRY *wglGetExtensionsStringARB)(HDC hdc)
        = w32gpa((const GLubyte*)"wglGetExtensionsStringARB");

    if (!wglGetExtensionsStringARB)
        goto unsupported;

    const char *wgl_exts = wglGetExtensionsStringARB(windc);
    if (!strstr(wgl_exts, "WGL_ARB_create_context"))
        goto unsupported;

    HGLRC (GLAPIENTRY *wglCreateContextAttribsARB)(HDC hDC, HGLRC hShareContext,
                                                   const int *attribList)
        = w32gpa((const GLubyte*)"wglCreateContextAttribsARB");

    if (!wglCreateContextAttribsARB)
        goto unsupported;

    int attribs[] = {
        WGL_CONTEXT_MAJOR_VERSION_ARB, 3,
        WGL_CONTEXT_MINOR_VERSION_ARB, 0,
        WGL_CONTEXT_FLAGS_ARB, 0,
        WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
        0
    };

    context = wglCreateContextAttribsARB(windc, 0, attribs);
    if (!context) {
        // NVidia, instead of ignoring WGL_CONTEXT_FLAGS_ARB, will error out if
        // it's present on pre-3.2 contexts.
        // Remove it from attribs and retry the context creation.
        attribs[6] = attribs[7] = 0;
        context = wglCreateContextAttribsARB(windc, 0, attribs);
    }
    if (!context) {
        int err = GetLastError();
        MP_FATAL(ctx->vo, "Could not create an OpenGL 3.x context: error 0x%x\n", err);
        goto out;
    }

    wglMakeCurrent(windc, NULL);
    wglDeleteContext(legacy_context);

    if (!wglMakeCurrent(windc, context)) {
        MP_FATAL(ctx->vo, "Could not set GL3 context!\n");
        wglDeleteContext(context);
        return false;
    }

    w32_ctx->context = context;

    /* update function pointers */
    mpgl_load_functions(ctx->gl, w32gpa, NULL, ctx->vo->log);

    return true;

unsupported:
    MP_ERR(ctx->vo, "The OpenGL driver does not support OpenGL 3.x \n");
out:
    wglMakeCurrent(windc, NULL);
    wglDeleteContext(legacy_context);
    return false;
}
Esempio n. 14
0
	void GlContext::create(uint32_t /*_width*/, uint32_t /*_height*/)
	{
		m_opengl32dll = bx::dlopen("opengl32.dll");
		BGFX_FATAL(NULL != m_opengl32dll, Fatal::UnableToInitialize, "Failed to load opengl32.dll.");

		wglGetProcAddress = (PFNWGLGETPROCADDRESSPROC)bx::dlsym(m_opengl32dll, "wglGetProcAddress");
		BGFX_FATAL(NULL != wglGetProcAddress, Fatal::UnableToInitialize, "Failed get wglGetProcAddress.");

		// If g_bgfxHwnd is NULL, the assumption is that GL context was created
		// by user (for example, using SDL, GLFW, etc.)
		BX_WARN(NULL != g_bgfxHwnd
			, "bgfx::winSetHwnd with valid window is not called. This might "
			  "be intentional when GL context is created by the user."
			);

		if (NULL != g_bgfxHwnd)
		{
			wglMakeCurrent = (PFNWGLMAKECURRENTPROC)bx::dlsym(m_opengl32dll, "wglMakeCurrent");
			BGFX_FATAL(NULL != wglMakeCurrent, Fatal::UnableToInitialize, "Failed get wglMakeCurrent.");

			wglCreateContext = (PFNWGLCREATECONTEXTPROC)bx::dlsym(m_opengl32dll, "wglCreateContext");
			BGFX_FATAL(NULL != wglCreateContext, Fatal::UnableToInitialize, "Failed get wglCreateContext.");

			wglDeleteContext = (PFNWGLDELETECONTEXTPROC)bx::dlsym(m_opengl32dll, "wglDeleteContext");
			BGFX_FATAL(NULL != wglDeleteContext, Fatal::UnableToInitialize, "Failed get wglDeleteContext.");

			m_hdc = GetDC(g_bgfxHwnd);
			BGFX_FATAL(NULL != m_hdc, Fatal::UnableToInitialize, "GetDC failed!");

			// Dummy window to peek into WGL functionality.
			//
			// An application can only set the pixel format of a window one time.
			// Once a window's pixel format is set, it cannot be changed.
			// MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/dd369049%28v=vs.85%29.aspx
			HWND hwnd = CreateWindowA("STATIC"
				, ""
				, WS_POPUP|WS_DISABLED
				, -32000
				, -32000
				, 0
				, 0
				, NULL
				, NULL
				, GetModuleHandle(NULL)
				, 0
				);

			HDC hdc = GetDC(hwnd);
			BGFX_FATAL(NULL != hdc, Fatal::UnableToInitialize, "GetDC failed!");

			HGLRC context = createContext(hdc);

			wglGetExtensionsStringARB  = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
			wglChoosePixelFormatARB    = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
			wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
			wglSwapIntervalEXT         = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");

			if (NULL != wglGetExtensionsStringARB)
			{
				const char* extensions = (const char*)wglGetExtensionsStringARB(hdc);
				BX_TRACE("WGL extensions:");
				dumpExtensions(extensions);
			}

			if (NULL != wglChoosePixelFormatARB
			&&  NULL != wglCreateContextAttribsARB)
			{
				int32_t attrs[] =
				{
					WGL_SAMPLE_BUFFERS_ARB, 0,
					WGL_SAMPLES_ARB, 0,
					WGL_SUPPORT_OPENGL_ARB, true,
					WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
					WGL_DRAW_TO_WINDOW_ARB, true,
					WGL_DOUBLE_BUFFER_ARB, true,
					WGL_COLOR_BITS_ARB, 32,
					WGL_DEPTH_BITS_ARB, 24,
					WGL_STENCIL_BITS_ARB, 8,
					0
				};

				int result;
				uint32_t numFormats = 0;
				do 
				{
					result = wglChoosePixelFormatARB(m_hdc, attrs, NULL, 1, &m_pixelFormat, &numFormats);
					if (0 == result
						||  0 == numFormats)
					{
						attrs[3] >>= 1;
						attrs[1] = attrs[3] == 0 ? 0 : 1;
					}

				} while (0 == numFormats);

				DescribePixelFormat(m_hdc, m_pixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &m_pfd);

				BX_TRACE("Pixel format:\n"
					"\tiPixelType %d\n"
					"\tcColorBits %d\n"
					"\tcAlphaBits %d\n"
					"\tcDepthBits %d\n"
					"\tcStencilBits %d\n"
					, m_pfd.iPixelType
					, m_pfd.cColorBits
					, m_pfd.cAlphaBits
					, m_pfd.cDepthBits
					, m_pfd.cStencilBits
					);

				result = SetPixelFormat(m_hdc, m_pixelFormat, &m_pfd);
				// When window is created by SDL and SDL_WINDOW_OPENGL is set SetPixelFormat
				// will fail. Just warn and continue. In case it failed for some other reason
				// create context will fail and it will error out there.
				BX_WARN(result, "SetPixelFormat failed (last err: 0x%08x)!", GetLastError() );

				uint32_t flags = BGFX_CONFIG_DEBUG ? WGL_CONTEXT_DEBUG_BIT_ARB : 0;
				BX_UNUSED(flags);
				int32_t contextAttrs[9] =
				{
#if BGFX_CONFIG_RENDERER_OPENGL >= 31
					WGL_CONTEXT_MAJOR_VERSION_ARB, BGFX_CONFIG_RENDERER_OPENGL / 10,
					WGL_CONTEXT_MINOR_VERSION_ARB, BGFX_CONFIG_RENDERER_OPENGL % 10,
					WGL_CONTEXT_FLAGS_ARB, flags,
					WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
#else
					WGL_CONTEXT_MAJOR_VERSION_ARB, 2,
					WGL_CONTEXT_MINOR_VERSION_ARB, 1,
					0, 0,
					0, 0,
#endif // BGFX_CONFIG_RENDERER_OPENGL >= 31
					0
				};

				m_context = wglCreateContextAttribsARB(m_hdc, 0, contextAttrs);
				if (NULL == m_context)
				{
					// nVidia doesn't like context profile mask for contexts below 3.2?
					contextAttrs[6] = WGL_CONTEXT_PROFILE_MASK_ARB == contextAttrs[6] ? 0 : contextAttrs[6];
					m_context = wglCreateContextAttribsARB(m_hdc, 0, contextAttrs);
				}
				BGFX_FATAL(NULL != m_context, Fatal::UnableToInitialize, "Failed to create context 0x%08x.", GetLastError() );

				BX_STATIC_ASSERT(sizeof(contextAttrs) == sizeof(m_contextAttrs) );
				memcpy(m_contextAttrs, contextAttrs, sizeof(contextAttrs) );
			}
Esempio n. 15
0
int
main (int argc, char** argv)
{
  GLenum err;
  GLContext ctx;

  /* ---------------------------------------------------------------------- */
  /* parse arguments */
  if (GL_TRUE == ParseArgs(argc-1, argv+1))
  {
#if defined(_WIN32)
    fprintf(stderr, "Usage: visualinfo [-a] [-s] [-h] [-pf <id>]\n");
    fprintf(stderr, "        -a: show all visuals\n");
    fprintf(stderr, "        -s: display to stdout instead of visualinfo.txt\n");
    fprintf(stderr, "        -pf <id>: use given pixelformat\n");
    fprintf(stderr, "        -h: this screen\n");
#else
    fprintf(stderr, "Usage: visualinfo [-h] [-display <display>] [-visual <id>]\n");
    fprintf(stderr, "        -h: this screen\n");
    fprintf(stderr, "        -display <display>: use given display\n");
    fprintf(stderr, "        -visual <id>: use given visual\n");
#endif
    return 1;
  }

  /* ---------------------------------------------------------------------- */
  /* create OpenGL rendering context */
  InitContext(&ctx);
  if (GL_TRUE == CreateContext(&ctx))
  {
    fprintf(stderr, "Error: CreateContext failed\n");
    DestroyContext(&ctx);
    return 1;
  }

  /* ---------------------------------------------------------------------- */
  /* initialize GLEW */
  glewExperimental = GL_TRUE;
#ifdef GLEW_MX
  err = glewContextInit(glewGetContext());
#  ifdef _WIN32
  err = err || wglewContextInit(wglewGetContext());
#  elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
  err = err || glxewContextInit(glxewGetContext());
#  endif
#else
  err = glewInit();
#endif
  if (GLEW_OK != err)
  {
    fprintf(stderr, "Error [main]: glewInit failed: %s\n", glewGetErrorString(err));
    DestroyContext(&ctx);
    return 1;
  }

  /* ---------------------------------------------------------------------- */
  /* open file */
#if defined(_WIN32)
  if (!displaystdout)
    file = fopen("visualinfo.txt", "w");
  if (file == NULL)
    file = stdout;
#else
  file = stdout;
#endif

  /* ---------------------------------------------------------------------- */
  /* output header information */
  /* OpenGL extensions */
  fprintf(file, "OpenGL vendor string: %s\n", glGetString(GL_VENDOR));
  fprintf(file, "OpenGL renderer string: %s\n", glGetString(GL_RENDERER));
  fprintf(file, "OpenGL version string: %s\n", glGetString(GL_VERSION));
  fprintf(file, "OpenGL extensions (GL_): \n");
  PrintExtensions((char*)glGetString(GL_EXTENSIONS));
  /* GLU extensions */
  fprintf(file, "GLU version string: %s\n", gluGetString(GLU_VERSION));
  fprintf(file, "GLU extensions (GLU_): \n");
  PrintExtensions((char*)gluGetString(GLU_EXTENSIONS));

  /* ---------------------------------------------------------------------- */
  /* extensions string */
#if defined(_WIN32)
  /* WGL extensions */
  if (WGLEW_ARB_extensions_string || WGLEW_EXT_extensions_string)
  {
    fprintf(file, "WGL extensions (WGL_): \n");
    PrintExtensions(wglGetExtensionsStringARB ?
                    (char*)wglGetExtensionsStringARB(ctx.dc) :
            (char*)wglGetExtensionsStringEXT());
  }
#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)

#else
  /* GLX extensions */
  fprintf(file, "GLX extensions (GLX_): \n");
  PrintExtensions(glXQueryExtensionsString(glXGetCurrentDisplay(),
                                           DefaultScreen(glXGetCurrentDisplay())));
#endif

  /* ---------------------------------------------------------------------- */
  /* enumerate all the formats */
  VisualInfo(&ctx);

  /* ---------------------------------------------------------------------- */
  /* release resources */
  DestroyContext(&ctx);
  if (file != stdout)
    fclose(file);
  return 0;
}
Esempio n. 16
0
	Window::Window(const char* _name, int32_t _width, int32_t _height, int32_t _xpos, int32_t _ypos, uint32_t _options)
		: m_inputHandler(new InputHandler())
		, m_initialized(false)
		, m_active(false){
		TCHAR* windowName = 0;
		m_windowPlacement.length = sizeof(WINDOWPLACEMENT);

		windowName = (TCHAR*)_strdup(_name);
		WNDCLASSEX windowClass = {
			sizeof(WNDCLASSEX),
			CS_CLASSDC,
			(WNDPROC)WndProc,
			0, 0,
			GetModuleHandle(nullptr),
			LoadIcon(NULL, IDI_WINLOGO),
			LoadCursor(0, IDC_ARROW),
			nullptr,
			nullptr,
			windowName
		};

		if (!RegisterClassEx(&windowClass)){
			std::cerr << "Failed to register Window class. RegisterClassEx returned FALSE\n";
			return;
		}

		auto btst = [](uint32_t _reg, uint32_t _mask) { return (_reg & _mask) != 0; };

		int32_t multisample = (btst(_options, MULTISAMPLE2) ? 2 :
			(btst(_options, MULTISAMPLE4) ? 4 :
			(btst(_options, MULTISAMPLE8) ? 8 :
			(btst(_options, MULTISAMPLE16) ? 16 :
			(btst(_options, MULTISAMPLE32) ? 32 : 0)))));

		const int32_t rgbbits = (btst(_options, RGB16) ? 16 :
			(btst(_options, RGB24) ? 24 :
			(btst(_options, RGB32) ? 32 :
			(btst(_options, RGB64) ? 64 : 32))));

		const int32_t alphabits = (btst(_options, ALPHA4) ? 4 :
			(btst(_options, ALPHA8) ? 8 :
			(btst(_options, ALPHA12) ? 12 :
			(btst(_options, ALPHA16) ? 16 : 0))));

		const int32_t depthbits = (btst(_options, DEPTH8) ? 8 :
			(btst(_options, DEPTH16) ? 16 :
			(btst(_options, DEPTH24) ? 24 :
			(btst(_options, DEPTH32) ? 32 : 24))));

		const int32_t stencilbits = (btst(_options, STENCIL4) ? 4 :
			(btst(_options, STENCIL8) ? 8 :
			(btst(_options, STENCIL16) ? 16 : 8)));

		if (!createWindow(windowName, windowName, WS_OVERLAPPEDWINDOW, _xpos, _ypos, _width, _height)){
			std::cerr << "Failed to create Window CreateWindowEx returned FALSE\n";
			return;
		}
		m_active = true;

		PIXELFORMATDESCRIPTOR pfd = {
			sizeof(PIXELFORMATDESCRIPTOR),  //  size of this pfd  
			1,                     // version number  
			PFD_DRAW_TO_WINDOW |   // support window  
			PFD_SUPPORT_OPENGL |   // support OpenGL  
			(btst(_options, DOUBLE_BUFFER) ? PFD_DOUBLEBUFFER : 0) |   // double buffered
			PFD_GENERIC_ACCELERATED,
			PFD_TYPE_RGBA,         // RGBA type  
			rgbbits,               // 24-bit color depth  
			0, 0, 0, 0, 0, 0,      // color bits ignored  
			alphabits,             // no alpha buffer  
			0,                     // shift bit ignored  
			0,                     // no accumulation buffer  
			0, 0, 0, 0,            // accum bits ignored  
			depthbits,             // 32-bit z-buffer      
			stencilbits,           // no stencil buffer  
			0,                     // no auxiliary buffer  
			PFD_MAIN_PLANE,        // main layer  
			0,                     // reserved  
			0, 0, 0                // layer masks ignored  
		};

		int32_t nPixelFormat = ChoosePixelFormat(m_hdc, &pfd);
		if (nPixelFormat == 0 || SetPixelFormat(m_hdc, nPixelFormat, &pfd) <= 0){
			GetLastError();
			std::cerr << "Error " << GetLastError() << ": Cannot find hardware accelerated OpenGL pixel format \n";
			return;
		}

		int32_t majorVersion = -1, minorVersion = -1;

		HGLRC dummyContext = wglCreateContext(m_hdc);
		if (dummyContext == 0){
			std::cerr << "Cannot create basic OpenGL context\n";
			return;
		}

		wglMakeCurrent(m_hdc, dummyContext);

		const GLubyte*(GL_FUNCPTR*_tempglGetString)(GLenum) = (const GLubyte*(GL_FUNCPTR*)(GLenum))GetGLProcAddress("glGetString");
		const GLubyte* str = _tempglGetString(GL_VERSION);
		sscanf_s((char*)str, "%d.%d", &majorVersion, &minorVersion);

		int32_t fails = LoadOpenGLFunctions(btst(_options, CORE_PROFILE));


		DeleteDC(m_hdc);
		DestroyWindow(m_hwnd);
		if (!createWindow(windowName, windowName, WS_OVERLAPPEDWINDOW, _xpos, _ypos, _width, _height)){
			std::cerr << "Cannot re-create the Window.\n";
			return;
		}

		//Check Extensions

		typedef BOOL(WINAPI *FPCPFARB)(HDC, const int32_t*, const float*, uint32_t, int32_t*, uint32_t*);
		typedef BOOL(WINAPI *FPGPFARB)(HDC, int32_t, int32_t, uint32_t, const int32_t*, int32_t*);

		FPCPFARB wglChoosePixelFormatARB = (FPCPFARB)wglGetProcAddress("wglChoosePixelFormatARB");
		FPGPFARB wglGetPixelFormatAttribivARB = (FPGPFARB)wglGetProcAddress("wglGetPixelFormatAttribivARB");

		int32_t pixelFormatAttribList[] = {
			WGL_DRAW_TO_WINDOW_ARB, GL_TRUE,
			WGL_SUPPORT_OPENGL_ARB, GL_TRUE,
			WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
			WGL_DOUBLE_BUFFER_ARB, btst(_options, DOUBLE_BUFFER),
			WGL_STEREO_ARB, btst(_options, STEREO),
			WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
			WGL_COLOR_BITS_ARB, rgbbits,
			WGL_DEPTH_BITS_ARB, depthbits,
			WGL_STENCIL_BITS_ARB, stencilbits,
			WGL_SAMPLE_BUFFERS_ARB, ((multisample > 0) ? 1 : 0),
			WGL_SAMPLES_ARB, multisample,
			0
		};

		const int32_t pixelFormatAttribListSize = sizeof(pixelFormatAttribList) / sizeof(int32_t);
		int32_t pixelFormats[255];
		UINT numFormats = 0;

		wglChoosePixelFormatARB(m_hdc, pixelFormatAttribList, nullptr, 255, &pixelFormats[0], &numFormats);
		while (numFormats <= 0 && multisample > 0){
			multisample >>= 1;
			pixelFormatAttribList[pixelFormatAttribListSize - 2] = multisample;
			pixelFormatAttribList[pixelFormatAttribListSize - 4] = (multisample > 0 ? 1 : 0);
			std::cout << "Unable to set pixel format. Trying: MSAAx" << multisample << "...";
			wglChoosePixelFormatARB(m_hdc, pixelFormatAttribList, nullptr, 255, &pixelFormats[0], &numFormats);
			std::cout << (numFormats <= 0 ? "failed\n" : "ok\n");
		}

		if (numFormats <= 0){
			std::cout << "Cannot find pixel format \n";
			return;
		}


		PIXELFORMATDESCRIPTOR dummy;
		memset(&dummy, 0, sizeof(PIXELFORMATDESCRIPTOR));
		dummy.nSize = sizeof(PIXELFORMATDESCRIPTOR);
		if (SetPixelFormat(m_hdc, pixelFormats[0], &dummy) <= 0){
			std::cout << "Cannot set the desired pixel format \n " << GetLastError() << std::endl;
			return;
		}


		if (multisample){
			glEnable(GL_MULTISAMPLE);
		}


		ShowWindow(m_hwnd, SW_SHOW);

		/*if (!CheckWGLExtension("WGL_ARB_create_context")){

		}*/

		typedef HGLRC(WINAPI * FPCCAARB)(HDC, HGLRC, const int32_t*);
		FPCCAARB wglCreateContextAttribsARB = (FPCCAARB)wglGetProcAddress("wglCreateContextAttribsARB");


		std::vector<int32_t> attribs;
		attribs.push_back(WGL_CONTEXT_MAJOR_VERSION_ARB);
		attribs.push_back(majorVersion);
		attribs.push_back(WGL_CONTEXT_MINOR_VERSION_ARB);
		attribs.push_back(minorVersion);
		if (btst(_options, DEBUG_CONTEXT)){
			attribs.push_back(WGL_CONTEXT_FLAGS_ARB);
			attribs.push_back(WGL_CONTEXT_DEBUG_BIT_ARB);
		}
		if (btst(_options, CORE_PROFILE)){
			//if (CheckWGLExtension("WGL_ARB_create_context_profile")){
			    attribs.push_back(WGL_CONTEXT_FLAGS_ARB);
			    attribs.push_back(WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB);
			    attribs.push_back(WGL_CONTEXT_PROFILE_MASK_ARB);
			    attribs.push_back(WGL_CONTEXT_CORE_PROFILE_BIT_ARB);
			//}
		}
		else{
			attribs.push_back(WGL_CONTEXT_PROFILE_MASK_ARB);
			attribs.push_back(WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB);
		}
		attribs.push_back(0);

		HGLRC hrc = wglCreateContextAttribsARB(m_hdc, nullptr, &attribs[0]);
		if (hrc <= 0){
			std::cerr << "Cannot create OpenGL context.. \n";
			return;
		}

		wglMakeCurrent(nullptr, nullptr);
		wglDeleteContext(dummyContext);
		wglMakeCurrent(m_hdc, hrc);

		if (fails == 0){
			std::cout << "OpenGL Context successfully initialized. Version " << majorVersion << "." << minorVersion << std::endl;
		}
		else{
			std::cout << "OpenGL Context Created, but failed to load " << fails << " functions. Version " << majorVersion << "." << minorVersion << std::endl;
		}
		//list of OpenGL Extensions
		static const char * (WINAPI *wglGetExtensionsStringARB)(HDC) = NULL;
		wglGetExtensionsStringARB = (const char * (WINAPI *)(HDC))GetGLProcAddress("wglGetExtensionsStringARB");
		std::cout << wglGetExtensionsStringARB(GetDC(GetDesktopWindow())) << std::endl;

		typedef BOOL(WINAPI* FPWGLSIEXT)(int);
		static FPWGLSIEXT wglSwapIntervalEXT = (FPWGLSIEXT)wglGetProcAddress("wglSwapIntervalEXT");

		if (wglSwapIntervalEXT){
			if (btst(_options, FRAME_SYNC))
				wglSwapIntervalEXT(1);
			else if (btst(_options, ADAPTIVE_FRAME_SYNC))
				wglSwapIntervalEXT(-1);
			else
				wglSwapIntervalEXT(0);
		}
		else{
			std::cout << "WARNING: Cannot set the FrameSync option. Using default Driver settings. \n";
		}


		SetWindowLong(m_hwnd, GWLP_USERDATA, (long)this);
		m_initialized = true;

//        setFullscreen(btst(_options, FULLSCREEN));
		delete[] windowName;
	}
Esempio n. 17
0
bool VDOpenGLBinding::Attach(HDC hdc, int minColorBits, int minAlphaBits, int minDepthBits, int minStencilBits, bool doubleBuffer) {
    PIXELFORMATDESCRIPTOR pfd= {};

    pfd.nSize			= sizeof(PIXELFORMATDESCRIPTOR);
    pfd.nVersion		= 1;
    pfd.dwFlags			= PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
    if (doubleBuffer)
        pfd.dwFlags |= PFD_DOUBLEBUFFER;
    pfd.iPixelType		= PFD_TYPE_RGBA;
    pfd.cColorBits		= minColorBits;
    pfd.cAlphaBits		= minAlphaBits;
    pfd.cDepthBits		= minDepthBits;
    pfd.cStencilBits	= minStencilBits;
    pfd.iLayerType		= PFD_MAIN_PLANE;

    int pf = ChoosePixelFormat(hdc, &pfd);
    if (!pf) {
        Detach();
        return false;
    }

    if (!SetPixelFormat(hdc, pf, &pfd)) {
        Detach();
        return false;
    }

    mhglrc = wglCreateContext(hdc);
    if (!mhglrc)
        return false;

    if (!Begin(hdc)) {
        Detach();
        return false;
    }

    for(int i=0; i<sizeof(kGLFunctions)/sizeof(kGLFunctions[0]); ++i) {
        void *p = (void *)GetProcAddress(mhmodOGL, kGLFunctions[i]);

        if (!p) {
            Detach();
            return false;
        }

        ((void **)static_cast<VDAPITableOpenGL *>(this))[i] = p;
    }

    for(int i=0; i<sizeof(kGLExtFunctions)/sizeof(kGLExtFunctions[0]); ++i) {
        void *p = (void *)wglGetProcAddress(kGLExtFunctions[i]);

        ((void **)static_cast<VDAPITableOpenGLEXT *>(this))[i] = p;
    }

    const char *ext = (const char *)glGetString(GL_EXTENSIONS);

    ARB_fragment_program = false;
    ARB_multitexture = false;
    ARB_pixel_buffer_object = false;
    ARB_vertex_program = false;
    ATI_fragment_shader = false;
    EXT_blend_minmax = false;
    EXT_blend_subtract = false;
    EXT_framebuffer_object = false;
    EXT_pixel_buffer_object = false;
    EXT_texture_env_combine = false;
    EXT_texture_edge_clamp = false;
    NV_occlusion_query = false;
    NV_register_combiners = false;
    NV_register_combiners2 = false;

    if (ext) {
        for(;;) {
            while(*ext == ' ')
                ++ext;

            if (!*ext)
                break;

            const char *start = ext;
            while(*ext && *ext != ' ')
                ++ext;

            int len = ext - start;

            switch(len) {
            case 19:
                if (!memcmp(start, "GL_ARB_multitexture", 19))
                    ARB_multitexture = true;
                else if (!memcmp(start, "GL_EXT_blend_minmax", 19))
                    EXT_blend_minmax = true;
                break;

            case 20:
                if (!memcmp(start, "GL_EXT_blend_subtract", 20))
                    EXT_blend_subtract = true;
                break;

            case 21:
                if (!memcmp(start, "GL_NV_occlusion_query", 21))
                    NV_occlusion_query = true;
                else if (!memcmp(start, "GL_ARB_vertex_program", 21))
                    ARB_vertex_program = true;
                break;

            case 22:
                if (!memcmp(start, "GL_ATI_fragment_shader", 22))
                    ATI_fragment_shader = true;
                else if (!memcmp(start, "GL_EXT_secondary_color", 22))
                    EXT_secondary_color = true;
                break;

            case 23:
                if (!memcmp(start, "GL_ARB_fragment_program", 23))
                    ARB_fragment_program = true;
                break;

            case 24:
                if (!memcmp(start, "GL_NV_register_combiners", 24))
                    NV_register_combiners = true;
                break;
            case 25:
                if (!memcmp(start, "GL_NV_register_combiners2", 25))
                    NV_register_combiners2 = true;
                else if (!memcmp(start, "GL_EXT_framebuffer_object", 25))
                    EXT_framebuffer_object = true;
                else if (!memcmp(start, "GL_EXT_texture_edge_clamp", 25))
                    EXT_texture_edge_clamp = true;
                break;
            case 26:
                if (!memcmp(start, "GL_EXT_pixel_buffer_object", 26))
                    EXT_pixel_buffer_object = true;
                else if (!memcmp(start, "GL_ARB_pixel_buffer_object", 26))
                    EXT_pixel_buffer_object = ARB_pixel_buffer_object = true;
                else if (!memcmp(start, "GL_EXT_texture_env_combine", 26))
                    EXT_texture_env_combine = true;
                else if (!memcmp(start, "GL_ARB_texture_env_combine", 26))
                    EXT_texture_env_combine = true;
                break;
            }
        }
    }

    ext = NULL;
    if (wglGetExtensionsStringARB)
        ext = wglGetExtensionsStringARB(hdc);
    else if (wglGetExtensionsStringEXT)
        ext = wglGetExtensionsStringEXT();

    EXT_swap_control = false;
    ARB_make_current_read = false;
    if (ext) {
        for(;;) {
            while(*ext == ' ')
                ++ext;

            if (!*ext)
                break;

            const char *start = ext;
            while(*ext && *ext != ' ')
                ++ext;

            int len = ext - start;

            switch(len) {
            case 20:
                if (!memcmp(start, "WGL_EXT_swap_control", 20))
                    EXT_swap_control = true;
                break;
            case 25:
                if (!memcmp(start, "WGL_ARB_make_current_read", 25))
                    ARB_make_current_read = true;
                break;
            }
        }
    }

    End();

    return true;
}
Esempio n. 18
0
void
WIN_GL_InitExtensions(_THIS)
{
    const char *(WINAPI * wglGetExtensionsStringARB) (HDC) = 0;
    const char *extensions;
    HWND hwnd;
    HDC hdc;
    HGLRC hglrc;
    PIXELFORMATDESCRIPTOR pfd;

    if (!_this->gl_data) {
        return;
    }

    hwnd =
        CreateWindow(SDL_Appname, SDL_Appname, (WS_POPUP | WS_DISABLED), 0, 0,
                     10, 10, NULL, NULL, SDL_Instance, NULL);
    if (!hwnd) {
        return;
    }
    WIN_PumpEvents(_this);

    hdc = GetDC(hwnd);

    WIN_GL_SetupPixelFormat(_this, &pfd);

    SetPixelFormat(hdc, ChoosePixelFormat(hdc, &pfd), &pfd);

    hglrc = _this->gl_data->wglCreateContext(hdc);
    if (!hglrc) {
        return;
    }
    _this->gl_data->wglMakeCurrent(hdc, hglrc);

    wglGetExtensionsStringARB = (const char *(WINAPI *) (HDC))
                                _this->gl_data->wglGetProcAddress("wglGetExtensionsStringARB");
    if (wglGetExtensionsStringARB) {
        extensions = wglGetExtensionsStringARB(hdc);
    } else {
        extensions = NULL;
    }

    /* Check for WGL_ARB_pixel_format */
    _this->gl_data->HAS_WGL_ARB_pixel_format = SDL_FALSE;
    if (HasExtension("WGL_ARB_pixel_format", extensions)) {
        _this->gl_data->wglChoosePixelFormatARB = (BOOL(WINAPI *)
                (HDC, const int *,
                 const FLOAT *, UINT,
                 int *, UINT *))
                WIN_GL_GetProcAddress(_this, "wglChoosePixelFormatARB");
        _this->gl_data->wglGetPixelFormatAttribivARB =
            (BOOL(WINAPI *) (HDC, int, int, UINT, const int *, int *))
            WIN_GL_GetProcAddress(_this, "wglGetPixelFormatAttribivARB");

        if ((_this->gl_data->wglChoosePixelFormatARB != NULL) &&
                (_this->gl_data->wglGetPixelFormatAttribivARB != NULL)) {
            _this->gl_data->HAS_WGL_ARB_pixel_format = SDL_TRUE;
        }
    }

    /* Check for WGL_EXT_swap_control */
    _this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_FALSE;
    if (HasExtension("WGL_EXT_swap_control", extensions)) {
        _this->gl_data->wglSwapIntervalEXT =
            WIN_GL_GetProcAddress(_this, "wglSwapIntervalEXT");
        _this->gl_data->wglGetSwapIntervalEXT =
            WIN_GL_GetProcAddress(_this, "wglGetSwapIntervalEXT");
        if (HasExtension("WGL_EXT_swap_control_tear", extensions)) {
            _this->gl_data->HAS_WGL_EXT_swap_control_tear = SDL_TRUE;
        }
    } else {
        _this->gl_data->wglSwapIntervalEXT = NULL;
        _this->gl_data->wglGetSwapIntervalEXT = NULL;
    }

    /* Check for WGL_EXT_create_context_es2_profile */
    _this->gl_data->HAS_WGL_EXT_create_context_es2_profile = SDL_FALSE;
    if (HasExtension("WGL_EXT_create_context_es2_profile", extensions)) {
        _this->gl_data->HAS_WGL_EXT_create_context_es2_profile = SDL_TRUE;
    }

    /* Check for GLX_ARB_context_flush_control */
    if (HasExtension("WGL_ARB_context_flush_control", extensions)) {
        _this->gl_data->HAS_WGL_ARB_context_flush_control = SDL_TRUE;
    }

    _this->gl_data->wglMakeCurrent(hdc, NULL);
    _this->gl_data->wglDeleteContext(hglrc);
    ReleaseDC(hwnd, hdc);
    DestroyWindow(hwnd);
    WIN_PumpEvents(_this);
}
Esempio n. 19
0
bool WINDOW::Init(	char * windowTitle, int newWidth, int newHeight,
					int newRedBits, int newGreenBits, int newBlueBits, int newAlphaBits,
					int newDepthBits, int newStencilBits,
					bool newFullscreen, bool newVSync, bool dialogBox)
{
	//Set member variables
	title=windowTitle;
	
	width=newWidth;
	height=newHeight;
	redBits=newRedBits;
	greenBits=newGreenBits;
	blueBits=newBlueBits;
	alphaBits=newAlphaBits;
	depthBits=newDepthBits;
	stencilBits=newStencilBits;
	fullscreen=newFullscreen;
	vSync=newVSync;

	LOG::Instance()->OutputSuccess("Creating temporary window");
	LOG::Instance()->OutputNewLine();

	//Init dummy window to get extension pointers
	if(!InitDummy())
		return false;
	
	LOG::Instance()->OutputNewLine();

	bool revertToStandard=false;

	//Initiate the WGL extensions. If not supported, use the standard window
	if(	!SetUpWGL_ARB_extensions_string())
		revertToStandard=true;
		
	//If ARB_extensions_string is supported,
	if(!revertToStandard)
	{
		//Get the WGL extensions string
		const char * wglExtensions;
		wglExtensions=wglGetExtensionsStringARB(hDC);
	
		//If the necessary extensions are not supported, use the standard window
		if(	!SetUpWGL_ARB_pixel_format(wglExtensions)	||
			!SetUpWGL_EXT_swap_control(wglExtensions))
			revertToStandard=true;
	
		//Also initialise ARB_multisample
		SetUpWGL_ARB_multisample(wglExtensions);
	}

	//If we need to revert to standard, shut down the dummy window, Create standard window
	//and return
	if(revertToStandard)
	{
		LOG::Instance()->OutputNewLine();
		LOG::Instance()->OutputSuccess("Destroying temporary window");
	
		ShutdownDummy();

		LOG::Instance()->OutputNewLine();
		LOG::Instance()->OutputSuccess("Replacing with standard, non WGL_extension window");
		LOG::Instance()->OutputNewLine();

		InitStandard();

		return true;
	}

	//If we have reached here, the ARB extensions are supported.
	//Shutdown this window and create a window using ARB_pixel_format etc

	//Find supported AA samples with given color bits, if ARB_multisample is supported
	for(int i=0; i<17; ++i)
		samplesSupported[i]=false;

	if(WGL_ARB_multisample_supported)
	{
		FindSamplesSupported();
	}
	else
	{
		samplesSupported[0]=true;
	}

	//Destroy temporary window
	LOG::Instance()->OutputNewLine();
	LOG::Instance()->OutputSuccess("Destroying temporary window");
	
	ShutdownDummy();

	//Creat WGL extension window
	LOG::Instance()->OutputNewLine();
	LOG::Instance()->OutputSuccess("Replacing with WGL_extension window");
	LOG::Instance()->OutputNewLine();

	if(InitExtended(dialogBox))
		return true;

	//If we reached here, InitExtended failed.
	//Try a standard window as a last resort

	//Destroy extended window
	LOG::Instance()->OutputNewLine();
	LOG::Instance()->OutputSuccess("Extended window creation failed - Destroying");
	
	ShutdownDummy();	//Use ShutdownDummy as we have not hidden the cursor yet.
						//So, we do not want the call to show it

	//Create standard window
	LOG::Instance()->OutputNewLine();
	LOG::Instance()->OutputSuccess("Replacing with standard window");
	LOG::Instance()->OutputNewLine();

	if(InitStandard())
		return true;

	//All window creation attempts failed
	LOG::Instance()->OutputNewLine();
	LOG::Instance()->OutputError("All window Creation attempts failed!");
	Shutdown();
	return false;
}
Esempio n. 20
0
File: gl_w32.c Progetto: benf/mpv
static bool create_context_w32_gl3(struct MPGLContext *ctx)
{
    struct w32_context *w32_ctx = ctx->priv;
    HGLRC *context = &w32_ctx->context;

    if (*context) // reuse existing context
        return true; // not reusing it breaks gl3!

    HWND win = ctx->vo->w32->window;
    HDC windc = GetDC(win);
    HGLRC new_context = 0;

    new_context = wglCreateContext(windc);
    if (!new_context) {
        MP_FATAL(ctx->vo, "Could not create GL context!\n");
        return false;
    }

    // set context
    if (!wglMakeCurrent(windc, new_context)) {
        MP_FATAL(ctx->vo, "Could not set GL context!\n");
        goto out;
    }

    const char *(GLAPIENTRY *wglGetExtensionsStringARB)(HDC hdc)
        = w32gpa((const GLubyte*)"wglGetExtensionsStringARB");

    if (!wglGetExtensionsStringARB)
        goto unsupported;

    const char *wgl_exts = wglGetExtensionsStringARB(windc);
    if (!strstr(wgl_exts, "WGL_ARB_create_context"))
        goto unsupported;

    HGLRC (GLAPIENTRY *wglCreateContextAttribsARB)(HDC hDC, HGLRC hShareContext,
                                                   const int *attribList)
        = w32gpa((const GLubyte*)"wglCreateContextAttribsARB");

    if (!wglCreateContextAttribsARB)
        goto unsupported;

    int gl_version = ctx->requested_gl_version;
    int attribs[] = {
        WGL_CONTEXT_MAJOR_VERSION_ARB, MPGL_VER_GET_MAJOR(gl_version),
        WGL_CONTEXT_MINOR_VERSION_ARB, MPGL_VER_GET_MINOR(gl_version),
        WGL_CONTEXT_FLAGS_ARB, 0,
        WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
        0
    };

    *context = wglCreateContextAttribsARB(windc, 0, attribs);
    if (! *context) {
        // NVidia, instead of ignoring WGL_CONTEXT_FLAGS_ARB, will error out if
        // it's present on pre-3.2 contexts.
        // Remove it from attribs and retry the context creation.
        attribs[6] = attribs[7] = 0;
        *context = wglCreateContextAttribsARB(windc, 0, attribs);
    }
    if (! *context) {
        int err = GetLastError();
        MP_FATAL(ctx->vo, "Could not create an OpenGL 3.x context: error 0x%x\n", err);
        goto out;
    }

    wglMakeCurrent(NULL, NULL);
    wglDeleteContext(new_context);

    if (!wglMakeCurrent(windc, *context)) {
        MP_FATAL(ctx->vo, "Could not set GL3 context!\n");
        wglDeleteContext(*context);
        return false;
    }

    /* update function pointers */
    mpgl_load_functions(ctx->gl, w32gpa, NULL, ctx->vo->log);

    int pfmt = GetPixelFormat(windc);
    PIXELFORMATDESCRIPTOR pfd;
    if (DescribePixelFormat(windc, pfmt, sizeof(PIXELFORMATDESCRIPTOR), &pfd)) {
        ctx->depth_r = pfd.cRedBits;
        ctx->depth_g = pfd.cGreenBits;
        ctx->depth_b = pfd.cBlueBits;
    }

    return true;

unsupported:
    MP_ERR(ctx->vo, "The current OpenGL implementation does not support OpenGL 3.x \n");
out:
    wglDeleteContext(new_context);
    return false;
}
Esempio n. 21
0
static void create_gl_context(HWND hwnd, bool *quit)
{
   struct retro_hw_render_callback *hwr = video_driver_get_hw_context();
   bool debug                           = hwr->debug_context;
   bool core_context                    = (win32_major * 1000 + win32_minor) >= 3001;
   win32_hdc                            = GetDC(hwnd);

   setup_pixel_format(win32_hdc);

#ifdef GL_DEBUG
   debug = true;
#endif

   if (win32_hrc)
   {
      RARCH_LOG("[WGL]: Using cached GL context.\n");
      video_driver_set_video_cache_context_ack();
   }
   else
   {
      win32_hrc = wglCreateContext(win32_hdc);

      /* We'll create shared context later if not. */
      if (win32_hrc && !core_context && !debug)
      {
         win32_hw_hrc = wglCreateContext(win32_hdc);
         if (win32_hw_hrc)
         {
            if (!wglShareLists(win32_hrc, win32_hw_hrc))
            {
               RARCH_LOG("[WGL]: Failed to share contexts.\n");
               *quit = true;
            }
         }
         else
            *quit = true;
      }
   }

   if (win32_hrc)
   {
      if (wglMakeCurrent(win32_hdc, win32_hrc))
         g_win32_inited = true;
      else
         *quit          = true;
   }
   else
   {
      *quit        = true;
      return;
   }

   if (core_context || debug)
   {
      int attribs[16];
      int *aptr = attribs;

      if (core_context)
      {
         *aptr++ = WGL_CONTEXT_MAJOR_VERSION_ARB;
         *aptr++ = win32_major;
         *aptr++ = WGL_CONTEXT_MINOR_VERSION_ARB;
         *aptr++ = win32_minor;

         /* Technically, we don't have core/compat until 3.2.
          * Version 3.1 is either compat or not depending
          * on GL_ARB_compatibility.
          */
         if ((win32_major * 1000 + win32_minor) >= 3002)
         {
            *aptr++ = WGL_CONTEXT_PROFILE_MASK_ARB;
            *aptr++ = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
         }
      }

      if (debug)
      {
         *aptr++ = WGL_CONTEXT_FLAGS_ARB;
         *aptr++ = WGL_CONTEXT_DEBUG_BIT_ARB;
      }

      *aptr = 0;

      if (!pcreate_context)
         pcreate_context = (wglCreateContextAttribsProc)gfx_ctx_wgl_get_proc_address("wglCreateContextAttribsARB");

      if (pcreate_context)
      {
         HGLRC context = pcreate_context(win32_hdc, NULL, attribs);

         if (context)
         {
            wglMakeCurrent(NULL, NULL);
            wglDeleteContext(win32_hrc);
            win32_hrc = context;
            if (!wglMakeCurrent(win32_hdc, win32_hrc))
               *quit = true;
         }
         else
            RARCH_ERR("[WGL]: Failed to create core context. Falling back to legacy context.\n");

         if (win32_use_hw_ctx)
         {
            win32_hw_hrc = pcreate_context(win32_hdc, context, attribs);
            if (!win32_hw_hrc)
            {
               RARCH_ERR("[WGL]: Failed to create shared context.\n");
               *quit = true;
            }
         }
      }
      else
         RARCH_ERR("[WGL]: wglCreateContextAttribsARB not supported.\n");
   }

   {

      const char *(WINAPI * wglGetExtensionsStringARB) (HDC) = 0;
      const char *extensions                                 = NULL;

      wglGetExtensionsStringARB = (const char *(WINAPI *) (HDC))
         gfx_ctx_wgl_get_proc_address("wglGetExtensionsStringARB");
      if (wglGetExtensionsStringARB)
         extensions = wglGetExtensionsStringARB(win32_hdc);
      RARCH_LOG("[WGL] extensions: %s\n", extensions);
      if (wgl_has_extension("WGL_EXT_swap_control_tear", extensions))
      {
         RARCH_LOG("[WGL]: Adaptive VSync supported.\n");
         wgl_adaptive_vsync = true;
      }
   }
}
	bool WindowRendererSupportGLWin32::initializeWGL(void)
	{
		const uint16_t moduleFlags =
			GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
			GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT;
		LPCWSTR moduleName = L"";
		HINSTANCE hInstance = nullptr;
		GetModuleHandleEx(moduleFlags, moduleName, &hInstance);

		WNDCLASS dummyClass;
		memset(&dummyClass, 0, sizeof(WNDCLASS));
		dummyClass.style = CS_OWNDC;
		dummyClass.hInstance = hInstance;
		dummyClass.lpfnWndProc = DefWindowProc;
		dummyClass.lpszClassName = mDummyText;
		RegisterClass(&dummyClass);

		mDummyHWND = CreateWindow(
			mDummyText,
			mDummyText,
			WS_POPUP | WS_CLIPCHILDREN,
			0, 0, 0, 0,
			0,
			0,
			hInstance,
			0);

		HDC hdc = GetDC(mDummyHWND);

		// assign a simple OpenGL pixel format that everyone supports
		PIXELFORMATDESCRIPTOR pfd;
		memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
		pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
		pfd.nVersion = 1;
		pfd.cColorBits = 16;
		pfd.cDepthBits = 15;
		pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
		pfd.iPixelType = PFD_TYPE_RGBA;

		int format = ChoosePixelFormat(hdc, &pfd);
		if(format != 0)
		{
			SetPixelFormat(hdc, format, &pfd);
		}

		bool success = true;

		DeviceContextWin32 dc(hdc);
		mDummyRenderContext = std::make_unique<RenderContextGLWin32>(&dc);
		success &= mDummyRenderContext->makeCurrent();

		if(success)
		{
			const GLubyte* pVersion = glGetString(GL_VERSION);
			std::cout << pVersion << "\n";
			const GLubyte* pShaderVersion = glGetString(GL_SHADING_LANGUAGE_VERSION);
			std::cout << pShaderVersion << "\n";

			wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
			success &= (wglGetExtensionsStringARB != nullptr);

			if(wglGetExtensionsStringARB)
			{
				hdc = wglGetCurrentDC();
				std::istringstream wglexts(wglGetExtensionsStringARB(hdc));
				std::string ext;
				while (wglexts >> ext)
				{
					if (ext == "WGL_ARB_pixel_format")
						mHasPixelFormatARB = true;
					else if (ext == "WGL_ARB_multisample")
						mHasMultisample = true;
					else if (ext == "WGL_EXT_framebuffer_sRGB")
						mHasHardwareGamma = true;
				}
			}

			wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
			success &= (wglChoosePixelFormatARB != nullptr);

			mDummyRenderContext->endCurrent();
		}

		return success;
	}
Esempio n. 23
0
void debug_dump(void)
{
	int					i,idx,cnt,mem_sz;
	obj_type			*obj;
	effect_type			*effect;
	proj_type			*proj;
	weapon_type			*weap;
	proj_setup_type		*proj_setup;
	model_type			*mdl;
	script_type			*script;
	timer_type			*timer;
	SDL_version			*sdl_ver;
	
	console_add_system("Debugging info dumped to stdout");
	
	fprintf(stdout,"\n\n");
	fprintf(stdout,"#########################################################################\n");
	fprintf(stdout,"Dump: dim3 Debugging Info\n");
	fprintf(stdout,"Engine v%s\n",dim3_version);
	fprintf(stdout,"(c) 2000-2007 Klink! Software\n");
	fprintf(stdout,"#########################################################################\n\n");

		// game info
		
	fprintf(stdout,"**************************************\n");
	fprintf(stdout,"Game\n");
	fprintf(stdout,"**************************************\n\n");
	fprintf(stdout,"Project:  %s\n",net_setup.host.proj_name);
	fprintf(stdout,"Tick: %d\n",game_time_get());
	
	debug_return();
	
		// system info
		
	fprintf(stdout,"**************************************\n");
	fprintf(stdout,"System\n");
	fprintf(stdout,"**************************************\n\n");
	fprintf(stdout,"Arch Type: %s\n",arch_type);

#ifdef D3_OS_MAC
	fprintf(stdout,"OS Version: %d.%d.%d\n",os_vers_major,os_vers_minor_1,os_vers_minor_2);
#endif
	
	sdl_ver=(SDL_version*)SDL_Linked_Version();
	fprintf(stdout,"SDL Version: %d.%d.%d\n",sdl_ver->major,sdl_ver->minor,sdl_ver->patch);
	fprintf(stdout,"JavaScript Version: %.2f\n",((float)JS_VERSION/100.0f));
	fprintf(stdout,"PNG Version: %s\n",PNG_LIBPNG_VER_STRING);
	
	debug_return();
	
		// video info
		
	fprintf(stdout,"**************************************\n");
	fprintf(stdout,"Video\n");
	fprintf(stdout,"**************************************\n\n");
	fprintf(stdout,"Engine: %s\n",render_info.name);
	fprintf(stdout,"Screen: %d,%d at %d\n",render_info.monitor_x_sz,render_info.monitor_y_sz,render_info.monitor_refresh_rate);
	fprintf(stdout,"Max Texture Units: %d\n",render_info.texture_unit_count);
	fprintf(stdout,"Max Texture Size: %d\n",render_info.texture_max_size);
	
	if (!gl_check_frame_buffer_ok()) fprintf(stdout,"Shadow support disabled; Unsupported on this video card.\n");
	if (!gl_check_fsaa_ok()) fprintf(stdout,"FSAA support disabled; Unsupported on this video card.\n");
	if (!gl_check_texture_compress_ok()) fprintf(stdout,"Compression disabled; Unsupported on this video card.\n");
	if (!gl_check_point_sprite_ok()) fprintf(stdout,"Point sprite support disabled; Unsupported on this video card.\n");
	if (!gl_check_shader_ok()) fprintf(stdout,"GLSL support disabled; Unsupported on this video card.\n");

	fprintf(stdout,"Extensions:\n%s\n",render_info.ext_string);

#ifdef D3_OS_WINDOWS
	fprintf(stdout,"WGL Extensions:\n%s\n",wglGetExtensionsStringARB(wglGetCurrentDC()));
#endif
	
	debug_return();

		// map info
		
	fprintf(stdout,"**************************************\n");
	fprintf(stdout,"Map\n");
	fprintf(stdout,"**************************************\n\n");
	fprintf(stdout,"Map:  %s\n",map.info.name);
	fprintf(stdout,"Author:  %s\n",map.info.author);
	fprintf(stdout,"Mesh Count:  %d\n",map.mesh.nmesh);
	fprintf(stdout,"Liquid Count:  %d\n",map.liquid.nliquid);
	fprintf(stdout,"Spot Count:  %d\n",map.nspot);
	fprintf(stdout,"Scenery Count:  %d\n",map.nscenery);
	fprintf(stdout,"Node Count:  %d\n",map.nnode);
	
	debug_return();
	
		// objects

	debug_header("Objects",server.count.obj,(sizeof(obj_type)*server.count.obj));
	
	debug_space("Name",25);
	debug_space("Type",15);
	debug_space("Script",25);
	debug_space("Binding",10);
	debug_return();
	debug_space("------------------------",25);
	debug_space("------------------------",15);
	debug_space("------------------------",25);
	debug_space("---------",10);
	debug_return();
	
	obj=server.objs;
	
	for ((i=0);(i!=server.count.obj);i++) {
		debug_space(obj->name,25);
		debug_space(obj->type,15);
		if (!obj->scenery.on) {
			idx=scripts_find_uid(obj->attach.script_uid);
			debug_space(js.scripts[idx].name,25);
		}
		else {
			debug_space("*",25);
		}
		debug_space(bind_type_str[obj->bind],10);
		debug_return();
		obj++;
	}
	
	debug_return();
	
		// weapons

	debug_header("Weapons",server.count.weapon,(sizeof(weapon_type)*server.count.weapon));
	
	debug_space("Name",20);
	debug_space("Object",20);
	debug_return();
	debug_space("-------------------",20);
	debug_space("-------------------",20);
	debug_return();
	
	weap=server.weapons;
	
	for ((i=0);(i!=server.count.weapon);i++) {
		obj=object_find_uid(weap->obj_uid);
		
		debug_space(weap->name,20);
		debug_space(obj->name,20);
		debug_return();
		weap++;
	}
	
	debug_return();
	
		// projectile setups

	debug_header("Projectile Setups",server.count.proj_setup,(sizeof(proj_setup_type)*server.count.proj_setup));
	
	debug_space("Name",20);
	debug_space("Object",20);
	debug_space("Weapon",20);
	debug_return();
	debug_space("-------------------",20);
	debug_space("-------------------",20);
	debug_space("-------------------",20);
	debug_return();
	
	proj_setup=server.proj_setups;
	
	for ((i=0);(i!=server.count.proj_setup);i++) {
		obj=object_find_uid(proj_setup->obj_uid);
		weap=weapon_find_uid(proj_setup->weap_uid);
		
		debug_space(proj_setup->name,20);
		debug_space(obj->name,20);
		debug_space(weap->name,20);
		debug_return();
		proj_setup++;
	}
	
	debug_return();
	
		// models

	mem_sz=sizeof(model_type)*server.count.model;

	mdl=server.models;
	
	for (i=0;i!=server.count.model;i++) {
		mem_sz+=model_memory_size(mdl);
		mdl++;
	}
		
	debug_header("Models",server.count.model,mem_sz);
	
	debug_space("Name",32);
	debug_space("Vertexes",10);
	debug_space("Trigs",10);
	debug_space("Ref Count",10);
	debug_return();
	debug_space("------------------------------",32);
	debug_space("---------",10);
	debug_space("---------",10);
	debug_space("---------",10);
	debug_return();

	mdl=server.models;
	
	for (i=0;i!=server.count.model;i++) {
		debug_space(mdl->name,32);
		debug_int_space(mdl->meshes[0].nvertex,10);
		debug_int_space(mdl->meshes[0].ntrig,10);
		debug_int_space(mdl->reference_count,10);
		debug_return();
		mdl++;
	}
	
	debug_return();
	
		// projectiles
		
	debug_header("Projectiles",server.count.proj,(sizeof(proj_type)*max_projectile));
	
	debug_space("Name",20);
	debug_space("Object",20);
	debug_space("Weapon",20);
	debug_return();
	debug_space("-------------------",20);
	debug_space("-------------------",20);
	debug_space("-------------------",20);
	debug_return();
	
	proj=server.projs;
	
	for ((i=0);(i!=server.count.proj);i++) {
		obj=object_find_uid(proj->obj_uid);
		weap=weapon_find_uid(proj->weap_uid);
		proj_setup=proj_setups_find_uid(proj->proj_setup_uid);
		
		debug_space(proj_setup->name,20);
		debug_space(obj->name,20);
		debug_space(weap->name,20);
		debug_return();
		proj++;
	}
	
	debug_return();
	
		// effects
		
	debug_header("Effects",server.count.effect,(sizeof(effect_type)*max_effect));
	
	debug_space("Type",10);
	debug_space("Life Tick",10);
	debug_return();
	debug_space("---------",10);
	debug_space("---------",10);
	debug_return();
	
	effect=server.effects;
	
	for ((i=0);(i!=server.count.effect);i++) {
		debug_space(effect_type_str[effect->effecttype],10);
		debug_int_space(effect->life_tick,10);
		debug_return();
		effect++;
	}
	
	debug_return();
	
		// scripts
		
	script=js.scripts;
	
	cnt=0;
	for ((i=0);(i!=max_scripts);i++) {
		if (script->used) cnt++;
		script++;
	}
		
	debug_header("Scripts",cnt,-1);
	
	debug_space("Name",32);
	debug_return();
	debug_space("-------------------------------",32);
	debug_return();
	
	script=js.scripts;
	
	for ((i=0);(i!=max_scripts);i++) {
		if (script->used) {
			debug_space(script->name,32);
			debug_return();
		}
		script++;
	}
	
	debug_return();
	
		// timers
		
	debug_header("Timers",js.count.timer,-1);
	
	debug_space("Script",32);
	debug_space("Count",10);
	debug_space("Type",10);
	debug_return();
	debug_space("-------------------------------",32);
	debug_space("---------",10);
	debug_space("---------",10);
	debug_return();
	
	timer=js.timers;
	
	for ((i=0);(i!=js.count.timer);i++) {
		script=&js.scripts[scripts_find_uid(timer->attach.script_uid)];
		debug_space(script->name,32);
		debug_int_space(timer->count,10);
		debug_space((timer->mode==timer_mode_repeat)?"Timer":"Wait",10);
		debug_return();
		timer++;
	}
	
	debug_return();

	fflush(stdout);
}
Esempio n. 24
0
int WDL_GPU::init(HWND hwnd)
{
  m_hwnd = hwnd;

  if(static_disableOpenGl) return 0;

  m_glDll = LoadLibrary("opengl32.dll");
  if(!m_glDll) return 0;

  *((int *)&wglCreateContext) = (int)GetProcAddress(m_glDll, "wglCreateContext");
  *((int *)&wglDeleteContext) = (int)GetProcAddress(m_glDll, "wglDeleteContext");
  *((int *)&wglMakeCurrent) = (int)GetProcAddress(m_glDll, "wglMakeCurrent");
  *((int *)&wglGetProcAddress) = (int)GetProcAddress(m_glDll, "wglGetProcAddress");
  *((int *)&glClearColor) = (int)GetProcAddress(m_glDll, "glClearColor");
  *((int *)&glClear) = (int)GetProcAddress(m_glDll, "glClear");
  *((int *)&glEnable) = (int)GetProcAddress(m_glDll, "glEnable");
  *((int *)&glDisable) = (int)GetProcAddress(m_glDll, "glDisable");
  *((int *)&glBlendFunc) = (int)GetProcAddress(m_glDll, "glBlendFunc");
  *((int *)&glLineWidth) = (int)GetProcAddress(m_glDll, "glLineWidth");
  *((int *)&glColor3f) = (int)GetProcAddress(m_glDll, "glColor3f");
  *((int *)&glBegin) = (int)GetProcAddress(m_glDll, "glBegin");
  *((int *)&glEnd) = (int)GetProcAddress(m_glDll, "glEnd");
  *((int *)&glFlush) = (int)GetProcAddress(m_glDll, "glFlush");
  *((int *)&glVertex2f) = (int)GetProcAddress(m_glDll, "glVertex2f");
  *((int *)&glFinish) = (int)GetProcAddress(m_glDll, "glFinish");
  *((int *)&glGetString) = (int)GetProcAddress(m_glDll, "glGetString");
  *((int *)&glReadPixels) = (int)GetProcAddress(m_glDll, "glReadPixels");

  if(!wglGetProcAddress)
  {
    FreeLibrary(m_glDll);
    m_glDll = NULL;
    return 0;
  }

  HDC pdc = GetDC(m_hwnd);

  PIXELFORMATDESCRIPTOR pfd;
	ZeroMemory( &pfd, sizeof( pfd ) );
	pfd.nSize = sizeof( pfd );
	pfd.nVersion = 1;
	pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
	pfd.iPixelType = PFD_TYPE_RGBA;
	pfd.cColorBits = 24;
	pfd.cDepthBits = 16;
	pfd.iLayerType = PFD_MAIN_PLANE;
	int format = ChoosePixelFormat( pdc, &pfd );
	SetPixelFormat( pdc, format, &pfd );

  m_rc = wglCreateContext(pdc);

  if(!m_rc)
  {
    ReleaseDC(m_hwnd, pdc);
    FreeLibrary(m_glDll);
    m_glDll = NULL;
    return 0;
  }
  wglMakeCurrent(pdc, m_rc);

  char *rend = (char *)glGetString(GL_RENDERER);
  if(!rend || (rend && strstr(rend, "GDI"))) goto ret; //opengl software rendering is slooooow

  wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
  
  if(!wglGetExtensionsStringARB)
  {
ret:
    ReleaseDC(m_hwnd, pdc);
    wglMakeCurrent(NULL, NULL);
    wglDeleteContext(m_rc);
    FreeLibrary(m_glDll);
    m_glDll = NULL;
    return 0;
  }
  
  char *ext = NULL;
  ext = (char*)wglGetExtensionsStringARB( pdc );
  if(!strstr( ext, "WGL_ARB_pbuffer" )) goto ret;

  wglCreatePbufferARB    = (PFNWGLCREATEPBUFFERARBPROC)wglGetProcAddress("wglCreatePbufferARB");
	wglGetPbufferDCARB     = (PFNWGLGETPBUFFERDCARBPROC)wglGetProcAddress("wglGetPbufferDCARB");
	wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC)wglGetProcAddress("wglReleasePbufferDCARB");
	wglDestroyPbufferARB   = (PFNWGLDESTROYPBUFFERARBPROC)wglGetProcAddress("wglDestroyPbufferARB");
	wglQueryPbufferARB     = (PFNWGLQUERYPBUFFERARBPROC)wglGetProcAddress("wglQueryPbufferARB");
  if( !wglCreatePbufferARB || !wglGetPbufferDCARB || !wglReleasePbufferDCARB || !wglDestroyPbufferARB || !wglQueryPbufferARB ) goto ret;
  
  wglGetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)wglGetProcAddress("wglGetPixelFormatAttribivARB");
	wglGetPixelFormatAttribfvARB = (PFNWGLGETPIXELFORMATATTRIBFVARBPROC)wglGetProcAddress("wglGetPixelFormatAttribfvARB");
	wglChoosePixelFormatARB      = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");

	if( !wglGetExtensionsStringARB || !wglCreatePbufferARB || !wglGetPbufferDCARB ) goto ret;

  ReleaseDC(m_hwnd, pdc);

  return 1;
}
int ObjMeshGPUDeformer_uUq_pbuffer::InitRTT()
{
  // init WGL extensions

  wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
  char *ext = NULL;

  if( wglGetExtensionsStringARB )
    ext = (char*)wglGetExtensionsStringARB( wglGetCurrentDC() );
  else
  {
    printf("Unable to get address for wglGetExtensionsStringARB!");
    return 1;
  }

  //
  // WGL_ARB_pbuffer
  //

  if( strstr( ext, "WGL_ARB_pbuffer" ) == NULL )
  {
    printf("WGL_ARB_pbuffer extension was not found");
    return 1;
  }
  else
  {
    wglCreatePbufferARB    = (PFNWGLCREATEPBUFFERARBPROC)wglGetProcAddress("wglCreatePbufferARB");
    wglGetPbufferDCARB     = (PFNWGLGETPBUFFERDCARBPROC)wglGetProcAddress("wglGetPbufferDCARB");
    wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC)wglGetProcAddress("wglReleasePbufferDCARB");
    wglDestroyPbufferARB   = (PFNWGLDESTROYPBUFFERARBPROC)wglGetProcAddress("wglDestroyPbufferARB");
    wglQueryPbufferARB     = (PFNWGLQUERYPBUFFERARBPROC)wglGetProcAddress("wglQueryPbufferARB");

    if( !wglCreatePbufferARB || !wglGetPbufferDCARB || !wglReleasePbufferDCARB ||
      !wglDestroyPbufferARB || !wglQueryPbufferARB )
    {
      printf("One or more WGL_ARB_pbuffer functions were not found");
      return 1;
    }
  }

  //
  // WGL_ARB_pixel_format
  //

  if( strstr( ext, "WGL_ARB_pixel_format" ) == NULL )
  {
    printf("Error: WGL_ARB_pixel_format extension was not found");
    return 1;
  }
  else
  {
    wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");

    if( !wglChoosePixelFormatARB )
    {
      printf("Error: One or more WGL_ARB_pixel_format functions were not found");
      return 1;
    }
  }

  //
  // WGL_ARB_render_texture
  //

  if( strstr( ext, "WGL_ARB_render_texture" ) == NULL )
  {
    printf("WGL_ARB_render_texture extension was not found");
    return 1;
  }
  else
  {
    wglBindTexImageARB     = (PFNWGLBINDTEXIMAGEARBPROC)wglGetProcAddress("wglBindTexImageARB");
    wglReleaseTexImageARB  = (PFNWGLRELEASETEXIMAGEARBPROC)wglGetProcAddress("wglReleaseTexImageARB");
    wglSetPbufferAttribARB = (PFNWGLSETPBUFFERATTRIBARBPROC)wglGetProcAddress("wglSetPbufferAttribARB");

    if( !wglBindTexImageARB || !wglReleaseTexImageARB || !wglSetPbufferAttribARB )
    {
      printf("One or more WGL_ARB_render_texture functions were not found");
      return 1;
    }
  }

  hDC = wglGetCurrentDC();
  hRC = wglGetCurrentContext();

  //-------------------------------------------------------------------------
  // Create a p-buffer for off-screen rendering.
  //-------------------------------------------------------------------------
  int width = vertexDeformationTextureSize;
  int height = vertexDeformationTextureSize;

  pbuffer.hPBuffer = NULL;
  pbuffer.nWidth   = width;
  pbuffer.nHeight  = height;

  //
  // Define the minimum pixel format requirements we will need for our 
  // p-buffer. A p-buffer is just like a frame buffer, it can have a depth 
  // buffer associated with it and it can be double buffered.
  //

  int pf_attr[] =
  {
    WGL_SUPPORT_OPENGL_ARB, TRUE,       // P-buffer will be used with OpenGL
      WGL_DRAW_TO_PBUFFER_ARB, TRUE,      // Enable render to p-buffer
      WGL_BIND_TO_TEXTURE_RGBA_ARB, TRUE, // P-buffer will be used as a texture
      WGL_RED_BITS_ARB, 32,                // At least 8 bits for RED channel
      WGL_GREEN_BITS_ARB, 32,              // At least 8 bits for GREEN channel
      WGL_BLUE_BITS_ARB, 32,               // At least 8 bits for BLUE channel
      WGL_ALPHA_BITS_ARB, 32,              // At least 8 bits for ALPHA channel
      WGL_DEPTH_BITS_ARB, 0,             // At least 0 bits for depth buffer
      WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_FLOAT_ATI,
      WGL_DOUBLE_BUFFER_ARB, FALSE,       // We don't require double buffering
      0                                   // Zero terminates the list
  };

  unsigned int count = 0;
  int pixelFormat;
  wglChoosePixelFormatARB( hDC, (const int*)pf_attr, NULL, 1, &pixelFormat, &count);

  if( count == 0 )
  {
    printf("Could not find an acceptable pixel format!");
    return 1;
  }

  //
  // Set some p-buffer attributes so that we can use this p-buffer as a
  // 2D RGBA texture target.
  //

  int pb_attr[] =
  {
    WGL_TEXTURE_FORMAT_ARB, WGL_TEXTURE_RGBA_ARB, // Our p-buffer will have a texture format of RGBA
      WGL_TEXTURE_TARGET_ARB, WGL_TEXTURE_2D_ARB,   // Of texture target will be GL_TEXTURE_2D
      0                                             // Zero terminates the list
  };

  //
  // Create the p-buffer...
  //

  pbuffer.hPBuffer = wglCreatePbufferARB( hDC, pixelFormat, 
    pbuffer.nWidth, pbuffer.nHeight, pb_attr );
  pbuffer.hDC      = wglGetPbufferDCARB( pbuffer.hPBuffer );
  pbuffer.hRC      = wglCreateContext( pbuffer.hDC );

  if( !pbuffer.hPBuffer )
  {
    printf("Error: could not create the p-buffer");
    return 1;
  }

  int queryHeight;
  int queryWidth;
  wglQueryPbufferARB( pbuffer.hPBuffer, WGL_PBUFFER_WIDTH_ARB, &queryHeight );
  wglQueryPbufferARB( pbuffer.hPBuffer, WGL_PBUFFER_WIDTH_ARB, &queryWidth );

  if( queryHeight != pbuffer.nHeight || queryWidth != pbuffer.nWidth )
  {
    printf("The width and height of the created p-buffer don't match the requirements!");
    return 1;
  }

  return 0;
}
Esempio n. 26
0
//Set up variables
bool DemoInit()
{
	if(!window.Init("Render To Texture", 640, 480, 32, 24, 8, WINDOWED_SCREEN))
		return 0;											//quit if not created

	camera.Init(VECTOR3D(0.0f, 0.0f, -2.5f), 2.0f, 100.0f);

	//Set up extensions
	if(	!SetUpWGL_ARB_extensions_string())
		return false;

	SetUpEXT_texture_filter_anisotropic();
	SetUpSGIS_generate_mipmap();
		
	//Get the WGL extensions string
	const char * wglExtensions;
	wglExtensions=wglGetExtensionsStringARB(window.hDC);

	//Set up wgl extensions
	if(	!SetUpWGL_ARB_pbuffer(wglExtensions) || !SetUpWGL_ARB_pixel_format(wglExtensions) ||
		!SetUpWGL_ARB_render_texture(wglExtensions))
		return false;


	//Init the pbuffer
	int pbufferExtraIAttribs[]={WGL_BIND_TO_TEXTURE_RGBA_ARB, true,
								0};

	int pbufferFlags[]={WGL_TEXTURE_FORMAT_ARB, WGL_TEXTURE_RGBA_ARB,
						WGL_TEXTURE_TARGET_ARB, WGL_TEXTURE_2D_ARB,
						
						//request mipmap space if mipmaps are to be used
						SGIS_generate_mipmap_supported ? WGL_MIPMAP_TEXTURE_ARB : 0,
						SGIS_generate_mipmap_supported ? true : 0,

						0};

	if(!pbuffer.Init(pbufferSize, pbufferSize, 32, 24, 8, 1, pbufferExtraIAttribs, pbufferFlags))
		return false;
	

	//Create the texture object to relate to the pbuffer
	glGenTextures(1, &pbufferTexture);
	glBindTexture(GL_TEXTURE_2D, pbufferTexture);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

	//Use generated mipmaps if supported
	if(SGIS_generate_mipmap_supported)
	{
		glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, true);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
		glHint(GL_GENERATE_MIPMAP_HINT_SGIS, GL_NICEST);
		useMipmapFilter=true;
	}

	//Use maximum anisotropy if supported
	if(EXT_texture_filter_anisotropic_supported)
	{
		glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAnisotropy);
		currentAnisotropy=maxAnisotropy;
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, currentAnisotropy);
	}



	//Load the decal texture
	//Note: This MUST be done when the pbuffer is the current context
	pbuffer.MakeCurrent();
	
	IMAGE decalImage;
	decalImage.Load("decal.bmp");

	glGenTextures(1, &decalTexture);
	glBindTexture(GL_TEXTURE_2D, decalTexture);
	glTexImage2D(	GL_TEXTURE_2D, 0, GL_RGBA8, decalImage.width, decalImage.height,
					0, decalImage.format, GL_UNSIGNED_BYTE, decalImage.data);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);


	
	//reset timer for start
	timer.Reset();
	
	return true;
}
int CmnOGLOffscreen::init(void)
{
  /* Fehlercodes:
  -1 = Unable to get address for wglGetExtensionsStringARB
  -2 = WGL_ARB_pbuffer extension was not found
  -3 = One or more WGL_ARB_pbuffer functions were not found
  -4 = WGL_ARB_pixel_format extension was not found
  -5 = One or more WGL_ARB_pixel_format functions were not found
  -6 = WGL_ARB_render_texture extension was not found
  -7 = One or more WGL_ARB_render_texture functions were not found
  -8 = Could not find an acceptable pixel format
  -9 = Could not create the p-buffer
  */
  wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
	char *ext = NULL;
	
	if( wglGetExtensionsStringARB ) ext = (char*)wglGetExtensionsStringARB( wglGetCurrentDC() ); else return -1;
	
  if( strstr( ext, "WGL_ARB_pbuffer" ) == NULL ) return -2;
  
  wglCreatePbufferARB    = (PFNWGLCREATEPBUFFERARBPROC)wglGetProcAddress("wglCreatePbufferARB");
  wglGetPbufferDCARB     = (PFNWGLGETPBUFFERDCARBPROC)wglGetProcAddress("wglGetPbufferDCARB");
  wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC)wglGetProcAddress("wglReleasePbufferDCARB");
	wglDestroyPbufferARB   = (PFNWGLDESTROYPBUFFERARBPROC)wglGetProcAddress("wglDestroyPbufferARB");
	wglQueryPbufferARB     = (PFNWGLQUERYPBUFFERARBPROC)wglGetProcAddress("wglQueryPbufferARB");
  
  if( !wglCreatePbufferARB || !wglGetPbufferDCARB || !wglReleasePbufferDCARB ||!wglDestroyPbufferARB || !wglQueryPbufferARB ) return -3;
	
  if( strstr( ext, "WGL_ARB_pixel_format" ) == NULL ) return -4;
	
  wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");

  if( !wglChoosePixelFormatARB ) return -5;

	g_pbuffer.hPBuffer = NULL;
	g_pbuffer.nWidth   = iWidth;
	g_pbuffer.nHeight  = iHeight;

	int pf_attr[] =
	{
		WGL_SUPPORT_OPENGL_ARB, TRUE,       // P-buffer will be used with OpenGL
		WGL_DRAW_TO_PBUFFER_ARB, TRUE,      // Enable render to p-buffer
		WGL_BIND_TO_TEXTURE_RGBA_ARB, TRUE, // P-buffer will be used as a texture
		WGL_RED_BITS_ARB, 8,                // At least 8 bits for RED channel
		WGL_GREEN_BITS_ARB, 8,              // At least 8 bits for GREEN channel
		WGL_BLUE_BITS_ARB, 8,               // At least 8 bits for BLUE channel
		WGL_ALPHA_BITS_ARB, 8,              // At least 8 bits for ALPHA channel
		WGL_DEPTH_BITS_ARB, 16,             // At least 16 bits for depth buffer
		WGL_DOUBLE_BUFFER_ARB, FALSE,       // We don't require double buffering
		0                                   // Zero terminates the list
	};

	unsigned int count = 0;
  int pixelFormat;
	wglChoosePixelFormatARB( m_hgldc,(const int*)pf_attr, NULL, 1, &pixelFormat, &count);

  if( count == 0 ) return -8;
	
	g_pbuffer.hPBuffer = wglCreatePbufferARB( m_hgldc, pixelFormat, g_pbuffer.nWidth, g_pbuffer.nHeight, NULL/*pb_attr*/ );
	g_pbuffer.hDC      = wglGetPbufferDCARB( g_pbuffer.hPBuffer );
	g_pbuffer.hRC      = wglCreateContext( g_pbuffer.hDC );
	if( !g_pbuffer.hPBuffer ) return -9;


  enable();

  glShadeModel(GL_SMOOTH);						
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);			
	glClearDepth(1.0f);							
	glEnable(GL_DEPTH_TEST);					
	glDepthFunc(GL_LEQUAL);						
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
  glViewport(0,0,iWidth,iHeight);	
  glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	double m_dAspect = (iHeight == 0) ? (double)iWidth : (double)iWidth/(double)iHeight;
  double m_dNearPlane   = 0.0; 
	double m_dFarPlane    = 15.0; 
  gluPerspective(45.0, m_dAspect, m_dNearPlane, m_dFarPlane); 
	glMatrixMode(GL_MODELVIEW);

  disable();


  return 1;
}
Esempio n. 28
0
///////////////////////////////////////////////////////////////////////////////
// extract openGL info
// This function must be called after GL rendering context opened.
///////////////////////////////////////////////////////////////////////////////
bool glInfo::getInfo(unsigned int param)
{
    const char* str = 0;
    char* tok = 0;

    // get vendor string
    str = (const char*)glGetString(GL_VENDOR);
    if(str) this->vendor = str;                  // check NULL return value
    else return false;

    // get renderer string
    str = (const char*)glGetString(GL_RENDERER);
    if(str) this->renderer = str;                // check NULL return value
    else return false;

    // get version string
    str = (const char*)glGetString(GL_VERSION);
    if(str) this->version = str;                 // check NULL return value
    else return false;

    // get version string (v2.0+)
    str = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
    if(str) this->glslVersion = str;            // check NULL return value
    else glslVersion = "";

    // get all extensions as a string
    str = (const char*)glGetString(GL_EXTENSIONS);

    // split extensions
    if(str)
    {
        tok = strtok((char*)str, " ");
        while(tok)
        {
            this->extensions.push_back(tok);    // put a extension into struct
            tok = strtok(0, " ");               // next token
        }
    }

    // get WGL specific extensions for v3.0+
#ifdef _WIN32 //===========================================
    wglGetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
    if(wglGetExtensionsStringARB && param)
    {
        str = wglGetExtensionsStringARB((HDC)param);
        if(str)
        {
            tok = strtok((char*)str, " ");
            while(tok)
            {
                this->extensions.push_back(tok);    // put a extension into struct
                tok = strtok(0, " ");               // next token
            }
        }
    }
#endif //==================================================

    // sort extension by alphabetical order
    std::sort(this->extensions.begin(), this->extensions.end());

    // get number of color bits
    glGetIntegerv(GL_RED_BITS, &this->redBits);
    glGetIntegerv(GL_GREEN_BITS, &this->greenBits);
    glGetIntegerv(GL_BLUE_BITS, &this->blueBits);
    glGetIntegerv(GL_ALPHA_BITS, &this->alphaBits);

    // get depth bits
    glGetIntegerv(GL_DEPTH_BITS, &this->depthBits);

    // get stecil bits
    glGetIntegerv(GL_STENCIL_BITS, &this->stencilBits);

    // get max number of lights allowed
    glGetIntegerv(GL_MAX_LIGHTS, &this->maxLights);

    // get max texture resolution
    glGetIntegerv(GL_MAX_TEXTURE_SIZE, &this->maxTextureSize);

    // get max number of clipping planes
    glGetIntegerv(GL_MAX_CLIP_PLANES, &this->maxClipPlanes);

    // get max modelview and projection matrix stacks
    glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &this->maxModelViewStacks);
    glGetIntegerv(GL_MAX_PROJECTION_STACK_DEPTH, &this->maxProjectionStacks);
    glGetIntegerv(GL_MAX_ATTRIB_STACK_DEPTH, &this->maxAttribStacks);

    // get max texture stacks
    glGetIntegerv(GL_MAX_TEXTURE_STACK_DEPTH, &this->maxTextureStacks);

    return true;
}
Esempio n. 29
0
static int init_platform_gl_extensions(lite3d_video_settings *settings)
{
    SDL_SysWMinfo wminfo;
    SDL_VERSION(&wminfo.version);
    if (!SDL_GetWindowWMInfo(gRenderWindow, &wminfo))
    {
        SDL_LogWarn(
            SDL_LOG_CATEGORY_APPLICATION,
            "SDL_GetWindowWMInfo: %s",
            SDL_GetError());

        return LITE3D_FALSE;
    }

#ifndef GLES
# ifdef PLATFORM_Windows

    if (!WGLEW_ARB_extensions_string)
    {
        SDL_LogWarn(
            SDL_LOG_CATEGORY_APPLICATION,
            "SDL_GetWindowWMInfo: %s",
            SDL_GetError());

        return LITE3D_FALSE;
    }

    SDL_LogDebug(
        SDL_LOG_CATEGORY_APPLICATION,
        "%s: WGL Extensions %s",
        LITE3D_CURRENT_FUNCTION,
        (char *) wglGetExtensionsStringARB(GetDC(wminfo.info.win.window)));

# elif defined PLATFORM_Linux

    if (!GLXEW_VERSION_1_3)
    {
        SDL_LogCritical(
            SDL_LOG_CATEGORY_APPLICATION,
            "%s: GLX v1.3 not supported..",
            LITE3D_CURRENT_FUNCTION);

        return LITE3D_FALSE;
    }

    SDL_LogDebug(
        SDL_LOG_CATEGORY_APPLICATION,
        "%s: GLX Client %s",
        LITE3D_CURRENT_FUNCTION,
        (char *) glXGetClientString(wminfo.info.x11.display, 1));

    SDL_LogDebug(
        SDL_LOG_CATEGORY_APPLICATION,
        "%s: GLX Server %s",
        LITE3D_CURRENT_FUNCTION,
        (char *) glXQueryServerString(wminfo.info.x11.display, 0, 1));

    SDL_LogDebug(
        SDL_LOG_CATEGORY_APPLICATION,
        "%s: GLX Extensions %s",
        LITE3D_CURRENT_FUNCTION,
        (char *) glXQueryExtensionsString(wminfo.info.x11.display, 0));

# endif
#endif

    return LITE3D_TRUE;
}