OSDN Git Service

Implement a Radiance prototype.
[android-x86/external-swiftshader.git] / src / Radiance / libEGL / main.h
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
17 #define EGLAPI
18 #include <EGL/egl.h>
19 #include <EGL/eglext.h>
20 #include <RAD/rad.h>
21
22 namespace egl
23 {
24         struct Current
25         {
26                 EGLint error;
27                 EGLenum API;
28                 EGLDisplay display;
29                 EGLContext context;
30                 EGLSurface drawSurface;
31                 EGLSurface readSurface;
32         };
33
34         void setCurrentError(EGLint error);
35         EGLint getCurrentError();
36
37         void setCurrentAPI(EGLenum API);
38         EGLenum getCurrentAPI();
39
40         void setCurrentDisplay(EGLDisplay dpy);
41         EGLDisplay getCurrentDisplay();
42
43         void setCurrentContext(EGLContext ctx);
44         EGLContext getCurrentContext();
45
46         void setCurrentDrawSurface(EGLSurface surface);
47         EGLSurface getCurrentDrawSurface();
48
49         void setCurrentReadSurface(EGLSurface surface);
50         EGLSurface getCurrentReadSurface();
51 }
52
53 void error(EGLint errorCode);
54
55 template<class T>
56 const T &error(EGLint errorCode, const T &returnValue)
57 {
58     error(errorCode);
59
60     return returnValue;
61 }
62
63 template<class T>
64 const T &success(const T &returnValue)
65 {
66     egl::setCurrentError(EGL_SUCCESS);
67
68     return returnValue;
69 }
70
71 namespace egl
72 {
73         class Config;
74         class Surface;
75         class Display;
76         class Context;
77         class Image;
78 }
79
80 namespace sw
81 {
82         class FrameBuffer;
83         enum Format : unsigned char;
84 }
85
86 // libRAD dependencies
87 namespace es2
88 {
89         extern egl::Context *(*createContext)(const egl::Config *config, const egl::Context *shareContext);
90
91         extern egl::Image *(*createBackBuffer)(int width, int height, const egl::Config *config);
92         extern egl::Image *(*createDepthStencil)(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard);
93         extern sw::FrameBuffer *(*createFrameBuffer)(EGLNativeDisplayType display, EGLNativeWindowType window, int width, int height);
94 }
95
96 namespace rad
97 {
98         extern __eglMustCastToProperFunctionPointerType (RADAPIENTRY *getProcAddress)(const char *procname);
99 }
100
101 extern void *libRAD;    // Handle to the libRAD module
102
103 #endif  // LIBEGL_MAIN_H_