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

📄 r_d3d_old.cpp

📁 The source code of Doom legacy for windows
💻 CPP
📖 第 1 页 / 共 5 页
字号:

        case HWD_SET_ALPHABLEND:
            if (Value == HWD_ALPHABLEND_NONE)
            {
                grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO);
                grAlphaTestFunction (GR_CMP_ALWAYS);
            }
            else
            if (Value == HWD_ALPHABLEND_TRANSLUCENT)
            {
                grAlphaBlendFunction (GR_BLEND_SRC_ALPHA,
                                      GR_BLEND_ONE_MINUS_SRC_ALPHA,
                                      GR_BLEND_ONE,
                                      GR_BLEND_ZERO );
            }
            break;

        case HWD_SET_TEXTURECLAMP:
            if (Value == HWD_TEXTURE_CLAMP_XY)
            {
                grTexClampMode (GR_TMU0, GR_TEXTURECLAMP_CLAMP, GR_TEXTURECLAMP_CLAMP);
            }
            else if (Value == HWD_TEXTURE_WRAP_XY)
            {
                grTexClampMode (GR_TMU0, GR_TEXTURECLAMP_WRAP, GR_TEXTURECLAMP_WRAP);
            }
            break;

        case HWD_SET_TEXTURECOMBINE:
            if (Value == HWD_TEXTURECOMBINE_NORMAL)
            {
                grTexCombine (GR_TMU0, GR_COMBINE_FUNCTION_LOCAL,
                                   GR_COMBINE_FACTOR_NONE,
                                   GR_COMBINE_FUNCTION_LOCAL,
                                   GR_COMBINE_FACTOR_NONE,
                                   FXFALSE, FXFALSE );
            }
            break;

        case HWD_SET_TEXTUREFILTERMODE:
            if (Value == HWD_SET_TEXTUREFILTER_BILINEAR)
            {
                grTexFilterMode (GR_TMU0, GR_TEXTUREFILTER_BILINEAR,
                                          GR_TEXTUREFILTER_BILINEAR);
            }
            else if (Value == HWD_SET_TEXTUREFILTER_POINTSAMPLED)
            {
                grTexFilterMode (GR_TMU0, GR_TEXTUREFILTER_POINT_SAMPLED,
                                          GR_TEXTUREFILTER_POINT_SAMPLED);
            }
            break;

        case HWD_SET_MIPMAPMODE:
            if (Value == HWD_MIPMAP_DISABLE)
            {
                grTexMipMapMode (GR_TMU0,
                                 GR_MIPMAP_DISABLE,         // no mipmaps based on depth
                                 FXFALSE );
            }
            break;

        //!!!hardcoded 3Dfx Value!!!
        case HWD_SET_ALPHATESTFUNC:
            grAlphaTestFunction (Value);
            break;

        //!!!hardcoded 3Dfx Value!!!
        case HWD_SET_ALPHATESTREFVALUE:
            grAlphaTestReferenceValue ((unsigned char)Value);
            break;
        
        case HWD_SET_ALPHASOURCE:
            if (Value == HWD_ALPHASOURCE_CONSTANT)
            {
                // constant color alpha
                grAlphaCombine( GR_COMBINE_FUNCTION_LOCAL_ALPHA,
                                GR_COMBINE_FACTOR_NONE,
                                GR_COMBINE_LOCAL_CONSTANT,
                                GR_COMBINE_OTHER_NONE,
                                FXFALSE );
            }
            else if (Value == HWD_ALPHASOURCE_TEXTURE)
            {
                // 1 * texture alpha channel
                grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,
                    GR_COMBINE_FACTOR_ONE,
                    GR_COMBINE_LOCAL_NONE,
                    GR_COMBINE_OTHER_TEXTURE,
                    FXFALSE );
            }
            break;

        case HWD_ENABLE:
            if (Value == HWD_SHAMELESS_PLUG)
                grEnable (GR_SHAMELESS_PLUG);
            break;

        case HWD_DISABLE:
            if (Value == HWD_SHAMELESS_PLUG)
                grDisable (GR_SHAMELESS_PLUG);
            break;

        case HWD_SET_FOG_TABLE:
            grFogTable ((unsigned char *)Value);
            break;

        case HWD_SET_FOG_COLOR:
            grFogColorValue (Value);
            break;

        case HWD_SET_FOG_MODE:
            if (Value == HWD_FOG_DISABLE)
                grFogMode (GR_FOG_DISABLE);
            else if (Value == HWD_FOG_ENABLE)
                grFogMode (GR_FOG_WITH_TABLE_ON_Q);
            break;

        case HWD_SET_CHROMAKEY_MODE:
            if (Value == HWD_CHROMAKEY_ENABLE)
                grChromakeyMode (GR_CHROMAKEY_ENABLE);
            break;

        case HWD_SET_CHROMAKEY_VALUE:
            grChromakeyValue (Value);
            break;

        default:
            break;
    }
