xref: /aosp_15_r20/external/deqp/framework/opengl/gluDefs.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
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) : tcu::TestError(message), m_error(error)
42 {
43 }
44 
~Error(void)45 Error::~Error(void) throw()
46 {
47 }
48 
OutOfMemoryError(const char * message,const char * expr,const char * file,int line)49 OutOfMemoryError::OutOfMemoryError(const char *message, const char *expr, const char *file, int line)
50     : tcu::ResourceError(message, expr, file, line)
51 {
52 }
53 
OutOfMemoryError(const std::string & message)54 OutOfMemoryError::OutOfMemoryError(const std::string &message) : tcu::ResourceError(message)
55 {
56 }
57 
~OutOfMemoryError(void)58 OutOfMemoryError::~OutOfMemoryError(void) throw()
59 {
60 }
61 
checkError(const RenderContext & context,const char * msg,const char * file,int line)62 void checkError(const RenderContext &context, const char *msg, const char *file, int line)
63 {
64     checkError(context.getFunctions().getError(), msg, file, line);
65 }
66 
checkError(uint32_t err,const char * msg,const char * file,int line)67 void checkError(uint32_t err, const char *msg, const char *file, int line)
68 {
69     if (err != GL_NO_ERROR)
70     {
71         std::ostringstream msgStr;
72         if (msg)
73             msgStr << msg << ": ";
74 
75         msgStr << "glGetError() returned " << getErrorStr(err);
76 
77         if (err == GL_OUT_OF_MEMORY)
78             throw OutOfMemoryError(msgStr.str().c_str(), DE_NULL, file, line);
79         else
80             throw Error(err, msgStr.str().c_str(), DE_NULL, file, line);
81     }
82 }
83 
84 } // namespace glu
85