void CL_DisplayWindow_OpenGL::destroy_window()
{
	install_event_handler(0, 1);

	if (context)
		aglSetCurrentContext(0);

	if (fs_context)
	{
		aglDestroyContext(fs_context);
		fs_context = 0;
	}

	if (win_context)
	{
		aglDestroyContext(win_context);
		win_context = 0;
	}

	keyboard = CL_InputDevice();
	mouse = CL_InputDevice();
	get_ic()->clear();

	if (window_ref)
		ReleaseWindow(window_ref);
	window_ref = 0;
}
Esempio n. 2
0
void QGLExtensions::init()
{
    static bool init_done = false;

    if (init_done)
        return;
    init_done = true;

    GLint attribs[] = { AGL_RGBA, AGL_NONE };
    AGLPixelFormat fmt = aglChoosePixelFormat(0, 0, attribs);
    if (!fmt) {
        qDebug("QGLExtensions: Couldn't find any RGB visuals");
        return;
    }
    AGLContext ctx = aglCreateContext(fmt, 0);
    if (!ctx) {
        qDebug("QGLExtensions: Unable to create context");
    } else {
        aglSetCurrentContext(ctx);
        init_extensions();
        aglSetCurrentContext(0);
        aglDestroyContext(ctx);
    }
    aglDestroyPixelFormat(fmt);
}
Esempio n. 3
0
void Window::configExit()
{
    WindowRef window = getCarbonWindow();
    setCarbonWindow( 0 );

    AGLContext context = getAGLContext();

    if( getIAttribute( WindowSettings::IATTR_HINT_FULLSCREEN ) == ON )
    {
        LBASSERT( !window );
        exitEventHandler();
    }
    else if( window )
    {
        Global::enterCarbon();
        aglSetWindowRef( context, 0 );
        DisposeWindow( window );
        Global::leaveCarbon();
    }

    configExitFBO();
    exitGLEW();

    if( context )
    {
        Global::enterCarbon();
        aglSetCurrentContext( 0 );
        aglDestroyContext( context );
        Global::leaveCarbon();
        setAGLContext( 0 );
    }

    LBVERB << "Destroyed AGL window and context" << std::endl;
}
Esempio n. 4
0
void _glfwPlatformCloseWindow( void )
{
    if( _glfwWin.WindowFunctions != NULL )
    {
	    if( _glfwWin.WindowUPP != NULL )
	    {
	        DisposeEventHandlerUPP( _glfwWin.WindowUPP );
	        _glfwWin.WindowUPP = NULL;
	    }

	    _glfwWin.WindowFunctions->CloseWindow();

	    if( _glfwWin.AGLContext != NULL )
	    {
		    aglSetCurrentContext( NULL );
		    aglSetDrawable( _glfwWin.AGLContext, NULL );
		    aglDestroyContext( _glfwWin.AGLContext );
		    _glfwWin.AGLContext = NULL;
		}

    	if( _glfwWin.MacWindow != NULL )
    	{
		    ReleaseWindow( _glfwWin.MacWindow );
		    _glfwWin.MacWindow = NULL;
	    }

	    _glfwWin.WindowFunctions = NULL;
    }
}
Esempio n. 5
0
/*
** OS Specific unloading
*/
AESDK_OpenGL_Err AESDK_OpenGL_Shutdown(AESDK_OpenGL_EffectCommonData& inData)
{
	AESDK_OpenGL_Err result = AESDK_OpenGL_OK;
	try
	{
#ifdef AE_OS_WIN
		if( inData.mHRC != NULL )
		{
			if(!wglMakeCurrent( NULL, NULL ))
				GL_CHECK(AESDK_OpenGL_OS_Unload_Err);
			if( !wglDeleteContext( inData.mHRC ))
				GL_CHECK(AESDK_OpenGL_OS_Unload_Err);
			inData.mHRC = NULL;
		}

		if( inData.mHDC != NULL )
		{
			ReleaseDC( inData.mHWnd, inData.mHDC );
			inData.mHDC = NULL;
		}
		::UnregisterClass( "AESDK_OpenGL_Win_Class", NULL );
#elif defined(AE_OS_MAC)
		if( GL_FALSE == aglDestroyContext(inData.mAGLContext) )
			GL_CHECK(AESDK_OpenGL_OS_Unload_Err);
		
		DisposeWindow(inData.mMacWnd);
#endif
	}
	catch(AESDK_OpenGL_Err& err)
	{
		result = err;
	}

	return result;
}
Esempio n. 6
0
wxGLContext::~wxGLContext()
{
    if (m_glContext)
    {
        aglSetCurrentContext(NULL);
        aglDestroyContext(m_glContext);
    }
}
Esempio n. 7
0
static void deleteContext(AGLContext ctx) {
    if (g_Window.fs) {
        aglSetFullScreen(ctx, 0, 0, 0, 0);
    } else {
        aglSetWindowRef(ctx, 0);
    }
    aglSetCurrentContext(0);
    aglDestroyContext(ctx);
}
Esempio n. 8
0
void WXGLDestroyContext( WXGLContext context )
{
    if ( context )
    {
        if ( !aglDestroyContext(context) )
        {
            wxLogAGLError("aglDestroyContext");
        }
    }
}
    //-------------------------------------------------------------------------------------------------//
    void OSXCarbonWindow::destroy(void)
    {
        if(!mCreated)
            return;

        if(mIsFullScreen)
        {
            // Handle fullscreen destruction
            destroyCGLFullscreen();
        }
        else
        {
            // Handle windowed destruction
            
            // Destroy the Ogre context
            if(mCGLContext)
            {
                OGRE_DELETE mCGLContext;
                mCGLContext = NULL;
            }
            
            if(mCarbonContext)
            {
                OGRE_DELETE mCarbonContext;
                mCarbonContext = NULL;
            }

            if(mContext)
            {
                // mContext is a reference to either the AGL or CGL context, already deleted.
                // Just clear the variable
                mContext = NULL;
            }

            if(!mIsExternal)
            {
                // Remove the window from the Window listener
                WindowEventUtilities::_removeRenderWindow( this );
                
                // Remove our event handler
                if(mEventHandlerRef)
                    RemoveEventHandler(mEventHandlerRef);        
            }

            if(mAGLContext)
                aglDestroyContext(mAGLContext);
            
            if(mWindow)
                DisposeWindow(mWindow);
        }

        mActive = false;
        mClosed = true;
        mCreated = false;
    }
Esempio n. 10
0
static void RLXAPI ReleaseSurfaces(void)
{
	if (!g_pAGLC)
		return;

	aglSetCurrentContext(NULL);
    aglSetDrawable(g_pAGLC, NULL);
    aglDestroyContext(g_pAGLC);
    g_pAGLC = 0;
	g_pRLX->pGX->Surfaces.maxSurface = 0;
}
Esempio n. 11
0
void Mac_GL_Quit(_THIS)
{
#ifdef HAVE_OPENGL
	if ( glContext != NULL ) {
		aglSetCurrentContext(NULL);
		aglSetDrawable(glContext, NULL);
		aglDestroyContext(glContext);		
		glContext = NULL;
	}
#endif
}
Esempio n. 12
0
void OpenGLApp::exitAPI(){
	delete renderer;
	
	aglSetCurrentContext(NULL);
	aglSetDrawable(glContext, NULL);
	aglDestroyContext(glContext);
	ReleaseWindow(window);

	if (fullscreen){
		CGReleaseAllDisplays();
		CGDisplaySwitchToMode(kCGDirectMainDisplay, initialMode);
	}
}
glitz_status_t
glitz_agl_query_extensions (glitz_agl_thread_info_t *thread_info)
{
    GLint attrib[] = {
	AGL_RGBA,
	AGL_NO_RECOVERY,
	AGL_NONE
    };
    AGLPixelFormat pf;
    AGLContext context;

    thread_info->agl_feature_mask = 0;

    pf = aglChoosePixelFormat (NULL, 0, attrib);
    context = aglCreateContext (pf, NULL);

    if (context) {
	const char *gl_extensions_string;

	aglSetCurrentContext (context);

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

	thread_info->agl_feature_mask =
	    glitz_extensions_query (0.0,
				    gl_extensions_string,
				    agl_extensions);

	if (thread_info->agl_feature_mask & GLITZ_AGL_FEATURE_MULTISAMPLE_MASK)
	{
	    const char *vendor;

	    vendor = glGetString (GL_VENDOR);

	    if (vendor) {

		/* NVIDIA's driver seem to support multisample with pbuffers */
		if (!strncmp ("NVIDIA", vendor, 6))
		    thread_info->agl_feature_mask |=
			GLITZ_AGL_FEATURE_PBUFFER_MULTISAMPLE_MASK;
	    }
	}

	aglSetCurrentContext (NULL);
	aglDestroyContext (context);
    }

    aglDestroyPixelFormat (pf);

    return GLITZ_STATUS_SUCCESS;
}
void
GelatinePaneView::dispose()
{
  _model.getSpace().getView().dispose();

  aglSetCurrentContext(NULL);
  aglSetDrawable(_model._aglContext, NULL);

  aglDestroyContext(_model._aglContext);
  aglDestroyPixelFormat(_model._aglPixelFormat);

  _model._aglContext = NULL;
  _model._aglPixelFormat = NULL;
}
Esempio n. 15
0
void Shell::CloseWindow()
{
	// Shutdown OpenGL if necessary.
	if (opengl_attached)
	{
		aglSetCurrentContext(NULL);
		aglSetDrawable(gl_context, NULL);
		aglDestroyContext(gl_context);
		
		gl_context = NULL;
	}

	// Close the window.
	HideWindow(window);
	ReleaseWindow(window);
}
void
glitz_agl_context_destroy (glitz_agl_thread_info_t *thread_info,
			   glitz_agl_context_t *context)
{
    if (context->backend.drawable_formats)
	free (context->backend.drawable_formats);

    if (context->backend.formats)
	free (context->backend.formats);

    if (context->backend.texture_formats)
	free (context->backend.texture_formats);

    aglDestroyContext (context->context);

    free (context);
}
void CSMNativeWindow::resolveLinks(void)
{
    if(_pCarbWindow != NULL)
    {
        _pCarbWindow->setContext(NULL);
    }

    if(_pContext != NULL)
        aglDestroyContext(_pContext);

    if(_pLocalWindow != NULL)
        DisposeWindow(_pLocalWindow);

    if(_pEventHandler != NULL)
        DisposeEventHandlerUPP(_pEventHandler);

    Inherited::resolveLinks();
}
Esempio n. 18
0
void QGLContext::reset()
{
    Q_D(QGLContext);
    if(!d->valid)
        return;
    doneCurrent();
    if(d->cx)
        aglDestroyContext((AGLContext)d->cx);
    d->cx = 0;
    if(d->vi)
        aglDestroyPixelFormat((AGLPixelFormat)d->vi);
    d->vi = 0;
    d->crWin = false;
    d->sharing = false;
    d->valid = false;
    d->transpColor = QColor();
    d->initDone = false;
    qgl_share_reg()->removeShare(this);
}
void windowDestroy(GLWindow *glw)
{
	MenuHandle hMenu;
	aglSetDrawable(glw->glCtx, NULL);
	aglSetCurrentContext(NULL);
	aglDestroyContext(glw->glCtx);
	
	DisposeWindow((WindowPtr)glw->pWin);
	glw->pWin = NULL;
	if(glw->supportWindow)
	    DisposeWindow((WindowPtr)glw->supportWindow);
	hMenu = GetMenuHandle (kMenuFile);
	DeleteMenu (kMenuFile);
	DisposeMenu (hMenu);

	hMenu = GetMenuHandle (kMenuApple);
	DeleteMenu (kMenuApple);
	DisposeMenu (hMenu);

}
static void
_glitz_agl_context_destroy (void *abstract_context)
{
    glitz_agl_context_t *context = (glitz_agl_context_t *) abstract_context;
    glitz_agl_drawable_t *drawable = (glitz_agl_drawable_t *)
	context->base.drawable;

    if (drawable->thread_info->cctx == &context->base)
    {
	aglSetCurrentContext (NULL);

	drawable->thread_info->cctx = NULL;
    }

    aglDestroyContext (context->context);

    _glitz_context_fini (&context->base);

    free (context);
}
SkEGLContext::~SkEGLContext() {
    if (this->context) {
        aglDestroyContext(this->context);
    }
}
Esempio n. 22
0
ContextGL_OSX::~ContextGL_OSX() {

	if (context)
		aglDestroyContext(context);
}
Esempio n. 23
0
void _glfwPlatformCloseWindow( void )
{
    if( _glfwWin.mouseUPP != NULL )
    {
        DisposeEventHandlerUPP( _glfwWin.mouseUPP );
        _glfwWin.mouseUPP = NULL;
    }
    if( _glfwWin.commandUPP != NULL )
    {
        DisposeEventHandlerUPP( _glfwWin.commandUPP );
        _glfwWin.commandUPP = NULL;
    }
    if( _glfwWin.keyboardUPP != NULL )
    {
        DisposeEventHandlerUPP( _glfwWin.keyboardUPP );
        _glfwWin.keyboardUPP = NULL;
    }
    if( _glfwWin.windowUPP != NULL )
    {
        DisposeEventHandlerUPP( _glfwWin.windowUPP );
        _glfwWin.windowUPP = NULL;
    }

    if( _glfwWin.fullscreen )
    {
        if( _glfwWin.cglContext != NULL )
        {
            CGLSetCurrentContext( NULL );
            CGLClearDrawable( _glfwWin.cglContext );
            CGLDestroyContext( _glfwWin.cglContext );
            CGReleaseAllDisplays();
            _glfwWin.cglContext = NULL;
        }

        if( _glfwWin.cglPixelFormat != NULL )
        {
            CGLDestroyPixelFormat( _glfwWin.cglPixelFormat );
            _glfwWin.cglPixelFormat = NULL;
        }
    }
    else
    {
        if( _glfwWin.aglContext != NULL )
        {
            aglSetCurrentContext( NULL );
            aglSetDrawable( _glfwWin.aglContext, NULL );
            aglDestroyContext( _glfwWin.aglContext );
            _glfwWin.aglContext = NULL;
        }

        if( _glfwWin.aglPixelFormat != NULL )
        {
            aglDestroyPixelFormat( _glfwWin.aglPixelFormat );
            _glfwWin.aglPixelFormat = NULL;
        }
    }

    if( _glfwWin.window != NULL )
    {
        ReleaseWindow( _glfwWin.window );
        _glfwWin.window = NULL;
    }
}
Esempio n. 24
0
// ---------------------------------------------------------------------------
void OSXWindowImpl::dispose_gl()
{
  aglSetCurrentContext(0);
  aglDestroyContext(mGLContext);
}
Esempio n. 25
0
AquaOglGlue::~AquaOglGlue()
{
//    GNASH_REPORT_FUNCTION;
    aglDestroyContext (_context);
}
Esempio n. 26
0
bool OpenGLApp::initAPI(){
	initialMode = CGDisplayCurrentMode(kCGDirectMainDisplay);

	dmodes = CGDisplayAvailableModes(kCGDirectMainDisplay);
	int count = CFArrayGetCount(dmodes);

	Array <DispRes> modes;
	int foundMode = -1;
	for (int i = 0; i < count; i++){
		CFDictionaryRef mode = (CFDictionaryRef) CFArrayGetValueAtIndex(dmodes, i);

		long bitsPerPixel = GetDictionaryLong(mode, kCGDisplayBitsPerPixel);
		Boolean safeForHardware = GetDictionaryBoolean(mode, kCGDisplayModeIsSafeForHardware);
		Boolean stretched = GetDictionaryBoolean(mode, kCGDisplayModeIsStretched);

		if (bitsPerPixel < colorBits || !safeForHardware || stretched) continue;

		long width  = GetDictionaryLong(mode, kCGDisplayWidth);
		long height = GetDictionaryLong(mode, kCGDisplayHeight);
		long refreshRate = GetDictionaryLong(mode, kCGDisplayRefreshRate);

//		printf("Mode: %dx%dx%d @ %d\n", width, height, bitsPerPixel, refreshRate);

		if (width >= 640 && height >= 480){
			modes.add(newRes(width, height, i));

			if (width == fullscreenWidth && height == fullscreenHeight){
				foundMode = i;
			}
		}
	}

	resolution->clear();
	modes.sort(dComp);
	char str[64];
	for (uint i = 0; i < modes.getCount(); i++){
		sprintf(str, "%dx%d", modes[i].w, modes[i].h);
		int index = resolution->addItemUnique(str);
		if (modes[i].index == foundMode) resolution->selectItem(index);
	}

	if (fullscreen){
		if (foundMode < 0 || CGDisplaySwitchToMode(kCGDirectMainDisplay, (CFDictionaryRef) CFArrayGetValueAtIndex(dmodes, foundMode)) != kCGErrorSuccess){
			sprintf(str, "Couldn't set fullscreen to %dx%d.", fullscreenWidth, fullscreenHeight);
			ErrorMsg(str);
			fullscreen = false;
		}
	}


	Rect rect;
	if (fullscreen){
		rect.left = 0;
		rect.top  = 0;
	} else {
		long w = GetDictionaryLong(initialMode, kCGDisplayWidth);
		long h = GetDictionaryLong(initialMode, kCGDisplayHeight);

		rect.left = (w - width) / 2;
		rect.top  = (h - height) / 2;
	}
	rect.right = rect.left + width;
	rect.bottom = rect.top + height;

	WindowAttributes attributes = fullscreen? (kWindowNoTitleBarAttribute | kWindowNoShadowAttribute) : (kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute);

	OSStatus error = CreateNewWindow(kDocumentWindowClass, attributes, &rect, &window);
	if (error != noErr || window == NULL){
		ErrorMsg("Couldn't create window");
		return false;
	}

    GDHandle screen = GetGWorldDevice(GetWindowPort(window));
    if (screen == NULL){
        ErrorMsg("Couldn't get device");
        ReleaseWindow(window);
        return false;
    }

	AGLPixelFormat pixelFormat;
	while (true){
		GLint attributes[] = {
			fullscreen? AGL_FULLSCREEN : AGL_WINDOW,
			AGL_RGBA,
			AGL_DOUBLEBUFFER,
			AGL_RED_SIZE,            8,
			AGL_GREEN_SIZE,          8,
			AGL_BLUE_SIZE,           8,
			AGL_ALPHA_SIZE,         (colorBits > 24)? 8 : 0,
			AGL_DEPTH_SIZE,          depthBits,
			AGL_STENCIL_SIZE,        stencilBits,
			AGL_SAMPLE_BUFFERS_ARB, (antiAliasSamples > 0),
			AGL_SAMPLES_ARB,         antiAliasSamples,
			AGL_NONE
		};

		pixelFormat = aglChoosePixelFormat(&screen, 1, attributes);
		if (pixelFormat != NULL) break;

		antiAliasSamples -= 2;
		if (antiAliasSamples < 0){
			ErrorMsg("No suitable pixel format");
			ReleaseWindow(window);
			return false;
		}
	}

	glContext = aglCreateContext(pixelFormat, NULL);
    aglDestroyPixelFormat(pixelFormat);

	if (glContext == NULL){
		ErrorMsg("Couldn't create context");
		ReleaseWindow(window);
		return false;
	}

	if (fullscreen){
		CGCaptureAllDisplays();
		aglSetFullScreen(glContext, 0, 0, 0, 0);
	} else {
		if (!aglSetDrawable(glContext, GetWindowPort(window))){
			ErrorMsg("Couldn't set drawable");
			aglDestroyContext(glContext);
			ReleaseWindow(window);
			return false;
		}
	}

	if (!aglSetCurrentContext(glContext)){
		ErrorMsg("Couldn't make context current");
		aglDestroyContext(glContext);
		ReleaseWindow(window);
		return false;
	}

	setWindowTitle(getTitle());
    ShowWindow(window);

	initExtensions();

	if (antiAliasSamples > 0){
		glEnable(GL_MULTISAMPLE_ARB);
	}

	if (fullscreen) captureMouse(!configDialog->isVisible());

	renderer = new OpenGLRenderer(glContext);
	renderer->setViewport(width, height);

	antiAlias->selectItem(antiAliasSamples / 2);

	linearClamp = renderer->addSamplerState(LINEAR, CLAMP, CLAMP, CLAMP);
	defaultFont = renderer->addFont("../Textures/Fonts/Future.dds", "../Textures/Fonts/Future.font", linearClamp);
	blendSrcAlpha = renderer->addBlendState(SRC_ALPHA, ONE_MINUS_SRC_ALPHA);
	noDepthTest  = renderer->addDepthState(false, false);
	noDepthWrite = renderer->addDepthState(true,  false);
	cullNone  = renderer->addRasterizerState(CULL_NONE);
	cullBack  = renderer->addRasterizerState(CULL_BACK);
	cullFront = renderer->addRasterizerState(CULL_FRONT);

	return true;
}
Esempio n. 27
0
void DestroyContext (GLContext* ctx)
{
  if (NULL == ctx) return;
  aglSetCurrentContext(ctx->octx);
  if (NULL != ctx->ctx) aglDestroyContext(ctx->ctx);
}
void SkNativeGLContext::destroyGLContext() {
    if (fContext) {
        aglDestroyContext(fContext);
    }
}
void COffscreenGLContext::WorkerThreadFree()
{
	aglSetCurrentContext(NULL);
	aglDestroyContext(workerCtx);
	aglDestroyPixelFormat(pxlfmt);
}
Esempio n. 30
0
void glewDestroyContext ()
{
  aglSetCurrentContext(octx);
  if (NULL != ctx) aglDestroyContext(ctx);
}