~glproxy-dev/glproxy/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/* Copyright (C) 2010-2011 Linaro Ltd.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

/*
 * Authors:
 *  Jammy Zhou <jammy.zhou@linaro.org>
 *  Marc Ordinas i Llopis, Collabora Ltd <marc.ordinasillopis@linaro.org>
 */

#include "GL/gl_proxy.h"
#include "GL/glx_proxy.h"
#include "GL/glxext_proxy.h"

PFNPROXYCHOOSEVISUALPROC            pfnProxyChooseVisual = NULL;
PFNPROXYCREATECONTEXTPROC           pfnProxyCreateContext = NULL;
PFNPROXYDESTROYCONTEXTPROC          pfnProxyDestroyContext = NULL;
PFNPROXYMAKECURRENTPROC             pfnProxyMakeCurrent = NULL;
PFNPROXYCOPYCONTEXTPROC             pfnProxyCopyContext = NULL;
PFNPROXYSWAPBUFFERSPROC             pfnProxySwapBuffers = NULL;
PFNPROXYCREATEGLXPIXMAPPROC         pfnProxyCreateGLXPixmap = NULL;
PFNPROXYDESTROYGLXPIXMAPPROC        pfnProxyDestroyGLXPixmap = NULL;
PFNPROXYQUERYEXTENSIONPROC          pfnProxyQueryExtension = NULL;
PFNPROXYQUERYVERSIONPROC            pfnProxyQueryVersion = NULL;
PFNPROXYISDIRECTPROC                pfnProxyIsDirect = NULL;
PFNPROXYGETCONFIGPROC               pfnProxyGetConfig = NULL;
PFNPROXYGETCURRENTCONTEXTPROC       pfnProxyGetCurrentContext = NULL;
PFNPROXYGETCURRENTDRAWABLEPROC      pfnProxyGetCurrentDrawable = NULL;
PFNPROXYWAITGLPROC                  pfnProxyWaitGL = NULL;
PFNPROXYWAITXPROC                   pfnProxyWaitX = NULL;
PFNPROXYUSEXFONTPROC                pfnProxyUseXFont = NULL;
PFNPROXYQUERYEXTENSIONSSTRINGPROC   pfnProxyQueryExtensionsString = NULL;
PFNPROXYQUERYSERVERSTRINGPROC       pfnProxyQueryServerString = NULL;
PFNPROXYGETCLIENTSTRINGPROC         pfnProxyGetClientString = NULL;
PFNPROXYGETCURRENTDISPLAYPROC       pfnProxyGetCurrentDisplay = NULL;
PFNPROXYCHOOSEFBCONFIGPROC          pfnProxyChooseFBConfig = NULL;
PFNPROXYGETFBCONFIGATTRIBPROC       pfnProxyGetFBConfigAttrib = NULL;
PFNPROXYGETFBCONFIGSPROC            pfnProxyGetFBConfigs = NULL;
PFNPROXYGETVISUALFROMFBCONFIGPROC   pfnProxyGetVisualFromFBConfig = NULL;
PFNPROXYCREATEWINDOWPROC            pfnProxyCreateWindow = NULL;
PFNPROXYDESTROYWINDOWPROC           pfnProxyDestroyWindow = NULL;
PFNPROXYCREATEPIXMAPPROC            pfnProxyCreatePixmap = NULL;
PFNPROXYDESTROYPIXMAPPROC           pfnProxyDestroyPixmap = NULL;
PFNPROXYCREATEPBUFFERPROC           pfnProxyCreatePBuffer = NULL;
PFNPROXYDESTROYPBUFFERPROC          pfnProxyDestroyPBuffer = NULL;
PFNPROXYQUERYDRAWABLEPROC           pfnProxyQueryDrawable = NULL;
PFNPROXYCREATENEWCONTEXTPROC        pfnProxyCreateNewContext = NULL;
PFNPROXYMAKECONTEXTCURRENTPROC      pfnProxyMakeContextCurrent = NULL;
PFNPROXYGETCURRENTREADDRAWABLEPROC  pfnProxyGetCurrentReadDrawable = NULL;
PFNPROXYQUERYCONTEXTPROC            pfnProxyQueryContext = NULL;
PFNPROXYSELECTEVENTPROC             pfnProxySelectEvent = NULL;
PFNPROXYGETSELECTEDEVENTPROC        pfnProxyGetSelectedEvent = NULL;
/* Proc address for EGL/GLX symbol resolve function
 * Note:
 * eglGetProcAddress can only be used for GL or EGL extension function
 * glXGetProcAddress/glXGetProcAddressARB can be used for all GL/GLX funtions
 */
