xref: /aosp_15_r20/external/deqp/framework/opengl/gluDefs.hpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
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)  \
34     do                                   \
35     {                                    \
36         CALL;                            \
37         GLU_EXPECT_NO_ERROR(ERR, #CALL); \
38     } while (false)
39 #define GLU_CHECK_CALL(CALL)                      \
40     do                                            \
41     {                                             \
42         CALL;                                     \
43         GLU_EXPECT_NO_ERROR(glGetError(), #CALL); \
44     } while (false)
45 
46 #define GLU_CHECK_GLW_MSG(GL, MSG) GLU_EXPECT_NO_ERROR((GL).getError(), MSG)
47 #define GLU_CHECK_GLW(GL) GLU_CHECK_GLW_MSG(GL, DE_NULL)
48 #define GLU_CHECK_GLW_CALL(GL, CALL)                 \
49     do                                               \
50     {                                                \
51         (GL).CALL;                                   \
52         GLU_EXPECT_NO_ERROR((GL).getError(), #CALL); \
53     } while (false)
54 
55 /*--------------------------------------------------------------------*//*!
56  * \brief OpenGL (ES) utilities
57  *//*--------------------------------------------------------------------*/
58 namespace glu
59 {
60 
BufferOffsetAsPointer(uintptr_t byteOffset)61 DE_INLINE void *BufferOffsetAsPointer(uintptr_t byteOffset)
62 {
63     return reinterpret_cast<void *>(byteOffset);
64 }
65 
66 class RenderContext;
67 
68 class Error : public tcu::TestError
69 {
70 public:
71     Error(int error, const char *message, const char *expr, const char *file, int line);
72     Error(int error, const std::string &message);
73     virtual ~Error(void) throw();
74 
getError(void) const75     int getError(void) const
76     {
77         return m_error;
78     }
79 
80 private:
81     int m_error;
82 };
83 
84 class OutOfMemoryError : public tcu::ResourceError
85 {
86 public:
87     OutOfMemoryError(const char *message, const char *expr, const char *file, int line);
88     OutOfMemoryError(const std::string &message);
89     virtual ~OutOfMemoryError(void) throw();
90 };
91 
92 void checkError(uint32_t err, const char *msg, const char *file, int line);
93 void checkError(const RenderContext &context, const char *msg, const char *file, int line);
94 
95 } // namespace glu
96 
97 #endif // _GLUDEFS_HPP
98