*/
}


// ==========================================================================
// Read a rectangle region of the truecolor framebuffer
// store pixels as 16bit 565 RGB
// ==========================================================================
EXPORT void HWRAPI( ReadRect ) (int x, int y, int width, int height,
                                int dst_stride, unsigned short * dst_data)
{
    DBG_Printf ("ReadRect()\r\n");
    //grLfbReadRegion (GR_BUFFER_FRONTBUFFER,
    //                 x, y, width, height, dst_stride, dst_data);
}


// ==========================================================================
// Defines the 2D hardware clipping window
// ==========================================================================
EXPORT void HWRAPI( ClipRect ) (int minx, int miny, int maxx, int maxy)
{
    DBG_Printf ("ClipRect()\r\n");
    //grClipWindow ( (DWORD)minx, (DWORD)miny, (DWORD)maxx, (DWORD)maxy);
}


// ==========================================================================
// Clear the color/alpha/depth buffer(s)
// ==========================================================================
EXPORT void HWRAPI( ClearBuffer ) (int color, int alpha, hwdcleardepth_t depth)
{
    DBG_Printf ("ClearBuffer()\r\n");
    //grBufferClear ((GrColor_t)color, (GrAlpha_t)alpha, gr_wrange[depth]);
}


// ==========================================================================
//
// ==========================================================================
EXPORT void HWRAPI( DrawLine ) (wallVert2D* v1, wallVert2D* v2) 
{
    //grDrawLine (v1, v2);
}


// ==========================================================================
//
// ==========================================================================
EXPORT void HWRAPI( GetState ) (hwdgetstate_t IdState, void* dest)
{
    DBG_Printf ("GetState()\r\n");
/*
    if (IdState == HWD_GET_FOGTABLESIZE)
    {
        grGet (GR_FOG_TABLE_ENTRIES, 4, dest);
    }
*/
}


// ==========================================================================
// Draw a triangulated polygon
// ==========================================================================
EXPORT void HWRAPI( DrawPolygon ) (wallVert2D *projVerts, int nClipVerts, unsigned long col)
{
/*
    int nTris;
    int i;

    if (nClipVerts < 3)
        return;

    nTris = nClipVerts-2;
    
    // triangles fan
    for(i=0; i < nTris; i++)
    {
        // set some weird colours
        projVerts[0].argb = col;
        projVerts[i+1].argb = col | 0x80;
        projVerts[i+2].argb = col | 0xf0;

        //FIXME: 3Dfx : check for 'crash' coordinates if not clipped
        if (projVerts[0].x > 1280.0f ||
            projVerts[0].x < -640.0f)
            goto skip;
        if (projVerts[0].y > 900.0f ||
            projVerts[0].y < -500.0f)
            goto skip;
        if (projVerts[i+1].x > 1280.0f ||
            projVerts[i+1].x < -640.0f)
            goto skip;
        if (projVerts[i+1].y > 900.0f ||
            projVerts[i+1].y < -500.0f)
            goto skip;
        if (projVerts[i+2].x > 1280.0f ||
            projVerts[i+2].x < -640.0f)
            goto skip;
        if (projVerts[i+2].y > 900.0f ||
            projVerts[i+2].y < -500.0f)
            goto skip;
        
        grDrawTriangle ( projVerts,
                         &projVerts[i + 1],
                         &projVerts[i + 2] );
skip:
        col = col + 0x002000;
    }
*/
}



//****************************************************************************
// D3D_Text                                                              *
//****************************************************************************
void D3D_Text(unsigned x, unsigned y, unsigned scale, char* format, ...)
{

    va_list args;
    char buffer[1024];

    va_start(args, format);
    vsprintf(buffer, format, args);
    va_end(args);

    // Print to D3D output
}

