void @init() { EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); /* Use the real EGL functions */ typedef void* (*EglGetProcAddressFunc)(const char*); typedef void (*EglTerminateFunc)(EGLDisplay); EglGetProcAddressFunc lookup = (EglGetProcAddressFunc)trLookupFunction(0, "eglGetProcAddress")->pointer; EglTerminateFunc terminate = (EglTerminateFunc)trLookupFunction(0, "eglTerminate")->pointer; TR_ASSERT(lookup); TR_ASSERT(terminate); eglInitialize(display, 0, 0); LOAD_EXT("glDrawTexsOES"); LOAD_EXT("glDrawTexiOES"); LOAD_EXT("glDrawTexfOES"); LOAD_EXT("glDrawTexxOES"); LOAD_EXT("glDrawTexsvOES"); LOAD_EXT("glDrawTexivOES"); LOAD_EXT("glDrawTexfvOES"); LOAD_EXT("glDrawTexxvOES"); LOAD_EXT("glMatrixIndexPointerOES"); LOAD_EXT("glWeightPointerOES"); LOAD_EXT("glPointSizePointerOES"); LOAD_EXT("glLoadPaletteFromModelViewMatrixOES"); terminate(display); }
static int Open(vlc_gl_t *gl, unsigned width, unsigned height) { vout_display_sys_t *sys; /* Allocate structure */ gl->sys = sys = calloc(1, sizeof(*sys)); if (!sys) return VLC_ENOMEM; /* Process selected GPU affinity */ int nVidiaAffinity = var_InheritInteger(gl, "gpu-affinity"); if (nVidiaAffinity >= 0) CreateGPUAffinityDC(gl, nVidiaAffinity); vout_window_t *wnd = gl->surface; if (wnd->type != VOUT_WINDOW_TYPE_HWND || wnd->handle.hwnd == 0) goto error; sys->hvideownd = wnd->handle.hwnd; sys->hGLDC = GetDC(sys->hvideownd); if (sys->hGLDC == NULL) { msg_Err(gl, "Could not get the device context"); goto error; } /* Set the pixel format for the DC */ PIXELFORMATDESCRIPTOR pfd = VLC_PFD_INITIALIZER; SetPixelFormat(sys->hGLDC, ChoosePixelFormat(sys->hGLDC, &pfd), &pfd); /* Create the context. */ sys->hGLRC = wglCreateContext((sys->affinityHDC != NULL) ? sys->affinityHDC : sys->hGLDC); if (sys->hGLRC == NULL) { msg_Err(gl, "Could not create the OpenGL rendering context"); goto error; } wglMakeCurrent(sys->hGLDC, sys->hGLRC); #if 0 /* TODO pick higher display depth if possible and the source requires it */ int attribsDesired[] = { WGL_DRAW_TO_WINDOW_ARB, 1, WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB, WGL_RED_BITS_ARB, 10, WGL_GREEN_BITS_ARB, 10, WGL_BLUE_BITS_ARB, 10, WGL_ALPHA_BITS_ARB, 2, WGL_DOUBLE_BUFFER_ARB, 1, 0,0 }; UINT nMatchingFormats; int index = 0; PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB__ = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress( "wglChoosePixelFormatARB" ); if (wglChoosePixelFormatARB__!= NULL) wglChoosePixelFormatARB__(sys->hGLDC, attribsDesired, NULL, 1, &index, &nMatchingFormats); #endif #ifdef WGL_EXT_swap_control /* Create an GPU Affinity DC */ const char *extensions = (const char*)glGetString(GL_EXTENSIONS); if (vlc_gl_StrHasToken(extensions, "WGL_EXT_swap_control")) { PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT"); if (SwapIntervalEXT) SwapIntervalEXT(1); } #endif #define LOAD_EXT(name, type) \ sys->exts.name = (type) wglGetProcAddress("wgl" #name ) LOAD_EXT(GetExtensionsStringEXT, PFNWGLGETEXTENSIONSSTRINGEXTPROC); if (!sys->exts.GetExtensionsStringEXT) LOAD_EXT(GetExtensionsStringARB, PFNWGLGETEXTENSIONSSTRINGARBPROC); wglMakeCurrent(sys->hGLDC, NULL); gl->ext = VLC_GL_EXT_WGL; gl->makeCurrent = MakeCurrent; gl->releaseCurrent = ReleaseCurrent; gl->resize = NULL; gl->swap = Swap; gl->getProcAddress = OurGetProcAddress; if (sys->exts.GetExtensionsStringEXT || sys->exts.GetExtensionsStringARB) gl->wgl.getExtensionsString = GetExtensionsString; (void) width; (void) height; return VLC_SUCCESS; error: Close(gl); return VLC_EGENERIC; }