// OpenGL glTexSubImage() test/benchmark prg (C) 2001. by A'rpi/ESP-team #include #include #include #include #include // pixel size: 3 or 4 #define BYTES_PP 3 // blit by lines (defined) or frames (not defined) #define FAST_BLIT static uint32_t image_width=720; // DVD size static uint32_t image_height=576; static uint32_t image_format; static uint32_t image_bpp; static uint32_t image_bytes; static uint32_t texture_width=512; static uint32_t texture_height=512; static unsigned char *ImageData=NULL; static GLvoid resize(int x,int y){ printf("Resize: %dx%d\n",x,y); glViewport( 0, 0, x, y ); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, image_width, image_height, 0, -1,1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } float akarmi=0; int counter=0; float gen_time=0; float up_time=0; float render_time=0; unsigned char sintable[4096]; extern float GetRelativeTime(); static void redraw(void) { // glClear(GL_COLOR_BUFFER_BIT); int x,y,i; unsigned char *d=ImageData; int dstride=BYTES_PP*image_width; GetRelativeTime(); // generate some image: for(y=0;y2.0){ printf("%8.3f fps (gen: %2d%% upload: %2d%% render: %2d%%)\n", (float)counter/total, (int)(100.0*gen_time/total), (int)(100.0*up_time/total), (int)(100.0*render_time/total) ); gen_time=up_time=render_time=0; counter=0; } } } static GLvoid IdleFunc(){ akarmi+=0.1; glutPostRedisplay(); } int main(int argc, char **argv) { int i; glutInit(&argc, argv); glutInitWindowSize(640, 480); glutInitDisplayMode(GLUT_DOUBLE); (void) glutCreateWindow("csg"); glutDisplayFunc(redraw); glutReshapeFunc(resize); glutIdleFunc(IdleFunc); texture_width=32; while(texture_width