b1a718a5f0a5dfa89273092e6920d6a1736fd1b7
[mesa.git] / src / mesa / glapi / glapi_nop.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 7.8
4 *
5 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
6 * Copyright (C) 2010 VMWare, Inc. All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR 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 #ifdef HAVE_DIX_CONFIG_H
42 #include <dix-config.h>
43 #include "glapi/mesa.h"
44 #else
45 #include "main/compiler.h"
46 #include "main/glheader.h"
47 #endif
48
49 #include "glapi/glapi.h"
50
51 #ifdef DEBUG
52
53 /**
54 * Called by each of the no-op GL entrypoints.
55 */
56 static int
57 Warn(const char *func)
58 {
59 #if !defined(_WIN32_WCE)
60 if (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) {
61 fprintf(stderr, "GL User Error: gl%s called without a rendering context\n",
62 func);
63 }
64 #endif
65 return 0;
66 }
67
68
69 /**
70 * This is called if the user somehow calls an unassigned GL dispatch function.
71 */
72 static GLint
73 NoOpUnused(void)
74 {
75 return Warn(" function");
76 }
77
78 /*
79 * Defines for the glapitemp.h functions.
80 */
81 #define KEYWORD1 static
82 #define KEYWORD1_ALT static
83 #define KEYWORD2 GLAPIENTRY
84 #define NAME(func) NoOp##func
85 #define DISPATCH(func, args, msg) Warn(#func);
86 #define RETURN_DISPATCH(func, args, msg) Warn(#func); return 0
87
88
89 /*
90 * Defines for the table of no-op entry points.
91 */
92 #define TABLE_ENTRY(name) (_glapi_proc) NoOp##name
93
94 #else
95
96 static void
97 NoOpGeneric(void)
98 {
99 #if !defined(_WIN32_WCE)
100 if (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")) {
101 fprintf(stderr, "GL User Error: calling GL function without a rendering context\n");
102 }
103 #endif
104 }
105
106 #define TABLE_ENTRY(name) (_glapi_proc) NoOpGeneric
107
108 #endif
109
110 #define DISPATCH_TABLE_NAME __glapi_noop_table
111 #define UNUSED_TABLE_NAME __unused_noop_functions
112
113 #include "glapi/glapitemp.h"