0a5b7054005db24010691b7a0579d6d947c02567
[mesa.git] / src / mesa / vbo / vbo_save.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.3
4 *
5 * Copyright (C) 1999-2005 Brian Paul 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 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Keith Whitwell <keith@tungstengraphics.com>
26 */
27
28
29 #include "mtypes.h"
30 #include "dlist.h"
31 #include "vtxfmt.h"
32 #include "imports.h"
33
34 #include "vbo_context.h"
35
36
37
38 void vbo_save_init( GLcontext *ctx )
39 {
40 struct vbo_save_context *save = &vbo_context(ctx)->save;
41
42 save->ctx = ctx;
43
44 vbo_save_api_init( save );
45 vbo_save_wakeup(ctx);
46
47 ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
48 }
49
50
51 void vbo_save_destroy( GLcontext *ctx )
52 {
53 }
54
55
56
57
58 /* Note that this can occur during the playback of a display list:
59 */
60 void vbo_save_fallback( GLcontext *ctx, GLboolean fallback )
61 {
62 struct vbo_save_context *save = &vbo_context(ctx)->save;
63
64 if (fallback)
65 save->replay_flags |= VBO_SAVE_FALLBACK;
66 else
67 save->replay_flags &= ~VBO_SAVE_FALLBACK;
68 }
69
70
71 /* I don't see any reason to swap this code out on fallbacks. It
72 * wouldn't really mean anything to do so anyway as the old lists are
73 * still around from pre-fallback. Instead, the above code ensures
74 * that vertices are routed back through immediate mode dispatch on
75 * fallback.
76 *
77 * The below can be moved into init or removed:
78 */
79 void vbo_save_wakeup( GLcontext *ctx )
80 {
81 ctx->Driver.NewList = vbo_save_NewList;
82 ctx->Driver.EndList = vbo_save_EndList;
83 ctx->Driver.SaveFlushVertices = vbo_save_SaveFlushVertices;
84 ctx->Driver.BeginCallList = vbo_save_BeginCallList;
85 ctx->Driver.EndCallList = vbo_save_EndCallList;
86 ctx->Driver.NotifySaveBegin = vbo_save_NotifyBegin;
87
88 /* Assume we haven't been getting state updates either:
89 */
90 vbo_save_invalidate_state( ctx, ~0 );
91 }
92
93
94