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