PFNPROXYGLXGETPROCADDRESSPROC pfnProxyGLXGetProcAddressARB = NULL;
PFNPROXYGLXGETPROCADDRESSPROC pfnProxyGLXGetProcAddress = NULL;

extern void *glProxyGetProcAddr(void *handle, const char *name);

int glxProxyInit(void *handle)
{
	if (NULL == handle) {
        return -1;
    }

    pfnProxyChooseVisual = glProxyGetProcAddr(handle, "glXChooseVisual");
    pfnProxyCreateContext = glProxyGetProcAddr(handle, "glXCreateContext");
    pfnProxyDestroyContext = glProxyGetProcAddr(handle, "glXDestroyContext");
    pfnProxyMakeCurrent = glProxyGetProcAddr(handle, "glXMakeCurrent");
    pfnProxyCopyContext = glProxyGetProcAddr(handle, "glXCopyContext");
    pfnProxySwapBuffers = glProxyGetProcAddr(handle, "glXSwapBuffers");
    pfnProxyCreateGLXPixmap = glProxyGetProcAddr(handle, "glXCreateGLXPixmap");
    pfnProxyDestroyGLXPixmap
            = glProxyGetProcAddr(handle, "glXDestroyGLXPixmap");
    pfnProxyQueryExtension = glProxyGetProcAddr(handle, "glXQueryExtension");
    pfnProxyQueryVersion = glProxyGetProcAddr(handle, "glXQueryVersion");
    pfnProxyIsDirect = glProxyGetProcAddr(handle, "glXIsDirect");
    pfnProxyGetConfig = glProxyGetProcAddr(handle, "glXGetConfig");
    pfnProxyGetCurrentContext = glProxyGetProcAddr(handle,
            "glXGetCurrentContext");
    pfnProxyGetCurrentDrawable = glProxyGetProcAddr(handle,
            "glXGetCurrentDrawable");
    pfnProxyWaitGL = glProxyGetProcAddr(handle, "glXWaitGL");
    pfnProxyWaitX = glProxyGetProcAddr(handle, "glXWaitX");
    pfnProxyUseXFont = glProxyGetProcAddr(handle, "glXUseXFont");
    pfnProxyQueryExtensionsString = glProxyGetProcAddr(handle,
            "glXQueryExtensionsString");
    pfnProxyQueryServerString = glProxyGetProcAddr(handle,
            "glXQueryServerString");
    pfnProxyGetClientString = glProxyGetProcAddr(handle, "glXGetClientString");
    pfnProxyGetCurrentDisplay = glProxyGetProcAddr(handle,
            "glXGetCurrentDisplay");
    pfnProxyChooseFBConfig = glProxyGetProcAddr(handle, "glXChooseFBConfig");
    pfnProxyGetFBConfigAttrib = glProxyGetProcAddr(handle,
            "glXGetFBConfigAttrib");
    pfnProxyGetFBConfigs = glProxyGetProcAddr(handle, "glXGetFBConfigs");
    pfnProxyGetVisualFromFBConfig = glProxyGetProcAddr(handle,
            "glXGetVisualFromFBConfig");
    pfnProxyCreateWindow = glProxyGetProcAddr(handle, "glXCreateWindow");
    pfnProxyDestroyWindow = glProxyGetProcAddr(handle, "glXDestroyWindow");
    pfnProxyCreatePixmap = glProxyGetProcAddr(handle, "glXCreatePixmap");
    pfnProxyDestroyPixmap = glProxyGetProcAddr(handle, "glXDestroyPixmap");
    pfnProxyCreatePBuffer = glProxyGetProcAddr(handle, "glXCreatePBuffer");
    pfnProxyDestroyPBuffer = glProxyGetProcAddr(handle, "glXDestroyPBuffer");
    pfnProxyQueryDrawable = glProxyGetProcAddr(handle, "glXQueryDrawable");
    pfnProxyCreateNewContext
            = glProxyGetProcAddr(handle, "glXCreateNewContext");
    pfnProxyMakeContextCurrent = glProxyGetProcAddr(handle,
            "glXMakeContextCurrent");
    pfnProxyGetCurrentReadDrawable = glProxyGetProcAddr(handle,
            "glXGetCurrentReadDrawable");
    pfnProxyQueryContext = glProxyGetProcAddr(handle, "glXQueryContext");
    pfnProxySelectEvent = glProxyGetProcAddr(handle, "glXSelectEvent");
    pfnProxyGetSelectedEvent
            = glProxyGetProcAddr(handle, "glXGetSelectecEvent");

    return 0;
}