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 Simplified GLES reference context. 22 *//*--------------------------------------------------------------------*/ 23 24#include "sglrContext.hpp" 25#include "sglrGLContext.hpp" 26#include "gluTextureUtil.hpp" 27 28#include "glwEnums.hpp" 29 30namespace sglr 31{ 32 33using std::vector; 34 35void Context::texImage2D (deUint32 target, int level, deUint32 internalFormat, const tcu::Surface& src) 36{ 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()); 40} 41 42void Context::texImage2D (deUint32 target, int level, deUint32 internalFormat, int width, int height) 43{ 44 deUint32 format = GL_NONE; 45 deUint32 dataType = GL_NONE; 46 47 switch (internalFormat) 48 { 49 case GL_ALPHA: 50 case GL_LUMINANCE: 51 case GL_LUMINANCE_ALPHA: 52 case GL_RGB: 53 case GL_RGBA: 54 format = internalFormat; 55 dataType = GL_UNSIGNED_BYTE; 56 break; 57 58 default: 59 { 60 glu::TransferFormat transferFmt = glu::getTransferFormat(glu::mapGLInternalFormat(internalFormat)); 61 format = transferFmt.format; 62 dataType = transferFmt.dataType; 63 break; 64 } 65 } 66 67 texImage2D(target, level, internalFormat, width, height, 0, format, dataType, DE_NULL); 68} 69 70void Context::texSubImage2D (deUint32 target, int level, int xoffset, int yoffset, const tcu::Surface& src) 71{ 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()); 75} 76 77void Context::readPixels (tcu::Surface& dst, int x, int y, int width, int height) 78{ 79 dst.setSize(width, height); 80 readPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, dst.getAccess().getDataPtr()); 81} 82 83} // sglr 84