• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES Utilities
3  * ------------------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Context wrapper that exposes sglr API as GL-compatible API.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "sglrContextWrapper.hpp"
25 #include "sglrContext.hpp"
26 
27 namespace sglr
28 {
29 
ContextWrapper(void)30 ContextWrapper::ContextWrapper (void)
31  : m_curCtx(DE_NULL)
32 {
33 }
34 
~ContextWrapper(void)35 ContextWrapper::~ContextWrapper (void)
36 {
37 }
38 
setContext(Context * context)39 void ContextWrapper::setContext (Context* context)
40 {
41 	m_curCtx = context;
42 }
43 
getCurrentContext(void) const44 Context* ContextWrapper::getCurrentContext (void) const
45 {
46 	return m_curCtx;
47 }
48 
getWidth(void) const49 int ContextWrapper::getWidth (void) const
50 {
51 	return m_curCtx->getWidth();
52 }
53 
getHeight(void) const54 int ContextWrapper::getHeight (void) const
55 {
56 	return m_curCtx->getHeight();
57 }
58 
glViewport(int x,int y,int width,int height)59 void ContextWrapper::glViewport (int x, int y, int width, int height)
60 {
61 	m_curCtx->viewport(x, y, width, height);
62 }
63 
glActiveTexture(deUint32 texture)64 void ContextWrapper::glActiveTexture (deUint32 texture)
65 {
66 	m_curCtx->activeTexture(texture);
67 }
68 
glBindTexture(deUint32 target,deUint32 texture)69 void ContextWrapper::glBindTexture (deUint32 target, deUint32 texture)
70 {
71 	m_curCtx->bindTexture(target, texture);
72 }
73 
glGenTextures(int numTextures,deUint32 * textures)74 void ContextWrapper::glGenTextures (int numTextures, deUint32* textures)
75 {
76 	m_curCtx->genTextures(numTextures, textures);
77 }
78 
glDeleteTextures(int numTextures,const deUint32 * textures)79 void ContextWrapper::glDeleteTextures (int numTextures, const deUint32* textures)
80 {
81 	m_curCtx->deleteTextures(numTextures, textures);
82 }
83 
glBindFramebuffer(deUint32 target,deUint32 framebuffer)84 void ContextWrapper::glBindFramebuffer (deUint32 target, deUint32 framebuffer)
85 {
86 	m_curCtx->bindFramebuffer(target, framebuffer);
87 }
88 
glGenFramebuffers(int numFramebuffers,deUint32 * framebuffers)89 void ContextWrapper::glGenFramebuffers (int numFramebuffers, deUint32* framebuffers)
90 {
91 	m_curCtx->genFramebuffers(numFramebuffers, framebuffers);
92 }
93 
glDeleteFramebuffers(int numFramebuffers,const deUint32 * framebuffers)94 void ContextWrapper::glDeleteFramebuffers (int numFramebuffers, const deUint32* framebuffers)
95 {
96 	m_curCtx->deleteFramebuffers(numFramebuffers, framebuffers);
97 }
98 
glBindRenderbuffer(deUint32 target,deUint32 renderbuffer)99 void ContextWrapper::glBindRenderbuffer (deUint32 target, deUint32 renderbuffer)
100 {
101 	m_curCtx->bindRenderbuffer(target, renderbuffer);
102 }
103 
glGenRenderbuffers(int numRenderbuffers,deUint32 * renderbuffers)104 void ContextWrapper::glGenRenderbuffers (int numRenderbuffers, deUint32* renderbuffers)
105 {
106 	m_curCtx->genRenderbuffers(numRenderbuffers, renderbuffers);
107 }
108 
glDeleteRenderbuffers(int numRenderbuffers,const deUint32 * renderbuffers)109 void ContextWrapper::glDeleteRenderbuffers (int numRenderbuffers, const deUint32* renderbuffers)
110 {
111 	m_curCtx->deleteRenderbuffers(numRenderbuffers, renderbuffers);
112 }
113 
glPixelStorei(deUint32 pname,int param)114 void ContextWrapper::glPixelStorei (deUint32 pname, int param)
115 {
116 	m_curCtx->pixelStorei(pname, param);
117 }
118 
glTexImage1D(deUint32 target,int level,int internalFormat,int width,int border,deUint32 format,deUint32 type,const void * data)119 void ContextWrapper::glTexImage1D (deUint32 target, int level, int internalFormat, int width, int border, deUint32 format, deUint32 type, const void* data)
120 {
121 	m_curCtx->texImage1D(target, level, (deUint32)internalFormat, width, border, format, type, data);
122 }
123 
glTexImage2D(deUint32 target,int level,int internalFormat,int width,int height,int border,deUint32 format,deUint32 type,const void * data)124 void ContextWrapper::glTexImage2D (deUint32 target, int level, int internalFormat, int width, int height, int border, deUint32 format, deUint32 type, const void* data)
125 {
126 	m_curCtx->texImage2D(target, level, (deUint32)internalFormat, width, height, border, format, type, data);
127 }
128 
glTexImage3D(deUint32 target,int level,int internalFormat,int width,int height,int depth,int border,deUint32 format,deUint32 type,const void * data)129 void ContextWrapper::glTexImage3D (deUint32 target, int level, int internalFormat, int width, int height, int depth, int border, deUint32 format, deUint32 type, const void* data)
130 {
131 	m_curCtx->texImage3D(target, level, (deUint32)internalFormat, width, height, depth, border, format, type, data);
132 }
133 
glTexSubImage1D(deUint32 target,int level,int xoffset,int width,deUint32 format,deUint32 type,const void * data)134 void ContextWrapper::glTexSubImage1D (deUint32 target, int level, int xoffset, int width, deUint32 format, deUint32 type, const void* data)
135 {
136 	m_curCtx->texSubImage1D(target, level, xoffset, width, format, type, data);
137 }
138 
glTexSubImage2D(deUint32 target,int level,int xoffset,int yoffset,int width,int height,deUint32 format,deUint32 type,const void * data)139 void ContextWrapper::glTexSubImage2D (deUint32 target, int level, int xoffset, int yoffset, int width, int height, deUint32 format, deUint32 type, const void* data)
140 {
141 	m_curCtx->texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, data);
142 }
143 
glTexSubImage3D(deUint32 target,int level,int xoffset,int yoffset,int zoffset,int width,int height,int depth,deUint32 format,deUint32 type,const void * data)144 void ContextWrapper::glTexSubImage3D (deUint32 target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, deUint32 format, deUint32 type, const void* data)
145 {
146 	m_curCtx->texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, data);
147 }
148 
glCopyTexImage1D(deUint32 target,int level,deUint32 internalFormat,int x,int y,int width,int border)149 void ContextWrapper::glCopyTexImage1D (deUint32 target, int level, deUint32 internalFormat, int x, int y, int width, int border)
150 {
151 	m_curCtx->copyTexImage1D(target, level, internalFormat, x, y, width, border);
152 }
153 
glCopyTexImage2D(deUint32 target,int level,deUint32 internalFormat,int x,int y,int width,int height,int border)154 void ContextWrapper::glCopyTexImage2D (deUint32 target, int level, deUint32 internalFormat, int x, int y, int width, int height, int border)
155 {
156 	m_curCtx->copyTexImage2D(target, level, internalFormat, x, y, width, height, border);
157 }
158 
glCopyTexSubImage1D(deUint32 target,int level,int xoffset,int x,int y,int width)159 void ContextWrapper::glCopyTexSubImage1D (deUint32 target, int level, int xoffset, int x, int y, int width)
160 {
161 	m_curCtx->copyTexSubImage1D(target, level, xoffset, x, y, width);
162 }
163 
glCopyTexSubImage2D(deUint32 target,int level,int xoffset,int yoffset,int x,int y,int width,int height)164 void ContextWrapper::glCopyTexSubImage2D (deUint32 target, int level, int xoffset, int yoffset, int x, int y, int width, int height)
165 {
166 	m_curCtx->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
167 }
168 
glTexStorage2D(deUint32 target,int levels,deUint32 internalFormat,int width,int height)169 void ContextWrapper::glTexStorage2D (deUint32 target, int levels, deUint32 internalFormat, int width, int height)
170 {
171 	m_curCtx->texStorage2D(target, levels, internalFormat, width, height);
172 }
173 
glTexStorage3D(deUint32 target,int levels,deUint32 internalFormat,int width,int height,int depth)174 void ContextWrapper::glTexStorage3D (deUint32 target, int levels, deUint32 internalFormat, int width, int height, int depth)
175 {
176 	m_curCtx->texStorage3D(target, levels, internalFormat, width, height, depth);
177 }
178 
glTexParameteri(deUint32 target,deUint32 pname,int value)179 void ContextWrapper::glTexParameteri (deUint32 target, deUint32 pname, int value)
180 {
181 	m_curCtx->texParameteri(target, pname, value);
182 }
183 
glUseProgram(deUint32 program)184 void ContextWrapper::glUseProgram (deUint32 program)
185 {
186 	m_curCtx->useProgram(program);
187 }
188 
glFramebufferTexture2D(deUint32 target,deUint32 attachment,deUint32 textarget,deUint32 texture,int level)189 void ContextWrapper::glFramebufferTexture2D (deUint32 target, deUint32 attachment, deUint32 textarget, deUint32 texture, int level)
190 {
191 	m_curCtx->framebufferTexture2D(target, attachment, textarget, texture, level);
192 }
193 
glFramebufferTextureLayer(deUint32 target,deUint32 attachment,deUint32 texture,int level,int layer)194 void ContextWrapper::glFramebufferTextureLayer (deUint32 target, deUint32 attachment, deUint32 texture, int level, int layer)
195 {
196 	m_curCtx->framebufferTextureLayer(target, attachment, texture, level, layer);
197 }
198 
glFramebufferRenderbuffer(deUint32 target,deUint32 attachment,deUint32 renderbuffertarget,deUint32 renderbuffer)199 void ContextWrapper::glFramebufferRenderbuffer (deUint32 target, deUint32 attachment, deUint32 renderbuffertarget, deUint32 renderbuffer)
200 {
201 	m_curCtx->framebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
202 }
203 
glCheckFramebufferStatus(deUint32 target)204 deUint32 ContextWrapper::glCheckFramebufferStatus (deUint32 target)
205 {
206 	return m_curCtx->checkFramebufferStatus(target);
207 }
208 
glGetFramebufferAttachmentParameteriv(deUint32 target,deUint32 attachment,deUint32 pname,int * params)209 void ContextWrapper::glGetFramebufferAttachmentParameteriv (deUint32 target, deUint32 attachment, deUint32 pname, int* params)
210 {
211 	m_curCtx->getFramebufferAttachmentParameteriv(target, attachment, pname, params);
212 }
213 
glRenderbufferStorage(deUint32 target,deUint32 internalformat,int width,int height)214 void ContextWrapper::glRenderbufferStorage (deUint32 target, deUint32 internalformat, int width, int height)
215 {
216 	m_curCtx->renderbufferStorage(target, internalformat, width, height);
217 }
218 
glRenderbufferStorageMultisample(deUint32 target,int samples,deUint32 internalformat,int width,int height)219 void ContextWrapper::glRenderbufferStorageMultisample (deUint32 target, int samples, deUint32 internalformat, int width, int height)
220 {
221 	m_curCtx->renderbufferStorageMultisample(target, samples, internalformat, width, height);
222 }
223 
glBindBuffer(deUint32 target,deUint32 buffer)224 void ContextWrapper::glBindBuffer (deUint32 target, deUint32 buffer)
225 {
226 	m_curCtx->bindBuffer(target, buffer);
227 }
228 
glGenBuffers(int n,deUint32 * buffers)229 void ContextWrapper::glGenBuffers (int n, deUint32* buffers)
230 {
231 	m_curCtx->genBuffers(n, buffers);
232 }
233 
glDeleteBuffers(int n,const deUint32 * buffers)234 void ContextWrapper::glDeleteBuffers (int n, const deUint32* buffers)
235 {
236 	m_curCtx->deleteBuffers(n, buffers);
237 }
238 
glBufferData(deUint32 target,deIntptr size,const void * data,deUint32 usage)239 void ContextWrapper::glBufferData (deUint32 target, deIntptr size, const void* data, deUint32 usage)
240 {
241 	m_curCtx->bufferData(target, size, data, usage);
242 }
243 
glBufferSubData(deUint32 target,deIntptr offset,deIntptr size,const void * data)244 void ContextWrapper::glBufferSubData (deUint32 target, deIntptr offset, deIntptr size, const void* data)
245 {
246 	m_curCtx->bufferSubData(target, offset, size, data);
247 }
248 
glClearColor(float red,float green,float blue,float alpha)249 void ContextWrapper::glClearColor (float red, float green, float blue, float alpha)
250 {
251 	m_curCtx->clearColor(red, green, blue, alpha);
252 }
253 
glClearDepthf(float depth)254 void ContextWrapper::glClearDepthf (float depth)
255 {
256 	m_curCtx->clearDepthf(depth);
257 }
258 
glClearStencil(int stencil)259 void ContextWrapper::glClearStencil (int stencil)
260 {
261 	m_curCtx->clearStencil(stencil);
262 }
263 
glClear(deUint32 buffers)264 void ContextWrapper::glClear (deUint32 buffers)
265 {
266 	m_curCtx->clear(buffers);
267 }
268 
glClearBufferiv(deUint32 buffer,int drawbuffer,const int * value)269 void ContextWrapper::glClearBufferiv (deUint32 buffer, int drawbuffer, const int* value)
270 {
271 	m_curCtx->clearBufferiv(buffer, drawbuffer, value);
272 }
273 
glClearBufferfv(deUint32 buffer,int drawbuffer,const float * value)274 void ContextWrapper::glClearBufferfv (deUint32 buffer, int drawbuffer, const float* value)
275 {
276 	m_curCtx->clearBufferfv(buffer, drawbuffer, value);
277 }
278 
glClearBufferuiv(deUint32 buffer,int drawbuffer,const deUint32 * value)279 void ContextWrapper::glClearBufferuiv (deUint32 buffer, int drawbuffer, const deUint32* value)
280 {
281 	m_curCtx->clearBufferuiv(buffer, drawbuffer, value);
282 }
283 
glClearBufferfi(deUint32 buffer,int drawbuffer,float depth,int stencil)284 void ContextWrapper::glClearBufferfi (deUint32 buffer, int drawbuffer, float depth, int stencil)
285 {
286 	m_curCtx->clearBufferfi(buffer, drawbuffer, depth, stencil);
287 }
288 
glScissor(int x,int y,int width,int height)289 void ContextWrapper::glScissor (int x, int y, int width, int height)
290 {
291 	m_curCtx->scissor(x, y, width, height);
292 }
293 
glEnable(deUint32 cap)294 void ContextWrapper::glEnable (deUint32 cap)
295 {
296 	m_curCtx->enable(cap);
297 }
298 
glDisable(deUint32 cap)299 void ContextWrapper::glDisable (deUint32 cap)
300 {
301 	m_curCtx->disable(cap);
302 }
303 
glStencilFunc(deUint32 func,int ref,deUint32 mask)304 void ContextWrapper::glStencilFunc (deUint32 func, int ref, deUint32 mask)
305 {
306 	m_curCtx->stencilFunc(func, ref, mask);
307 }
308 
glStencilOp(deUint32 sfail,deUint32 dpfail,deUint32 dppass)309 void ContextWrapper::glStencilOp (deUint32 sfail, deUint32 dpfail, deUint32 dppass)
310 {
311 	m_curCtx->stencilOp(sfail, dpfail, dppass);
312 }
313 
glDepthFunc(deUint32 func)314 void ContextWrapper::glDepthFunc (deUint32 func)
315 {
316 	m_curCtx->depthFunc(func);
317 }
318 
glBlendEquation(deUint32 mode)319 void ContextWrapper::glBlendEquation (deUint32 mode)
320 {
321 	m_curCtx->blendEquation(mode);
322 }
323 
glBlendEquationSeparate(deUint32 modeRGB,deUint32 modeAlpha)324 void ContextWrapper::glBlendEquationSeparate (deUint32 modeRGB, deUint32 modeAlpha)
325 {
326 	m_curCtx->blendEquationSeparate(modeRGB, modeAlpha);
327 }
328 
glBlendFunc(deUint32 src,deUint32 dst)329 void ContextWrapper::glBlendFunc (deUint32 src, deUint32 dst)
330 {
331 	m_curCtx->blendFunc(src, dst);
332 }
333 
glBlendFuncSeparate(deUint32 srcRGB,deUint32 dstRGB,deUint32 srcAlpha,deUint32 dstAlpha)334 void ContextWrapper::glBlendFuncSeparate (deUint32 srcRGB, deUint32 dstRGB, deUint32 srcAlpha, deUint32 dstAlpha)
335 {
336 	m_curCtx->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
337 }
338 
glBlendColor(float red,float green,float blue,float alpha)339 void ContextWrapper::glBlendColor (float red, float green, float blue, float alpha)
340 {
341 	m_curCtx->blendColor(red, green, blue, alpha);
342 }
343 
glColorMask(deBool r,deBool g,deBool b,deBool a)344 void ContextWrapper::glColorMask (deBool r, deBool g, deBool b, deBool a)
345 {
346 	m_curCtx->colorMask(r, g, b, a);
347 }
348 
glDepthMask(deBool mask)349 void ContextWrapper::glDepthMask (deBool mask)
350 {
351 	m_curCtx->depthMask(mask);
352 }
353 
glStencilMask(deUint32 mask)354 void ContextWrapper::glStencilMask (deUint32 mask)
355 {
356 	m_curCtx->stencilMask(mask);
357 }
358 
glBlitFramebuffer(int srcX0,int srcY0,int srcX1,int srcY1,int dstX0,int dstY0,int dstX1,int dstY1,deUint32 mask,deUint32 filter)359 void ContextWrapper::glBlitFramebuffer (int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, deUint32 mask, deUint32 filter)
360 {
361 	m_curCtx->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
362 }
363 
glInvalidateSubFramebuffer(deUint32 target,int numAttachments,const deUint32 * attachments,int x,int y,int width,int height)364 void ContextWrapper::glInvalidateSubFramebuffer (deUint32 target, int numAttachments, const deUint32* attachments, int x, int y, int width, int height)
365 {
366 	m_curCtx->invalidateSubFramebuffer(target, numAttachments, attachments, x, y, width, height);
367 }
368 
glInvalidateFramebuffer(deUint32 target,int numAttachments,const deUint32 * attachments)369 void ContextWrapper::glInvalidateFramebuffer (deUint32 target, int numAttachments, const deUint32* attachments)
370 {
371 	m_curCtx->invalidateFramebuffer(target, numAttachments, attachments);
372 }
373 
glReadPixels(int x,int y,int width,int height,deUint32 format,deUint32 type,void * data)374 void ContextWrapper::glReadPixels (int x, int y, int width, int height, deUint32 format, deUint32 type, void* data)
375 {
376 	m_curCtx->readPixels(x, y, width, height, format, type, data);
377 }
378 
glGetError(void)379 deUint32 ContextWrapper::glGetError (void)
380 {
381 	return m_curCtx->getError();
382 }
383 
glGetIntegerv(deUint32 pname,int * params)384 void ContextWrapper::glGetIntegerv (deUint32 pname, int* params)
385 {
386 	m_curCtx->getIntegerv(pname, params);
387 }
388 
389 } // sglr
390