1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES Utilities
3 * ------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * \brief Simplified GLES reference context.
22 *//*--------------------------------------------------------------------*/
24 #include "sglrContext.hpp"
25 #include "sglrGLContext.hpp"
26 #include "gluTextureUtil.hpp"
28 #include "glwEnums.hpp"
35 void Context::texImage2D (deUint32 target, int level, deUint32 internalFormat, const tcu::Surface& src)
37 int width = src.getWidth();
38 int height = src.getHeight();
39 texImage2D(target, level, internalFormat, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, src.getAccess().getDataPtr());
42 void Context::texImage2D (deUint32 target, int level, deUint32 internalFormat, int width, int height)
44 deUint32 format = GL_NONE;
45 deUint32 dataType = GL_NONE;
47 switch (internalFormat)
51 case GL_LUMINANCE_ALPHA:
54 format = internalFormat;
55 dataType = GL_UNSIGNED_BYTE;
60 glu::TransferFormat transferFmt = glu::getTransferFormat(glu::mapGLInternalFormat(internalFormat));
61 format = transferFmt.format;
62 dataType = transferFmt.dataType;
67 texImage2D(target, level, internalFormat, width, height, 0, format, dataType, DE_NULL);
70 void Context::texSubImage2D (deUint32 target, int level, int xoffset, int yoffset, const tcu::Surface& src)
72 int width = src.getWidth();
73 int height = src.getHeight();
74 texSubImage2D(target, level, xoffset, yoffset, width, height, GL_RGBA, GL_UNSIGNED_BYTE, src.getAccess().getDataPtr());
77 void Context::readPixels (tcu::Surface& dst, int x, int y, int width, int height)
79 dst.setSize(width, height);
80 readPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, dst.getAccess().getDataPtr());