⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gpsi_uti.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
#ifndef lintstatic  char sccsid[] = "@(#)gpsi_uti.c 1.1 92/07/30 Copyr 1990 Sun Micro";#endif/* * Copyright (c) 1990 by Sun Microsystems, Inc. */#include <stdio.h>#include <sdrtns.h>     /* sdrtns.h should always be included */#include <sys/types.h>#include <suntool/sunview.h>#include <pixrect/gp1cmds.h>#include <pixrect/pixrect_hs.h>#include <pixrect/gp1reg.h>#include <varargs.h>#include <esd.h>#define GP3_SET_FB_PLANES_RGB	(100 << 8)#define MAX_ALLOC_TRIALS 10extern char *sprintf();externchar		*device_name;/* GP handles */static caddr_t GP_shmem;static int GP_fd;static int GP_offs;static int GP_statblk = -1;static int GP_mindev;static int GP_blocks;static Rect GP_r;static Pixrect *GP_pr = (Pixrect *)0;static unsigned int bitvec;/* aux. */static char errtxt[256];/* Context attributes */static int		dont_clear_ctx;static unsigned char	fb_num;static unsigned int	fb_planes;static short		rop;static short		ncliprect;static Rect		*cliprects;static unsigned char	clip_planes;static short		line_width;static short		line_width_opt;static short		*pr_tex_ptr;static short		pr_tex_offset;static short		pr_tex_options;static float		xscale;static float		xoffs;static float		yscale;static float		yoffs;static float		zscale;static float		zoffs;static unsigned char	use_mat_num;static unsigned char	set_mat_num;static Matrix_3D        *matrix_3d;static short		zbuf_depth;static short		zbuf_x;static short		zbuf_y;static short		zbuf_width;static short		zbuf_height;static unsigned char	depth_cue;static unsigned int	depth_cue_front_color;static unsigned int	depth_cue_back_color;static unsigned char	hidden_surf;static unsigned int	rgb_color;static float		rgb_color_red;static float		rgb_color_green;static float		rgb_color_blue;#ifdef RFSstaticshort *pdump;#endif/**********************************************************************/open_gp()/**********************************************************************//* opens pixrect device and initialise GPSI interface */{    char *init_gp();    Pixrect *pr;    char *errmsg;    func_name = "open_gp";    TRACE_IN    if (GP_pr) {	TRACE_OUT	return 1;    }        pr = pr_open(device_name);    if (pr == NULL) {	(void)sprintf(errtxt, errmsg_list[19], device_name);	error_report(errtxt);	TRACE_OUT	return 0;    }    GP_pr = pr;    errmsg = init_gp();    if (errmsg) {	error_report(errmsg);	pr_close(pr);	GP_pr = (Pixrect *)0;	TRACE_OUT	return 0;    }    TRACE_OUT    return 1;}/**********************************************************************/close_gp()/**********************************************************************//* close cg12 on exit */{    int err;    func_name = "close_gp";    TRACE_IN    if (GP_statblk != -1) {	err = gp1_free_static_block(GP_fd, GP_statblk);    }    if (GP_pr) {	pr_close(GP_pr);    }    TRACE_OUT}/**********************************************************************/short *allocbuf()/**********************************************************************//* allocates a shmem block to place GPSI commands */{    short  *p;    int     n = 0;    func_name = "allocbuf";    TRACE_IN    (void)check_key();    while ((GP_offs = gp1_alloc(GP_shmem, GP_blocks, &bitvec, GP_mindev,							GP_fd)) == 0) {        n++;	if (n > MAX_ALLOC_TRIALS) {	    p = (short *)-1;/*	    if (n == 0) */	       return(p); 	}    }    p = &((short *)GP_shmem)[GP_offs];#ifdef RFS    pdump = p;#endif    *p++ = GP1_USE_CONTEXT | GP_statblk;    TRACE_OUT    return(p);}/**********************************************************************/postbuf(p)/**********************************************************************/short        *p;/*   posts the command buffer pointed to by p, returns -1 in case   the GPSI code can not be posted and frees the buffer.*/{    int res;    func_name = "postbuf";    TRACE_IN    (void)check_key();    *p++ = GP1_EOCL | GP1_FREEBLKS;    GP1_PUT_I(p, bitvec);    res = gp1_post(GP_shmem, GP_offs, GP_fd);    if (res == -1) {	TRACE_OUT	return (res);    }        gp1_sync(GP_shmem, GP_fd);    TRACE_OUT    return 0;    }/**********************************************************************/postbuf_n_wait(p, result)/**********************************************************************/short        *p;short        *result;/*   posts the command buffer pointed to by p, returns -1 in case   the GPSI code can not be posted and frees the buffer.*/{    int res;    func_name = "postbuf_n_wait";    TRACE_IN    (void)check_key();    *p++ = GP1_EOCL;    GP1_PUT_I(p, bitvec);    res = gp1_post(GP_shmem, GP_offs, GP_fd);    if (res == -1) {	TRACE_OUT	return (res);    }    res = gp1_wait0(result, GP_fd);    if (res == -1) {	TRACE_OUT	return (res);    }        TRACE_OUT    return 0;    }/**********************************************************************/char *init_gp()/**********************************************************************//* initialises the global variables for subsequent GPSI calls. */{    register Pixrect *pr;    int i;    unsigned char red[256];    unsigned char green[256];    unsigned char blue[256];    func_name = "init_gp";    TRACE_IN    pr = GP_pr;    if (pr->pr_ops->pro_rop != gp1_rop) {	TRACE_OUT	return(errmsg_list[23]);    }    /* set plane group and attributes */    pr_set_planes(pr, PIXPG_24BIT_COLOR, PIX_ALL_PLANES);    /* load color map */    for (i=0 ; i <256 ; i++) {	red[i] = green[i] = blue[i] = i;    }    pr_putlut(pr, 0, 256, red, green, blue);    /* set global variables */    GP_pr = pr;    GP_r.r_width = pr->pr_width;    GP_r.r_height = pr->pr_height;    GP_r.r_left = gp1_d(pr)->cgpr_offset.x;    GP_r.r_top = gp1_d(pr)->cgpr_offset.y;    GP_shmem = gp1_d(pr)->gp_shmem;    GP_fd = gp1_d(pr)->ioctl_fd;    GP_mindev = gp1_d(pr)->minordev;    GP_statblk = gp1_get_static_block(GP_fd);    if (GP_statblk < 0) {	TRACE_OUT	return(errmsg_list[24]);    }    GP_blocks = 4;    /* print the number of cg12 free blocks */    TRACE_OUT    return (char *)0;}/**********************************************************************/post_diag_test(cmd, mode, arg0, arg1, arg2, arg3, arg4, arg5, arg6,								arg7)/**********************************************************************/short cmd, mode, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7;/* posts test and wait for return code, if test fails to start * return -1,, otherwise return the result of the test passed * through the shared memory. */{        short *sptr;    short *ssptr;    short *compl;    short *result;    int res;    int mone = -1;    func_name = "post_diag_test";    TRACE_IN    (void)check_key();    sptr = allocbuf();    if (sptr == (short *)-1) {	error_report(errmsg_list[52]);	TRACE_OUT	return  -1;    }    ssptr = sptr;    *sptr++ = cmd;    *sptr++ = mode;    *sptr++ = arg0;    *sptr++ = arg1;    *sptr++ = arg2;    *sptr++ = arg3;    *sptr++ = arg4;    *sptr++ = arg5;    *sptr++ = arg6;    *sptr++ = arg7;    compl   = sptr;    *sptr++ = -1;    result  = sptr;    GP1_PUT_I(sptr, mone);    *sptr++ = GP1_EOCL;#ifdef RFS    dump_p ((unsigned short *) pdump, (unsigned short *) sptr);#endif    if(gp1_post(GP_shmem, GP_offs, GP_fd) == -1) {	error_report(errmsg_list[20]);	TRACE_OUT	return  -1;    }    if(gp1_wait0(compl, GP_fd) == -1) {	error_report(errmsg_list[21]);	TRACE_OUT	return  -1;    }    GP1_GET_I(result, res);    sptr = ssptr;    *sptr++ = GP1_EOCL | GP1_FREEBLKS;    GP1_PUT_I(sptr, bitvec);    if(gp1_post(GP_shmem, GP_offs, GP_fd) == -1) {	error_report("Can not start C30 test code.\n");	TRACE_OUT	return  -1;    }    TRACE_OUT    return res;}/**********************************************************************/char *ctx_set(va_alist)/**********************************************************************/va_dcl{    char *ctx_post();    register Context_attribute attr;    va_list ap;    func_name = "ctx_set";    TRACE_IN    /* set all default values in the static block */    (void)ctx_default();    va_start(ap);    while (attr = va_arg(ap, Context_attribute)) {	switch((Context_attribute)attr) {	    case CTX_ATTR_END:		break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -