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

📄 hw_draw.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 2 页
字号:
    HWD.pfnDrawPolygon( NULL, v, 4, PF_NoDepthTest); //PF_Translucent );}// --------------------------------------------------------------------------// Fade down the screen so that the menu drawn on top of it looks brighter// --------------------------------------------------------------------------//  3--2//  | /|//  |/ |//  0--1void HWR_FadeScreenMenuBack( unsigned long color, int height ){    FOutVector  v[4];    FSurfaceInfo Surf;    // setup some neat-o translucency effect    if (!height) //cool hack 0 height is full height        height = VIDHEIGHT;    v[0].x = v[3].x = -1.0f;    v[2].x = v[1].x =  1.0f;    v[0].y = v[1].y =  1.0f-((height<<1)/(float)VIDHEIGHT);    v[2].y = v[3].y =  1.0f;    v[0].oow = v[1].oow = v[2].oow = v[3].oow = 1.0f;        v[0].sow = v[3].sow = 0.0f;    v[2].sow = v[1].sow = 1.0f;    v[0].tow = v[1].tow = 1.0f;    v[2].tow = v[3].tow = 0.0f;    Surf.FlatColor.rgba = UINT2RGBA(color);    Surf.FlatColor.s.alpha = (0xff/2) * ((float)height / VIDHEIGHT);    //calum: varies console alpha    HWD.pfnDrawPolygon( &Surf, v, 4, PF_NoTexture|PF_Modulated|PF_Translucent|PF_NoDepthTest);}// ==========================================================================//                                                             R_DRAW.C STUFF// ==========================================================================// ------------------// HWR_DrawViewBorder // Fill the space around the view window with a Doom flat texture, draw the// beveled edges.// 'clearlines' is useful to clear the heads up messages, when the view// window is reduced, it doesn't refresh all the view borders.// ------------------extern int st_borderpatchnum;void HWR_DrawViewBorder (int clearlines){    int         x,y;    int         top,side;    int         baseviewwidth,baseviewheight;    int         basewindowx,basewindowy;    GlidePatch_t*   patch;// comment by hurdler//    if (gr_viewwidth == VIDWIDTH)//        return;    if (!clearlines)        clearlines = BASEVIDHEIGHT; //refresh all    // calc view size based on original game resolution    baseviewwidth  = (cv_viewsize.value * BASEVIDWIDTH/10)&~7;    if (cv_scalestatusbar.value)    {        baseviewheight = (cv_viewsize.value * (BASEVIDHEIGHT-ST_HEIGHT/2)/10)&~1;        top  = (BASEVIDHEIGHT - ST_HEIGHT/2 - baseviewheight) / 2;    }    else    {        baseviewheight = (cv_viewsize.value * (BASEVIDHEIGHT-ST_HEIGHT)/10)&~1;        top  = (BASEVIDHEIGHT - ST_HEIGHT - baseviewheight) / 2;    }    side = (BASEVIDWIDTH  - baseviewwidth) / 2;    // top    HWR_DrawFlatFill (0, 0,                     BASEVIDWIDTH, (top<clearlines ? top : clearlines),                     st_borderpatchnum);        // left    if (top<clearlines)        HWR_DrawFlatFill (0, top,                         side, (clearlines-top < baseviewheight ? clearlines-top : baseviewheight),                         st_borderpatchnum);            // right    if (top<clearlines)        HWR_DrawFlatFill (side + baseviewwidth, top,                         side, (clearlines-top < baseviewheight ? clearlines-top : baseviewheight),                         st_borderpatchnum);        // bottom    if (top+baseviewheight<clearlines)        HWR_DrawFlatFill (0, top+baseviewheight,                         BASEVIDWIDTH, (clearlines-baseviewheight-top < top ? clearlines-baseviewheight-top : top),                         st_borderpatchnum);    //    // draw the view borders    //    basewindowx = (BASEVIDWIDTH - baseviewwidth)>>1;    if (baseviewwidth==BASEVIDWIDTH)        basewindowy = 0;    else    {        if (cv_scalestatusbar.value)            basewindowy = (BASEVIDHEIGHT - ST_HEIGHT/2 - baseviewheight)>>1;        else            basewindowy = (BASEVIDHEIGHT - ST_HEIGHT - baseviewheight)>>1;    }    // top edge    if (clearlines > basewindowy-8) {        patch = W_CachePatchNum (viewborderlump[BRDR_T],PU_CACHE);        for (x=0 ; x<baseviewwidth; x+=8)            HWR_DrawPatch (patch,basewindowx+x,basewindowy-8);    }        // bottom edge    if (clearlines > basewindowy+baseviewheight) {        patch = W_CachePatchNum (viewborderlump[BRDR_B],PU_CACHE);        for (x=0 ; x<baseviewwidth ; x+=8)            HWR_DrawPatch (patch,basewindowx+x,basewindowy+baseviewheight);    }        // left edge    if (clearlines > basewindowy) {        patch = W_CachePatchNum (viewborderlump[BRDR_L],PU_CACHE);        for (y=0 ; y<baseviewheight && (basewindowy+y < clearlines); y+=8)            HWR_DrawPatch (patch,basewindowx-8,basewindowy+y);    }        // right edge    if (clearlines > basewindowy) {        patch = W_CachePatchNum (viewborderlump[BRDR_R],PU_CACHE);        for (y=0 ; y<baseviewheight && (basewindowy+y < clearlines); y+=8)            HWR_DrawPatch (patch,basewindowx+baseviewwidth,basewindowy+y);    }    // Draw beveled corners.    if (clearlines > basewindowy-8)        HWR_DrawPatch (W_CachePatchNum (viewborderlump[BRDR_TL],PU_CACHE),                      basewindowx-8,                      basewindowy-8);    if (clearlines > basewindowy-8)        HWR_DrawPatch (W_CachePatchNum (viewborderlump[BRDR_TR],PU_CACHE),                      basewindowx+baseviewwidth,                      basewindowy-8);    if (clearlines > basewindowy+baseviewheight)        HWR_DrawPatch (W_CachePatchNum (viewborderlump[BRDR_BL],PU_CACHE),                      basewindowx-8,                      basewindowy+baseviewheight);    if (clearlines > basewindowy+baseviewheight)        HWR_DrawPatch (W_CachePatchNum (viewborderlump[BRDR_BR],PU_CACHE),                      basewindowx+baseviewwidth,                      basewindowy+baseviewheight);}// ==========================================================================//                                                     AM_MAP.C DRAWING STUFF// ==========================================================================// Clear the automap part of the screenvoid HWR_clearAutomap( void ){    FRGBAFloat fColor = { 0,0,0,1 };    //FIXTHIS faB - optimize by clearing only colors ?    //HWD.pfnSetBlend ( PF_NoOcclude );    // minx,miny,maxx,maxy    HWD.pfnGClipRect( 0, 0, VIDWIDTH , VIDHEIGHT - STAT_HEIGHT, 0.9f );    HWD.pfnClearBuffer( true, true, &fColor );    HWD.pfnGClipRect( 0, 0, VIDWIDTH, VIDHEIGHT, 0.9f );}// -----------------+// HWR_drawAMline   : draw a line of the automap (the clipping is already done in automap code)// Arg              : color is a RGB 888 value// -----------------+void HWR_drawAMline( fline_t* fl, int color ){    F2DCoord  v1, v2;    RGBA_t    color_rgba;    color_rgba = V_GetColor( color );    v1.x = ((float)fl->a.x-(vid.width/2.0f))*(2.0f/vid.width);    v1.y = ((float)fl->a.y-(vid.height/2.0f))*(2.0f/vid.height);    v2.x = ((float)fl->b.x-(vid.width/2.0f))*(2.0f/vid.width);    v2.y = ((float)fl->b.y-(vid.height/2.0f))*(2.0f/vid.height);    HWD.pfnDraw2DLine( &v1, &v2, color_rgba );}// -----------------+// HWR_DrawFill     : draw flat coloured rectangle, with no texture// -----------------+void HWR_DrawFill( int x, int y, int w, int h, int color ){    FOutVector  v[4];    FSurfaceInfo Surf;    //  3--2//  | /|//  |/ |//  0--1    v[0].x = v[3].x = (x - 160.0f)/160.0f;    v[2].x = v[1].x = ((x+w) - 160.0f)/160.0f;    v[0].y = v[1].y = -(y - 100.0f)/100.0f;    v[2].y = v[3].y = -((y+h) - 100.0f)/100.0f;    //Hurdler: do we still use this argb color? if not, we should remove it    v[0].argb = v[1].argb = v[2].argb = v[3].argb = 0xff00ff00; //;    v[0].oow = v[1].oow = v[2].oow = v[3].oow = 1.0f;    v[0].sow = v[3].sow = 0.0f;    v[2].sow = v[1].sow = 1.0f;    v[0].tow = v[1].tow = 0.0f;    v[2].tow = v[3].tow = 1.0f;    Surf.FlatColor = V_GetColor( color );    HWD.pfnDrawPolygon( &Surf, v, 4, PF_Modulated|PF_NoTexture| PF_NoDepthTest );}// --------------------------------------------------------------------------// screen shot// --------------------------------------------------------------------------boolean HWR_Screenshot (char *lbmname){    int         i;    byte*   bufw;    unsigned short* bufr;    byte*   dest;    unsigned short   rgb565;    bufr = malloc(VIDWIDTH*VIDHEIGHT*2);    if (!bufr)        return false;    bufw = malloc(VIDWIDTH*VIDHEIGHT*3);    if (!bufw)    {        free(bufr);        return false;    }    //returns 16bit 565 RGB    HWD.pfnReadRect (0, 0, VIDWIDTH, VIDHEIGHT, VIDWIDTH*2, bufr);    for (dest = bufw,i=0; i<VIDWIDTH*VIDHEIGHT; i++)    {        rgb565 = bufr[i];        *(dest++) = (rgb565 & 31) <<3;        *(dest++) = ((rgb565 >> 5) & 63) <<2;        *(dest++) = ((rgb565 >> 11) & 31) <<3;    }    free(bufr);        // find a file name to save it to    strcpy(lbmname,"DOOM000.tga");    for (i=0 ; i<=999 ; i++)    {            lbmname[4] = i/100 + '0';            lbmname[5] = i/10  + '0';            lbmname[6] = i%10  + '0';            if (access(lbmname,0) == -1)                break;  // file doesn't exist    }    if (i<1000)    {        // save the file        saveTGA(lbmname, VIDWIDTH, VIDHEIGHT, (GLRGB *)bufw);        free(bufw);        return true;    }    free(bufw);    return false;}// --------------------------------------------------------------------------// save screenshots with TGA format// --------------------------------------------------------------------------void saveTGA(char *file_name, int width, int height, GLRGB *buffer){    int fd;    long size;    TGAHeader tga_hdr;    fd = open(file_name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);    if (fd < 0)        return;    memset(&tga_hdr, 0, sizeof(tga_hdr));    tga_hdr.width = SHORT(width);    tga_hdr.height = SHORT(height);    tga_hdr.image_pix_size = 24;    tga_hdr.image_type = 2;    tga_hdr.image_descriptor = 32;    size = (long)width * (long)height * 3L;    write(fd, &tga_hdr, sizeof(TGAHeader));    write(fd, buffer, size);    close(fd);}

⌨️ 快捷键说明

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