~rsalveti/linaro-graphics-misc/glew-es-core-trunk

« back to all changes in this revision

Viewing changes to auto/src/glewinfo_tail.c

  • Committer: Shariq
  • Date: 2011-10-07 05:03:57 UTC
  • Revision ID: git-v1:bd0be7d494b4332137231a2616b86dcb32a28524
glewinfo provide information on OpenGL ES and  EGL extensions.
This support is there for Linux only.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
}
2
2
 
3
 
#endif /* _WIN32 */
 
3
#endif /* GLEW_USE_LIB_ES */
4
4
 
5
5
/* ------------------------------------------------------------------------ */
6
6
 
7
 
#if defined(_WIN32) || !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
 
7
#if defined(_WIN32) || !defined(__APPLE__) || defined(GLEW_APPLE_GLX) || defined(GLEW_USE_LIB_ES)
8
8
int main (int argc, char** argv)
9
9
#else
10
10
int main (void)
12
12
{
13
13
  GLuint err;
14
14
 
15
 
#if defined(_WIN32) || !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
 
15
#if defined(_WIN32) || !defined(__APPLE__) || defined(GLEW_APPLE_GLX) || defined(GLEW_USE_LIB_ES)
16
16
  char* display = NULL;
17
17
  int visual = -1;
18
18
 
19
19
  if (glewParseArgs(argc-1, argv+1, &display, &visual))
20
20
  {
21
 
#if defined(_WIN32)
 
21
# if defined(GLEW_USE_LIB_ES)
 
22
   fprintf(stderr, "Usage: glewinfo [-display <display>] \n");
 
23
# elif defined(_WIN32)
22
24
    fprintf(stderr, "Usage: glewinfo [-pf <id>]\n");
23
25
#else
24
26
    fprintf(stderr, "Usage: glewinfo [-display <display>] [-visual <id>]\n");
27
29
  }
28
30
#endif
29
31
 
30
 
#if defined(_WIN32)
 
32
# if defined(GLEW_USE_LIB_ES)
 
33
if (GL_TRUE == glewCreateContext(display))
 
34
#elif defined(_WIN32)
31
35
  if (GL_TRUE == glewCreateContext(&visual))
32
36
#elif defined(__APPLE__) && !defined(GLEW_APPLE_GLX)
33
37
  if (GL_TRUE == glewCreateContext())
42
46
  glewExperimental = GL_TRUE;
43
47
#ifdef GLEW_MX
44
48
  err = glewContextInit(glewGetContext());
45
 
#ifdef _WIN32
 
49
# if defined(GLEW_USE_LIB_ES)
 
50
#if defined GLEW_INC_EGL
 
51
  err = eglewContextInit(eglewGetContext());
 
52
#endif
 
53
#elif defined _WIN32
46
54
  err = err || wglewContextInit(wglewGetContext());
47
55
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
48
56
  err = err || glxewContextInit(glxewGetContext());
67
75
  fprintf(f, "    GLEW Extension Info\n");
68
76
  fprintf(f, "---------------------------\n\n");
69
77
  fprintf(f, "GLEW version %s\n", glewGetString(GLEW_VERSION));
70
 
#if defined(_WIN32)
 
78
# if defined(GLEW_USE_LIB_ES)
 
79
  fprintf(f, "Reporting capabilities of display %s , \n", 
 
80
    display == NULL ? getenv("DISPLAY") : (char *)display);
 
81
#elif defined(_WIN32)
71
82
  fprintf(f, "Reporting capabilities of pixelformat %d\n", visual);
72
83
#elif !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
73
84
  fprintf(f, "Reporting capabilities of display %s, visual 0x%x\n", 
77
88
          glGetString(GL_RENDERER), glGetString(GL_VENDOR));
78
89
  fprintf(f, "OpenGL version %s is supported\n", glGetString(GL_VERSION));
79
90
  glewInfo();
80
 
#if defined(_WIN32)
 
91
# if defined(GLEW_USE_LIB_ES)
 
92
#if defined (GLEW_INC_EGL)
 
93
  eglewInfo();
 
94
#endif
 
95
#elif defined(_WIN32)
81
96
  wglewInfo();
82
97
#else
83
98
  glxewInfo();
89
104
 
90
105
/* ------------------------------------------------------------------------ */
91
106
 
92
 
#if defined(_WIN32) || !defined(__APPLE__) || defined(GLEW_APPLE_GLX)
 
107
#if defined(_WIN32) || !defined(__APPLE__) || defined(GLEW_APPLE_GLX) || defined(GLEW_USE_LIB_ES)
93
108
GLboolean glewParseArgs (int argc, char** argv, char** display, int* visual)
94
109
{
95
110
  int p = 0;
96
111
  while (p < argc)
97
112
  {
98
 
#if defined(_WIN32)
 
113
#if defined(GLEW_USE_LIB_ES)
 
114
    if (!strcmp(argv[p], "-display"))
 
115
    {
 
116
      if (++p >= argc) return GL_TRUE;
 
117
      *display = argv[p++];
 
118
          *visual = -1;
 
119
    }
 
120
    else
 
121
      return GL_TRUE;
 
122
#elif defined(_WIN32)
99
123
    if (!strcmp(argv[p], "-pf") || !strcmp(argv[p], "-pixelformat"))
100
124
    {
101
125
      if (++p >= argc) return GL_TRUE;
125
149
 
126
150
/* ------------------------------------------------------------------------ */
127
151
 
128
 
#if defined(_WIN32)
 
152
#if defined(GLEW_USE_LIB_ES)
 
153
 
 
154
EGLDisplay eDpy = NULL;
 
155
EGLSurface eSurf = NULL;
 
156
EGLContext eCtx = NULL;
 
157
 
 
158
Display *dpy;
 
159
Window wnd;
 
160
 
 
161
 
 
162
GLboolean glewCreateContext (const char* display)
 
163
{
 
164
   int noCfg = 0;
 
165
   EGLConfig cfg[1];
 
166
# if defined(GLEW_USE_LIB_ES20)
 
167
   EGLint attribs[] = {EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
 
168
                       EGL_SURFACE_TYPE, EGL_WINDOW_BIT,EGL_NONE};
 
169
   EGLint contextAttribs[] = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE};
 
170
#else
 
171
   EGLint attribs[] = {EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_NONE};
 
172
   EGLint contextAttribs[] = {EGL_NONE};        
 
173
#endif
 
174
 
 
175
#ifdef linux
 
176
        dpy = XOpenDisplay(display);
 
177
        wnd = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, 1, 1,
 
178
                                                                0, 0, 0);
 
179
#endif
 
180
   eDpy = eglGetDisplay((NativeDisplayType)dpy);
 
181
   if(eDpy == NULL) return GL_TRUE;
 
182
   if(!eglInitialize(eDpy, NULL, NULL)) return GL_TRUE;
 
183
   if(!eglChooseConfig(eDpy, attribs, cfg, 1, &noCfg)) return GL_TRUE;
 
184
   eCtx = eglCreateContext(eDpy, cfg[0], EGL_NO_CONTEXT, contextAttribs);
 
185
   if(eCtx == NULL) return GL_TRUE;
 
186
   eSurf = eglCreateWindowSurface(eDpy, cfg[0], (EGLNativeWindowType)wnd, NULL);
 
187
   if(eSurf == NULL) return GL_TRUE;
 
188
   if(!eglMakeCurrent(eDpy, eSurf, eSurf, eCtx)) return GL_TRUE;
 
189
   return GL_FALSE;
 
190
}
 
191
 
 
192
void glewDestroyContext ()
 
193
{
 
194
   eglMakeCurrent(eDpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 
195
   if (!eDpy && !eSurf) eglDestroySurface(eDpy, eSurf);
 
196
   if (!eDpy && !eCtx) eglDestroyContext(eDpy, eCtx);
 
197
   if (!eDpy) eglTerminate(eDpy);
 
198
#ifdef linux
 
199
        if(NULL != dpy && 0 != wnd) XDestroyWindow(dpy, wnd);
 
200
    if(NULL != dpy) XCloseDisplay(dpy);
 
201
#endif
 
202
}
 
203
 
 
204
#elif defined(_WIN32)
129
205
 
130
206
HWND wnd = NULL;
131
207
HDC dc = NULL;