📄 i_video_3dfx.c
字号:
// Emacs style mode select -*- C++ -*- //-----------------------------------------------------------------------------//// $Id: i_video_3dfx.c,v 1.4 2001/04/27 13:32:14 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: i_video_3dfx.c,v $// Revision 1.4 2001/04/27 13:32:14 bpereira// no message//// Revision 1.3 2000/11/02 19:49:40 bpereira// no message//// 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:// Inspired from Voodoo 3DFX framebuffer module by Udo Munk <um@compuserve.com>////-----------------------------------------------------------------------------#include <stdio.h>#include <unistd.h>#include <termios.h>#include <glide.h>#include <signal.h>#include <fcntl.h>#include <assert.h>#include <sys/ioctl.h>#include <sys/kd.h>#include "doomstat.h"#include "d_main.h"#include "i_system.h"#include "i_video.h"#include "v_video.h"/* * Select one of the possible render modes. * If you don't have a SGI Octane or a 1000MHz Pentium CPU, drawing * anti-aliased pixels is to slow and the result doesn't look that * much better then simply doubling the pixels anyway. */#define RENDER_LFB /* fast direct framebuffer writes *//*#define RENDER_AAP*/ /* anti-aliased pixels *//* * Define one of the framebuffer formats, 24bit colors (888) is pretty * hefty and should be used on systems better then Pentium 200 only. * Both formats look the same because the Doom engine uses 256 color * textures only anyway, so 555 is the default because it's a lot faster. */#define FRAMEBUFFER_FORMAT GR_LFB_SRC_FMT_555/*#define FRAMEBUFFER_FORMAT GR_LFB_SRC_FMT_888*//* pixel format and bytes per pixel in the framebuffer */#if (FRAMEBUFFER_FORMAT == GR_LFB_SRC_FMT_888)typedef FxU32 pixel_t;#define BPP 4#elsetypedef FxU16 pixel_t;#define BPP 2#endif/* * The resolution we use on the 3DFX */#define DFX_WIDTH 640#define DFX_HEIGHT 400static void keyboard_events(void);static int xlatekey(int);/* colormap */#ifdef RENDER_LFBstatic pixel_t colors[256];#elsestatic float colors[3][256];#endif/* image to write to framebuffer */#ifdef RENDER_LFBstatic pixel_t image[DFX_WIDTH * DFX_HEIGHT];#endif/* vertex for anti-aliased pixel rendering */#ifdef RENDER_AAPstatic GrVertex vertex;#endif/* line discipline */static struct termios term;/* stdio I/O flag */static int io_flag;void I_InitGraphics(void){ char version[80]; struct termios t; /* make sure that signals bring us back into text mode */ signal(SIGINT, (void (*)(int)) I_Quit); signal(SIGQUIT, (void (*)(int)) I_Quit); signal(SIGHUP, (void (*)(int)) I_Quit); signal(SIGTERM, (void (*)(int)) I_Quit); /* get and print glide version used */ grGlideGetVersion(version); fprintf(stderr, "Using glide version %s\n", version); /* initialize glide */ grGlideInit(); grSstSelect(0); assert(grSstWinOpen(0, GR_RESOLUTION_640x400, GR_REFRESH_75Hz, GR_COLORFORMAT_ARGB, GR_ORIGIN_UPPER_LEFT, 2, 1)); /* setup renderering engine */ grDitherMode(GR_DITHER_DISABLE);#ifdef RENDER_AAP grAlphaCombine(GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, GR_COMBINE_LOCAL_ITERATED, GR_COMBINE_OTHER_NONE, FXFALSE); grAlphaBlendFunction(GR_BLEND_SRC_ALPHA, GR_BLEND_ONE_MINUS_SRC_ALPHA, GR_BLEND_ZERO, GR_BLEND_ZERO); vertex.a = 255.0f;#endif /* set keyboard into keycode mode */ ioctl(fileno(stdin), KDSKBMODE, K_MEDIUMRAW); /* save line discipline and set into raw mode */ tcgetattr(fileno(stdin), &term); t = term; t.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG); t.c_iflag &= ~(IMAXBEL | IGNBRK | IGNCR | IGNPAR | BRKINT | INLCR | ICRNL | INPCK | ISTRIP | IXON | IUCLC | IXANY | IXOFF); t.c_cflag &= ~(CSIZE | PARENB); t.c_cflag |= CS8; t.c_oflag &= ~(OCRNL | OLCUC | ONLCR | OPOST); t.c_cc[VMIN] = 1; t.c_cc[VTIME] = 0; tcsetattr(fileno(stdin), TCSAFLUSH, &t); /* save I/O flags and set into non blocking mode */ io_flag = fcntl(fileno(stdin), F_GETFL); fcntl(fileno(stdin), F_SETFL, O_RDONLY | O_NONBLOCK);}void I_ShutdownGraphics(void){ /* shutdown glide and return to text mode */ grGlideShutdown(); /* reset keyboard to xlate mode */ ioctl(fileno(stdin), KDSKBMODE, K_XLATE); /* restore line discipline */ tcsetattr(fileno(stdin), TCSAFLUSH, &term); /* restore I/O flag */ fcntl(fileno(stdin), F_SETFL, io_flag);}void I_FinishUpdate(void){ int x, y; static int lasttic; int tics; int i; unsigned char *src = (unsigned char *) screens[0];#ifdef RENDER_LFB pixel_t pixel; pixel_t *dst1 = &image[0]; pixel_t *dst2 = &image[SCREENWIDTH*2]; int step = SCREENWIDTH*2;#endif /* draws little dots on the bottom of the screen */ if (devparm) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -