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 OpenGL ES Test Utility Library. 22e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ci#include "gluDefs.hpp" 25e5c31af7Sopenharmony_ci#include "gluRenderContext.hpp" 26e5c31af7Sopenharmony_ci#include "gluStrUtil.hpp" 27e5c31af7Sopenharmony_ci#include "glwFunctions.hpp" 28e5c31af7Sopenharmony_ci#include "glwEnums.hpp" 29e5c31af7Sopenharmony_ci 30e5c31af7Sopenharmony_ci#include <sstream> 31e5c31af7Sopenharmony_ci 32e5c31af7Sopenharmony_cinamespace glu 33e5c31af7Sopenharmony_ci{ 34e5c31af7Sopenharmony_ci 35e5c31af7Sopenharmony_ciError::Error (int error, const char* message, const char* expr, const char* file, int line) 36e5c31af7Sopenharmony_ci : tcu::TestError (message, expr, file, line) 37e5c31af7Sopenharmony_ci , m_error (error) 38e5c31af7Sopenharmony_ci{ 39e5c31af7Sopenharmony_ci} 40e5c31af7Sopenharmony_ci 41e5c31af7Sopenharmony_ciError::Error (int error, const std::string& message) 42e5c31af7Sopenharmony_ci : tcu::TestError (message) 43e5c31af7Sopenharmony_ci , m_error (error) 44e5c31af7Sopenharmony_ci{ 45e5c31af7Sopenharmony_ci} 46e5c31af7Sopenharmony_ci 47e5c31af7Sopenharmony_ciError::~Error (void) throw() 48e5c31af7Sopenharmony_ci{ 49e5c31af7Sopenharmony_ci} 50e5c31af7Sopenharmony_ci 51e5c31af7Sopenharmony_ciOutOfMemoryError::OutOfMemoryError (const char* message, const char* expr, const char* file, int line) 52e5c31af7Sopenharmony_ci : tcu::ResourceError(message, expr, file, line) 53e5c31af7Sopenharmony_ci{ 54e5c31af7Sopenharmony_ci} 55e5c31af7Sopenharmony_ci 56e5c31af7Sopenharmony_ciOutOfMemoryError::OutOfMemoryError (const std::string& message) 57e5c31af7Sopenharmony_ci : tcu::ResourceError(message) 58e5c31af7Sopenharmony_ci{ 59e5c31af7Sopenharmony_ci} 60e5c31af7Sopenharmony_ci 61e5c31af7Sopenharmony_ciOutOfMemoryError::~OutOfMemoryError (void) throw() 62e5c31af7Sopenharmony_ci{ 63e5c31af7Sopenharmony_ci} 64e5c31af7Sopenharmony_ci 65e5c31af7Sopenharmony_civoid checkError (const RenderContext& context, const char* msg, const char* file, int line) 66e5c31af7Sopenharmony_ci{ 67e5c31af7Sopenharmony_ci checkError(context.getFunctions().getError(), msg, file, line); 68e5c31af7Sopenharmony_ci} 69e5c31af7Sopenharmony_ci 70e5c31af7Sopenharmony_civoid checkError (deUint32 err, const char* msg, const char* file, int line) 71e5c31af7Sopenharmony_ci{ 72e5c31af7Sopenharmony_ci if (err != GL_NO_ERROR) 73e5c31af7Sopenharmony_ci { 74e5c31af7Sopenharmony_ci std::ostringstream msgStr; 75e5c31af7Sopenharmony_ci if (msg) 76e5c31af7Sopenharmony_ci msgStr << msg << ": "; 77e5c31af7Sopenharmony_ci 78e5c31af7Sopenharmony_ci msgStr << "glGetError() returned " << getErrorStr(err); 79e5c31af7Sopenharmony_ci 80e5c31af7Sopenharmony_ci if (err == GL_OUT_OF_MEMORY) 81e5c31af7Sopenharmony_ci throw OutOfMemoryError(msgStr.str().c_str(), DE_NULL, file, line); 82e5c31af7Sopenharmony_ci else 83e5c31af7Sopenharmony_ci throw Error(err, msgStr.str().c_str(), DE_NULL, file, line); 84e5c31af7Sopenharmony_ci } 85e5c31af7Sopenharmony_ci} 86e5c31af7Sopenharmony_ci 87e5c31af7Sopenharmony_ci} // glu 88