/*
//---------------------------------------------------------------------------
// Set to flat shading.
// This code fragment assumes that lpDev3 is a valid pointer to 
// an IDirect3DDevice3 interface.
    hr = lpDev3->SetRenderState(D3DRENDERSTATE_SHADEMODE, D3DSHADE_FLAT);
    if(FAILED(hr))
    {
        // Code to handle the error goes here.
    }
 
    // Set to Gouraud shading (this is the default for Direct3D).
    hr = lpDev3->SetRenderState(D3DRENDERSTATE_SHADEMODE,
                                D3DSHADE_GOURAUD);
    if(FAILED(hr))
    {
        // Code to handle the error goes here.
    }


//---------------------------------------------------------------------------
    D3DVERTEX lpVertices[3];
 
    // A vertex can be specified one structure member at a time.
    lpVertices[0].x = 0;
    lpVertices[0].y = 5;
    lpVertices[0].z = 5;
    lpVertices[0].nx = 0;    // X component of the normal vector.
    lpVertices[0].ny = 0;    // Y component of the normal vector.
    lpVertices[0].nz = -1;   // Points the normal back at the origin.
    lpVertices[0].tu = 0;    // Only used if a texture is being used.
    lpVertices[0].tv = 0;    // Only used if a texture is being used.
 
    // Vertices can also by specified on one line of code for each vertex
    // by using some of the D3DOVERLOADS macros.
    lpVertices[1] = D3DVERTEX(D3DVECTOR(-5,-5,5),D3DVECTOR(0,0,-1),0,0);
    lpVertices[2] = D3DVERTEX(D3DVECTOR(5,-5,5),D3DVECTOR(0,0,-1),0,0);

//----------------------------------------------------------------------------
    An application uses the dwShadeCaps member of the D3DPRIMCAPS structure to
        determine what forms of interpolation the current device driver supports. 

//----------------------------------------------------------------------------
    DirectDrawCreate
    You can call the IDirect3D3::CreateDevice method to create a Direct3DDevice
    object and retrieve an IDirect3DDevice3 interface.

//----------------------------------------------------------------------------

The Direct3D Immediate Mode API consists primarily of the following COM interfaces: 

IDirect3D3                  Root interface, used to obtain other interfaces
IDirect3DDevice         3D Device for execute-buffer based programming
IDirect3DDevice3            3D Device for DrawPrimitive-based programming
IDirect3DLight          Interface used to work with lights
IDirect3DMaterial3          Surface-material interface
IDirect3DTexture2           Texture-map interface
IDirect3DVertexBuffer   Interface used to work with vertex buffers.
IDirect3DViewport3          Interface to define the viewport's characteristics.
IDirect3DExecuteBuffer  Interface for working with execute buffers

*/

static char* DDErr(HRESULT hresult)
{
    static char errmsg[128];
    static char msgtxt[128];
    switch(hresult)
    {
        case DD_OK:
             strcpy(errmsg,"The request completed successfully.");
             break;

        case DDERR_ALREADYINITIALIZED:
             strcpy(errmsg,"The object has already been initialized.");
             break;

        case DDERR_BLTFASTCANTCLIP:
             strcpy(errmsg,"A DirectDrawClipper object is attached to a source surface that has passed into a call to the IDirectDrawSurface2::BltFast method.");
             break;

        case DDERR_CANNOTATTACHSURFACE:
             strcpy(errmsg,"A surface cannot be attached to another requested surface.");
             break;

        case DDERR_CANNOTDETACHSURFACE:
             strcpy(errmsg,"A surface cannot be detached from another requested surface.");
             break;

        case DDERR_CANTCREATEDC:
             strcpy(errmsg,"Windows cannot create any more device contexts (DCs).");
             break;

        case DDERR_CANTDUPLICATE:
             strcpy(errmsg,"Primary and 3D surfaces, or surfaces that are implicitly created, cannot be duplicated.");
             break;

        case DDERR_CANTLOCKSURFACE:
             strcpy(errmsg,"Access to this surface is refused because an attempt was made to lock the primary surface without DCI support.");
             break;

        case DDERR_CANTPAGELOCK:
             strcpy(errmsg,"An attempt to page lock a surface failed. Page lock will not work on a display-memory surface or an emulated primary surface.");
             break;

        case DDERR_CANTPAGEUNLOCK:

⌨️ 快捷键说明

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