📄 bnch_msh.c
字号:
/*............................ BNCH_MSH.C ............... 2-15-96 ..........*/
/* This routine benchmarks VSA_SHADED_TRIANGLE and VSA_TRIANGLE_FILL */
/*..........................................................................*/
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<math.h>
#include<time.h>
#include<vsa.h>
#include<vsa_font.h>
#include<my_tools.h>
extern unsigned _stklen = 20000; /* This is for Borland C Only ! */
void main()
{
char atext[100];
int points[4000],m,n,mm,nn,vmode;
unsigned i,j,k,p,dx,dy,x,y,repeat;
clock_t delta,clk;
float timer,pixels,triangles,fa,fb;
printf("Input video mode: ");
scanf("%x",&vmode);
vsa_init(vmode);
special_lut();
color_bar(100,305);
vsa_set_triangle_clip_mode(0);
ZIPPY:
dx = 3;
dy = 3;
m=n= 32;
repeat = 6;
for(p=0;p<3;p++)
{
mm=nn=m+1;
for(j=0;j<nn;j++)
for(i=0;i<mm;i++)
{
fa = sin(3.14*i/mm);
fb = sin(3.14*j/nn);
points[j*mm+i] = 223*fa*fa*fb*fb;
}
pixels = (float)dx*(float)dy*(float)m*(float)n*(float)repeat;
triangles = 2*m*n*repeat;
clk = clock();
for(k=0;k<repeat;k++)
{
vsa_set_color(64+k*32);
for(j=0;j<n;j++)
for(i=0;i<m;i++)
{
x = i*dx+50;
y = j*dy+50;
vsa_triangle_fill(x,y,x+dx,y,x,y+dy);
vsa_triangle_fill(x+dx,y,x,y+dy,x+dx,y+dy);
}
}
delta = clock() - clk;
timer = ((float)(delta))/((float)CLOCKS_PER_SEC);
vsa_move_to(0,0);
vsa_set_color(0);
vsa_rect_fill(350,35);
if(timer == 0.0)
timer = 0.00001;
sprintf(atext,"Drawing Rate = %f pixels/sec\n",pixels/timer);
vsa_write_string(5,5,253,atext);
sprintf(atext," %f triangles/sec\n",triangles/timer);
vsa_write_string(5,20,253,atext);
if(getch() == 27)
goto BAIL;
clk = clock();
for(k=0;k<repeat;k++)
{
for(j=0;j<n;j++)
for(i=0;i<m;i++)
{
x = i*dx+50;
y = j*dy+50;
vsa_shaded_triangle(x,y,points[j*mm+i]+k*16,
x+dx,y,points[j*mm+i+1]+k*16,
x,y+dy,points[j*mm+i+mm]+k*16);
vsa_shaded_triangle(x+dx,y,points[j*mm+i+1]+k*16,
x,y+dy,points[j*mm+i+mm]+k*16,
x+dx,y+dy,points[j*mm+i+1+mm]+k*16);
}
}
delta = clock() - clk;
timer = ((float)(delta))/((float)CLOCKS_PER_SEC);
vsa_move_to(0,0);
vsa_set_color(0);
vsa_rect_fill(350,35);
if(timer == 0.0)
timer = 0.00001;
sprintf(atext,"Drawing Rate = %f pixels/sec\n",pixels/timer);
vsa_write_string(5,5,253,atext);
sprintf(atext," %f triangles/sec\n",triangles/timer);
vsa_write_string(5,20,253,atext);
if(getch() == 27)
goto BAIL;
dx *= 10;
dy *= 10;
m /= 4;
n /= 4;
repeat ++;
}
goto ZIPPY;
BAIL:
vsa_init(0x3);
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -