xref: /aosp_15_r20/external/deqp/framework/opengl/gluDefs.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker  * drawElements Quality Program OpenGL ES Utilities
3*35238bceSAndroid Build Coastguard Worker  * ------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker  *
5*35238bceSAndroid Build Coastguard Worker  * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker  *
11*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker  *
19*35238bceSAndroid Build Coastguard Worker  *//*!
20*35238bceSAndroid Build Coastguard Worker  * \file
21*35238bceSAndroid Build Coastguard Worker  * \brief OpenGL ES Test Utility Library.
22*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
23*35238bceSAndroid Build Coastguard Worker 
24*35238bceSAndroid Build Coastguard Worker #include "gluDefs.hpp"
25*35238bceSAndroid Build Coastguard Worker #include "gluRenderContext.hpp"
26*35238bceSAndroid Build Coastguard Worker #include "gluStrUtil.hpp"
27*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
28*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
29*35238bceSAndroid Build Coastguard Worker 
30*35238bceSAndroid Build Coastguard Worker #include <sstream>
31*35238bceSAndroid Build Coastguard Worker 
32*35238bceSAndroid Build Coastguard Worker namespace glu
33*35238bceSAndroid Build Coastguard Worker {
34*35238bceSAndroid Build Coastguard Worker 
Error(int error,const char * message,const char * expr,const char * file,int line)35*35238bceSAndroid Build Coastguard Worker Error::Error(int error, const char *message, const char *expr, const char *file, int line)
36*35238bceSAndroid Build Coastguard Worker     : tcu::TestError(message, expr, file, line)
37*35238bceSAndroid Build Coastguard Worker     , m_error(error)
38*35238bceSAndroid Build Coastguard Worker {
39*35238bceSAndroid Build Coastguard Worker }
40*35238bceSAndroid Build Coastguard Worker 
Error(int error,const std::string & message)41*35238bceSAndroid Build Coastguard Worker Error::Error(int error, const std::string &message) : tcu::TestError(message), m_error(error)
42*35238bceSAndroid Build Coastguard Worker {
43*35238bceSAndroid Build Coastguard Worker }
44*35238bceSAndroid Build Coastguard Worker 
~Error(void)45*35238bceSAndroid Build Coastguard Worker Error::~Error(void) throw()
46*35238bceSAndroid Build Coastguard Worker {
47*35238bceSAndroid Build Coastguard Worker }
48*35238bceSAndroid Build Coastguard Worker 
OutOfMemoryError(const char * message,const char * expr,const char * file,int line)49*35238bceSAndroid Build Coastguard Worker OutOfMemoryError::OutOfMemoryError(const char *message, const char *expr, const char *file, int line)
50*35238bceSAndroid Build Coastguard Worker     : tcu::ResourceError(message, expr, file, line)
51*35238bceSAndroid Build Coastguard Worker {
52*35238bceSAndroid Build Coastguard Worker }
53*35238bceSAndroid Build Coastguard Worker 
OutOfMemoryError(const std::string & message)54*35238bceSAndroid Build Coastguard Worker OutOfMemoryError::OutOfMemoryError(const std::string &message) : tcu::ResourceError(message)
55*35238bceSAndroid Build Coastguard Worker {
56*35238bceSAndroid Build Coastguard Worker }
57*35238bceSAndroid Build Coastguard Worker 
~OutOfMemoryError(void)58*35238bceSAndroid Build Coastguard Worker OutOfMemoryError::~OutOfMemoryError(void) throw()
59*35238bceSAndroid Build Coastguard Worker {
60*35238bceSAndroid Build Coastguard Worker }
61*35238bceSAndroid Build Coastguard Worker 
checkError(const RenderContext & context,const char * msg,const char * file,int line)62*35238bceSAndroid Build Coastguard Worker void checkError(const RenderContext &context, const char *msg, const char *file, int line)
63*35238bceSAndroid Build Coastguard Worker {
64*35238bceSAndroid Build Coastguard Worker     checkError(context.getFunctions().getError(), msg, file, line);
65*35238bceSAndroid Build Coastguard Worker }
66*35238bceSAndroid Build Coastguard Worker 
checkError(uint32_t err,const char * msg,const char * file,int line)67*35238bceSAndroid Build Coastguard Worker void checkError(uint32_t err, const char *msg, const char *file, int line)
68*35238bceSAndroid Build Coastguard Worker {
69*35238bceSAndroid Build Coastguard Worker     if (err != GL_NO_ERROR)
70*35238bceSAndroid Build Coastguard Worker     {
71*35238bceSAndroid Build Coastguard Worker         std::ostringstream msgStr;
72*35238bceSAndroid Build Coastguard Worker         if (msg)
73*35238bceSAndroid Build Coastguard Worker             msgStr << msg << ": ";
74*35238bceSAndroid Build Coastguard Worker 
75*35238bceSAndroid Build Coastguard Worker         msgStr << "glGetError() returned " << getErrorStr(err);
76*35238bceSAndroid Build Coastguard Worker 
77*35238bceSAndroid Build Coastguard Worker         if (err == GL_OUT_OF_MEMORY)
78*35238bceSAndroid Build Coastguard Worker             throw OutOfMemoryError(msgStr.str().c_str(), DE_NULL, file, line);
79*35238bceSAndroid Build Coastguard Worker         else
80*35238bceSAndroid Build Coastguard Worker             throw Error(err, msgStr.str().c_str(), DE_NULL, file, line);
81*35238bceSAndroid Build Coastguard Worker     }
82*35238bceSAndroid Build Coastguard Worker }
83*35238bceSAndroid Build Coastguard Worker 
84*35238bceSAndroid Build Coastguard Worker } // namespace glu
85