Skip to content

Commit

Permalink
G3D files could have too many vertices; split to per-frame
Browse files Browse the repository at this point in the history
  • Loading branch information
Will authored and Will committed Jan 20, 2012
1 parent 0b2b417 commit 535853b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions barebones/g3d.cpp
Expand Up @@ -102,6 +102,7 @@ g3d_t::mesh_t::mesh_t(g3d_t& g,binary_reader_t& in,char ver):
for(uint32_t f=0; f<frame_count; f++) {
glBindBuffer(GL_ARRAY_BUFFER,vn_vbo[f]);
glBufferData(GL_ARRAY_BUFFER,vertex_count*6*sizeof(GLfloat),vn_data+f*vertex_count*6,GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER,0);
glCheck();
}
const size_t texture_size = textures?tex_frame_count*vertex_count*2:0;
Expand All @@ -119,13 +120,14 @@ g3d_t::mesh_t::mesh_t(g3d_t& g,binary_reader_t& in,char ver):
for(uint32_t f=0; f<tex_frame_count; f++) {
glBindBuffer(GL_ARRAY_BUFFER,t_vbo[f]);
glBufferData(GL_ARRAY_BUFFER,vertex_count*2*sizeof(GLfloat),t_data+f*vertex_count*2,GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER,0);
glCheck();
}
i_data = new GLushort[index_count];
for(uint32_t i=0; i<index_count; i++) {
i_data[i] = in.uint32();
if(i_data[i] >= vertex_count)
data_error("index[" << i << "]=" << i_data[i] << " out of bounds (" << vertex_count << ')');
data_error("index[" << i << "]=" << i_data[i] << " out of bounds (" << vertex_count << ')');
}
glGenBuffers(1,&i_vbo);
glCheck();
Expand Down Expand Up @@ -225,7 +227,7 @@ void g3d_t::mesh_t::draw(float time,const glm::mat4& projection,const glm::mat4&
glDisableVertexAttribArray(attrib_tex);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,i_vbo);
std::cerr << "drawing " << g3d.filename << ':' << name << ' ' << __LINE__ << std::endl;
glDrawElements(GL_TRIANGLES,index_count,GL_UNSIGNED_SHORT,0);
glDrawElements(GL_TRIANGLES,index_count,GL_UNSIGNED_SHORT,(void*)(0));
std::cerr << "drawing " << g3d.filename << ':' << name << ' ' << __LINE__ << std::endl;
glCheck();
std::cerr << "drew " << g3d.filename << ':' << name << std::endl;
Expand Down

0 comments on commit 535853b

Please sign in to comment.