61
63
} GPUBufferMaterial;
63
65
/* meshes are split up by material since changing materials requires
64
GL state changes that can't occur in the middle of drawing an
67
some simplifying assumptions are made:
68
* all quads are treated as two triangles.
69
* no vertex sharing is used; each triangle gets its own copy of the
70
vertices it uses (this makes it easy to deal with a vertex used
71
by faces with different properties, such as smooth/solid shading,
72
different MCols, etc.)
74
to avoid confusion between the original MVert vertices and the
75
arrays of OpenGL vertices, the latter are referred to here and in
76
the source as `points'. similarly, the OpenGL triangles generated
77
for MFaces are referred to as triangles rather than faces.
66
* GL state changes that can't occur in the middle of drawing an
69
* some simplifying assumptions are made:
70
* - all quads are treated as two triangles.
71
* - no vertex sharing is used; each triangle gets its own copy of the
72
* vertices it uses (this makes it easy to deal with a vertex used
73
* by faces with different properties, such as smooth/solid shading,
74
* different MCols, etc.)
76
* to avoid confusion between the original MVert vertices and the
77
* arrays of OpenGL vertices, the latter are referred to here and in
78
* the source as `points'. similarly, the OpenGL triangles generated
79
* for MFaces are referred to as triangles rather than faces.
79
81
typedef struct GPUDrawObject {
122
124
GPUBuffer *GPU_buffer_alloc(int size);
123
125
void GPU_buffer_free(GPUBuffer *buffer);
125
GPUDrawObject *GPU_drawobject_new( struct DerivedMesh *dm );
126
void GPU_drawobject_free( struct DerivedMesh *dm );
127
GPUDrawObject *GPU_drawobject_new(struct DerivedMesh *dm );
128
void GPU_drawobject_free(struct DerivedMesh *dm );
128
130
/* called before drawing */
129
void GPU_vertex_setup( struct DerivedMesh *dm );
130
void GPU_normal_setup( struct DerivedMesh *dm );
131
void GPU_uv_setup( struct DerivedMesh *dm );
132
void GPU_color_setup( struct DerivedMesh *dm );
133
void GPU_edge_setup( struct DerivedMesh *dm ); /* does not mix with other data */
134
void GPU_uvedge_setup( struct DerivedMesh *dm );
135
void GPU_interleaved_setup( GPUBuffer *buffer, int data[] );
131
void GPU_vertex_setup(struct DerivedMesh *dm );
132
void GPU_normal_setup(struct DerivedMesh *dm );
133
void GPU_uv_setup(struct DerivedMesh *dm );
134
void GPU_color_setup(struct DerivedMesh *dm );
135
void GPU_edge_setup(struct DerivedMesh *dm ); /* does not mix with other data */
136
void GPU_uvedge_setup(struct DerivedMesh *dm );
136
137
int GPU_attrib_element_size( GPUAttrib data[], int numdata );
137
138
void GPU_interleaved_attrib_setup( GPUBuffer *buffer, GPUAttrib data[], int numdata );
142
143
void GPU_buffer_unlock( GPUBuffer *buffer );
144
145
/* upload three unsigned chars, representing RGB colors, for each vertex. Resets dm->drawObject->colType to -1 */
145
void GPU_color3_upload( struct DerivedMesh *dm, unsigned char *data );
146
/* upload four unsigned chars, representing RGBA colors, for each vertex. Resets dm->drawObject->colType to -1 */
147
void GPU_color4_upload( struct DerivedMesh *dm, unsigned char *data );
146
void GPU_color3_upload(struct DerivedMesh *dm, unsigned char *data );
148
147
/* switch color rendering on=1/off=0 */
149
148
void GPU_color_switch( int mode );
155
154
void GPU_buffer_unbind(void);
157
156
/* used to check whether to use the old (without buffers) code */
158
int GPU_buffer_legacy( struct DerivedMesh *dm );
157
int GPU_buffer_legacy(struct DerivedMesh *dm );
160
159
/* Buffers for non-DerivedMesh drawing */
161
160
typedef struct GPU_Buffers GPU_Buffers;
162
GPU_Buffers *GPU_build_mesh_buffers(struct GHash *map, struct MVert *mvert,
163
struct MFace *mface, int *face_indices,
164
int totface, int *vert_indices, int uniq_verts,
162
GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4],
163
struct MFace *mface, struct MVert *mvert,
164
int *face_indices, int totface);
166
166
void GPU_update_mesh_buffers(GPU_Buffers *buffers, struct MVert *mvert,
167
167
int *vert_indices, int totvert);
168
GPU_Buffers *GPU_build_grid_buffers(struct DMGridData **grids,
169
int *grid_indices, int totgrid, int gridsize);
169
GPU_Buffers *GPU_build_grid_buffers(int *grid_indices, int totgrid,
170
unsigned int **grid_hidden, int gridsize);
170
172
void GPU_update_grid_buffers(GPU_Buffers *buffers, struct DMGridData **grids,
171
int *grid_indices, int totgrid, int gridsize, int smooth);
172
void GPU_draw_buffers(GPU_Buffers *buffers);
173
const struct DMFlagMat *grid_flag_mats,
174
int *grid_indices, int totgrid, int gridsize);
176
void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial);
173
178
void GPU_free_buffers(GPU_Buffers *buffers);