Skip to content

Commit 1983e88

Browse files
committed
Update callback API example.
Update API document.
1 parent dfe9d7b commit 1983e88

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

examples/callback_api/main.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void index_cb(void *user_data, tinyobj::index_t *indices, int num_indices) {
6262
// index).
6363
// Also, the first index starts with 1, not 0.
6464
// See fixIndex() function in tiny_obj_loader.h for details.
65-
// Also, -2147483648(0x80000000 = -INT_MAX) is set for the index value which
65+
// Also, 0 is set for the index value which
6666
// does not exist in .obj
6767
MyMesh *mesh = reinterpret_cast<MyMesh *>(user_data);
6868

@@ -71,13 +71,13 @@ void index_cb(void *user_data, tinyobj::index_t *indices, int num_indices) {
7171
printf("idx[%ld] = %d, %d, %d\n", mesh->v_indices.size(), idx.vertex_index,
7272
idx.normal_index, idx.texcoord_index);
7373

74-
if (idx.vertex_index != 0x80000000) {
74+
if (idx.vertex_index != 0) {
7575
mesh->v_indices.push_back(idx.vertex_index);
7676
}
77-
if (idx.normal_index != 0x80000000) {
77+
if (idx.normal_index != 0) {
7878
mesh->vn_indices.push_back(idx.normal_index);
7979
}
80-
if (idx.texcoord_index != 0x80000000) {
80+
if (idx.texcoord_index != 0) {
8181
mesh->vt_indices.push_back(idx.texcoord_index);
8282
}
8383
}
@@ -143,7 +143,7 @@ int main(int argc, char **argv) {
143143

144144
tinyobj::MaterialFileReader mtlReader("../../models/");
145145

146-
bool ret = tinyobj::LoadObjWithCallback(&mesh, cb, &err, &ifs, &mtlReader);
146+
bool ret = tinyobj::LoadObjWithCallback(ifs, cb, &mesh, &mtlReader, &err);
147147

148148
if (!err.empty()) {
149149
std::cerr << err << std::endl;

tiny_obj_loader.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ typedef struct callback_t_ {
156156

157157
// called per 'f' line. num_indices is the number of face indices(e.g. 3 for
158158
// triangle, 4 for quad)
159-
// -2147483648(-INT_MAX) will be passed for undefined index in index_t
160-
// members.
159+
// 0 will be passed for undefined index in index_t members.
161160
void (*index_cb)(void *user_data, index_t *indices, int num_indices);
162161
// `name` material name, `material_id` = the array index of material_t[]. -1
163162
// if

0 commit comments

Comments
 (0)