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
BufferOffsetAsPointer(uintptr_t byteOffset)46 DE_INLINE void* BufferOffsetAsPointer (uintptr_t byteOffset)
47 {
48 return reinterpret_cast<void*>(byteOffset);
49 }
50
51 class RenderContext;
52
53 class Error : public tcu::TestError
54 {
55 public:
56 Error (int error, const char* message, const char* expr, const char* file, int line);
57 Error (int error, const std::string& message);
58 virtual ~Error (void) throw();
59
getError(void) const60 int getError (void) const { return m_error; }
61
62 private:
63 int m_error;
64 };
65
66 class OutOfMemoryError : public tcu::ResourceError
67 {
68 public:
69 OutOfMemoryError (const char* message, const char* expr, const char* file, int line);
70 OutOfMemoryError (const std::string& message);
71 virtual ~OutOfMemoryError (void) throw();
72 };
73
74 void checkError (deUint32 err, const char* msg, const char* file, int line);
75 void checkError (const RenderContext& context, const char* msg, const char* file, int line);
76
77 } // glu
78
79 #endif // _GLUDEFS_HPP
80