From b478785d8960987bd294285fc3d15525f0834d1f Mon Sep 17 00:00:00 2001 From: diego Date: Tue, 20 Mar 2007 01:06:51 +0000 Subject: Move gltest and bmovl-test into the main TOOLS directory, subdirectories for single files are silly. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22755 b3059339-0415-0410-9bf9-f77b7e298cf2 --- TOOLS/gltest.c | 189 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 TOOLS/gltest.c (limited to 'TOOLS/gltest.c') diff --git a/TOOLS/gltest.c b/TOOLS/gltest.c new file mode 100644 index 0000000000..e8c6d33146 --- /dev/null +++ b/TOOLS/gltest.c @@ -0,0 +1,189 @@ +// 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