OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BENCH_GL_MAIN_H_ | 5 #ifndef BENCH_GL_MAIN_H_ |
6 #define BENCH_GL_MAIN_H_ | 6 #define BENCH_GL_MAIN_H_ |
7 | 7 |
8 #include <gflags/gflags.h> | 8 #include <gflags/gflags.h> |
9 #include <sys/time.h> | 9 #include <sys/time.h> |
10 | 10 |
11 #ifdef USE_EGL | 11 #if defined(USE_OPENGLES) |
12 #include <GLES2/gl2.h> | 12 #include <GLES2/gl2.h> |
13 #include <EGL/egl.h> | 13 #include <EGL/egl.h> |
14 #else | 14 #elif defined(USE_OPENGL) |
15 #include <GL/gl.h> | 15 #include <GL/gl.h> |
16 #include <GL/glx.h> | 16 #include <GL/glx.h> |
17 | 17 |
18 #define LIST_PROC_FUNCTIONS(F) \ | 18 #define LIST_PROC_FUNCTIONS(F) \ |
19 F(glAttachShader, PFNGLATTACHSHADERPROC) \ | 19 F(glAttachShader, PFNGLATTACHSHADERPROC) \ |
20 F(glBindBuffer, PFNGLBINDBUFFERPROC) \ | 20 F(glBindBuffer, PFNGLBINDBUFFERPROC) \ |
21 F(glBufferData, PFNGLBUFFERDATAPROC) \ | 21 F(glBufferData, PFNGLBUFFERDATAPROC) \ |
22 F(glCompileShader, PFNGLCOMPILESHADERPROC) \ | 22 F(glCompileShader, PFNGLCOMPILESHADERPROC) \ |
23 F(glCreateProgram, PFNGLCREATEPROGRAMPROC) \ | 23 F(glCreateProgram, PFNGLCREATEPROGRAMPROC) \ |
24 F(glCreateShader, PFNGLCREATESHADERPROC) \ | 24 F(glCreateShader, PFNGLCREATESHADERPROC) \ |
(...skipping 15 matching lines...) Expand all Loading... |
40 F(glUseProgram, PFNGLUSEPROGRAMPROC) \ | 40 F(glUseProgram, PFNGLUSEPROGRAMPROC) \ |
41 F(glVertexAttribPointer, PFNGLVERTEXATTRIBPOINTERPROC) \ | 41 F(glVertexAttribPointer, PFNGLVERTEXATTRIBPOINTERPROC) \ |
42 F(glXSwapIntervalSGI, PFNGLXSWAPINTERVALSGIPROC) \ | 42 F(glXSwapIntervalSGI, PFNGLXSWAPINTERVALSGIPROC) \ |
43 F(glXBindTexImageEXT, PFNGLXBINDTEXIMAGEEXTPROC) \ | 43 F(glXBindTexImageEXT, PFNGLXBINDTEXIMAGEEXTPROC) \ |
44 F(glXReleaseTexImageEXT, PFNGLXRELEASETEXIMAGEEXTPROC) | 44 F(glXReleaseTexImageEXT, PFNGLXRELEASETEXIMAGEEXTPROC) |
45 | 45 |
46 #define F(fun, type) extern type fun; | 46 #define F(fun, type) extern type fun; |
47 LIST_PROC_FUNCTIONS(F) | 47 LIST_PROC_FUNCTIONS(F) |
48 #undef F | 48 #undef F |
49 | 49 |
| 50 #else |
| 51 #error bad graphics backend |
50 #endif | 52 #endif |
51 | 53 |
52 inline uint64_t GetUTime() { | 54 inline uint64_t GetUTime() { |
53 struct timeval tv; | 55 struct timeval tv; |
54 gettimeofday(&tv, NULL); | 56 gettimeofday(&tv, NULL); |
55 return static_cast<uint64_t>(tv.tv_usec) + | 57 return static_cast<uint64_t>(tv.tv_usec) + |
56 1000000ULL*static_cast<uint64_t>(tv.tv_sec); | 58 1000000ULL*static_cast<uint64_t>(tv.tv_sec); |
57 } | 59 } |
58 | 60 |
59 extern GLint g_width; | 61 extern GLint g_width; |
60 extern GLint g_height; | 62 extern GLint g_height; |
61 DECLARE_bool(override_redirect); | 63 DECLARE_bool(override_redirect); |
62 | 64 |
63 bool Init(); | 65 bool Init(); |
64 bool InitContext(); | 66 bool InitContext(); |
65 void DestroyContext(); | 67 void DestroyContext(); |
66 void SwapBuffers(); | 68 void SwapBuffers(); |
67 bool SwapInterval(int interval); | 69 bool SwapInterval(int interval); |
68 | 70 |
69 // This size is for a window that is very large but will fit on all | 71 // This size is for a window that is very large but will fit on all |
70 // the displays we care about. | 72 // the displays we care about. |
71 #define WINDOW_WIDTH 512 | 73 #define WINDOW_WIDTH 512 |
72 #define WINDOW_HEIGHT 512 | 74 #define WINDOW_HEIGHT 512 |
73 | 75 |
74 #endif // BENCH_GL_MAIN_H_ | 76 #endif // BENCH_GL_MAIN_H_ |
OLD | NEW |