OSDN Git Service

mesa: Unifdef _WIN32_WCE.
[android-x86/external-mesa.git] / src / mapi / glapi / glapi_nop.c
1 /*
2  * Mesa 3-D graphics library
3  *
4  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
5  * Copyright (C) 2010  VMware, Inc.  All Rights Reserved.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation
10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11  * and/or sell copies of the Software, and to permit persons to whom the
12  * Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23  * OTHER DEALINGS IN THE SOFTWARE.
24  */
25
26
27 /**
28  * No-op dispatch table.
29  *
30  * This file defines a special dispatch table which is loaded with no-op
31  * functions.
32  *
33  * When there's no current rendering context, calling a GL function like
34  * glBegin() is a no-op.  Apps should never normally do this.  So as a
35  * debugging aid, each of the no-op functions will emit a warning to
36  * stderr if the MESA_DEBUG or LIBGL_DEBUG env var is set.
37  */
38
39
40
41 #include "glapi/glapi_priv.h"
42
43
44 void
45 _glapi_noop_enable_warnings(unsigned char enable)
46 {
47 }
48
49 void
50 _glapi_set_warning_func(_glapi_proc func)
51 {
52 }
53
54 /*
55  * When GLAPIENTRY is __stdcall (i.e. Windows), the stack is popped by the
56  * callee making the number/type of arguments significant.
57  */
58 #if defined(_WIN32) || defined(DEBUG)
59
60 /**
61  * Called by each of the no-op GL entrypoints.
62  */
63 static int
64 Warn(const char *func)
65 {
66 #if defined(DEBUG)
67    if (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) {
68       fprintf(stderr, "GL User Error: gl%s called without a rendering context\n",
69               func);
70    }
71 #endif
72    return 0;
73 }
74
75
76 /**
77  * This is called if the user somehow calls an unassigned GL dispatch function.
78  */
79 static GLint
80 NoOpUnused(void)
81 {
82    return Warn(" function");
83 }
84
85 /*
86  * Defines for the glapitemp.h functions.
87  */
88 #define KEYWORD1 static
89 #define KEYWORD1_ALT static
90 #define KEYWORD2 GLAPIENTRY
91 #define NAME(func)  NoOp##func
92 #define DISPATCH(func, args, msg)  Warn(#func);
93 #define RETURN_DISPATCH(func, args, msg)  Warn(#func); return 0
94
95
96 /*
97  * Defines for the table of no-op entry points.
98  */
99 #define TABLE_ENTRY(name) (_glapi_proc) NoOp##name
100
101 #else
102
103 static int
104 NoOpGeneric(void)
105 {
106    if (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) {
107       fprintf(stderr, "GL User Error: calling GL function without a rendering context\n");
108    }
109    return 0;
110 }
111
112 #define TABLE_ENTRY(name) (_glapi_proc) NoOpGeneric
113
114 #endif
115
116 #define DISPATCH_TABLE_NAME __glapi_noop_table
117 #define UNUSED_TABLE_NAME __unused_noop_functions
118
119 #include "glapi/glapitemp.h"