blob: 8bdfcb239a46cc1cb89da70ba35f4f4c9e372e11 [file] [log] [blame]
John Bauman66b8ab22014-05-06 15:57:45 -04001// 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 Capensa2308052015-04-15 16:50:21 -040017#include "libGLES_CM/libGLES_CM.hpp"
18#include "libGLESv2/libGLESv2.hpp"
19
John Bauman66b8ab22014-05-06 15:57:45 -040020#include <EGL/egl.h>
21#include <EGL/eglext.h>
22
23namespace egl
24{
Nicolas Capens9cc8c962015-04-02 13:18:21 -040025 class Display;
26 class Context;
27 class Surface;
28
John Bauman66b8ab22014-05-06 15:57:45 -040029 struct Current
30 {
31 EGLint error;
32 EGLenum API;
Nicolas Capens3f1ab0c2016-02-08 15:13:57 -050033 EGLDisplay display;
Nicolas Capens9cc8c962015-04-02 13:18:21 -040034 Context *context;
35 Surface *drawSurface;
36 Surface *readSurface;
John Bauman66b8ab22014-05-06 15:57:45 -040037 };
38
39 void setCurrentError(EGLint error);
40 EGLint getCurrentError();
41
42 void setCurrentAPI(EGLenum API);
43 EGLenum getCurrentAPI();
44
Nicolas Capens3f1ab0c2016-02-08 15:13:57 -050045 void setCurrentDisplay(EGLDisplay dpy);
46 EGLDisplay getCurrentDisplay();
John Bauman66b8ab22014-05-06 15:57:45 -040047
Nicolas Capens9cc8c962015-04-02 13:18:21 -040048 void setCurrentContext(Context *ctx);
49 Context *getCurrentContext();
Nicolas Capens6899f6c2014-10-24 10:40:41 -040050
Nicolas Capens9cc8c962015-04-02 13:18:21 -040051 void setCurrentDrawSurface(Surface *surface);
52 Surface *getCurrentDrawSurface();
John Bauman66b8ab22014-05-06 15:57:45 -040053
Nicolas Capens9cc8c962015-04-02 13:18:21 -040054 void setCurrentReadSurface(Surface *surface);
55 Surface *getCurrentReadSurface();
John Bauman66b8ab22014-05-06 15:57:45 -040056
Nicolas Capensa2308052015-04-15 16:50:21 -040057 void error(EGLint errorCode);
Nicolas Capens3f1ab0c2016-02-08 15:13:57 -050058
Nicolas Capensa2308052015-04-15 16:50:21 -040059 template<class T>
60 const T &error(EGLint errorCode, const T &returnValue)
61 {
62 egl::error(errorCode);
John Bauman66b8ab22014-05-06 15:57:45 -040063
Nicolas Capensa2308052015-04-15 16:50:21 -040064 return returnValue;
65 }
John Bauman66b8ab22014-05-06 15:57:45 -040066
Nicolas Capensa2308052015-04-15 16:50:21 -040067 template<class T>
68 const T &success(const T &returnValue)
69 {
70 egl::setCurrentError(EGL_SUCCESS);
John Bauman66b8ab22014-05-06 15:57:45 -040071
Nicolas Capensa2308052015-04-15 16:50:21 -040072 return returnValue;
73 }
John Bauman66b8ab22014-05-06 15:57:45 -040074
John Bauman66b8ab22014-05-06 15:57:45 -040075 class Config;
76 class Surface;
77 class Display;
Nicolas Capensc2df1252014-10-24 11:59:19 -040078 class Context;
Nicolas Capensead7ac52014-10-27 23:56:02 -040079 class Image;
John Bauman66b8ab22014-05-06 15:57:45 -040080}
81
Nicolas Capensa2308052015-04-15 16:50:21 -040082extern LibGLES_CM libGLES_CM;
83extern LibGLESv2 libGLESv2;
John Bauman66b8ab22014-05-06 15:57:45 -040084
85#endif // LIBEGL_MAIN_H_