📄 bnch_blt.c
字号:
/*........................... BENCH_BitBlt.C ................ 2-24-96 ......*/
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <math.h>
#include <limits.h>
#include <my_tools.h>
#include <vsa.h>
#include <vsa_font.h>
/*..... #include <graph.h> .....*/
extern unsigned _stklen = 10000; /* This is for Borland C Only ! */
void cube_3d(int,int);
float SIN_LUT[1024];
void main()
{
char text[100];
clock_t clk,delta;
unsigned mode,op[5]={0,1,2,3,6};
unsigned i,j,m[1000],n[1000],image_size,xx,yy,a,b,c,d,k,l;
unsigned long num_loops;
float timer,pixs[5];
unsigned char *image;
num_loops = 200;
/*..........................................................................*/
/* Initialize sin look up table. */
/* Index 'i' goes from 0 to 1023 and is equivalent to 0 to 360 degrees. */
/*..........................................................................*/
for(i=0;i<1024;i++)
SIN_LUT[i] = sin(i*6.28/1024.0);
printf("input graphics mode (hex): ");
scanf("%x",&mode);
vsa_init(mode);
xx = XResolution;
yy = YResolution;
/*..........................................................................*/
/* Initialize array of BitBlt positions */
/*..........................................................................*/
k = 0;
l = 256;
c = .09*xx;
d = .12*yy;
for(i=0;i<num_loops;i++)
{
m[i] = xx/2 - c/2 + (i)*SIN_LUT[k];
n[i] = yy/2 - d/2 + (i)*SIN_LUT[l];
k-=32;
l-=32;
k=k & 0x3ff;
l=l & 0x3ff;
}
/*..........................................................................*/
/* Allocate memory for image array */
/*..........................................................................*/
image_size = vsa_image_size(0,0,c,d);
if((image = malloc(image_size)) == NULL)
{
vsa_write_string(0,0,31,"Error allocating memory for IMAGE");
getch();
goto BAIL;
}
for(j=0;j<5;j++) /* restore to j<5 !!! */
{
vsa_set_color(0);
vsa_move_to(0,0);
vsa_rect_fill(xx-1,yy-1);
/*..........................................................................*/
/* Draw color look up table at bottom of screen. */
/*..........................................................................*/
rainbow_lut();
a = .125*xx;
b = .83*yy;
color_bar(a,b);
/*..........................................................................*/
/* Draw a 3-D shaded Cube */
/*..........................................................................*/
a = .5*xx;
b = .35*yy;
cube_3d(a,b);
a = .495*xx;
b = .295*yy;
vsa_get_image(a,b,a+c,b+d,image);
vsa_set_color(255);
vsa_move_to(a,b);
vsa_rect(a+c,b+d);
clk = clock();
for(i=0;i<num_loops;i++)
vsa_put_image(m[i],n[i],image,op[j]);
delta = clock() - clk;
timer = ((float)(delta))/((float)CLOCKS_PER_SEC);
if(timer == 0) timer = .000001;
pixs[j] = ((float)(num_loops)*(c+1L)*(d+1L))/timer;
}
sprintf(text,"BitBlt: Drawing Rate (Replace) = %f Pixels/sec\n",pixs[0]);
vsa_write_string(10,10,15,text);
sprintf(text,"BitBlt: Drawing Rate (AND) = %f Pixels/sec\n",pixs[1]);
vsa_write_string(10,25,15,text);
sprintf(text,"BitBlt: Drawing Rate (OR) = %f Pixels/sec\n",pixs[2]);
vsa_write_string(10,40,15,text);
sprintf(text,"BitBlt: Drawing Rate (XOR) = %f Pixels/sec\n",pixs[3]);
vsa_write_string(10,55,15,text);
sprintf(text,"BitBlt: Drawing Rate (Sprite) = %f Pixels/sec\n",pixs[4]);
vsa_write_string(10,70,15,text);
free(image);
getch();
BAIL:
vsa_init(0x03);
return;
}
void cube_3d(int a,int b)
{
int dy,dx,dd;
dx = .045*XResolution;
dy = .06*YResolution;
dd = .5*dx;
vsa_shaded_triangle(a,b,75,a+dx,b,91,a+dx,b+dy,75);
vsa_shaded_triangle(a,b,75,a,b+dy,49,a+dx,b+dy,75);
a+= 0.05*dx;
b-= 0.2*dy;
vsa_shaded_triangle(a,b,75,a+dx,b,91,a+3*dd,b-dd,75);
vsa_shaded_triangle(a,b,75,a+dd,b-dd,49,a+3*dd,b-dd,75);
a+= 0.15*dx;
b+= 0.15*dy;
vsa_shaded_triangle(a+dx,b+dy,75,a+dx,b,91,a+3*dd,b-dd,75);
vsa_shaded_triangle(a+dx,b+dy,75,a+3*dd,b+dy-dd,49,a+3*dd,b-dd,75);
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -