1e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 2e5c31af7Sopenharmony_ci * drawElements Quality Program OpenGL ES Utilities 3e5c31af7Sopenharmony_ci * ------------------------------------------------ 4e5c31af7Sopenharmony_ci * 5e5c31af7Sopenharmony_ci * Copyright 2014 The Android Open Source Project 6e5c31af7Sopenharmony_ci * 7e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 8e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 9e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 10e5c31af7Sopenharmony_ci * 11e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 12e5c31af7Sopenharmony_ci * 13e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 14e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 15e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 17e5c31af7Sopenharmony_ci * limitations under the License. 18e5c31af7Sopenharmony_ci * 19e5c31af7Sopenharmony_ci *//*! 20e5c31af7Sopenharmony_ci * \file 21e5c31af7Sopenharmony_ci * \brief Simplified GLES reference context. 22e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ci#include "sglrContext.hpp" 25e5c31af7Sopenharmony_ci#include "sglrGLContext.hpp" 26e5c31af7Sopenharmony_ci#include "gluTextureUtil.hpp" 27e5c31af7Sopenharmony_ci 28e5c31af7Sopenharmony_ci#include "glwEnums.hpp" 29e5c31af7Sopenharmony_ci 30e5c31af7Sopenharmony_cinamespace sglr 31e5c31af7Sopenharmony_ci{ 32e5c31af7Sopenharmony_ci 33e5c31af7Sopenharmony_ciusing std::vector; 34e5c31af7Sopenharmony_ci 35e5c31af7Sopenharmony_civoid Context::texImage2D (deUint32 target, int level, deUint32 internalFormat, const tcu::Surface& src) 36e5c31af7Sopenharmony_ci{ 37e5c31af7Sopenharmony_ci int width = src.getWidth(); 38e5c31af7Sopenharmony_ci int height = src.getHeight(); 39e5c31af7Sopenharmony_ci texImage2D(target, level, internalFormat, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, src.getAccess().getDataPtr()); 40e5c31af7Sopenharmony_ci} 41e5c31af7Sopenharmony_ci 42e5c31af7Sopenharmony_civoid Context::texImage2D (deUint32 target, int level, deUint32 internalFormat, int width, int height) 43e5c31af7Sopenharmony_ci{ 44e5c31af7Sopenharmony_ci deUint32 format = GL_NONE; 45e5c31af7Sopenharmony_ci deUint32 dataType = GL_NONE; 46e5c31af7Sopenharmony_ci 47e5c31af7Sopenharmony_ci switch (internalFormat) 48e5c31af7Sopenharmony_ci { 49e5c31af7Sopenharmony_ci case GL_ALPHA: 50e5c31af7Sopenharmony_ci case GL_LUMINANCE: 51e5c31af7Sopenharmony_ci case GL_LUMINANCE_ALPHA: 52e5c31af7Sopenharmony_ci case GL_RGB: 53e5c31af7Sopenharmony_ci case GL_RGBA: 54e5c31af7Sopenharmony_ci format = internalFormat; 55e5c31af7Sopenharmony_ci dataType = GL_UNSIGNED_BYTE; 56e5c31af7Sopenharmony_ci break; 57e5c31af7Sopenharmony_ci 58e5c31af7Sopenharmony_ci default: 59e5c31af7Sopenharmony_ci { 60e5c31af7Sopenharmony_ci glu::TransferFormat transferFmt = glu::getTransferFormat(glu::mapGLInternalFormat(internalFormat)); 61e5c31af7Sopenharmony_ci format = transferFmt.format; 62e5c31af7Sopenharmony_ci dataType = transferFmt.dataType; 63e5c31af7Sopenharmony_ci break; 64e5c31af7Sopenharmony_ci } 65e5c31af7Sopenharmony_ci } 66e5c31af7Sopenharmony_ci 67e5c31af7Sopenharmony_ci texImage2D(target, level, internalFormat, width, height, 0, format, dataType, DE_NULL); 68e5c31af7Sopenharmony_ci} 69e5c31af7Sopenharmony_ci 70e5c31af7Sopenharmony_civoid Context::texSubImage2D (deUint32 target, int level, int xoffset, int yoffset, const tcu::Surface& src) 71e5c31af7Sopenharmony_ci{ 72e5c31af7Sopenharmony_ci int width = src.getWidth(); 73e5c31af7Sopenharmony_ci int height = src.getHeight(); 74e5c31af7Sopenharmony_ci texSubImage2D(target, level, xoffset, yoffset, width, height, GL_RGBA, GL_UNSIGNED_BYTE, src.getAccess().getDataPtr()); 75e5c31af7Sopenharmony_ci} 76e5c31af7Sopenharmony_ci 77e5c31af7Sopenharmony_civoid Context::readPixels (tcu::Surface& dst, int x, int y, int width, int height) 78e5c31af7Sopenharmony_ci{ 79e5c31af7Sopenharmony_ci dst.setSize(width, height); 80e5c31af7Sopenharmony_ci readPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, dst.getAccess().getDataPtr()); 81e5c31af7Sopenharmony_ci} 82e5c31af7Sopenharmony_ci 83e5c31af7Sopenharmony_ci} // sglr 84