1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
5 * Copyright (C) 2011 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 * GLvertexformat no-op functions. Used in out-of-memory situations.
29 */
30
31 #ifdef _WIN32
32 #define NOGDI
33 #endif
34
35 #include "main/glheader.h"
36 #include "main/context.h"
37 #include "main/dispatch.h"
38 #include "main/dlist.h"
39 #include "main/eval.h"
40 #include "vbo/vbo_noop.h"
41 #include "vbo_attrib.h"
42
43 static void GLAPIENTRY
_mesa_noop_Materialfv(GLenum face,GLenum pname,const GLfloat * params)44 _mesa_noop_Materialfv(GLenum face, GLenum pname, const GLfloat * params)
45 {
46 }
47
48 static void GLAPIENTRY
_mesa_noop_EvalCoord1f(GLfloat a)49 _mesa_noop_EvalCoord1f(GLfloat a)
50 {
51 }
52
53 static void GLAPIENTRY
_mesa_noop_EvalCoord1fv(const GLfloat * v)54 _mesa_noop_EvalCoord1fv(const GLfloat * v)
55 {
56 }
57
58 static void GLAPIENTRY
_mesa_noop_EvalCoord2f(GLfloat a,GLfloat b)59 _mesa_noop_EvalCoord2f(GLfloat a, GLfloat b)
60 {
61 }
62
63 static void GLAPIENTRY
_mesa_noop_EvalCoord2fv(const GLfloat * v)64 _mesa_noop_EvalCoord2fv(const GLfloat * v)
65 {
66 }
67
68 static void GLAPIENTRY
_mesa_noop_EvalPoint1(GLint a)69 _mesa_noop_EvalPoint1(GLint a)
70 {
71 }
72
73 static void GLAPIENTRY
_mesa_noop_EvalPoint2(GLint a,GLint b)74 _mesa_noop_EvalPoint2(GLint a, GLint b)
75 {
76 }
77
78 static void GLAPIENTRY
_mesa_noop_ArrayElement(GLint elem)79 _mesa_noop_ArrayElement(GLint elem)
80 {
81 }
82
83
84 static void GLAPIENTRY
_mesa_noop_Begin(GLenum mode)85 _mesa_noop_Begin(GLenum mode)
86 {
87 }
88
89 static void GLAPIENTRY
_mesa_noop_End(void)90 _mesa_noop_End(void)
91 {
92 }
93
94 static void GLAPIENTRY
_mesa_noop_PrimitiveRestartNV(void)95 _mesa_noop_PrimitiveRestartNV(void)
96 {
97 }
98
99 /**
100 * If index=0, does glVertexAttrib*() alias glVertex() to emit a vertex?
101 * It depends on a few things, including whether we're inside or outside
102 * of glBegin/glEnd.
103 */
104 static inline bool
is_vertex_position(const struct gl_context * ctx,GLuint index)105 is_vertex_position(const struct gl_context *ctx, GLuint index)
106 {
107 return false; /* it doesn't matter for noop */
108 }
109
110 #define ATTR_UNION(A, N, T, C, V0, V1, V2, V3) do { (void)ctx; (void)(A); } while(0)
111 #define ERROR(err) _mesa_error(ctx, err, __func__)
112 #define TAG(x) _mesa_noop_##x
113
114 #include "vbo_attrib_tmp.h"
115
116
117 /**
118 * Build a vertexformat of functions that are no-ops.
119 * These are used in out-of-memory situations when we have no VBO
120 * to put the vertex data into.
121 */
122 void
_mesa_noop_vtxfmt_init(struct gl_context * ctx,GLvertexformat * vfmt)123 _mesa_noop_vtxfmt_init(struct gl_context *ctx, GLvertexformat * vfmt)
124 {
125 #define NAME_AE(x) _mesa_noop_##x
126 #define NAME_CALLLIST(x) _mesa_##x
127 #define NAME(x) _mesa_noop_##x
128 #define NAME_ES(x) _mesa_noop_##x##ARB
129
130 #include "vbo_init_tmp.h"
131 }
132
133
134 /**
135 * Is the given dispatch table using the no-op functions?
136 */
137 GLboolean
_mesa_using_noop_vtxfmt(const struct _glapi_table * dispatch)138 _mesa_using_noop_vtxfmt(const struct _glapi_table *dispatch)
139 {
140 return GET_Begin((struct _glapi_table *) dispatch) == _mesa_noop_Begin;
141 }
142