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

📄 gp2gpcitest.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
            ftemp = b; GP1_PUT_F(shmptr,ftemp);        }    }    *shmptr++ = GP1_EOCL | GP1_FREEBLKS;    GP1_PUT_I(shmptr, bitvec);    if ((gp1_post(gp1_shmem, offset, ioctlfd)) !=0)    {        gp_send_message(-POST_ERROR, FATAL, gp1poly3_msg4);    }}/* ******************************************************************** *	init_static_blk1 * *	1). set color to blue *	2). set to rop mode *	3). set hidden serface removal on. *	4). set width and line text. *	5). set view port whole screen. *	6). set to normal transform matrix. *	7). set clip list to whole screen. ******************************************************************** */init_static_blk1(){    unsigned int bitvec;    int offset;    int planesmask;    short *shmptr;    float ftemp;    offset = 0;    offset = gp1_alloc(gp1_shmem, 1, &bitvec, minordev, ioctlfd);    if(offset == 0)         gp_send_message(-DEV_NO_STATBLK, FATAL, init_blk1_msg1);    shmptr = &((short *) gp1_shmem)[offset];    *shmptr++ = GP1_USE_CONTEXT | statblk;    *shmptr++ = GP1_SET_COLOR | BLUE_COLOR;    *shmptr++ = GP1_SET_FB_NUM | gp1_d(screen)->cg2_index;    *shmptr++ = GP1_SET_ROP;    *shmptr++ = PIX_SRC;    pr_getattributes(screen, &planesmask);    if ( CgTWO )       *shmptr++ = GP1_SET_FB_PLANES | planesmask;    *shmptr++ = GP1_SET_CLIP_PLANES | 0x3F;    *shmptr++ = GP1_SETHIDDENSURF | GP1_ZBHIDDENSURF;    *shmptr++ = GP1_SET_MAT_NUM | 0;    *shmptr++ = GP1_SET_LINE_WIDTH;    *shmptr++ = 1;    *shmptr++ = 0;    *shmptr++ = GP1_SET_LINE_TEX;    *shmptr++ = 0;    *shmptr++ = 0;    *shmptr++ = 0;    *shmptr++ = GP1_SET_VWP_3D;    ftemp = 576.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 576.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = -450.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 450.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 30000.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    *shmptr++ = GP1_SET_MAT_3D | 0;    ftemp = 1.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 1.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 1.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 1.0;    GP1_PUT_F(shmptr, ftemp);    *shmptr++ = GP1_SET_CLIP_LIST;    *shmptr++ = 1;    *shmptr++ = 0;    *shmptr++ = 0;    *shmptr++ = 1152;    *shmptr++ = 900;    *shmptr++ = GP1_EOCL | GP1_FREEBLKS;    GP1_PUT_I(shmptr, bitvec);    if ((gp1_post(gp1_shmem, offset, ioctlfd)) != 0)        gp_send_message(-SYNC_ERROR, FATAL, init_blk1_msg2);}/* ******************************************************************** *      init_static_blk2 * *      1). set color to blue *      2). set to rop mode *      3). set hidden serface removal off. *      4). set width and line text. *      5). set view port whole screen. *      6). set to normal transform matrix. *      7). set clip list to whole screen. ******************************************************************** */init_static_blk2(){    unsigned int bitvec;    int offset;    int planesmask;    short *shmptr;    float ftemp;     offset = 0;    offset = gp1_alloc(gp1_shmem, 2, &bitvec, minordev, ioctlfd);    if(offset == 0)         gp_send_message(-DEV_NO_STATBLK, FATAL, init_blk2_msg1);    shmptr = &((short *) gp1_shmem)[offset];    *shmptr++ = GP1_USE_CONTEXT | statblk;    *shmptr++ = GP1_SET_COLOR | BLUE_COLOR;    *shmptr++ = GP1_SET_FB_NUM | gp1_d(screen)->cg2_index;    *shmptr++ = GP1_SET_ROP;    *shmptr++ = PIX_SRC;    pr_getattributes(screen, &planesmask);    if ( CgTWO )       *shmptr++ = GP1_SET_FB_PLANES | planesmask;    *shmptr++ = GP1_SET_CLIP_PLANES | 0x3F;    *shmptr++ = GP1_SETHIDDENSURF | GP1_NOHIDDENSURF;    *shmptr++ = GP1_SET_MAT_NUM | 0;    *shmptr++ = GP1_SET_LINE_WIDTH;    *shmptr++ = 1;    *shmptr++ = 0;    *shmptr++ = GP1_SET_LINE_TEX;    *shmptr++ = 0;    *shmptr++ = 0;    *shmptr++ = 0;    *shmptr++ = GP1_SET_VWP_3D;    ftemp = 576.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 576.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = -450.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 450.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 30000.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    *shmptr++ = GP1_SET_MAT_3D | 0;    ftemp = 1.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 1.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 1.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 0.0;    GP1_PUT_F(shmptr, ftemp);    ftemp = 1.0;    GP1_PUT_F(shmptr, ftemp);    *shmptr++ = GP1_SET_CLIP_LIST;    *shmptr++ = 1;    *shmptr++ = 0;    *shmptr++ = 0;    *shmptr++ = 1152;    *shmptr++ = 900;    *shmptr++ = GP1_EOCL | GP1_FREEBLKS;    GP1_PUT_I(shmptr, bitvec);    if ((gp1_post(gp1_shmem, offset, ioctlfd)) != 0)        gp_send_message(-SYNC_ERROR, FATAL, init_blk2_msg2);}/* ******************************************************************** *	clrzb * *	This routine will clear the z (or depth buffer) for the  *	entire screen. ******************************************************************** */clrzb(){    unsigned int bitvec;    int offset;    short *shmptr;    offset = 0;    offset = gp1_alloc(gp1_shmem, 2, &bitvec, minordev, ioctlfd);    if (offset == 0)         gp_send_message(-DEV_NO_STATBLK, FATAL, clrzb_msg1);    shmptr = &((short *) gp1_shmem)[offset];    *shmptr++ = GP1_USE_CONTEXT | statblk;    *shmptr++ = GP1_PR_ROP_NF | 255;        *shmptr++ = 0;        *shmptr++ = PIX_SRC | PIX_COLOR(0);        *shmptr++ = 0;        *shmptr++ = 0;        *shmptr++ = 1152;        *shmptr++ = 900;        *shmptr++ = 0;        *shmptr++ = 0;        *shmptr++ = 1152;        *shmptr++ = 900;    *shmptr++ = GP1_SETZBUF;    *shmptr++ = 0xFFFF;    *shmptr++ = 0;    *shmptr++ = 0;    *shmptr++ = 1152;    *shmptr++ = 900;    *shmptr++ = GP1_EOCL | GP1_FREEBLKS;    GP1_PUT_I(shmptr, bitvec);    if ((gp1_post(gp1_shmem, offset, ioctlfd)) != 0)    	gp_send_message(-POST_ERROR, FATAL, clrzb_msg2);}/* ******************************************************************** *	gp1poly3 *	 *	This routine will take the points that were generated by *	the bldpolygons routine and post them to the gp2 context *	blocks.  If all context blocks have been used it will free *	some up that are no longer needed and post some polygons *	to the GP2. All of the polygons are Gouraud shaded. ******************************************************************** */gp1poly3(plst, n, points_per_poly)    struct polygon plst[];    int n;    int points_per_poly;{    register int m, i, j, *nvp, overflow;    unsigned int bitvec;    register int offset, roomleft;    register short *shmptr, *nvshmptr;    register float *ptr;    int needed;    float ftemp;    int itemp;    int blocks_per_transfer = 1;    offset = 0;    offset = gp1_alloc(gp1_shmem, blocks_per_transfer, &bitvec,                 minordev, ioctlfd);    if (offset == 0)         gp_send_message(-DEV_NO_STATBLK, FATAL, gp1poly3_msg1);/* Allows at most two bands. */#ifdef GOURAUD    needed = 4 + 8 * points_per_poly;#else    needed = 4 + 6 * points_per_poly;#endif    shmptr = &((short *) gp1_shmem)[offset];    *shmptr++ = GP1_USE_CONTEXT | statblk;    roomleft = 512 * blocks_per_transfer - 2;    for (i = 0; i < n; i++) {        if (roomleft < needed) {            *shmptr++ = GP1_EOCL | GP1_FREEBLKS;            GP1_PUT_I(shmptr, bitvec);PRE_POST_SYNC(gp1_shmem, ioctlfd);            if ((gp1_post(gp1_shmem, offset, ioctlfd)) !=0)                gp_send_message(-POST_ERROR, FATAL, gp1poly3_msg2);POST_POST_SYNC(gp1_shmem, ioctlfd);            offset = 0;            offset = gp1_alloc(gp1_shmem, blocks_per_transfer, &bitvec,                         minordev, ioctlfd);            if (offset == 0)                gp_send_message(-DEV_NO_STATBLK, FATAL, gp1poly3_msg1);            shmptr = &((short *) gp1_shmem)[offset];            *shmptr++ = GP1_USE_CONTEXT | statblk;            roomleft = 512 * blocks_per_transfer - 2;        }        nvp = plst[i].nvptr;        ptr = (float *) plst[i].coordptr;#ifdef GOURAUD	if ( CgTWO )		*shmptr++ = GP1_XF_PGON_FLT_3D | GP1_SHADE_GOURAUD;	else        	*shmptr++ = GP2_XF_PGON_FLT_3D_RGB | GP2_RGB_COLOR_PACK;#else        *shmptr++ = GP1_XF_PGON_FLT_3D | GP1_SHADE_CONSTANT;#endif        *shmptr++ = plst[i].nbnds;        nvshmptr = shmptr;        shmptr += plst[i].nbnds;        roomleft -= (plst[i].nbnds + 2);        overflow = 0;        for (j = 0; j < plst[i].nbnds; j++) {            m = *nvp++;            if (roomleft >= 3 + 8 * m) {                *nvshmptr++ = m;                roomleft -= 8 * m;                while (m--) {                    ftemp = *ptr++;                    GP1_PUT_F(shmptr, ftemp);                    ftemp = *ptr++;                    GP1_PUT_F(shmptr, ftemp);                    ftemp = *ptr++;                    GP1_PUT_F(shmptr, ftemp);#ifdef GOURAUD                    itemp = *((int *) ptr)++;                    GP1_PUT_I(shmptr, itemp);#else                    ((int *) ptr)++;#endif                }            }            else                overflow = 1;        }        if (overflow) {            shmptr = &((short *) gp1_shmem)[offset];            gp_send_message(-2, ERROR, gp1poly3_msg3);            return;        }#ifdef ONE_PGON_PER_POST        roomleft = 0;#endif    }          *shmptr++ = GP1_EOCL | GP1_FREEBLKS;    GP1_PUT_I(shmptr, bitvec);    if ((gp1_post(gp1_shmem, offset, ioctlfd)) !=0)        gp_send_message(-POST_ERROR, FATAL, gp1poly3_msg4);}

⌨️ 快捷键说明

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