wip - import hostgl from abi v0 and adapt to abi v1/GL.library ABI
[AROS.git] / arch / all-hosted / libs / hostgl / hostgl_gladestroycontext.c
blobe96b6d6e998aa7590e3571feed95eb15cb5dc902
1 /*
2 Copyright 2011-2015, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
8 #include <proto/exec.h>
9 #include <proto/oop.h>
11 #include "hostgl_ctx_manager.h"
12 #include "hostgl_funcs.h"
13 #include "hostgl_support.h"
15 #include <bitmap_class.h>
17 /*****************************************************************************
19 NAME */
21 void glADestroyContext(
23 /* SYNOPSIS */
24 GLAContext ctx)
26 /* FUNCTION
27 Destroys the GL rendering context and frees all resoureces.
29 INPUTS
30 ctx - pointer to GL rendering context. A NULL pointer will be
31 ignored.
33 RESULT
34 The GL context is destroyed. Do no use it anymore.
36 BUGS
38 INTERNALS
40 HISTORY
42 *****************************************************************************/
44 struct hostgl_context *_ctx = (struct hostgl_context *)ctx;
46 if (_ctx)
48 Display * dsp = NULL;
49 struct hostgl_context *cur_ctx = NULL;
51 HostGL_Lock();
53 dsp = HostGL_GetGlobalX11Display();
54 cur_ctx = HostGL_GetCurrentContext();
56 /* If the passed context is current context, detach it */
57 if (_ctx == cur_ctx)
59 HostGL_SetCurrentContext(NULL);
60 HostGL_UpdateGlobalGLXContext();
63 if (_ctx->glXctx)
64 GLXCALL(glXDestroyContext, dsp, _ctx->glXctx);
66 #if defined(RENDERER_SEPARATE_X_WINDOW)
67 GLXCALL(glXDestroyWindow, dsp, _ctx->glXWindow);
68 XCALL(XDestroyWindow, dsp, _ctx->XWindow);
69 #endif
70 #if defined(RENDERER_PBUFFER_WPA)
71 HostGL_DeAllocatePBuffer(_ctx);
72 #endif
73 #if defined(RENDERER_PIXMAP_BLIT)
74 HostGL_DeAllocatePixmap(_ctx);
75 #endif
77 if (_ctx->HiddX11BitMapAB)
78 OOP_ReleaseAttrBase(IID_Hidd_X11BitMap);
80 XCALL(XFree, _ctx->framebuffer->fbconfigs);
81 FreeVec(_ctx->framebuffer);
82 HostGLFreeContext(ctx);
84 HostGL_UnLock();