John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1 | // SwiftShader Software Renderer |
| 2 | // |
| 3 | // Copyright(c) 2005-2012 TransGaming Inc. |
| 4 | // |
| 5 | // All rights reserved. No part of this software may be copied, distributed, transmitted, |
| 6 | // transcribed, stored in a retrieval system, translated into any human or computer |
| 7 | // language by any means, or disclosed to third parties without the explicit written |
| 8 | // agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express |
| 9 | // or implied, including but not limited to any patent rights, are granted to you. |
| 10 | // |
| 11 | |
| 12 | // main.h: Management of thread-local data. |
| 13 | |
| 14 | #ifndef LIBEGL_MAIN_H_ |
| 15 | #define LIBEGL_MAIN_H_ |
| 16 | |
Nicolas Capens | a230805 | 2015-04-15 16:50:21 -0400 | [diff] [blame] | 17 | #include "libGLES_CM/libGLES_CM.hpp" |
| 18 | #include "libGLESv2/libGLESv2.hpp" |
| 19 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 20 | #include <EGL/egl.h> |
| 21 | #include <EGL/eglext.h> |
| 22 | |
| 23 | namespace egl |
| 24 | { |
Nicolas Capens | 9cc8c96 | 2015-04-02 13:18:21 -0400 | [diff] [blame] | 25 | class Display; |
| 26 | class Context; |
| 27 | class Surface; |
| 28 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 29 | struct Current |
| 30 | { |
| 31 | EGLint error; |
| 32 | EGLenum API; |
Nicolas Capens | 3f1ab0c | 2016-02-08 15:13:57 -0500 | [diff] [blame^] | 33 | EGLDisplay display; |
Nicolas Capens | 9cc8c96 | 2015-04-02 13:18:21 -0400 | [diff] [blame] | 34 | Context *context; |
| 35 | Surface *drawSurface; |
| 36 | Surface *readSurface; |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | void setCurrentError(EGLint error); |
| 40 | EGLint getCurrentError(); |
| 41 | |
| 42 | void setCurrentAPI(EGLenum API); |
| 43 | EGLenum getCurrentAPI(); |
| 44 | |
Nicolas Capens | 3f1ab0c | 2016-02-08 15:13:57 -0500 | [diff] [blame^] | 45 | void setCurrentDisplay(EGLDisplay dpy); |
| 46 | EGLDisplay getCurrentDisplay(); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 47 | |
Nicolas Capens | 9cc8c96 | 2015-04-02 13:18:21 -0400 | [diff] [blame] | 48 | void setCurrentContext(Context *ctx); |
| 49 | Context *getCurrentContext(); |
Nicolas Capens | 6899f6c | 2014-10-24 10:40:41 -0400 | [diff] [blame] | 50 | |
Nicolas Capens | 9cc8c96 | 2015-04-02 13:18:21 -0400 | [diff] [blame] | 51 | void setCurrentDrawSurface(Surface *surface); |
| 52 | Surface *getCurrentDrawSurface(); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 53 | |
Nicolas Capens | 9cc8c96 | 2015-04-02 13:18:21 -0400 | [diff] [blame] | 54 | void setCurrentReadSurface(Surface *surface); |
| 55 | Surface *getCurrentReadSurface(); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 56 | |
Nicolas Capens | a230805 | 2015-04-15 16:50:21 -0400 | [diff] [blame] | 57 | void error(EGLint errorCode); |
Nicolas Capens | 3f1ab0c | 2016-02-08 15:13:57 -0500 | [diff] [blame^] | 58 | |
Nicolas Capens | a230805 | 2015-04-15 16:50:21 -0400 | [diff] [blame] | 59 | template<class T> |
| 60 | const T &error(EGLint errorCode, const T &returnValue) |
| 61 | { |
| 62 | egl::error(errorCode); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 63 | |
Nicolas Capens | a230805 | 2015-04-15 16:50:21 -0400 | [diff] [blame] | 64 | return returnValue; |
| 65 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 66 | |
Nicolas Capens | a230805 | 2015-04-15 16:50:21 -0400 | [diff] [blame] | 67 | template<class T> |
| 68 | const T &success(const T &returnValue) |
| 69 | { |
| 70 | egl::setCurrentError(EGL_SUCCESS); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 71 | |
Nicolas Capens | a230805 | 2015-04-15 16:50:21 -0400 | [diff] [blame] | 72 | return returnValue; |
| 73 | } |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 74 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 75 | class Config; |
| 76 | class Surface; |
| 77 | class Display; |
Nicolas Capens | c2df125 | 2014-10-24 11:59:19 -0400 | [diff] [blame] | 78 | class Context; |
Nicolas Capens | ead7ac5 | 2014-10-27 23:56:02 -0400 | [diff] [blame] | 79 | class Image; |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 80 | } |
| 81 | |
Nicolas Capens | a230805 | 2015-04-15 16:50:21 -0400 | [diff] [blame] | 82 | extern LibGLES_CM libGLES_CM; |
| 83 | extern LibGLESv2 libGLESv2; |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 84 | |
| 85 | #endif // LIBEGL_MAIN_H_ |