Fixed typo
[reactos.git] / dll / opengl / mesa / vbo / vbo_save.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 7.2
4 *
5 * Copyright (C) 1999-2008 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 #include <precomp.h>
29
30 #if FEATURE_dlist
31
32
33 static void vbo_save_callback_init( struct gl_context *ctx )
34 {
35 ctx->Driver.NewList = vbo_save_NewList;
36 ctx->Driver.EndList = vbo_save_EndList;
37 ctx->Driver.SaveFlushVertices = vbo_save_SaveFlushVertices;
38 ctx->Driver.BeginCallList = vbo_save_BeginCallList;
39 ctx->Driver.EndCallList = vbo_save_EndCallList;
40 ctx->Driver.NotifySaveBegin = vbo_save_NotifyBegin;
41 }
42
43
44
45 void vbo_save_init( struct gl_context *ctx )
46 {
47 struct vbo_context *vbo = vbo_context(ctx);
48 struct vbo_save_context *save = &vbo->save;
49
50 save->ctx = ctx;
51
52 vbo_save_api_init( save );
53 vbo_save_callback_init(ctx);
54
55 {
56 struct gl_client_array *arrays = save->arrays;
57 unsigned i;
58
59 memcpy(arrays, vbo->currval,
60 VBO_ATTRIB_MAX * sizeof(arrays[0]));
61 for (i = 0; i < VBO_ATTRIB_MAX; ++i) {
62 struct gl_client_array *array;
63 array = &arrays[i];
64 array->BufferObj = NULL;
65 _mesa_reference_buffer_object(ctx, &arrays->BufferObj,
66 vbo->currval[i].BufferObj);
67 }
68 }
69
70 ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
71 }
72
73
74 void vbo_save_destroy( struct gl_context *ctx )
75 {
76 struct vbo_context *vbo = vbo_context(ctx);
77 struct vbo_save_context *save = &vbo->save;
78 GLuint i;
79
80 if (save->prim_store) {
81 if ( --save->prim_store->refcount == 0 ) {
82 FREE( save->prim_store );
83 save->prim_store = NULL;
84 }
85 if ( --save->vertex_store->refcount == 0 ) {
86 _mesa_reference_buffer_object(ctx,
87 &save->vertex_store->bufferobj, NULL);
88 FREE( save->vertex_store );
89 save->vertex_store = NULL;
90 }
91 }
92
93 for (i = 0; i < VBO_ATTRIB_MAX; i++) {
94 _mesa_reference_buffer_object(ctx, &save->arrays[i].BufferObj, NULL);
95 }
96 }
97
98
99
100
101 /* Note that this can occur during the playback of a display list:
102 */
103 void vbo_save_fallback( struct gl_context *ctx, GLboolean fallback )
104 {
105 struct vbo_save_context *save = &vbo_context(ctx)->save;
106
107 if (fallback)
108 save->replay_flags |= VBO_SAVE_FALLBACK;
109 else
110 save->replay_flags &= ~VBO_SAVE_FALLBACK;
111 }
112
113
114 #endif /* FEATURE_dlist */