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

📄 hw_draw.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 2 页
字号:
// Emacs style mode select   -*- C++ -*- //-----------------------------------------------------------------------------//// $Id: hw_draw.c,v 1.18 2001/04/01 17:35:07 bpereira Exp $//// Copyright (C) 1998-2000 by DooM Legacy Team.//// This program is free software; you can redistribute it and/or// modify it under the terms of the GNU General Public License// as published by the Free Software Foundation; either version 2// of the License, or (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.////// $Log: hw_draw.c,v $// Revision 1.18  2001/04/01 17:35:07  bpereira// no message//// Revision 1.17  2001/02/28 17:50:56  bpereira// no message//// Revision 1.16  2001/02/24 13:35:22  bpereira// no message//// Revision 1.15  2001/01/31 17:15:09  hurdler// Add cv_scalestatusbar in hardware mode//// Revision 1.14  2001/01/25 18:56:27  bpereira// no message//// Revision 1.13  2000/11/02 19:49:39  bpereira// no message//// Revision 1.12  2000/10/04 16:21:57  hurdler// small clean-up//// Revision 1.11  2000/09/14 10:42:47  hurdler// Fix compiling problem under win32//// Revision 1.10  2000/09/10 10:48:13  metzgermeister// *** empty log message ***//// Revision 1.9  2000/08/31 14:30:57  bpereira// no message//// Revision 1.8  2000/08/11 19:11:57  metzgermeister// *** empty log message ***//// Revision 1.7  2000/04/27 17:48:47  hurdler// colormap code in hardware mode is now the default//// Revision 1.6  2000/04/24 15:22:47  hurdler// Support colormap for text//// Revision 1.5  2000/04/23 00:30:47  hurdler// fix a small bug in skin color//// Revision 1.4  2000/04/22 21:08:23  hurdler// I like it better like that//// Revision 1.3  2000/04/14 16:34:26  hurdler// some nice changes for coronas//// Revision 1.2  2000/02/27 00:42:11  hurdler// fix CR+LF problem//// Revision 1.1.1.1  2000/02/22 20:32:33  hurdler// Initial import into CVS (v1.29 pr3)////// DESCRIPTION://      miscellaneous drawing (mainly 2d)////-----------------------------------------------------------------------------#include "hw_glob.h"#include "hw_drv.h"#include "../m_misc.h"      //FIL_WriteFile()#include "../r_draw.h"      //viewborderlump#include "../r_main.h"#include "../w_wad.h"#include "../z_zone.h"#include "../v_video.h"#ifndef LINUX // unix does not need this 19991024 by Kin#ifndef __MACOS__#include <io.h>#endif#else#define O_BINARY 0#include <unistd.h>#endif // normalunix#include <fcntl.h>#include "../i_video.h"  // for rendermode != render_glidefloat   gr_patch_scalex;float   gr_patch_scaley;static  BOOL    gr_scale_patch=true;     // HWR_DrawPatch() scaling state#ifdef WIN32#pragma pack(1)#endiftypedef struct {  // sizeof() = 18  char  id_field_length;  char  color_map_type;  char  image_type;  char  dummy[5];/*short c_map_origin;  short c_map_length;  char  c_map_size;*/  short x_origin;  short y_origin;  short width;  short height;  char  image_pix_size;  char  image_descriptor;} TGAHeader, *PTGAHeader;#ifdef WIN32#pragma pack()#endiftypedef unsigned char GLRGB[3];void saveTGA(char *file_name, int width, int height, GLRGB *buffer);//// Set current scaling state for HWR_DrawPatch()//void HWR_ScalePatch ( BOOL bScalePatch ){    gr_scale_patch = bScalePatch;}#define BLENDMODE PF_Translucent// // -----------------+// HWR_DrawPatch    : Draw a 'tile' graphic// Notes            : x,y : positions relative to the original Doom resolution//                  : textes(console+score) + menus + status bar// -----------------+void HWR_DrawPatch (GlidePatch_t* gpatch, int x, int y){    FOutVector      v[4];    // make patch ready in hardware cache    HWR_GetPatch (gpatch);//  3--2//  | /|//  |/ |//  0--1    if ( gr_scale_patch ) {        v[0].x = v[3].x = (x-gpatch->leftoffset-160.0f)/160.0f;        v[2].x = v[1].x = (x-gpatch->leftoffset+gpatch->width-160.0f)/160.0f;        v[0].y = v[1].y = -(y-gpatch->topoffset-100.0f)/100.0f;        v[2].y = v[3].y = -(y-gpatch->topoffset+gpatch->height-100.0f)/100.0f;    }    else {        v[0].x = v[3].x = ((x-gpatch->leftoffset-vid.width/2.0f)/(vid.width/2.0f));        v[2].x = v[1].x = ((x-gpatch->leftoffset+gpatch->width-vid.width/2.0f)/(vid.width/2.0f));        v[0].y = v[1].y = -((y-gpatch->topoffset-vid.height/2.0f)/(vid.height/2.0f));        v[2].y = v[3].y = -((y-gpatch->topoffset+gpatch->height-vid.height/2.0f)/(vid.height/2.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 = gpatch->max_s;    v[0].tow = v[1].tow = 0.0f;    v[2].tow = v[3].tow = gpatch->max_t;    // clip it since it is used for bunny scroll in doom I    HWD.pfnDrawPolygon( NULL, v, 4, BLENDMODE | PF_Clip | PF_NoZClip | PF_NoDepthTest);}// // HWR_DrawMappedPatch(): Like HWR_DrawPatch but with translated color//void HWR_DrawMappedPatch (GlidePatch_t* gpatch, int x, int y, byte *colormap){    FOutVector      v[4];    // make patch ready in hardware cache    HWR_GetMappedPatch (gpatch, colormap);    if ( gr_scale_patch ) {        v[0].x = v[3].x = (x-gpatch->leftoffset-160.0f)/160.0f;        v[2].x = v[1].x = (x-gpatch->leftoffset+gpatch->width-160.0f)/160.0f;        v[0].y = v[1].y = -(y-gpatch->topoffset-100.0f)/100.0f;        v[2].y = v[3].y = -(y-gpatch->topoffset+gpatch->height-100.0f)/100.0f;    }    else {        v[0].x = v[3].x = ((x-gpatch->leftoffset-vid.width/2.0f)/(vid.width/2.0f));        v[2].x = v[1].x = ((x-gpatch->leftoffset+gpatch->width-vid.width/2.0f)/(vid.width/2.0f));        v[0].y = v[1].y = -((y-gpatch->topoffset-vid.height/2.0f)/(vid.height/2.0f));        v[2].y = v[3].y = -((y-gpatch->topoffset+gpatch->height-vid.height/2.0f)/(vid.height/2.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 = gpatch->max_s;    v[0].tow = v[1].tow = 0.0f;    v[2].tow = v[3].tow = gpatch->max_t;    // clip it since it is used for bunny scroll in doom I    HWD.pfnDrawPolygon( NULL, v, 4, BLENDMODE | PF_Clip | PF_NoZClip | PF_NoDepthTest);}// this one doesn't scale at all// Hurdler: ca fait quoi cette proc???// BP: Bein sa draw des patch non scaled (scale = retresisement ou agrendisement)!// Hurdler: mouahahah... zonder big blague? //          Are you sure this function is called by another one?void HWR_DrawNonScaledPatch (GlidePatch_t* gpatch, int x, int y){    FOutVector      v[4];    int             x2,y2;    // make patch ready in hardware cache    HWR_GetPatch (gpatch);//  3--2//  | /|//  |/ | //  0--1        x -= gpatch->leftoffset;    y -= gpatch->topoffset;    x2 = x + gpatch->width;    y2 = y + gpatch->height;    v[0].x = v[3].x = (float)x;    v[2].x = v[1].x = (float)x2;    v[0].y = v[1].y = -(float)y;    v[2].y = v[3].y = -(float)y2;    v[0].oow = v[1].oow = v[2].oow = v[3].oow = 1.0f;    v[0].sow = v[3].sow = 0;//.5f;    v[2].sow = v[1].sow = gpatch->max_s;//+0.5f;    v[0].tow = v[1].tow = 0;//.5f;    v[2].tow = v[3].tow = gpatch->max_t;//+0.5f;    HWD.pfnDrawPolygon( NULL, v, 4, PF_Translucent | PF_NoDepthTest);}void HWR_DrawPic(int x, int y, int lumpnum){    FOutVector      v[4];    GlidePatch_t    *patch;    // make pic ready in hardware cache    patch = HWR_GetPic( lumpnum );    //  3--2//  | /|//  |/ |//  0--1        v[0].x = v[3].x = (x - 160.0f)/160.0f;    v[2].x = v[1].x = ((x+patch->width) - 160.0f)/160.0f;    v[0].y = v[1].y = -(y - 100.0f)/100.0f;    v[2].y = v[3].y = -((y+patch->height) - 100.0f)/100.0f;    v[0].oow = v[1].oow = v[2].oow = v[3].oow = 1.0f;    v[0].sow = v[3].sow =  0;    v[2].sow = v[1].sow =  patch->max_s;    v[0].tow = v[1].tow =  0;    v[2].tow = v[3].tow =  patch->max_t;    //Hurdler: Boris, the same comment as above... but maybe for pics    // it not a problem since they don't have any transparent pixel    // if I'm right !?     // But then, the question is: why not 0 instead of PF_Masked ?    // or maybe PF_Environment ??? (like what I said above)    // BP: PF_Environment don't change anything ! and 0 is undifined    HWD.pfnDrawPolygon( NULL, v, 4, BLENDMODE | PF_NoDepthTest | PF_Clip | PF_NoZClip); //PF_Masked); //PF_Translucent );}// ==========================================================================//                                                            V_VIDEO.C STUFF// ==========================================================================// --------------------------------------------------------------------------// Fills a box of pixels using a flat texture as a pattern// --------------------------------------------------------------------------void HWR_DrawFlatFill (int x, int y, int w, int h, int flatlumpnum){    FOutVector  v[4];//  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;    v[0].oow = v[1].oow = v[2].oow = v[3].oow = 1.0f;    // flat is 64x64 lod and texture offsets are [0.0, 1.0]    v[0].sow = v[3].sow = (x & 63)/64.0f;    v[2].sow = v[1].sow = v[0].sow + w/64.0f;    v[0].tow = v[1].tow = (y & 63)/64.0f;    v[2].tow = v[3].tow = v[0].tow + h/64.0f;    HWR_GetFlat (flatlumpnum);    //Hurdler: Boris, the same comment as above... but maybe for pics    // it not a problem since they don't have any transparent pixel    // if I'm right !?    // BTW, I see we put 0 for PFs, and If I'm right, that    // means we take the previous PFs as default    // how can we be sure they are ok?

⌨️ 快捷键说明

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