Esempio n. 1
0
GLXWindow get_glx_window(Display    *XJ_disp,     GLXFBConfig  glx_fbconfig,
                         Window      gl_window,   GLXContext   glx_context,
                         GLXPbuffer  glx_pbuffer, const QSize &window_size)
{
    X11L;

    GLXWindow glx_window = glXCreateWindow(
        XJ_disp, glx_fbconfig, gl_window, NULL);

    glXMakeContextCurrent(XJ_disp, glx_window, glx_pbuffer, glx_context);

    glDrawBuffer(GL_BACK_LEFT);
    glReadBuffer(GL_FRONT_LEFT);
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glShadeModel(GL_FLAT);
    glEnable(GL_TEXTURE_RECTANGLE_NV);
    
    glViewport(0, 0, window_size.width(), window_size.height());
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    // left, right, botton, top, near, far
    glOrtho(0, window_size.width(), 0, window_size.height(), -2, 2);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glFinish();

    glXMakeContextCurrent(XJ_disp, None, None, NULL);

    X11U;

    return glx_window;
}                       
bool makeCurrent(EGLNativeDisplayType dpy,EglSurface* read,EglSurface* draw,EGLNativeContextType ctx){

    ErrorHandler handler(dpy);
    bool retval = false;
    if (!ctx && !read && !draw) {
        // unbind
        retval = glXMakeContextCurrent(dpy, NULL, NULL, NULL);
    }
    else if (ctx && read && draw) {
        retval = glXMakeContextCurrent(dpy,draw->native()->srfc(),read->native()->srfc(),ctx);
    }
    return (handler.getLastError() == 0) && retval;
}
Esempio n. 3
0
void XvMCTextures::Show(int scan)
{
    X11L;

    glXMakeContextCurrent(XJ_disp, glx_window, glx_pbuffer, glx_context);

    CompositeFrameAndOSD(scan);

    glFinish();
    glXSwapBuffers(XJ_disp, glx_window);

    glXMakeContextCurrent(XJ_disp, None, None, NULL);

    X11U;
}
Esempio n. 4
0
static void
OpenGLEventProc(ClientData clientData, XEvent *eventPtr)
{

  OpenGLClientData *OpenGLPtr = (OpenGLClientData *) clientData;
  if (eventPtr->type == DestroyNotify) 
  {
#ifndef _WIN32
    glXMakeContextCurrent(OpenGLPtr->display, None, None, 0);
#else
    wglMakeCurrent(OpenGLPtr->hDC,0);
#endif
    XSync(OpenGLPtr->display, False);
    //      glXDestroyWindow(OpenGLPtr->display, OpenGLPtr->glx_win);
#ifndef _WIN32
    glXDestroyContext(OpenGLPtr->display, OpenGLPtr->cx);
#else
    wglDeleteContext( OpenGLPtr->cx ); 
#endif
    XSync(OpenGLPtr->display, False);

    Tcl_DeleteCommand(OpenGLPtr->interp, Tk_PathName(OpenGLPtr->tkwin));
    OpenGLPtr->tkwin = NULL;
    Tk_EventuallyFree((ClientData) OpenGLPtr, (Tcl_FreeProc*)OpenGLDestroy);
  }
}
Esempio n. 5
0
static void
clutter_backend_glx_dispose (GObject *gobject)
{
  ClutterBackendGLX *backend_glx = CLUTTER_BACKEND_GLX (gobject);
  ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (gobject);

  /* Unrealize all shaders, since the GL context is going away */
  _clutter_shader_release_all ();

  if (backend_glx->gl_context)
    {
      glXMakeContextCurrent (backend_x11->xdpy, None, None, NULL);
      glXDestroyContext (backend_x11->xdpy, backend_glx->gl_context);
      backend_glx->gl_context = None;
    }

  if (backend_glx->dummy_glxwin)
    {
      glXDestroyWindow (backend_x11->xdpy, backend_glx->dummy_glxwin);
      backend_glx->dummy_glxwin = None;
    }

  if (backend_glx->dummy_xwin)
    {
      XDestroyWindow (backend_x11->xdpy, backend_glx->dummy_xwin);
      backend_glx->dummy_xwin = None;
    }

  G_OBJECT_CLASS (clutter_backend_glx_parent_class)->dispose (gobject);
}
Esempio n. 6
0
void
TopCanvas::CreateGLX(_XDisplay *_x_display,
                     X11Window x_window,
                     GLXFBConfig *fb_cfg)
{
  x_display = _x_display;

  glx_context = glXCreateNewContext(_x_display, *fb_cfg, GLX_RGBA_TYPE,
                                    nullptr, true);
  if (glx_context == nullptr) {
    fprintf(stderr, "Failed to create GLX context\n");
    exit(EXIT_FAILURE);
  }
  glx_window = glXCreateWindow(_x_display, *fb_cfg, x_window, nullptr);
  XSync(x_display, false);

  if (!glXMakeContextCurrent(_x_display, glx_window, glx_window, glx_context)) {
    fprintf(stderr, "Failed to attach GLX context to GLX window\n");
    exit(EXIT_FAILURE);
  }

  const PixelSize effective_size = GetNativeSize();
  if (effective_size.cx <= 0 || effective_size.cy <= 0) {
    fprintf(stderr, "Failed to query GLX drawable size\n");
    exit(EXIT_FAILURE);
  }

  OpenGL::SetupContext();
  SetupViewport(effective_size);
}
Esempio n. 7
0
bool GlxContext::makeCurrent()
{
    if (!m_context)
        return false;

#if defined(GLX_DEBUGGING)
    GlxErrorHandler handler(m_display);
#endif

    bool result = false;

    if (m_pbuffer)
    {
        result = glXMakeContextCurrent(m_display, m_pbuffer, m_pbuffer, m_context);
    }
    else if (m_window)
    {
        result = glXMakeCurrent(m_display, m_window, m_context);
    }

#if defined(GLX_DEBUGGING)
    if (glxErrorOccurred)
        err() << "GLX error in GlxContext::makeCurrent()" << std::endl;
#endif

    return result;
}
void HeadlessView::activate() {
     if (thread != std::thread::id()) {
        throw std::runtime_error("OpenGL context was already current");
    }
    thread = std::this_thread::get_id();

    if (!glContext) {
        createContext();
    }

#if MBGL_USE_CGL
    CGLError error = CGLSetCurrentContext(glContext);
    if (error != kCGLNoError) {
        throw std::runtime_error(std::string("Switching OpenGL context failed:") + CGLErrorString(error) + "\n");
    }
#endif

#if MBGL_USE_GLX
    if (!glXMakeContextCurrent(xDisplay, glxPbuffer, glxPbuffer, glContext)) {
        throw std::runtime_error("Switching OpenGL context failed.\n");
    }
#endif

    loadExtensions();
}
Esempio n. 9
0
void exit_display()
{
   int i;

   glXMakeContextCurrent(display, None, None, NULL);
   glXDestroyContext(display, gl_context);
   glXDestroyWindow(display, gl_window);
   glXDestroyPbuffer(display, gl_pbuffer);

#ifdef USE_NV_FENCE
   glDeleteFencesNV(1, &nvFence);
#endif

   XDestroyWindow(display, window);

   for(i = 0; i < numsurfaces; i++) {
     XvMCDestroySurface(display, &surfaces[i]);
   }

   XvMCDestroyBlocks(display, &blocks);
   XvMCDestroyMacroBlocks(display, &macro_blocks);
   XvMCDestroyContext(display, &context);
   XvUngrabPort(display, portNum, CurrentTime);
  
   XCloseDisplay(display);
}
Esempio n. 10
0
static void gfx_ctx_x_bind_hw_render(void *data, bool enable)
{
   gfx_ctx_x_data_t *x = (gfx_ctx_x_data_t*)data;

   if (!x)
      return;

   switch (x_api)
   {
      case GFX_CTX_OPENGL_API:
      case GFX_CTX_OPENGL_ES_API:
#ifdef HAVE_OPENGL
         x->g_use_hw_ctx = enable;
         if (!g_x11_dpy || !x->g_glx_win)
            return;
         glXMakeContextCurrent(g_x11_dpy, x->g_glx_win,
               x->g_glx_win, enable ? x->g_hw_ctx : x->g_ctx);
#endif
         break;

      case GFX_CTX_NONE:
      default:
         break;
   }
}
Esempio n. 11
0
void 
Glf_TestGLContextPrivate::makeCurrent( ) const
{
    glXMakeContextCurrent(_dpy, _win, _win, _context);

    _currenGLContext=this;
}
Esempio n. 12
0
static void xdpy_unset_current_display(ALLEGRO_DISPLAY *d)
{
   ALLEGRO_SYSTEM_XGLX *system = (ALLEGRO_SYSTEM_XGLX *)al_get_system_driver();
   (void)d;

   glXMakeContextCurrent(system->gfxdisplay, None, None, NULL);
}
Esempio n. 13
0
void
TopCanvas::CreateGLX(_XDisplay *_x_display,
                     X11Window x_window,
                     GLXFBConfig *fb_cfg)
{
  x_display = _x_display;

  glx_context = glXCreateNewContext(_x_display, *fb_cfg, GLX_RGBA_TYPE,
                                    nullptr, true);
  if (glx_context == nullptr) {
    fprintf(stderr, "Failed to create GLX context\n");
    exit(EXIT_FAILURE);
  }
  glx_window = glXCreateWindow(_x_display, *fb_cfg, x_window, nullptr);
  XSync(x_display, false);

  if (!glXMakeContextCurrent(_x_display, glx_window, glx_window, glx_context)) {
    fprintf(stderr, "Failed to attach GLX context to GLX window\n");
    exit(EXIT_FAILURE);
  }

  unsigned int glx_width = -1, glx_height = -1;
  glXQueryDrawable(_x_display, glx_window, GLX_WIDTH, &glx_width);
  glXQueryDrawable(_x_display, glx_window, GLX_HEIGHT, &glx_height);
  if ((glx_width <= 0) || (glx_height <= 0)) {
    fprintf(stderr, "Failed to query GLX drawable size\n");
    exit(EXIT_FAILURE);
  }
  const PixelSize effective_size = { glx_width, glx_height };

  OpenGL::SetupContext();
  OpenGL::SetupViewport(UnsignedPoint2D(effective_size.cx,
                                        effective_size.cy));
  Canvas::Create(effective_size);
}
Esempio n. 14
0
EGLBoolean __internalTerminate(NativeLocalStorageContainer* nativeLocalStorageContainer)
{
	if (!nativeLocalStorageContainer)
	{
		return EGL_FALSE;
	}

	if (nativeLocalStorageContainer->display)
	{
		glXMakeContextCurrent(nativeLocalStorageContainer->display, 0, 0, 0);
	}

	if (nativeLocalStorageContainer->display && nativeLocalStorageContainer->ctx)
	{
		glXDestroyContext(nativeLocalStorageContainer->display, nativeLocalStorageContainer->ctx);
		nativeLocalStorageContainer->ctx = 0;
	}

	if (nativeLocalStorageContainer->display && nativeLocalStorageContainer->window)
	{
		XDestroyWindow(nativeLocalStorageContainer->display, nativeLocalStorageContainer->window);
		nativeLocalStorageContainer->window = 0;
	}

	if (nativeLocalStorageContainer->display)
	{
		XCloseDisplay(nativeLocalStorageContainer->display);
		nativeLocalStorageContainer->display = 0;
	}

	return EGL_TRUE;
}
Esempio n. 15
0
/* static */
bool wxGLContext::MakeCurrent(GLXDrawable drawable, GLXContext context)
{
    if (wxGLCanvas::GetGLXVersion() >= 13)
        return glXMakeContextCurrent( wxGetX11Display(), drawable, drawable, context);
    else // GLX <= 1.2 doesn't have glXMakeContextCurrent()
        return glXMakeCurrent( wxGetX11Display(), drawable, context);
}
Esempio n. 16
0
extern void device_leave_context(gs_device_t *device)
{
	Display *display = device->plat->display;

	if (!glXMakeContextCurrent(display, None, None, NULL)) {
		blog(LOG_ERROR, "Failed to reset current context.");
	}
}
Esempio n. 17
0
File: glx.c Progetto: 0xheart0/vlc
static int MakeCurrent (vlc_gl_t *gl)
{
    vlc_gl_sys_t *sys = gl->sys;

    if (!glXMakeContextCurrent (sys->display, sys->win, sys->win, sys->ctx))
        return VLC_EGENERIC;
    return VLC_SUCCESS;
}
Esempio n. 18
0
static void gl_context_destroy(struct gl_platform *plat)
{
	Display *display = plat->display;

	glXMakeContextCurrent(display, None, None, NULL);
	glXDestroyContext(display, plat->context);
	bfree(plat);
}
Esempio n. 19
0
static void useGL(Display *dpy, Window win, GLXContext ctx, int width, int height, float c, int swapInterval)
{
    glXMakeContextCurrent(dpy, win, win, ctx);
    glViewport(0, 0, width, height);
    if(0 < swapInterval) {
        fprintf(stderr, "%s: glXSwapIntervalSGI(1)\n", msg);
        _glXSwapIntervalSGI(1); // offending op after retargeting drawable
    }
    fprintf(stderr, "GL_VENDOR: %s\n", glGetString(GL_VENDOR));
    fprintf(stderr, "GL_VERSION: %s\n", glGetString(GL_VERSION));
    fprintf(stderr, "GL_RENDERER: %s\n", glGetString(GL_RENDERER));
    glClearColor(c, c, c, 0.0f);
    glClearDepth(1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glXSwapBuffers(dpy, win);
    glXMakeContextCurrent(dpy, 0, 0, 0);
}
Esempio n. 20
0
extern void device_enter_context(gs_device_t *device)
{
	GLXContext context = device->plat->context;
	Display *display = device->plat->display;

	if (device->cur_swap) {
		XID window = device->cur_swap->wi->window;
		if (!glXMakeContextCurrent(display, window, window, context)) {
			blog(LOG_ERROR, "Failed to make context current.");
		}
	} else {
		GLXPbuffer pbuf = device->plat->pbuffer;
		if (!glXMakeContextCurrent(display, pbuf, pbuf, context)) {
			blog(LOG_ERROR, "Failed to make context current.");
		}
	}
}
Esempio n. 21
0
/*!
 * This function destroys the OpenGL context using GLX with a Pbuffer.
 */
void gr3_terminateGL_GLX_Pbuffer_(void) {
  gr3_log_("gr3_terminateGL_GLX_Pbuffer_();");
  
  glXMakeContextCurrent(display,None,None,NULL);
  glXDestroyContext(display, context);
  /*glXDestroyPbuffer(display, pbuffer);*/
  XCloseDisplay(display);
  context_struct_.gl_is_initialized = 0;
}
JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_GLX13_nglXMakeContextCurrent(JNIEnv *__env, jclass clazz, jlong displayAddress, jlong drawAddress, jlong readAddress, jlong ctxAddress, jlong __functionAddress) {
	Display *display = (Display *)(intptr_t)displayAddress;
	GLXDrawable draw = (GLXDrawable)(intptr_t)drawAddress;
	GLXDrawable read = (GLXDrawable)(intptr_t)readAddress;
	GLXContext ctx = (GLXContext)(intptr_t)ctxAddress;
	glXMakeContextCurrentPROC glXMakeContextCurrent = (glXMakeContextCurrentPROC)(intptr_t)__functionAddress;
	UNUSED_PARAMS(__env, clazz)
	return (jint)glXMakeContextCurrent(display, draw, read, ctx);
}
Esempio n. 23
0
void
rtb_window_unlock(struct rtb_window *rwin)
{
    struct xrtb_window *self = RTB_WINDOW_AS(rwin, xrtb_window);

    glXMakeContextCurrent(self->xrtb->dpy, None, None, NULL);
    XUnlockDisplay(self->xrtb->dpy);
    uv_mutex_unlock(&self->lock);
}
Esempio n. 24
0
int glXMakeCurrent(Display *pDisplay, GLXDrawable drawable, GLXContext ctx)
{
    // assume drawable is an Window or Pixmap if we haven't set it's type yet
    if (gDrawables.find(drawable) == gDrawables.end())
    {
        gDrawables[drawable] = X;
    }
    return glXMakeContextCurrent(pDisplay, drawable, drawable, ctx);
}
Esempio n. 25
0
/*!
 * This function destroys the OpenGL context using GLX with a XPixmap.
 */
void gr3_terminateGL_GLX_Pixmap_(void) {
  gr3_log_("gr3_terminateGL_GLX_Pixmap_();");
  
  glXMakeContextCurrent(display,None,None,NULL);
  glXDestroyContext(display, context);
  XFreePixmap(display,pixmap);
  XCloseDisplay(display);
  context_struct_.gl_is_initialized = 0;
}
Esempio n. 26
0
static void gfx_ctx_destroy(void)
{
   if (g_dpy && g_ctx)
   {
      glXMakeContextCurrent(g_dpy, None, None, NULL);
      glXDestroyContext(g_dpy, g_ctx);
      g_ctx = NULL;
   }

   if (g_win)
   {
      glXDestroyWindow(g_dpy, g_glx_win);
      g_glx_win = 0;

      // Save last used monitor for later.
#ifdef HAVE_XINERAMA
      XWindowAttributes target;
      Window child;

      int x = 0, y = 0;
      XGetWindowAttributes(g_dpy, g_win, &target);
      XTranslateCoordinates(g_dpy, g_win, DefaultRootWindow(g_dpy),
            target.x, target.y, &x, &y, &child);

      g_screen = x11_get_xinerama_monitor(g_dpy, x, y,
            target.width, target.height);

      RARCH_LOG("[GLX]: Saved monitor #%u.\n", g_screen);
#endif

      XUnmapWindow(g_dpy, g_win);
      XDestroyWindow(g_dpy, g_win);
      g_win = None;
   }

   if (g_cmap)
   {
      XFreeColormap(g_dpy, g_cmap);
      g_cmap = None;
   }

   if (g_should_reset_mode)
   {
      x11_exit_fullscreen(g_dpy, &g_desktop_mode);
      g_should_reset_mode = false;
   }

   if (g_dpy)
   {
      XCloseDisplay(g_dpy);
      g_dpy = NULL;
   }

   g_inited = false;
   g_pglSwapInterval = NULL;
}
Esempio n. 27
0
void
rtb_window_lock(struct rtb_window *rwin)
{
    struct xrtb_window *self = RTB_WINDOW_AS(rwin, xrtb_window);

    uv_mutex_lock(&self->lock);
    XLockDisplay(self->xrtb->dpy);
    glXMakeContextCurrent(
        self->xrtb->dpy, self->gl_draw, self->gl_draw, self->gl_ctx);
}
Esempio n. 28
0
void SnapshotTaker::snapshotCallback(TCAlert *alert)
{
	if (getUseFBO())
	{
		return;
	}
	if (strcmp(alert->getMessage(), "PreFbo") == 0)
	{
		static int visualAttribs[] = { None };
		int numberOfFramebufferConfigurations = 0;
		GLXFBConfig* fbConfigs = glXChooseFBConfig(display, DefaultScreen(display), visualAttribs, &numberOfFramebufferConfigurations);
		if (fbConfigs == NULL)
		{
			return;
		}
		static int attributeList[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_RED_SIZE, 8, GLX_GREEN_SIZE, 8, GLX_BLUE_SIZE, 8, GLX_ALPHA_SIZE, 8, GLX_STENCIL_SIZE, 8, None };
		XVisualInfo *vi = glXChooseVisual(display, DefaultScreen(display), attributeList);
		if (vi == NULL)
		{
			size_t count = sizeof(attributeList) / sizeof(attributeList[0]);
			attributeList[count - 3] = None;
			vi = glXChooseVisual(display, DefaultScreen(display), attributeList);
		}
		if (vi == NULL)
		{
			XFree(fbConfigs);
		}
		context = glXCreateContext(display, vi, 0, True);
		XFree(vi);
		if (context == NULL)
		{
			XFree(fbConfigs);
			return;
		}
		// We're using FBO, but we need a PBuffer to bind something to the
		// context, so create a tiny one.
		int pbufferAttribs[] =
		{
			GLX_PBUFFER_WIDTH,  32,
			GLX_PBUFFER_HEIGHT, 32,
			None
		};
		pbuffer = glXCreatePbuffer(display, fbConfigs[0], pbufferAttribs);
		XFree(fbConfigs);
		XSync(display, False);
		if (!glXMakeContextCurrent(display, pbuffer, pbuffer, context))
		{
			cleanupContext();
			return;
		}
		TREGLExtensions::setup();
		ldSnapshotTaker = (LDSnapshotTaker*)alert->getSender()->retain();
		ldSnapshotTaker->setUseFBO(true);
	}
}
Esempio n. 29
0
static void gfx_ctx_bind_hw_render(void *data, bool enable)
{
   (void)data;
   g_use_hw_ctx = enable;

   if (g_dpy && g_glx_win)
   {
      //RARCH_LOG("[GLX]: Binding context (%s): %p\n", enable ? "RetroArch" : "HW render", enable ? (void*)g_hw_ctx : (void*)g_ctx);
      glXMakeContextCurrent(g_dpy, g_glx_win, g_glx_win, enable ? g_hw_ctx : g_ctx);
   }
}
Esempio n. 30
0
void XvMCTextures::PrepareFrame(XvMCSurface *surf,
                                const QRect &video_rect, int scan)
{
    int field = (scan <= 0) ? 1 : scan;

    X11L;

    glXMakeContextCurrent(XJ_disp, glx_window, glx_pbuffer, glx_context);

    /////

    int h = gl_video_size.height();
    if (XVMC_FRAME_PICTURE != field)
        h = gl_video_size.height() / 2;

    uint tex_idx = gl_vid_tex_index;

    glBindTexture(GL_TEXTURE_RECTANGLE_NV,
                  gl_vid_textures[tex_idx]);

    XvMCCopySurfaceToGLXPbuffer(XJ_disp, surf, glx_pbuffer, 0, 0,
                                gl_video_size.width(), h,
                                0, 0, GL_FRONT_LEFT, field);

    glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_NV, 0, 0, 0, 0, 0,
                        gl_video_size.width(), h);

    gl_vid_tex_size[tex_idx] = QSize(gl_video_size.width(), h);

    /////

    last_video_rect = video_rect;

    /////

    glFlush();

    glXMakeContextCurrent(XJ_disp, None, None, NULL);

    X11U;
}