glinterface.h revision 068608273fa39b4032003d3a1f00d4125cc321e3
1// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef BENCH_GL_GLINTERFACE_H_
6#define BENCH_GL_GLINTERFACE_H_
7
8#include <X11/Xutil.h>
9
10#include "base/memory/scoped_ptr.h"
11
12#if defined(USE_OPENGL)
13
14struct __GLXcontextRec;  // Forward declaration from GLX.h.
15typedef struct __GLXcontextRec *GLXContext;
16typedef GLXContext GLContext;
17
18#elif defined(USE_OPENGLES)
19
20typedef void *EGLContext;  // Forward declaration from EGL.h.
21typedef EGLContext GLContext;
22
23#endif
24
25class GLInterface {
26 public:
27  GLInterface() {}
28  virtual ~GLInterface() {}
29  virtual bool Init() = 0;
30  virtual void Cleanup() = 0;
31  virtual XVisualInfo* GetXVisual() = 0;
32
33  virtual void SwapBuffers() = 0;
34  virtual bool SwapInterval(int interval) = 0;
35
36  virtual void CheckError() = 0;
37
38  virtual bool MakeCurrent(const GLContext& context) = 0;
39  virtual const GLContext CreateContext() = 0;
40  virtual void DeleteContext(const GLContext& context) = 0;
41  virtual const GLContext& GetMainContext() = 0;
42
43  static GLInterface* Create();
44};
45
46extern scoped_ptr<GLInterface> g_main_gl_interface;
47
48#endif  // BENCH_GL_GLINTERFACE_H_
49