glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo1);
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
glBindTexture( GL_TEXTURE_2D, tex1 );
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo1);
//--------------codes for timing---------------------------------------start
GLuint query;
glGenQueries(1, &query);
glBeginQuery(GL_TIME_ELAPSED,query);
//---------------------------------------------------------------------end
glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0,tex1_width,tex1_height,GL_RED_INTEGER,GL_UNSIGNED_INT,0); //where the data transfer occurs
DrawSomePoints();
//-----------codes for timing--------------------------------------------start
glEndQuery(GL_TIME_ELAPSED);
GLuint elapsed_time;
glGetQueryObjectuiv(query, GL_QUERY_RESULT, &elapsed_time);
glDeleteQueries(1, &query);
float time_ms = elapsed_time/1000000.0f;
LogTime( time_ms ); //write time_ms to a log file.
//-----------------------------------------------------------------------end
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
Render();
//remap the buffer
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo1);
glBufferData(GL_PIXEL_UNPACK_BUFFER, buffersize, 0, GL_STREAM_DRAW);
pBufferData = (byte*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER,GL_WRITE_ONLY);
//pBufferData is a global variable, it will be refilled in another thread which focus on I/O.
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);