Tizen 2.1 base
[platform/upstream/libbullet.git] / Extras / CUDA / cutil_gl_error.h
1 /*
2 * Copyright 1993-2006 NVIDIA Corporation.  All rights reserved.
3 *
4 * NOTICE TO USER:   
5 *
6 * This source code is subject to NVIDIA ownership rights under U.S. and 
7 * international Copyright laws.  
8 *
9 * NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE 
10 * CODE FOR ANY PURPOSE.  IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR 
11 * IMPLIED WARRANTY OF ANY KIND.  NVIDIA DISCLAIMS ALL WARRANTIES WITH 
12 * REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF 
13 * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.   
14 * IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, 
15 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 
16 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 
17 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE 
18 * OR PERFORMANCE OF THIS SOURCE CODE.  
19 *
20 * U.S. Government End Users.  This source code is a "commercial item" as 
21 * that term is defined at 48 C.F.R. 2.101 (OCT 1995), consisting  of 
22 * "commercial computer software" and "commercial computer software 
23 * documentation" as such terms are used in 48 C.F.R. 12.212 (SEPT 1995) 
24 * and is provided to the U.S. Government only as a commercial end item.  
25 * Consistent with 48 C.F.R.12.212 and 48 C.F.R. 227.7202-1 through 
26 * 227.7202-4 (JUNE 1995), all U.S. Government End Users acquire the 
27 * source code with only those rights set forth herein.
28 */
29
30 #ifndef CUTIL_GL_ERROR
31 #define CUTIL_GL_ERROR
32
33 /* CUda UTility Library */
34
35 // includes, system
36 #ifdef _WIN32
37 #  define WINDOWS_LEAN_AND_MEAN
38 #  include <windows.h>
39 #  include <stdlib.h>
40 #  undef min
41 #  undef max
42 #endif
43
44 // includes, graphics
45 #if defined (__APPLE__) || defined(MACOSX)
46 #include <OpenGL/gl.h>
47 #include <OpenGL/glu.h>
48 #else
49 #include <GL/gl.h>
50 #include <GL/glu.h>
51 #endif
52
53 ////////////////////////////////////////////////////////////////////////////
54 //! Check for OpenGL error
55 //! @return CUTTrue if no GL error has been encountered, otherwise 0
56 //! @param file  __FILE__ macro
57 //! @param line  __LINE__ macro
58 //! @note The GL error is listed on stderr
59 //! @note This function should be used via the CHECK_ERROR_GL() macro
60 ////////////////////////////////////////////////////////////////////////////
61 CUTBoolean CUTIL_API
62 cutCheckErrorGL( const char* file, const int line) 
63 {
64         CUTBoolean ret_val = CUTTrue;
65
66         // check for error
67         GLenum gl_error = glGetError();
68         if (gl_error != GL_NO_ERROR) 
69         {
70                 fprintf(stderr, "GL Error in file '%s' in line %d :\n", file, line);
71                 fprintf(stderr, "%s\n", gluErrorString(gl_error));
72                 ret_val = CUTFalse;
73         }
74         return ret_val;
75 }
76
77 #ifdef _DEBUG
78
79 #define CUT_CHECK_ERROR_GL()                                               \
80         if( CUTFalse == cutCheckErrorGL( __FILE__, __LINE__)) {                  \
81         exit(EXIT_FAILURE);                                                  \
82         }
83
84 #endif // _DEBUG
85
86 #endif // CUTIL_GL_ERROR