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

📄 i_video.c

📁 The source code of Doom legacy for windows
💻 C
📖 第 1 页 / 共 2 页
字号:
}//// I_UpdateNoBlit//void I_UpdateNoBlit(void){    /* empty */}//// I_FinishUpdate//void I_FinishUpdate(void){    if(render_soft == rendermode)    {        if(screens[0] != vid.direct)        {            memcpy(vid.direct, screens[0], vid.width*vid.height*vid.bpp);            //screens[0] = vid.direct; //FIXME: we MUST render directly into the surface        }	        //SDL_Flip(vidSurface);        SDL_UpdateRect(vidSurface, 0, 0, 0, 0);                if(SDL_MUSTLOCK(vidSurface))         {            SDL_UnlockSurface(vidSurface);        }    }    else    {        OglSdlFinishUpdate(cv_vidwait.value);    }        I_GetEvent();        return;}//// I_ReadScreen//void I_ReadScreen(byte* scr){    if (rendermode != render_soft)        I_Error ("I_ReadScreen: called while in non-software mode");        memcpy (scr, screens[0], vid.width*vid.height*vid.bpp);}//// I_SetPalette//void I_SetPalette(RGBA_t* palette){    int i;    for(i=0; i<256; i++)    {        localPalette[i].r = palette[i].s.red;        localPalette[i].g = palette[i].s.green;        localPalette[i].b = palette[i].s.blue;    }        SDL_SetColors(vidSurface, localPalette, 0, 256);    return;}// return number of fullscreen + X11 modesint   VID_NumModes(void) {    if(cv_fullscreen.value)         return numVidModes - firstEntry;    else        return MAXWINMODES;}char  *VID_GetModeName(int modeNum) {    if(cv_fullscreen.value) { // fullscreen modes        modeNum += firstEntry;        if(modeNum >= numVidModes)            return NULL;                sprintf(&vidModeName[modeNum][0], "%dx%d",                modeList[modeNum]->w,                modeList[modeNum]->h);    }    else { // windowed modes        if(modeNum > MAXWINMODES)            return NULL;                sprintf(&vidModeName[modeNum][0], "win %dx%d",                windowedModes[modeNum][0],                windowedModes[modeNum][1]);    }    return &vidModeName[modeNum][0];}int VID_GetModeForSize(int w, int h) {    int matchMode, i;        if(cv_fullscreen.value)    {        matchMode=-1;                for(i=firstEntry; i<numVidModes; i++)        {            if(modeList[i]->w == w &&               modeList[i]->h == h)            {                matchMode = i;                break;            }        }        if(-1 == matchMode) // use smallest mode        {            matchMode = numVidModes-1;        }        matchMode -= firstEntry;    }    else    {        matchMode=-1;                for(i=0; i<MAXWINMODES; i++)        {            if(windowedModes[i][0] == w &&               windowedModes[i][1] == h)            {                matchMode = i;                break;            }        }                if(-1 == matchMode) // use smallest mode        {            matchMode = MAXWINMODES-1;        }    }        return matchMode;}void VID_PrepareModeList(void){    int i;        if(cv_fullscreen.value) // only fullscreen needs preparation    {        if(-1 != numVidModes)         {            for(i=0; i<numVidModes; i++)            {                if(modeList[i]->w <= MAXVIDWIDTH &&                   modeList[i]->h <= MAXVIDHEIGHT)                {                    firstEntry = i;                    break;                }            }        }    }        allow_fullscreen = true;    return;}int VID_SetMode(int modeNum) {    doUngrabMouse();    if(cv_fullscreen.value)    {        modeNum += firstEntry;                vid.width = modeList[modeNum]->w;        vid.height = modeList[modeNum]->h;        vid.rowbytes = vid.width * vid.bpp;        vid.recalc = true;                if(render_soft == rendermode)        {            SDL_FreeSurface(vidSurface);            free(vid.buffer);                        vidSurface = SDL_SetVideoMode(vid.width, vid.height, BitsPerPixel, surfaceFlags|SDL_FULLSCREEN);            if(NULL == vidSurface)            {                I_Error("Could not set vidmode\n");            }                        vid.buffer = malloc(vid.width * vid.height * vid.bpp * NUMSCREENS);                        vid.direct = vidSurface->pixels; // FIXME        }        else // (render_soft == rendermode)        {            if(!OglSdlSurface(vid.width, vid.height, cv_fullscreen.value))            {                I_Error("Could not set vidmode\n");            }                    }	vid.modenum = modeNum-firstEntry;    }    else //(cv_fullscreen.value)    {        vid.width = windowedModes[modeNum][0];        vid.height = windowedModes[modeNum][1];        vid.rowbytes = vid.width * vid.bpp;        vid.recalc = true;                // Window title        SDL_WM_SetCaption("Legacy", "Legacy");                if(render_soft == rendermode)        {            SDL_FreeSurface(vidSurface);            free(vid.buffer);                        vidSurface = SDL_SetVideoMode(vid.width, vid.height, BitsPerPixel, surfaceFlags);                        if(NULL == vidSurface)            {                I_Error("Could not set vidmode\n");            }                        vid.buffer = malloc(vid.width * vid.height * vid.bpp * NUMSCREENS);            vid.direct = vidSurface->pixels; // FIXME        }        else //(render_soft == rendermode)        {            if(!OglSdlSurface(vid.width, vid.height, cv_fullscreen.value))            {                I_Error("Could not set vidmode\n");            }        }	vid.modenum = modeNum;    }        I_StartupMouse();    return 1;}void I_StartupGraphics(void){    if(graphics_started)        return;        CV_RegisterVar (&cv_vidwait);    // Initialize Audio as well, otherwise DirectX can not use audio    if(SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0)    {        CONS_Printf("Couldn't initialize SDL: %s\n", SDL_GetError());        return;    }        // Get video info for screen resolutions    //videoInfo = SDL_GetVideoInfo();    // even if I set vid.bpp and highscreen properly it does seem to    // support only 8 bit  ...  strange    // so lets force 8 bit    BitsPerPixel = 8;        // Set color depth; either 1=256pseudocolor or 2=hicolor    vid.bpp = 1 /*videoInfo->vfmt->BytesPerPixel*/;    highcolor = (vid.bpp == 2) ? true:false;        modeList = SDL_ListModes(NULL, SDL_FULLSCREEN|surfaceFlags);    if(NULL == modeList)    {        CONS_Printf("No video modes present\n");        return;    }        numVidModes=0;    if(NULL != modeList)    {        while(NULL != modeList[numVidModes])            numVidModes++;    }    else        // should not happen with fullscreen modes        numVidModes = -1;        //CONS_Printf("Found %d Video Modes\n", numVidModes);        // default size for startup    vid.width = BASEVIDWIDTH;    vid.height = BASEVIDHEIGHT;    vid.rowbytes = vid.width * vid.bpp;    vid.recalc = true;    // Window title    SDL_WM_SetCaption("Legacy", "Legacy");    if(M_CheckParm("-opengl"))     {       rendermode = render_opengl;       HWD.pfnInit             = hwSym("Init");       HWD.pfnFinishUpdate     = hwSym("FinishUpdate");       HWD.pfnDraw2DLine       = hwSym("Draw2DLine");       HWD.pfnDrawPolygon      = hwSym("DrawPolygon");       HWD.pfnSetBlend         = hwSym("SetBlend");       HWD.pfnClearBuffer      = hwSym("ClearBuffer");       HWD.pfnSetTexture       = hwSym("SetTexture");       HWD.pfnReadRect         = hwSym("ReadRect");       HWD.pfnGClipRect        = hwSym("GClipRect");       HWD.pfnClearMipMapCache = hwSym("ClearMipMapCache");       HWD.pfnSetSpecialState  = hwSym("SetSpecialState");       HWD.pfnSetPalette       = hwSym("SetPalette");       HWD.pfnGetTextureUsed   = hwSym("GetTextureUsed");       HWD.pfnDrawMD2          = hwSym("DrawMD2");       HWD.pfnSetTransform     = hwSym("SetTransform");       HWD.pfnGetRenderVersion = hwSym("GetRenderVersion");       // check gl renderer lib       if (HWD.pfnGetRenderVersion() != VERSION)       {           I_Error ("The version of the renderer doesn't match the version of the executable\nBe sure you have installed Doom Legacy properly.\n");       }       vid.width = 640; // hack to make voodoo cards work in 640x480       vid.height = 480;       if(!OglSdlSurface(vid.width, vid.height, cv_fullscreen.value))           rendermode = render_soft;    }        if(render_soft == rendermode)    {           vidSurface = SDL_SetVideoMode(vid.width, vid.height, BitsPerPixel, surfaceFlags);                if(NULL == vidSurface)        {            CONS_Printf("Could not set vidmode\n");            return;        }        vid.buffer = malloc(vid.width * vid.height * vid.bpp * NUMSCREENS);        vid.direct = vidSurface->pixels; // FIXME    }            SDL_ShowCursor(0);    doUngrabMouse();    graphics_started = 1;        return;}void I_ShutdownGraphics(void){    // was graphics initialized anyway?    if (!graphics_started)        return;    if(render_soft == rendermode)    {        if(NULL != vidSurface)        {            SDL_FreeSurface(vidSurface);            vidSurface = NULL;        }    }    else    {        OglSdlShutdown();    }        SDL_Quit();   }

⌨️ 快捷键说明

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