vbo.h revision 4a49301e
17117f1b4Smrg/*
27117f1b4Smrg * mesa 3-D graphics library
37117f1b4Smrg * Version:  6.5
47117f1b4Smrg *
57117f1b4Smrg * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
67117f1b4Smrg *
77117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a
87117f1b4Smrg * copy of this software and associated documentation files (the "Software"),
97117f1b4Smrg * to deal in the Software without restriction, including without limitation
107117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
117117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the
127117f1b4Smrg * Software is furnished to do so, subject to the following conditions:
137117f1b4Smrg *
147117f1b4Smrg * The above copyright notice and this permission notice shall be included
157117f1b4Smrg * in all copies or substantial portions of the Software.
167117f1b4Smrg *
177117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
187117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
197117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
207117f1b4Smrg * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
217117f1b4Smrg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
227117f1b4Smrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
237117f1b4Smrg */
247117f1b4Smrg
257117f1b4Smrg/**
267117f1b4Smrg * \file vbo_context.h
277117f1b4Smrg * \brief VBO builder module datatypes and definitions.
287117f1b4Smrg * \author Keith Whitwell
297117f1b4Smrg */
307117f1b4Smrg
317117f1b4Smrg
327117f1b4Smrg#ifndef _VBO_H
337117f1b4Smrg#define _VBO_H
347117f1b4Smrg
35c1f859d4Smrg#include "main/mtypes.h"
367117f1b4Smrg
377117f1b4Smrgstruct _mesa_prim {
387117f1b4Smrg   GLuint mode:8;
397117f1b4Smrg   GLuint indexed:1;
407117f1b4Smrg   GLuint begin:1;
417117f1b4Smrg   GLuint end:1;
427117f1b4Smrg   GLuint weak:1;
437117f1b4Smrg   GLuint pad:20;
447117f1b4Smrg
457117f1b4Smrg   GLuint start;
467117f1b4Smrg   GLuint count;
474a49301eSmrg   GLint basevertex;
487117f1b4Smrg};
497117f1b4Smrg
507117f1b4Smrg/* Would like to call this a "vbo_index_buffer", but this would be
517117f1b4Smrg * confusing as the indices are not neccessarily yet in a non-null
527117f1b4Smrg * buffer object.
537117f1b4Smrg */
547117f1b4Smrgstruct _mesa_index_buffer {
557117f1b4Smrg   GLuint count;
567117f1b4Smrg   GLenum type;
577117f1b4Smrg   struct gl_buffer_object *obj;
587117f1b4Smrg   const void *ptr;
597117f1b4Smrg};
607117f1b4Smrg
617117f1b4Smrg
627117f1b4Smrg
637117f1b4SmrgGLboolean _vbo_CreateContext( GLcontext *ctx );
647117f1b4Smrgvoid _vbo_DestroyContext( GLcontext *ctx );
657117f1b4Smrgvoid _vbo_InvalidateState( GLcontext *ctx, GLuint new_state );
667117f1b4Smrg
677117f1b4Smrg
687117f1b4Smrgtypedef void (*vbo_draw_func)( GLcontext *ctx,
697117f1b4Smrg			       const struct gl_client_array **arrays,
707117f1b4Smrg			       const struct _mesa_prim *prims,
717117f1b4Smrg			       GLuint nr_prims,
727117f1b4Smrg			       const struct _mesa_index_buffer *ib,
734a49301eSmrg			       GLboolean index_bounds_valid,
747117f1b4Smrg			       GLuint min_index,
757117f1b4Smrg			       GLuint max_index );
767117f1b4Smrg
777117f1b4Smrg
787117f1b4Smrg
797117f1b4Smrg
807117f1b4Smrg/* Utility function to cope with various constraints on tnl modules or
817117f1b4Smrg * hardware.  This can be used to split an incoming set of arrays and
827117f1b4Smrg * primitives against the following constraints:
837117f1b4Smrg *    - Maximum number of indices in index buffer.
847117f1b4Smrg *    - Maximum number of vertices referenced by index buffer.
857117f1b4Smrg *    - Maximum hardware vertex buffer size.
867117f1b4Smrg */
877117f1b4Smrgstruct split_limits {
887117f1b4Smrg   GLuint max_verts;
897117f1b4Smrg   GLuint max_indices;
907117f1b4Smrg   GLuint max_vb_size;		/* bytes */
917117f1b4Smrg};
927117f1b4Smrg
937117f1b4Smrg
947117f1b4Smrgvoid vbo_split_prims( GLcontext *ctx,
957117f1b4Smrg		      const struct gl_client_array *arrays[],
967117f1b4Smrg		      const struct _mesa_prim *prim,
977117f1b4Smrg		      GLuint nr_prims,
987117f1b4Smrg		      const struct _mesa_index_buffer *ib,
997117f1b4Smrg		      GLuint min_index,
1007117f1b4Smrg		      GLuint max_index,
1017117f1b4Smrg		      vbo_draw_func draw,
1027117f1b4Smrg		      const struct split_limits *limits );
1037117f1b4Smrg
1047117f1b4Smrg
1057117f1b4Smrg/* Helpers for dealing translating away non-zero min_index.
1067117f1b4Smrg */
1077117f1b4SmrgGLboolean vbo_all_varyings_in_vbos( const struct gl_client_array *arrays[] );
1087117f1b4Smrg
1097117f1b4Smrgvoid vbo_rebase_prims( GLcontext *ctx,
1107117f1b4Smrg		       const struct gl_client_array *arrays[],
1117117f1b4Smrg		       const struct _mesa_prim *prim,
1127117f1b4Smrg		       GLuint nr_prims,
1137117f1b4Smrg		       const struct _mesa_index_buffer *ib,
1147117f1b4Smrg		       GLuint min_index,
1157117f1b4Smrg		       GLuint max_index,
1167117f1b4Smrg		       vbo_draw_func draw );
1174a49301eSmrgvoid
1184a49301eSmrgvbo_get_minmax_index(GLcontext *ctx, const struct _mesa_prim *prim,
1194a49301eSmrg		     const struct _mesa_index_buffer *ib,
1204a49301eSmrg		     GLuint *min_index, GLuint *max_index);
1217117f1b4Smrg
122c1f859d4Smrgvoid vbo_use_buffer_objects(GLcontext *ctx);
123c1f859d4Smrg
124c1f859d4Smrg
1254a49301eSmrgvoid vbo_set_draw_func(GLcontext *ctx, vbo_draw_func func);
1264a49301eSmrg
1274a49301eSmrg
1284a49301eSmrgvoid GLAPIENTRY
1294a49301eSmrg_vbo_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
1304a49301eSmrg
1314a49301eSmrgvoid GLAPIENTRY
1324a49301eSmrg_vbo_Normal3f(GLfloat x, GLfloat y, GLfloat z);
1334a49301eSmrg
1344a49301eSmrgvoid GLAPIENTRY
1354a49301eSmrg_vbo_MultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
1364a49301eSmrg
1374a49301eSmrgvoid GLAPIENTRY
1384a49301eSmrg_vbo_Materialfv(GLenum face, GLenum pname, const GLfloat *params);
1394a49301eSmrg
1404a49301eSmrgvoid GLAPIENTRY
1414a49301eSmrg_vbo_VertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
1424a49301eSmrg
1437117f1b4Smrg#endif
144