1 #ifndef _GLUDEFS_HPP
2 #define _GLUDEFS_HPP
3 /*-------------------------------------------------------------------------
4  * drawElements Quality Program OpenGL ES Utilities
5  * ------------------------------------------------
6  *
7  * Copyright 2014 The Android Open Source Project
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  *//*!
22  * \file
23  * \brief OpenGL ES Test Utility Library.
24  *//*--------------------------------------------------------------------*/
25 
26 #include "tcuDefs.hpp"
27 
28 // Macros for checking API errors.
29 #define GLU_EXPECT_NO_ERROR(ERR, MSG)	glu::checkError((ERR), MSG, __FILE__, __LINE__)
30 #define GLU_CHECK_ERROR(ERR)			GLU_EXPECT_NO_ERROR(ERR, DE_NULL)
31 #define GLU_CHECK_MSG(MSG)				GLU_EXPECT_NO_ERROR(glGetError(), MSG)
32 #define GLU_CHECK()						GLU_CHECK_MSG(DE_NULL)
33 #define GLU_CHECK_CALL_ERROR(CALL, ERR)	do { CALL; GLU_EXPECT_NO_ERROR(ERR, #CALL); } while (deGetFalse())
34 #define GLU_CHECK_CALL(CALL)			do { CALL; GLU_EXPECT_NO_ERROR(glGetError(), #CALL); } while (deGetFalse())
35 
36 #define GLU_CHECK_GLW_MSG(GL, MSG)		GLU_EXPECT_NO_ERROR((GL).getError(), MSG)
37 #define GLU_CHECK_GLW(GL)				GLU_CHECK_GLW_MSG(GL, DE_NULL)
38 #define GLU_CHECK_GLW_CALL(GL, CALL)	do { (GL).CALL; GLU_EXPECT_NO_ERROR((GL).getError(), #CALL); } while (deGetFalse())
39 
40 /*--------------------------------------------------------------------*//*!
41  * \brief OpenGL (ES) utilities
42  *//*--------------------------------------------------------------------*/
43 namespace glu
44 {
45 
46 class RenderContext;
47 
48 class Error : public tcu::TestError
49 {
50 public:
51 					Error				(int error, const char* message, const char* expr, const char* file, int line);
52 					Error				(int error, const std::string& message);
53 	virtual			~Error				(void) throw();
54 
getError(void) const55 	int				getError			(void) const { return m_error; }
56 
57 private:
58 	int				m_error;
59 };
60 
61 class OutOfMemoryError : public tcu::ResourceError
62 {
63 public:
64 					OutOfMemoryError	(const char* message, const char* expr, const char* file, int line);
65 					OutOfMemoryError	(const std::string& message);
66 	virtual			~OutOfMemoryError	(void) throw();
67 };
68 
69 void checkError (deUint32 err, const char* msg, const char* file, int line);
70 void checkError (const RenderContext& context, const char* msg, const char* file, int line);
71 
72 } // glu
73 
74 #endif // _GLUDEFS_HPP
75