-
Notifications
You must be signed in to change notification settings - Fork 5
/
IndexBuffer.h
31 lines (28 loc) · 882 Bytes
/
IndexBuffer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#pragma once
#include "client.h"
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
typedef unsigned short IndexBufferType;
#define INDEX_BUFFER_GL_TYPE GL_UNSIGNED_SHORT
#else
typedef unsigned int IndexBufferType;
#define INDEX_BUFFER_GL_TYPE GL_UNSIGNED_INT
#endif
class IndexBuffer {
public:
IndexBufferType *buf; // 16bit for ES, 32bit for normal
int array_len; // max len
int render_len; // actually used len
GLuint gl_name;
IndexBuffer() : buf(0), array_len(0), render_len(0), gl_name(0) {}
~IndexBuffer();
void reserve(int l );
void setIndex( int index_at, IndexBufferType ind );
IndexBufferType getIndex( int index_at );
void set( IndexBufferType *in, int l );
void setRenderLen(int l);
void bless();
void unbless();
void rebless() { unbless(); bless(); }
void dump(int lim);
void copyFromBuffer( IndexBufferType *buf, int ind_cnt );
};