コード例 #1
0
ファイル: drv_api.c プロジェクト: dborca/sage
int
sage_init (void)
{
    const char *str;

    if (hardware >= 0) {
	return (hardware >= GR_SSTTYPE_Voodoo4) ? 32 : 16;
    }

    grGlideInit();

    if (getInteger(GR_NUM_BOARDS) <= 0) {
	grGlideShutdown();
	return 0;
    }

    if (cfg_load("sage.ini") != 0) {
	cfg_load("/etc/sage.ini");
    }

    grSstSelect(0);

    hardware = getHardware();

    strcpy(renderer_name, "SAGE ");
    str = grGetString(GR_RENDERER);
    strcat(renderer_name, str);
    strcat(renderer_name, " ");
    str = grGetString(GR_VERSION);
    strcat(renderer_name, str);

    str = grGetString(GR_EXTENSION);
    hwext_texuma = (strstr(str, "TEXUMA") != NULL);
    hwext_texmirror = (strstr(str, "TEXMIRROR") != NULL);
    hwext_fogcoord = (strstr(str, "FOGCOORD") != NULL);
    hwext_texfmt = (strstr(str, "TEXFMT") != NULL);
    hwext_pixext = (strstr(str, "PIXEXT") != NULL);
    hwext_combine = (strstr(str, "COMBINE") != NULL);

    *(GrProc *)&gfGetRegistryOrEnvironmentStringExt = grGetProcAddress("grGetRegistryOrEnvironmentStringExt");
    *(GrProc *)&gfSstWinOpenExt = grGetProcAddress("grSstWinOpenExt");
    *(GrProc *)&gfBufferClearExt = grGetProcAddress("grBufferClearExt");
    *(GrProc *)&gfColorMaskExt = grGetProcAddress("grColorMaskExt");
    *(GrProc *)&gfStencilFuncExt = grGetProcAddress("grStencilFuncExt");
    *(GrProc *)&gfStencilMaskExt = grGetProcAddress("grStencilMaskExt");
    *(GrProc *)&gfStencilOpExt = grGetProcAddress("grStencilOpExt");
    *(GrProc *)&gfColorCombineExt = grGetProcAddress("grColorCombineExt");
    *(GrProc *)&gfAlphaCombineExt = grGetProcAddress("grAlphaCombineExt");
    *(GrProc *)&gfTexColorCombineExt = grGetProcAddress("grTexColorCombineExt");
    *(GrProc *)&gfTexAlphaCombineExt = grGetProcAddress("grTexAlphaCombineExt");
    *(GrProc *)&gfConstantColorValueExt = grGetProcAddress("grConstantColorValueExt");

    current = NULL;

    opengl_ver = cfg_get("3dfx.opengl.version", NULL);

    return (hardware >= GR_SSTTYPE_Voodoo4) ? 32 : 16;
}
コード例 #2
0
VNGError Vngo3Dfx::init()
{
    grGlideInit();
    if (!grSstQueryHardware (&hwconfig))
    {
        term();
        return (VNGO_MISSING_HARDWARE);
    }

    type_info = SCREENTYPE_3DFX;

    grSstSelect(0);
    return (VNGO_NO_ERROR);
}
コード例 #3
0
ファイル: fxclose.c プロジェクト: Almamu/homeworld
int main(void)
{
    GrHwConfiguration hwconfig;

    grGlideInit();

    if (grSstQueryHardware(&hwconfig))
    {
        grSstSelect(0);
        grSstWinOpen(0, GR_RESOLUTION_640x480, GR_REFRESH_60Hz,
                     GR_COLORFORMAT_ABGR, GR_ORIGIN_LOWER_LEFT,
                     2, 1);
        grSstControl(GR_CONTROL_DEACTIVATE);
        grGlideShutdown();
    }
    return 0;
}
コード例 #4
0
/*
 * Make the specified FX/Mesa context the current one.
 */
void GLAPIENTRY
fxMesaMakeCurrent(fxMesaContext fxMesa)
{
   if (!fxMesa) {
      _mesa_make_current(NULL, NULL, NULL);
      fxMesaCurrentCtx = NULL;

      if (TDFX_DEBUG & VERBOSE_DRIVER) {
	 fprintf(stderr, "fxMesaMakeCurrent(NULL)\n");
      }

      return;
   }

   /* if this context is already the current one, we can return early */
   if (fxMesaCurrentCtx == fxMesa
       && fxMesaCurrentCtx->glCtx == _mesa_get_current_context()) {
      if (TDFX_DEBUG & VERBOSE_DRIVER) {
	 fprintf(stderr, "fxMesaMakeCurrent(NOP)\n");
      }

      return;
   }

   if (TDFX_DEBUG & VERBOSE_DRIVER) {
      fprintf(stderr, "fxMesaMakeCurrent(...)\n");
   }

   if (fxMesaCurrentCtx)
      grGlideGetState((GrState *) fxMesaCurrentCtx->state);

   fxMesaCurrentCtx = fxMesa;

   grSstSelect(fxMesa->board);
   grGlideSetState((GrState *) fxMesa->state);

   _mesa_make_current(fxMesa->glCtx, fxMesa->glBuffer, fxMesa->glBuffer);

   fxSetupDDPointers(fxMesa->glCtx);
}
コード例 #5
0
ファイル: test15.c プロジェクト: basecq/q2dos
void main( int argc, char **argv) {
    char match; 
    char **remArgs;
    int  rv;

    GrScreenResolution_t resolution = GR_RESOLUTION_640x480;
    float                scrWidth   = 640.0f;
    float                scrHeight  = 480.0f;
    int frames                      = -1;

    float clipX, clipY, clipSize, clipSizeDelta, clipPosDelta;
    FxU32 zrange[2];

    /* Initialize Glide */
    grGlideInit();
    assert( hwconfig = tlVoodooType() );

    /* Process Command Line Arguments */
    while( rv = tlGetOpt( argc, argv, "nr", &match, &remArgs ) ) {
        if ( rv == -1 ) {
            printf( "Unrecognized command line argument\n" );
            printf( "%s %s\n", name, usage );
            printf( "Available resolutions:\n%s\n",
                    tlGetResolutionList() );
            return;
        }
        switch( match ) {
        case 'n':
            frames = atoi( remArgs[0] );
            break;
        case 'r':
            resolution = tlGetResolutionConstant( remArgs[0], 
                                                  &scrWidth, 
                                                  &scrHeight );
            break;
        }
    }

    tlSetScreen( scrWidth, scrHeight );

    version = grGetString( GR_VERSION );

    printf( "%s:\n%s\n", name, purpose );
    printf( "%s\n", version );
    printf( "Resolution: %s\n", tlGetResolutionString( resolution ) );
    if ( frames == -1 ) {
        printf( "Press A Key To Begin Test.\n" );
        tlGetCH();
    }
    
    grSstSelect( 0 );
    assert( grSstWinOpen(tlGethWnd(),
                         resolution,
                         GR_REFRESH_60Hz,
                         GR_COLORFORMAT_ABGR,
                         GR_ORIGIN_UPPER_LEFT,
                         2, 1 ) );
    
    tlConSet( 0.0f, 0.0f, 1.0f, 0.5f, 
              60, 15, 0xffffff );

    /* Set up Render State - iterated alpha + z buffering */
    grGet(GR_ZDEPTH_MIN_MAX, 8, zrange);  
    grVertexLayout(GR_PARAM_XY, 0, GR_PARAM_ENABLE);

    grColorCombine( GR_COMBINE_FUNCTION_LOCAL,
                    GR_COMBINE_FACTOR_NONE,
                    GR_COMBINE_LOCAL_CONSTANT,
                    GR_COMBINE_OTHER_NONE,
                    FXFALSE );
    
    clipX    = 0.2f;
    clipY    = 0.5f;
    clipSize = 0.3f;
    
    clipSizeDelta = 0.005f;
    clipPosDelta = 0.01f;

#define CLIPSIZE_MIN 0.05f
#define CLIPSIZE_MAX 0.6f

#define GRAY  0x00808080
#define BLACK 0x00000000

    tlConOutput( "+/- - grow/shrink clip rectangle\n" );
    tlConOutput( "a/d - clip window left/right \n" );
    tlConOutput( "w/s - clip window up/down \n" );
    tlConOutput( "Press any other key to quit\n" );
    while( frames-- && tlOkToRender()) {
        int x, y;
        GrVertex vtxA, vtxB, vtxC;
        int minx, miny, maxx, maxy;

        if (hwconfig == TL_VOODOORUSH) {
          tlGetDimsByConst(resolution,
                           &scrWidth, 
                           &scrHeight );
        
          grClipWindow(0, 0, (FxU32) scrWidth, (FxU32) scrHeight);
        }

        grClipWindow( (int)tlScaleX(0.0f),(int)tlScaleY(0.0f),
                      (int)tlScaleX(1.0f),(int)tlScaleY(1.0f) );
        grBufferClear( BLACK, 0, zrange[1] );

        /* Set Clipping Rectangle */
        minx = (int)tlScaleX(clipX);
        miny = (int)tlScaleY(clipY);
        if ( (clipX+clipSize)>1.0f ) 
            maxx = (int)tlScaleX( 1.0f );
        else 
            maxx = (int)tlScaleX( clipX + clipSize );
        if ( (clipY+clipSize)>1.0f ) 
            maxy = (int)tlScaleY( 1.0f );
        else 
            maxy = (int)tlScaleY( clipY + clipSize );
        grClipWindow( minx, miny, maxx, maxy );

        /* Draw 10x10 grid of triangles */
        for( y = 0; y < 10; y++ ) {
            for( x = 0; x < 10; x++ ) {
                /* 
                   A
                   |\
                   B-C
                 */
                vtxA.x = vtxB.x = tlScaleX( ((float)x)/10.0f );
                vtxA.y = tlScaleY( ((float)y)/10.0f );
                vtxB.y = vtxC.y = tlScaleY( (((float)y)/10.0f) + 0.1f );
                vtxC.x = tlScaleX( (((float)x)/10.0f) + 0.1f );
                
                grConstantColorValue( GRAY );
                grDrawTriangle( &vtxA, &vtxB, &vtxC );
            }
        }

        tlConRender();
        grBufferSwap( 1 );
        grFinish();
        
        while( tlKbHit() ) {
            switch( tlGetCH() ) {
            case '+':
                if ( clipSize < CLIPSIZE_MAX )
                    clipSize += clipSizeDelta;
                break;
            case '-':
                if ( clipSize > CLIPSIZE_MIN )
                    clipSize -= clipSizeDelta;
                break;
            case 'a':
            case 'A':
                if ( clipX > 0.0f )
                    clipX -= clipPosDelta;
                if ( clipX < 0.0f ) clipX = 0.0f;
                break;
            case 'd':
            case 'D':
                if ( clipX < 1.0f )
                    clipX += clipPosDelta;
                break;
            case 'w':
            case 'W':
                if ( clipY > 0.0f ) 
                    clipY -= clipPosDelta;
                if ( clipY < 0.0f ) clipY = 0.0f;
                break;
            case 's':
            case 'S':
                if ( clipY < 1.0f ) 
                    clipY += clipPosDelta;
                break;
            default:
                frames = 0;
                break;
            }
        }
    }
    
    grGlideShutdown();
    return;
}
コード例 #6
0
ファイル: test35.c プロジェクト: grakidov/Render3D
void main( int argc, char **argv) {
    char match; 
    char **remArgs;
    int  rv;

    GrScreenResolution_t resolution = GR_RESOLUTION_640x480;
    float                scrWidth   = 640.0f;
    float                scrHeight  = 480.0f;
    int frames                      = -1;
    FxBool               scrgrab = FXFALSE;
    char                 filename[256];
    int                  ftsize = 0;

    TlTexture  baseTexture;
    unsigned long baseTextureAddr;
    GrVertex vtxA, vtxB, vtxC, vtxD;
    FxBool texchroma = FXFALSE;
    char *extstr;

    GrProc grTexChromaModeExt = NULL;
    GrProc grTexChromaRangeExt = NULL;
    GrColor_t min = 0x00, max = 0x007f7f7f;
    FxU8 mincolor = 0x00;
    FxU8 maxcolor = 0x7f;
    FxFloat red = 1.7f, green = 1.7f, blue = 1.7f;

    /* Process Command Line Arguments */
    while( rv = tlGetOpt( argc, argv, "nrd", &match, &remArgs ) ) {
        if ( rv == -1 ) {
            printf( "Unrecognized command line argument\n" );
            printf( "%s %s\n", name, usage );
            printf( "Available resolutions:\n%s\n",
                    tlGetResolutionList() );
            return;
        }
        switch( match ) {
        case 'n':
            frames = atoi( remArgs[0] );
            break;
        case 'r':
            resolution = tlGetResolutionConstant( remArgs[0], 
                                                  &scrWidth, 
                                                  &scrHeight );
            break;
        case 'd':
            scrgrab = FXTRUE;
            frames = 1;
            strcpy(filename, remArgs[0]);
            break;
        }
    }

    tlSetScreen( scrWidth, scrHeight );

    version = grGetString( GR_VERSION );

    printf( "%s:\n%s\n", name, purpose );
    printf( "%s\n", version );
    printf( "Resolution: %s\n", tlGetResolutionString( resolution ) );
    if ( frames == -1 ) {
        printf( "Press A Key To Begin Test.\n" );
        tlGetCH();
    }
    
    /* Initialize Glide */
    grGlideInit();
    assert( hwconfig = tlVoodooType() );

    grSstSelect( 0 );
    assert( grSstWinOpen( 0,
                      resolution,
                      GR_REFRESH_60Hz,
                      GR_COLORFORMAT_ABGR,
                      GR_ORIGIN_UPPER_LEFT,
                      2, 1 ) );
    
    tlConSet( 0.0f, 0.0f, 1.0f, 1.0f, 
              60, 30, 0xffffff );

    grVertexLayout(GR_PARAM_XY,  GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE);
    grVertexLayout(GR_PARAM_Q,   GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
    grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);

    grColorCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,
                    GR_COMBINE_FACTOR_ONE,
                    GR_COMBINE_LOCAL_NONE,
                    GR_COMBINE_OTHER_TEXTURE,
                    FXFALSE );
    grTexMipMapMode( GR_TMU0,
                     GR_MIPMAP_NEAREST,
                     FXFALSE );
    grTexFilterMode( GR_TMU0,
                     GR_TEXTUREFILTER_BILINEAR,
                     GR_TEXTUREFILTER_BILINEAR );

    {
      /*
      ** texChroma extension
      */
      extension = grGetString(GR_EXTENSION);

      extstr = strstr(extension, "CHROMARANGE");
      if (!strncmp(extstr, "CHROMARANGE", 11)) {
        grTexChromaModeExt = grGetProcAddress("grTexChromaModeExt");
        grTexChromaRangeExt = grGetProcAddress("grTexChromaRangeExt");
      }
      grTexChromaModeExt(GR_TMU0, GR_TEXCHROMA_DISABLE_EXT);
      grTexChromaRangeExt(0, min, max, GR_TEXCHROMARANGE_RGB_ALL_EXT);
    }

    assert( tlLoadTexture( "miro.3df", 
                           &baseTexture.info, 
                           &baseTexture.tableType, 
                           &baseTexture.tableData ) );
    /* Download texture data to TMU */
    baseTextureAddr = grTexMinAddress( GR_TMU0 );
    grTexDownloadMipMap( GR_TMU0,
                         baseTextureAddr,
                         GR_MIPMAPLEVELMASK_BOTH,
                         &baseTexture.info );
    if ( baseTexture.tableType != NO_TABLE ) {
        grTexDownloadTable( baseTexture.tableType,
                            &baseTexture.tableData );
    }
    grTexCombine( GR_TMU0,
                  GR_COMBINE_FUNCTION_LOCAL,
                  GR_COMBINE_FACTOR_NONE,
                  GR_COMBINE_FUNCTION_LOCAL,
                  GR_COMBINE_FACTOR_NONE,
                  FXFALSE,
                  FXFALSE );
    grAlphaBlendFunction( GR_BLEND_ONE, GR_BLEND_ZERO,
                          GR_BLEND_ONE, GR_BLEND_ZERO );
    grTexSource( GR_TMU0,
                 baseTextureAddr,
                 GR_MIPMAPLEVELMASK_BOTH,
                 &baseTexture.info );
    grTexClampMode( GR_TMU0, GR_TEXTURECLAMP_WRAP, GR_TEXTURECLAMP_WRAP);

    {
      vtxA.x = tlScaleX( 0.2f );
      vtxA.y = tlScaleY( 0.2f );
      vtxA.oow = 1.0f;
      
      vtxB.x = tlScaleX( 0.8f );
      vtxB.y = tlScaleY( 0.2f ); 
      vtxB.oow = 1.0f;
      
      vtxC.x = tlScaleX( 0.2f );
      vtxC.y = tlScaleY( 0.8f );
      vtxC.oow = 1.0f;
      
      vtxD.x = tlScaleX( 0.8f ); 
      vtxD.y = tlScaleY( 0.8f );
      vtxD.oow = 1.0f;
      
      vtxA.tmuvtx[0].sow = 0.f;
      vtxA.tmuvtx[0].tow = 0.f;
      
      vtxB.tmuvtx[0].sow = 255.f;
      vtxB.tmuvtx[0].tow = 0.f;
      
      vtxC.tmuvtx[0].sow = 0.f;
      vtxC.tmuvtx[0].tow = 255.f;
      
      vtxD.tmuvtx[0].sow = 255.f;
      vtxD.tmuvtx[0].tow = 255.f;
    }
    
    tlConOutput( "Press a key to quit\n" );
    tlConOutput( "Press c to turn on/off texture chroma\n" );
    tlConOutput( "Press {/} to change max color range\n" );
    tlConOutput( "Press [/] to change min color range\n" );
    while( frames-- && tlOkToRender()) {
      char string[256], tmpstr[64];

      if (texchroma)
        strcpy(string, "");
      else
        strcpy(string, "");
      sprintf(tmpstr, " (%x,%x,%x) (%x,%x,%x) (%f %f %f)   \r", mincolor, mincolor, mincolor, maxcolor, maxcolor, maxcolor,red,green,blue);
      strcat(string, tmpstr);

      tlConOutput( string );

      if (hwconfig == TL_VOODOORUSH) {
        tlGetDimsByConst(resolution,
                         &scrWidth, 
                         &scrHeight );
        
        grClipWindow(0, 0, (FxU32) scrWidth, (FxU32) scrHeight);
      }

      grBufferClear( 0x3f3f3f, 0, 0 );
      
      grDrawTriangle( &vtxA, &vtxB, &vtxD );
      grDrawTriangle( &vtxA, &vtxD, &vtxC );
      
      tlConRender();
      grBufferSwap( 1 );
      
      /* grab the frame buffer */
      if (scrgrab) {
        if (!tlScreenDump(filename, (FxU16)scrWidth, (FxU16)scrHeight))
          printf( "Cannot open %s\n", filename);
        scrgrab = FXFALSE;
      }
      
      while( tlKbHit() ) {
        switch( tlGetCH() ) {
        case 'r':
          red -= 0.1f;
          guGammaCorrectionRGB(red, green, blue);
          break;
        case 'R':
          red += 0.1f;
          guGammaCorrectionRGB(red, green, blue);
          break;
        case 'g':
          green -= 0.1f;
          guGammaCorrectionRGB(red, green, blue);
          break;
        case 'G':
          green += 0.1f;
          guGammaCorrectionRGB(red, green, blue);
          break;
        case 'b':
          blue -= 0.1f;
          guGammaCorrectionRGB(red, green, blue);
          break;
        case 'B':
          blue += 0.1f;
          guGammaCorrectionRGB(red, green, blue);
          break;
        case 'c':
        case 'C':
          texchroma = !texchroma;
          if (texchroma)
            grTexChromaModeExt(GR_TMU0, GR_TEXCHROMA_ENABLE_EXT);
          else
            grTexChromaModeExt(GR_TMU0, GR_TEXCHROMA_DISABLE_EXT);
          break;
        case '{':
          if ((maxcolor > 0x00) && (maxcolor > mincolor))
            maxcolor--;
          max = (maxcolor << 16) | (maxcolor << 8) | maxcolor;
          grTexChromaRangeExt(0, min, max, GR_TEXCHROMARANGE_RGB_ALL_EXT);
          break;
        case '}':
          if (maxcolor < 0xff)
            maxcolor++;
          max = (maxcolor << 16) | (maxcolor << 8) | maxcolor;
          grTexChromaRangeExt(0, min, max, GR_TEXCHROMARANGE_RGB_ALL_EXT);
          break;
        case '[':
          if (mincolor > 0x00)
            mincolor--;
          min = (mincolor << 16) | (mincolor << 8) | mincolor;
          grTexChromaRangeExt(0, min, max, GR_TEXCHROMARANGE_RGB_ALL_EXT);
          break;
        case ']':
          if ((mincolor < 0xff) && (mincolor < maxcolor))
            mincolor++;
          min = (mincolor << 16) | (mincolor << 8) | mincolor;
          grTexChromaRangeExt(0, min, max, GR_TEXCHROMARANGE_RGB_ALL_EXT);
          break;
        default:
          frames = 0;
          break;
        }
      }
    }
    
    grGlideShutdown();
    return;
}
コード例 #7
0
ファイル: TEST13.C プロジェクト: grakidov/Render3D
void 
main(int argc, char **argv)
{
  float
    wWidth, wHeight;
  GrScreenResolution_t
    screenRes;
  int 
    numFrames = -1,
    frameCount = 0;
  int 
    i;
  wWidth = 640.f;
  wHeight = 480.f;
  screenRes = GR_RESOLUTION_640x480;

  if (argc > 1) {
    for(i = 1; i < argc; i++) {
      if (strstr(argv[i], "320x200")) {
        wWidth = 320.f; wHeight = 200.f;
        screenRes = GR_RESOLUTION_320x200;
      } else if (strstr(argv[i], "320x240")) {
        wWidth = 320.f; wHeight = 240.f;
        screenRes = GR_RESOLUTION_320x240;
      } else if (strstr(argv[i], "400x256")) {
        wWidth = 400.f; wHeight = 256.f;
        screenRes = GR_RESOLUTION_400x256;
      } else if (strstr(argv[i], "512x384")) {
        wWidth = 512.f; wHeight = 384.f;
        screenRes = GR_RESOLUTION_512x384;
      } else if (strstr(argv[i], "640x480")) {
        wWidth = 640.f; wHeight = 480.f;
        screenRes = GR_RESOLUTION_640x480;
      } else if (strstr(argv[i], "800x600")) {
        wWidth = 800.f; wHeight = 600.f;
        screenRes = GR_RESOLUTION_800x600;
      } else if (strstr(argv[i], "640x200")) {
        wWidth = 640.f; wHeight = 200.f;
        screenRes = GR_RESOLUTION_640x200;
      } else if (strstr(argv[i], "640x350")) {
        wWidth = 640.f; wHeight = 350.f;
        screenRes = GR_RESOLUTION_640x350;
      } else if (strstr(argv[i], "640x400")) {
        wWidth = 640.f; wHeight = 400.f;
        screenRes = GR_RESOLUTION_640x400;
      } else if (strstr(argv[i], "960x720")) {
        wWidth = 960.f; wHeight = 720.f;
        screenRes = GR_RESOLUTION_960x720;
      } else if (strstr(argv[i], "-n")) {
        if(argc > i + 1) {
          numFrames = atoi(argv[i + 1]);
          i++;
        } else {
          fprintf(stderr, "Usage: test13 {320x200|320x240|400x256|512x384|640x480|800x600|640x200|640x350|640x400|960x720} {-n numFrames}\n");
          exit(-1);
        } 
      } else {
        fprintf(stderr, "Usage: test13 {320x200|320x240|400x256|512x384|640x480|800x600} {-n numFrames}\n");
        exit(-1);
      }
    }
  }

  puts( "\nTEST13:" );
  puts( "backface culling test.  Green triangle should be backface" );
  puts( "culled, thus only a red triangle should be visible." );
  if(numFrames == -1)
  {
    puts( "Press a key to continue" );
    getch();
  }


  grGlideInit();

  if ( !grSstQueryHardware( &hwconfig ) )
  {
    fprintf( stderr, "main: grSstQueryHardware failed!\n" );
    grGlideShutdown();
    exit( -1 );
  }

  /*
  ** Select SST 0
  */
  grSstSelect( 0 );

  /*
  ** Open up the hardware
  */ 
  if ( !grSstOpen( screenRes,
                   GR_REFRESH_60Hz,
                   GR_COLORFORMAT_ABGR,
                   GR_ORIGIN_LOWER_LEFT,
                   GR_SMOOTHING_ENABLE,
                   2 ) )
  {
    fprintf( stderr, "main: grSstOpen failed!\n" );
    grGlideShutdown();
    exit( -1 );
  }

  /*
  ** Configure Glide to test backface culling
  */
  guColorCombineFunction( GR_COLORCOMBINE_CCRGB );
  grCullMode( GR_CULL_NEGATIVE );
  
  /*
  ** Render a green triangle on a red triangle.  The green triangle
  ** is clockwise and thus should not be rendered.  The red triangle
  ** is counterclockwise and should be rendered.
  */
  while ( 1 ) 
  {
    int i;
    GrVertex vtxlist[3];

    grBufferClear( 0, 0, 0 );

    vtxlist[0].x   = 160.f;
    vtxlist[0].y   = 100.f;

    vtxlist[1].x   = 320.f;
    vtxlist[1].y   = 380.f;

    vtxlist[2].x   = 480.f;
    vtxlist[2].y   = 100.f;

    for (i = 0; i < 3; i++) {
        vtxlist[i].x = WINSCALEX(vtxlist[i].x);
        vtxlist[i].y = WINSCALEY(vtxlist[i].y);
    }

    /*
    ** Red triangle (counterclockwise, should be visible)
    */
    grConstantColorValue( 0x000000FF );
    grDrawTriangle( &vtxlist[0], &vtxlist[2], &vtxlist[1] );

    /*
    ** Green triangle (clockwise, should be rejected)
    */
    grConstantColorValue( 0x0000FF00 );
    grDrawTriangle( &vtxlist[0], &vtxlist[1], &vtxlist[2] );

    grBufferSwap( 1 );

    if (kbhit())
    {
      getch();
      break;
    }
    frameCount++;
    if(frameCount < 0)
      frameCount = 0;
    if(frameCount == numFrames)
      break;
  }
  grGlideShutdown();
}
コード例 #8
0
ファイル: TEST20.C プロジェクト: grakidov/Render3D
void main( int argc, char **argv )
{
  GrMipMapId_t      decal0;
  Gu3dfInfo         info;
  float
    wWidth, wHeight;
  int automate = 0;
  int i;
  char *fileName;
  GrScreenResolution_t
    screenRes = GR_RESOLUTION_800x600;

  GrVertex vtx1, vtx2, vtx3, vtx4;
  float    near_z = 2.0F;
  float    far_z  = 16.0F;

  if (argc < 2 || strstr(argv[1], "-n")) {
    fprintf(stderr, "usage:  test20 filename.3df [-n]\n");
    exit(-1);
  }
  fileName = argv[1];
  if(argc > 2)
    if(strstr(argv[2], "-n"))
      automate = 1;
    else
    {
      fprintf(stderr, "usage:  test20 filename.3df [-n]\n");
      exit(-1);
    }

  wWidth = 800.f;
  wHeight = 600.f;

  puts( "TEST20: " );
  puts( "tests loading of 3df files");
  if(!automate)
  {
    puts("Press a key to continue");
    getch();
  }

  /*
  ** set up Glide and the hardware
  */
  grGlideInit();

  if ( !grSstQueryHardware( &hwconfig ) )
  {
    fprintf( stderr, "main: grSstQueryHardware failed!\n" );
    grGlideShutdown();
    exit( -1 );
  }
  grSstSelect( 0 );

  if ( !grSstOpen( screenRes,
                   GR_REFRESH_60Hz,
                   GR_COLORFORMAT_ABGR,
                   GR_ORIGIN_LOWER_LEFT,
                   GR_SMOOTHING_ENABLE,
                   2 ) )
  {
    fprintf( stderr, "main: grSstOpen failed!\n" );
    grGlideShutdown();
    exit( -1 );
  }

  /*
  ** load up texture maps
  */
  if ( !gu3dfGetInfo( fileName, &info ) )  
  {
    fprintf(stderr, "ERROR: could not load %s\n", fileName);
    grGlideShutdown();
    exit( -1 );
  }
  else
  {
     info.data = malloc( info.mem_required );

     if ( info.data == 0 ) {
        fprintf( stderr, "out of memory for texture\n" );
        grGlideShutdown();
        exit( -1 );
     }

     if ( !gu3dfLoad( fileName, &info ) ) {
        fprintf( stderr, "could not load texture file\n" );
        grGlideShutdown();
        exit( -1 );
     }

     decal0 = guTexAllocateMemory( 0, GR_MIPMAPLEVELMASK_BOTH,
                                  info.header.width, info.header.height,
                                  info.header.format,
                                  GR_MIPMAP_NEAREST,
                                  info.header.small_lod, info.header.large_lod,
                                  info.header.aspect_ratio,
                                  GR_TEXTURECLAMP_WRAP, GR_TEXTURECLAMP_WRAP,
                                  GR_TEXTUREFILTER_BILINEAR, GR_TEXTUREFILTER_BILINEAR,
                                  0.0F,
                                  FXFALSE );
     if ( decal0 == GR_NULL_MIPMAP_HANDLE ) {
        fprintf( stderr, "could not allocate memory for lava.3df\n" );
        grGlideShutdown();
        exit( -1 );
     }
     guTexDownloadMipMap( decal0, info.data, &info.table.nccTable );
     free( info.data );
  }

  grBufferClear( 0xFFFF0000, 0, GR_WDEPTHVALUE_FARTHEST );

  guColorCombineFunction(GR_COLORCOMBINE_DECAL_TEXTURE);

  guTexSource( decal0 );

  grTexCombineFunction(GR_TMU0, GR_TEXTURECOMBINE_DECAL);
 
  vtx1.x        = 160.f;
  vtx1.y        = 20.f;
  vtx1.r        = 255.f;
  vtx1.g        = 0.f;
  vtx1.b        = 0.f;
  vtx1.a        = 255.f;
  vtx1.oow = 1.f / near_z;
  vtx1.tmuvtx[0].sow = 0.f / near_z;
  vtx1.tmuvtx[0].tow = 255.f / near_z;
  
  vtx2.x        = 480.f;
  vtx2.y        = 20.f;
  vtx2.r        = 0.f;
  vtx2.g        = 255.f;
  vtx2.b        = 0.f;
  vtx2.a        = 255.f;
  vtx2.oow = 1.f / near_z;
  vtx2.tmuvtx[0].sow = 255.f / near_z;
  vtx2.tmuvtx[0].tow = 255.f / near_z;
  
  vtx3.x        = 300.f;
  vtx3.y        = 460.f;
  vtx3.r        = 0.f;
  vtx3.g        = 0.f;
  vtx3.b        = 255.f;
  vtx3.a        = 255.f;
  vtx3.oow =  1.f/ far_z;
  vtx3.tmuvtx[0].sow =  0.f/ far_z;
  vtx3.tmuvtx[0].tow = 0.f / far_z;
  
  vtx4.x        = 340.f;
  vtx4.y        = 460.f;
  vtx4.r        = 0.f;
  vtx4.g        = 0.f;
  vtx4.b        = 255.f;
  vtx4.a        = 255.f;
  vtx4.oow = 1.f / far_z;
  vtx4.tmuvtx[0].sow = 255.f / far_z;
  vtx4.tmuvtx[0].tow = 0.f / far_z;
  
  vtx1.x = WINSCALEX(vtx1.x);
  vtx1.y = WINSCALEX(vtx1.y);
  
  vtx2.x = WINSCALEX(vtx2.x);
  vtx2.y = WINSCALEX(vtx2.y);
  
  vtx3.x = WINSCALEX(vtx3.x);
  vtx3.y = WINSCALEX(vtx3.y);
  
  vtx4.x = WINSCALEX(vtx4.x);
  vtx4.y = WINSCALEX(vtx4.y);
  
  grDrawTriangle( &vtx1, &vtx2, &vtx3 );
  grDrawTriangle( &vtx3, &vtx4, &vtx2 );
  
  grBufferSwap( 1 );

  if(!automate)
  {
    printf("Press a key to end...\n");
    getch();
  }
  else
    for(i = 0; i < 700000000; i++);
  grGlideShutdown();
}
コード例 #9
0
ファイル: test11.c プロジェクト: basecq/q2dos
void main( int argc, char **argv) {
    char match; 
    char **remArgs;
    int  rv;

    GrScreenResolution_t resolution = GR_RESOLUTION_640x480;
    float                scrWidth   = 640.0f;
    float                scrHeight  = 480.0f;
    int frames                      = -1;
    GrContext_t          gc = 0;

    static unsigned short colorBuf[64][64];
    static unsigned short grabBuf[64][64];
    
    int x,y;

    /* Initialize Glide */
    grGlideInit();
    assert( hwconfig = tlVoodooType() );

    /* Process Command Line Arguments */
    while( rv = tlGetOpt( argc, argv, "nr", &match, &remArgs ) ) {
        if ( rv == -1 ) {
            printf( "Unrecognized command line argument\n" );
            printf( "%s %s\n", name, usage );
            printf( "Available resolutions:\n%s\n",
                    tlGetResolutionList() );
            return;
        }
        switch( match ) {
        case 'n':
            frames = atoi( remArgs[0] );
            break;
        case 'r':
            resolution = tlGetResolutionConstant( remArgs[0], 
                                                  &scrWidth, 
                                                  &scrHeight );
            break;
        }
    }

    tlSetScreen( scrWidth, scrHeight );

    version = grGetString( GR_VERSION );

    printf( "%s:\n%s\n", name, purpose );
    printf( "%s\n", version );
    printf( "Resolution: %s\n", tlGetResolutionString( resolution ) );
    if ( frames == -1 ) {
        printf( "Press A Key To Begin Test.\n" );
        tlGetCH();
    }
    
    grSstSelect( 0 );
    gc = grSstWinOpen(tlGethWnd(),
                      resolution,
                      GR_REFRESH_60Hz,
                      GR_COLORFORMAT_ABGR,
                      GR_ORIGIN_UPPER_LEFT,
                      2, 1 );
    if (!gc) {
      printf("Could not allocate glide fullscreen context.\n");
      goto __errExit;
    }
    
    tlConSet( 0.0f, 0.0f, 1.0f, 0.5f, 
              60, 15, 0xffffff );

    /* Set up Render State - disable dithering*/
    grDitherMode( GR_DITHER_DISABLE );


    /* Create Source Bitmap to be copied to framebuffer */
    for( y = 0; y < 64; y++ ) {
        for( x = 0; x < 64; x++ ) {
            FxU8 red = x << 2;
            FxU8 grn = y << 2;
            FxU8 blu = ( x + y )<<1;
            colorBuf[y][x] =  (red & 0xF8) << 8;
            colorBuf[y][x] |= (grn & 0xFC) << 3;
            colorBuf[y][x] |= (blu & 0xF8) >> 3;
        }
    }


    tlConOutput( "Press any key to quit\n" );
    while( frames-- && tlOkToRender()) {
        GrLfbInfo_t info;
        int startX, startY;

        if (hwconfig == TL_VOODOORUSH) {
          tlGetDimsByConst(resolution,
                           &scrWidth, 
                           &scrHeight );
        
          grClipWindow(0, 0, (FxU32) scrWidth, (FxU32) scrHeight);
        }

        grBufferClear( 0x00, 0, 0 );

        /* prepare info structure */
        info.size = sizeof( GrLfbInfo_t );
        
        /* lock back buffer */
        if ( grLfbLock( GR_LFB_WRITE_ONLY,
                        GR_BUFFER_BACKBUFFER,
                        GR_LFBWRITEMODE_565,
                        GR_ORIGIN_UPPER_LEFT,
                        FXFALSE,
                        &info )==FXFALSE) {
            tlConOutput( "Error, failed to take write lock\n" );
            break;
        } 

        if ( tlScaleX(1.0f) < 64.0 ||
             tlScaleY(1.0f) < 64.0 )
            return;
        
        /* generate random start position */
        startX = (int)rRandom( 64, (int)tlScaleX(1.0f) - 65 );
        startY = (int)rRandom( 64, (int)tlScaleY(1.0f) - 65 );
        
        /* render image to back buffer */
        for( y = 0; y < 64; y++ ) {
            for( x = 0; x < 64; x++ ) {
                FxU16 *pixel = 
                    (FxU16*)(((char*)info.lfbPtr) + 
                             (y+startY)*info.strideInBytes+
                             (x+startX)*2);
                *pixel = colorBuf[y][x];
            }
        }
        /* unlock the backbuffer */
        grLfbUnlock( GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER );

        /* swap to front buffer */
        grBufferSwap( 1 );
        grBufferClear( 0,0,0 );

        tlSleep( 1 );
        
        /* lock the front buffer */
        if ( grLfbLock( GR_LFB_READ_ONLY,
                        GR_BUFFER_FRONTBUFFER,
                        GR_LFBWRITEMODE_ANY,
                        GR_ORIGIN_UPPER_LEFT,
                        FXFALSE,
                        &info )==FXFALSE) {
            tlConOutput( "Error, failed to take read lock\n" );
            break;
        } 
        
        /* grab the source image out of the front buffer */
        for( y = 0; y < 64; y++ ) {
            for( x = 0; x < 64; x++ ) {
                FxU16 *pixel = 
                    (FxU16*)(((char*)info.lfbPtr) + 
                             (y+startY)*info.strideInBytes+
                             (x+startX)*2);
                grabBuf[y][x] = *pixel;
            }
        }
        /* unlock the front buffer */
        grLfbUnlock( GR_LFB_READ_ONLY, GR_BUFFER_FRONTBUFFER );

        tlConClear();
        
        /* compare the source image to the readback image */
        if ( memcmp( colorBuf, grabBuf, sizeof( colorBuf ) ) ) {
            tlConOutput( "Failed readback test\n" );
        } else {
            tlConOutput( "Passed readback test\n" );
        }

        grBufferSwap( 1 );
        tlConOutput( "Press any key to quit\n" );
        tlConRender();
        grBufferSwap( 1 );

        tlSleep( 1 );

        while( tlKbHit() ) {
            switch( tlGetCH() ) {
            default:
                frames = 0;
                break;
            }
        }
    }
    
 __errExit:    
    grGlideShutdown();
    return;
}
コード例 #10
0
ファイル: test01.c プロジェクト: grakidov/Render3D
void
main( int argc, char **argv) {
  char match; 
  char **remArgs;
  int  rv;
  
  GrScreenResolution_t resolution = GR_RESOLUTION_640x480;
  float                scrWidth   = 640.0f;
  float                scrHeight  = 480.0f;
  int frames                      = -1;
  FxBool               scrgrab = FXFALSE;
  char                 filename[256];
  FxU32                wrange[2];

  
  /* Process Command Line Arguments */
  while( rv = tlGetOpt( argc, argv, "nrd", &match, &remArgs ) ) {
    if ( rv == -1 ) {
      printf( "Unrecognized command line argument\n" );
      printf( "%s %s\n", name, usage );
      printf( "Available resolutions:\n%s\n",
             tlGetResolutionList() );
      return;
    }
    switch( match ) {
    case 'n':
      frames = atoi( remArgs[0] );
      break;
    case 'r':
      resolution = tlGetResolutionConstant( remArgs[0], 
                                           &scrWidth, 
                                           &scrHeight );
      break;
    case 'd':
      scrgrab = FXTRUE;
      frames = 1;
      strcpy(filename, remArgs[0]);
      break;
    }
  }
  
  tlSetScreen( scrWidth, scrHeight );
  
  version = grGetString( GR_VERSION );
  
  printf( "%s:\n%s\n", name, purpose );
  printf( "%s\n", version );
  printf( "Resolution: %s\n", tlGetResolutionString( resolution ) );
  if ( frames == -1 ) {
    printf( "Press A Key To Begin Test.\n" );
    tlGetCH();
  }
  
  /* Initialize Glide */
  grGlideInit();

  assert( hwconfig = tlVoodooType() );

  grSstSelect( 0 );
  assert( grSstWinOpen( 0,
                       resolution,
                       GR_REFRESH_60Hz,
                       GR_COLORFORMAT_ABGR,
                       GR_ORIGIN_UPPER_LEFT,
                       2, 1 ) );
  
  grGet(GR_WDEPTH_MIN_MAX, 8, wrange);  
  grVertexLayout(GR_PARAM_XY, 0, GR_PARAM_ENABLE);

  tlConSet( 0.0f, 0.0f, 1.0f, 1.0f, 
           60, 30, 0xffffff );
  
  /* Set up Render State - flat shading */
  grColorCombine( GR_COMBINE_FUNCTION_LOCAL,
                 GR_COMBINE_FACTOR_NONE,
                 GR_COMBINE_LOCAL_CONSTANT,
                 GR_COMBINE_OTHER_NONE,
                 FXFALSE );
  grConstantColorValue( 0xFFFFFF );
  
  
  tlConOutput( "Press a key to quit\n" );
  while( frames-- && tlOkToRender()) {
    int i;
    GrVertex vtx;

    if (hwconfig == TL_VOODOORUSH) {
      tlGetDimsByConst(resolution,
                       &scrWidth, 
                       &scrHeight );
        
      grClipWindow(0, 0, (FxU32) scrWidth, (FxU32) scrHeight);
    } 
    grBufferClear(0x00000000, 0, wrange[1]);

    for( i = 0; i < 100; i++ ) {
      float pos = ((float)i)/100.0f;

      vtx.x = tlScaleX( pos ), vtx.y = tlScaleY( pos );
      grDrawPoint( &vtx );
    }


    tlConRender();
    grBufferSwap( 1 );

    /* grab the frame buffer */
    if (scrgrab) {
      if (!tlScreenDump(filename, (FxU16)scrWidth, (FxU16)scrHeight))
        printf( "Cannot open %s\n", filename);
      scrgrab = FXFALSE;
    }
    if ( tlKbHit() ) frames = 0;
  }
  
  grGlideShutdown();
  return;
}
コード例 #11
0
ファイル: test27.c プロジェクト: basecq/q2dos
void main( int argc, char **argv) {
    char match; 
    char **remArgs;
    int  rv;

    GrScreenResolution_t resolution = GR_RESOLUTION_640x480;
    float                scrWidth   = 640.0f;
    float                scrHeight  = 480.0f;
    int frames                      = -1;
    int doNothing = 0;

    int cycles;
    FxU32 wrange[2];

    /* Initialize Glide */
    grGlideInit();
    assert( hwconfig = tlVoodooType() );

    /* Process Command Line Arguments */
    while( rv = tlGetOpt( argc, argv, "Nnr", &match, &remArgs ) ) {
        if ( rv == -1 ) {
            printf( "Unrecognized command line argument\n" );
            printf( "%s %s\n", name, usage );
            printf( "Available resolutions:\n%s\n",
                    tlGetResolutionList() );
            return;
        }
        switch( match ) {
        case 'n':
            frames = atoi( remArgs[0] );
            break;
        case 'r':
            resolution = tlGetResolutionConstant( remArgs[0], 
                                                  &scrWidth, 
                                                  &scrHeight );
            break;
        case 'N':
            doNothing = 1;
            break;
        }
    }

    tlSetScreen( scrWidth, scrHeight );

    version = grGetString( GR_VERSION );

    printf( "%s:\n%s\n", name, purpose );
    printf( "%s\n", version );
    printf( "Resolution: %s\n", tlGetResolutionString( resolution ) );
    if ( frames == -1 ) {
        printf( "Press A Key To Begin Test.\n" );
        tlGetCH();
    }
    
    grSstSelect( 0 );


    cycles = 0;
    while( frames-- && tlOkToRender()) {
        GrVertex a, b, c;
        GrContext_t context;
        char inchar;

        context = grSstWinOpen(tlGethWnd(),
                               resolution,
                               GR_REFRESH_60Hz,
                               GR_COLORFORMAT_ABGR,
                               GR_ORIGIN_UPPER_LEFT,
                               2, 1 );
        assert(context);

        /* 
         * Don't like gotos?  In the immortal words of Schwarzenegger
         * (Total Recall): "...so sue me d**khead"
         */
        if (doNothing) goto doNothing;

        grVertexLayout(GR_PARAM_XY,  0, GR_PARAM_ENABLE);
        grVertexLayout(GR_PARAM_RGB, GR_VERTEX_R_OFFSET << 2, GR_PARAM_ENABLE);
        grGet(GR_WDEPTH_MIN_MAX, 8, wrange);  

        grColorCombine( GR_COMBINE_FUNCTION_LOCAL,
                        GR_COMBINE_FACTOR_NONE,
                        GR_COMBINE_LOCAL_ITERATED,
                        GR_COMBINE_OTHER_NONE,
                        FXFALSE );

        tlConSet( 0.0f, 0.0f, 1.0f, 1.0f, 
                  60, 30, 0xffffff );
        
        
        /* deal with dynamic resizing */
        if (hwconfig == TL_VOODOORUSH) {
          tlGetDimsByConst(resolution, &scrWidth, &scrHeight);
          grClipWindow(0, 0, (FxU32) scrWidth, (FxU32) scrHeight);
        }

        tlConOutput( "Press <space> to cycle hardware\n" );
        tlConOutput( "Any other key to quit\n" );
        
        grBufferClear( 0x000000, 0, wrange[1] );

        a.r = a.g = a.b = 0.0f;
        b = c = a;

        a.x = tlScaleX(((float)rRandom( 0, 100 ))/100.0f);
        a.y = tlScaleY(((float)rRandom( 0, 100 ))/100.0f);
        a.r = 255.0f;

        b.x = tlScaleX(((float)rRandom( 0, 100 ))/100.0f);
        b.y = tlScaleY(((float)rRandom( 0, 100 ))/100.0f);
        b.g = 255.0f;

        c.x = tlScaleX(((float)rRandom( 0, 100 ))/100.0f);
        c.y = tlScaleY(((float)rRandom( 0, 100 ))/100.0f);
        c.b = 255.0f;

        grDrawTriangle( &a, &b, &c );

        tlConOutput( "Cycle: %d\r", cycles );
        tlConRender();
        grBufferSwap( 1 );

doNothing:
        inchar = tlGetCH();
        if ( inchar != ' ' ) frames = 0;
        
        grSstWinClose(context);
        cycles++;
    }
    
    grGlideShutdown();
    return;
}
コード例 #12
0
ファイル: TEST30.C プロジェクト: grakidov/Render3D
void
main( int argc, char **argv ) {
  float
    minColor = 55.f,
    maxColor = 200.f;

  GrVertex
    localVerts[3],
    texVerts[4];

  float
    alpha = 192.0f,
    y_angle = 0.0f;

  int
    n,
    nTris = 0;

  FxBool
    depthBias = FXTRUE,
    blend = FXFALSE,
    texturing = FXFALSE,
    antialias = FXTRUE,
    bilinear = FXTRUE,
    render = FXTRUE,
    backbuffer = FXTRUE,
    background = FXTRUE;

  GrState
    nonBlendState, blendState;

  float
    wWidth, wHeight;

  GrScreenResolution_t
    screenRes;

  GrMipMapId_t
    triDecal,
    bgDecal;

  Gu3dfInfo
    bgInfo, triInfo;

  FxU16
    *scrnImage;

  GrColorCombineFnc_t
    ccFnc = GR_COLORCOMBINE_ITRGB;

  int
    numFrames = -1,
    frameCount = 0;

  char
    *bgFileName = NULL,
    *triFileName = NULL;
  wWidth = 640.0f;
  wHeight = 480.0f;

  screenRes = GR_RESOLUTION_640x480;

  --argc; ++argv;

  while (argc) {
    if (strstr(*argv, "320x200")) {
      wWidth = 320.0f; wHeight = 200.0f;
      screenRes = GR_RESOLUTION_320x200;
      --argc; ++argv;
    } else if (strstr(*argv, "320x240")) {
      wWidth = 320.0f; wHeight = 240.0f;
      screenRes = GR_RESOLUTION_320x240;
      --argc; ++argv;
    } else if (strstr(*argv, "400x256")) {
      wWidth = 400.0f; wHeight = 256.0f;
      screenRes = GR_RESOLUTION_400x256;
      --argc; ++argv;
    } else if (strstr(*argv, "512x384")) {
      wWidth = 512.0f; wHeight = 384.0f;
      screenRes = GR_RESOLUTION_512x384;
      --argc; ++argv;
    } else if (strstr(*argv, "640x480")) {
      wWidth = 640.0f; wHeight = 480.0f;
      screenRes = GR_RESOLUTION_640x480;
      --argc; ++argv;
    } else if (strstr(*argv, "800x600")) {
      wWidth = 800.0f; wHeight = 600.0f;
      screenRes = GR_RESOLUTION_800x600;
      --argc; ++argv;
    } else if (strstr(*argv, "856x480")) {
      wWidth = 856.0f; wHeight = 480.0f;
      screenRes = GR_RESOLUTION_856x480;
      --argc; ++argv;
    } else if (strstr(*argv, "960x720")) {
      wWidth = 960.0f; wHeight = 720.0f;
      screenRes = GR_RESOLUTION_960x720;
      --argc; ++argv;
    } else if (strstr(*argv, "640x200")) {
      wWidth = 640.f; wHeight = 200.f;
      screenRes = GR_RESOLUTION_640x200;
      --argc; ++argv;
    } else if (strstr(*argv, "640x350")) {
      wWidth = 640.f; wHeight = 350.f;
      screenRes = GR_RESOLUTION_640x350;
      --argc; ++argv;
    } else if (strstr(*argv, "640x400")) {
      wWidth = 640.f; wHeight = 400.f;
      screenRes = GR_RESOLUTION_640x400;
      --argc; ++argv;
    } else if (strstr(*argv, "bgFile")) {
      bgFileName = argv[1];
      argc-= 2; argv += 2;
    } else if (strstr(*argv, "triFile")) {
      triFileName = argv[1];
      argc-= 2; argv += 2;
    } else if (strstr(*argv, "alpha")) {
      alpha = (float)atof(argv[1]);
      argc -= 2; argv += 2;                    
    } else if (strstr(*argv, "-n")) {
      numFrames = atoi(argv[1]);
      argc -= 2; argv += 2;
    } else {
      fprintf(
              stderr,
              "Useage:  test24 [-bgFile bgfile.3ds] [-triFile triFile.3ds] [ScreenRes (i.e. 640x480 .. 960x720] [-alpha alphavalue] [-n numFrames]\n");
      exit(-1);
    }
  }

  scrnImage = malloc((int)wWidth * (int)wHeight * sizeof(FxU16));

  puts( "\ntest30:" );
  puts( "Depth Bias Level Test\n" );
  puts("press H for help\n");
  if(numFrames == -1)
  {
    puts("Press a key to continue");
    getch();
  }

  grGlideInit();

  if ( !grSstQueryHardware( &hwconfig ) )
  {
    fprintf( stderr, "main: grSstQueryHardware failed!\n" );
    grGlideShutdown();
    exit( -1 );
  }

  /* Select SST 0 */
  grSstSelect( 0 );

  /* Open up the hardware */
  if ( !grSstOpen( screenRes,
                   GR_REFRESH_60Hz,
                   GR_COLORFORMAT_ABGR,
                   GR_ORIGIN_LOWER_LEFT,
                   GR_SMOOTHING_ENABLE,
                   2 ) )
  {
    fprintf( stderr, "main: grSstOpen failed!\n" );
    grGlideShutdown();
    exit( -1 );
  }

  localVerts[0].x = 0.f;
  localVerts[0].y = 0.75f;
  localVerts[0].z = 0.0f;
  localVerts[0].tmuvtx[0].sow = 255.f;
  localVerts[0].tmuvtx[0].tow = 255.f;
  localVerts[0].oow = 1.f;  
  localVerts[0].r = maxColor;
  localVerts[0].g = minColor;
  localVerts[0].b = minColor;
  localVerts[0].a = 255.f;

  localVerts[1].x = -0.75f;
  localVerts[1].y = -0.75f;
  localVerts[1].z = 0.0f;
  localVerts[1].tmuvtx[0].sow = 0.f;
  localVerts[1].tmuvtx[0].tow = 255.f;
  localVerts[1].oow = 1.f;  
  localVerts[1].r = minColor;
  localVerts[1].g = maxColor;
  localVerts[1].b = minColor;
  localVerts[1].a = 255.f;

  localVerts[2].x = 0.75f;
  localVerts[2].y = -0.75f;
  localVerts[2].z = 0.0f;
  localVerts[2].tmuvtx[0].sow = 255.f;
  localVerts[2].tmuvtx[0].tow = 0.f;
  localVerts[2].oow = 1.f;  
  localVerts[2].r = minColor;
  localVerts[2].g = minColor;
  localVerts[2].b = maxColor;
  localVerts[2].a = 255.f;

  texVerts[0].x = 0.f;
  texVerts[0].y = 0.f;
  texVerts[0].a = 255.f;
  texVerts[0].oow = 1.f;
  texVerts[0].tmuvtx[0].sow = 0.f * texVerts[0].oow;
  texVerts[0].tmuvtx[0].tow = 255.f * texVerts[0].oow;

  texVerts[1].x = wWidth;
  texVerts[1].y = 0.f;
  texVerts[1].a = 255.f;
  texVerts[1].oow = 1.f;
  texVerts[1].tmuvtx[0].sow = 255.f * texVerts[1].oow;
  texVerts[1].tmuvtx[0].tow = 255.f * texVerts[1].oow;

  texVerts[2].x = wWidth;
  texVerts[2].y = wHeight;
  texVerts[2].a = 255.f;
  texVerts[2].oow = 1.f;
  texVerts[2].tmuvtx[0].sow = 255.f * texVerts[2].oow;
  texVerts[2].tmuvtx[0].tow = 0.f * texVerts[2].oow;
  
  texVerts[3].x = 0.f;
  texVerts[3].y = wHeight;
  texVerts[3].a = 255.f;
  texVerts[3].oow = 1.f;
  texVerts[3].tmuvtx[0].sow = 0.f * texVerts[3].oow;
  texVerts[3].tmuvtx[0].tow = 0.f * texVerts[3].oow;
  
  if (bgFileName == NULL)
    bgFileName = "miro.3df";
  if (triFileName == NULL)
    triFileName = "matt1.3df";

  if ( gu3dfGetInfo( bgFileName, &bgInfo ) )  {
     bgInfo.data = malloc( bgInfo.mem_required );

     if ( bgInfo.data == 0 ) {
       fprintf( stderr, "out of memory for texture file %s\n", bgFileName );
       grGlideShutdown();
       exit( -1 );
     }

     if ( !gu3dfLoad( bgFileName, &bgInfo ) ) {
       fprintf( stderr, "could not load texture file %s\n", bgFileName );
       grGlideShutdown();
       exit( -1 );
     }

     bgDecal = guTexAllocateMemory( 0, GR_MIPMAPLEVELMASK_BOTH,
                                  bgInfo.header.width, bgInfo.header.height,
                                  bgInfo.header.format,
                                  GR_MIPMAP_NEAREST,
                                  bgInfo.header.small_lod, bgInfo.header.large_lod,
                                  bgInfo.header.aspect_ratio,
                                  GR_TEXTURECLAMP_WRAP, GR_TEXTURECLAMP_WRAP,
                                  GR_TEXTUREFILTER_BILINEAR, GR_TEXTUREFILTER_BILINEAR,
                                  0.0F,
                                  FXFALSE );
     if ( bgDecal == GR_NULL_MIPMAP_HANDLE ) {
       fprintf( stderr, "could not allocate memory for texture file %s\n", bgFileName );
       grGlideShutdown();
       exit( -1 );
     }
     guTexDownloadMipMap( bgDecal, bgInfo.data, &bgInfo.table.nccTable );
     free( bgInfo.data );
  } else {
    fprintf( stderr, "could not get info on %s\n", bgFileName );
    grGlideShutdown();
    exit( -1 );
  }
  
  if ( gu3dfGetInfo( triFileName, &triInfo ) )  {
    triInfo.data = malloc( triInfo.mem_required );
    
    if ( triInfo.data == 0 ) {
      fprintf( stderr, "out of memory for texture file  %s\n", triFileName );
      grGlideShutdown();
      exit( -1 );
    }
    
    if ( !gu3dfLoad( triFileName, &triInfo ) ) {
      fprintf( stderr, "could not load texture file %s\n", triFileName );
      grGlideShutdown();
      exit( -1 );
    }

    triDecal = guTexAllocateMemory( 0, GR_MIPMAPLEVELMASK_BOTH,
                                    triInfo.header.width,  
                                    triInfo.header.height, 
                                    triInfo.header.format,
                                    GR_MIPMAP_NEAREST,
                                    triInfo.header.small_lod,
                                    triInfo.header.large_lod, 
                                    triInfo.header.aspect_ratio,
                                    GR_TEXTURECLAMP_WRAP,
                                    GR_TEXTURECLAMP_WRAP, 
                                    GR_TEXTUREFILTER_BILINEAR,
                                    GR_TEXTUREFILTER_BILINEAR, 
                                    0.0F,
                                    FXFALSE );
    if ( triDecal == GR_NULL_MIPMAP_HANDLE ) {
       fprintf( stderr, "could not allocate memory for %s\n", triFileName );
       grGlideShutdown();
       exit( -1 );
     }
     guTexDownloadMipMap( triDecal, triInfo.data, &triInfo.table.nccTable );
     free( triInfo.data );
  } else {
    fprintf( stderr, "could not get info on %s\n", triFileName );
    grGlideShutdown();
    exit( -1 );
  }

  grTexCombineFunction(GR_TMU0, GR_TEXTURECOMBINE_DECAL);
  grRenderBuffer(backbuffer == FXTRUE ? GR_BUFFER_BACKBUFFER : GR_BUFFER_FRONTBUFFER);

  /* Set up alpha blend state for compositing and antialiasing */
  guAlphaSource( GR_ALPHASOURCE_ITERATED_ALPHA );
  grAlphaBlendFunction( GR_BLEND_SRC_ALPHA,
                        GR_BLEND_ONE_MINUS_SRC_ALPHA, GR_BLEND_ONE,
                        GR_BLEND_ZERO ); 
  grAlphaTestFunction( GR_CMP_ALWAYS );
  
  while ( 1 ) {
    Matrix rotm;
    GrVertex xformedVerts[4];
    int i;

    grSstIdle();

    
    ++nTris;
    MatMakeYRot( rotm, DEG2RAD( y_angle ) );
    
    for( i = 0; i < 4; i++ ) {
      PointMatMult( &xformedVerts[i], &localVerts[i], rotm );
      xformedVerts[i].x = xformedVerts[i].x / ( xformedVerts[i].z + 2.0f );
      xformedVerts[i].y = xformedVerts[i].y / ( xformedVerts[i].z + 2.0f );
      xformedVerts[i].x *= wHeight / 2.0f;
      xformedVerts[i].y *= wHeight / 2.0f;
      xformedVerts[i].x += wHeight / 2.0f;
      xformedVerts[i].y += wHeight / 2.0f;
      xformedVerts[i].oow = 1.f / ((xformedVerts[i].z + 2) * wHeight);
      xformedVerts[i].tmuvtx[0].sow *= xformedVerts[i].oow;
      xformedVerts[i].tmuvtx[0].tow *= xformedVerts[i].oow;
      SNAP_COORD( xformedVerts[i].x );
      SNAP_COORD( xformedVerts[i].y );
    }
    

    if (render == FXTRUE) {
      grBufferClear( 0xffffffff, 0, GR_WDEPTHVALUE_FARTHEST );
    
      if (background == FXTRUE) {
        GrState
          oldState;

        grGlideGetState(&oldState);

        grAlphaBlendFunction(
                             GR_BLEND_ONE, GR_BLEND_ZERO,
                             GR_BLEND_ONE, GR_BLEND_ZERO);

        grColorCombine(
                       GR_COMBINE_FUNCTION_SCALE_OTHER,
                       GR_COMBINE_FACTOR_ONE,
                       GR_COMBINE_LOCAL_NONE,
                       GR_COMBINE_OTHER_TEXTURE, FXFALSE
                       );

        guTexSource(bgDecal);
        
        for (i = 0; i < NTRIS; i++) {
          grDrawTriangle(&texVerts[0], &texVerts[1], &texVerts[2]);
          grDrawTriangle(&texVerts[2], &texVerts[3], &texVerts[0]);
        }
        grGlideSetState(&oldState);

      }

      guTexSource(triDecal);

      if (antialias == FXTRUE) {
        if (depthBias) 
            grDepthBiasLevel((short)0x8000);
        guColorCombineFunction(GR_COLORCOMBINE_DECAL_TEXTURE);
        grAADrawTriangle(
                         &xformedVerts[0],  &xformedVerts[1],
                         &xformedVerts[2], FXTRUE, FXTRUE, FXTRUE
                         );
#define SHIFT 20.f;
        for (n = 0; n < 3; n++) {
          xformedVerts[n].x += SHIFT;
          xformedVerts[n].y -= SHIFT;
        }
        if (depthBias)
          grDepthBiasLevel(0x7fff);
        guColorCombineFunction(GR_COLORCOMBINE_ITRGB);
        grAADrawTriangle(
                         &xformedVerts[0],  &xformedVerts[1],
                         &xformedVerts[2], FXTRUE, FXTRUE, FXTRUE
                         );
        
      } else {
        if (depthBias)
            grDepthBiasLevel((short)0x8000);
        guColorCombineFunction(GR_COLORCOMBINE_DECAL_TEXTURE);
        grDrawTriangle(
                       &xformedVerts[0], &xformedVerts[1],
                       &xformedVerts[2]
                       );
        for (n = 0; n < 3; n++) {
          xformedVerts[n].x += SHIFT;
          xformedVerts[n].y -= SHIFT;
        }
        if (depthBias)
          grDepthBiasLevel(0x7fff);
        guColorCombineFunction(GR_COLORCOMBINE_ITRGB);
        grDrawTriangle(
                       &xformedVerts[0], &xformedVerts[1],
                       &xformedVerts[2]
                       );
      }
      if (backbuffer) {
        grBufferSwap( 1 );
      }
    }
    
    if (kbhit()) {
      char c = getch();
      
      switch (c) {
      case 'a':
      case 'A':
        if (antialias == FXFALSE) {
          printf("Turning ON Antialiasing\n");
          antialias = FXTRUE;
        } else {
          printf("Turning OFF Antialiasing\n");
          antialias = FXFALSE;
        }
        break;
      case 'B':
      case 'b':
        if (bilinear == FXFALSE) {
          bilinear = FXTRUE;
          printf("Turning ON BiLinear blending\n");
          guTexChangeAttributes(
                                triDecal, bgInfo.header.width,
                                bgInfo.header.height, 
                                bgInfo.header.format, GR_MIPMAP_NEAREST,
                                bgInfo.header.small_lod,
                                bgInfo.header.large_lod, 
                                bgInfo.header.aspect_ratio,
                                GR_TEXTURECLAMP_WRAP, GR_TEXTURECLAMP_WRAP,
                                GR_TEXTUREFILTER_BILINEAR,
                                GR_TEXTUREFILTER_BILINEAR);
        } else {
          bilinear = FXFALSE;
          printf("Turning OFF BiLinear blending\n");
          guTexChangeAttributes(
                                triDecal, bgInfo.header.width,
                                bgInfo.header.height, 
                                bgInfo.header.format, GR_MIPMAP_NEAREST,
                                bgInfo.header.small_lod,
                                bgInfo.header.large_lod,
                                bgInfo.header.aspect_ratio, 
                                GR_TEXTURECLAMP_WRAP, GR_TEXTURECLAMP_WRAP,
                                GR_TEXTUREFILTER_POINT_SAMPLED,
                                GR_TEXTUREFILTER_POINT_SAMPLED);
        }
        break;

      case 'c':
      case 'C':
        if (blend == FXTRUE) {
          blend = FXFALSE;
          localVerts[0].a = 255.0f;
          localVerts[1].a = 255.0f;
          localVerts[2].a = 255.0f;
          localVerts[3].a = 255.0f;

        } else {
          blend = FXTRUE;
          localVerts[0].a = alpha;
          localVerts[1].a = alpha;
          localVerts[2].a = alpha;
        }
        break;

      case 'd':
      case 'D':
        if (depthBias == FXTRUE)  {
          printf("Turning OFF depth bias level\n");
          depthBias = FXFALSE;
          grDepthBiasLevel(0);
        } else {
          printf("Turning ON depth bias level\n");        
          depthBias = FXTRUE;
        }
        break;

      case 'f':
      case 'F':
        if (backbuffer == FXTRUE) {
          backbuffer = FXFALSE;
          grRenderBuffer(GR_BUFFER_FRONTBUFFER);
        } else {
          backbuffer = FXTRUE;
          grRenderBuffer(GR_BUFFER_BACKBUFFER);
        }
        break;

      case 'g':
      case 'G':
        grLfbBegin();

        grLfbWriteMode(GR_LFBWRITEMODE_565);
        grLfbOrigin(GR_ORIGIN_UPPER_LEFT);
        grLfbGetReadPtr(GR_BUFFER_FRONTBUFFER);
        printf("Press a key to get front buffer\n");
        while (!kbhit());
        c = getch();
        guFbReadRegion(0,0,(int)wWidth,(int)wHeight,scrnImage,(int)wWidth * sizeof(FxU16));
        printf("Press a key to put image in back buffer and swap\n");
        while (!kbhit());
        getch();

        grLfbGetWritePtr(GR_BUFFER_BACKBUFFER);
        guFbWriteRegion(0,0,(int)wWidth,(int)wHeight,scrnImage,(int)wWidth * sizeof(FxU16));
        grBufferSwap(1);

        printf("Press a key to continue...\n");
        while (!kbhit());
        getch();

        grLfbEnd();

        break;

      case 'h':
      case 'H':
      case '?':
        grSstPassthruMode(GR_PASSTHRU_SHOW_VGA);
        printf("Keymap:\n");
        printf("        A or a:         toggle Antialiasing\n");
        printf("        B or b:         toggle Bilinear\n");
        printf("        D or d:         toggle Depth bias level\n");
        printf("        F or f:         toggle Front buffer \n");
        printf("        H, h, or ?:     Help\n");
        printf("        I or i:         toggle background Image\n");
        printf("        P or p:         Pause rendering\n");
        printf("        Q or q:         Quit\n");
        printf("Press a key to continue...\n");
        getch();
        grSstPassthruMode(GR_PASSTHRU_SHOW_SST1);
        break;

      case 'i':
      case 'I':
        if (background == FXTRUE) {
          background = FXFALSE;
          printf("Turning off background\n");
        } else {
          printf("Turning on background\n");
          background = FXTRUE;
        }
        break;

      case 'p':
      case 'P':
        if (render == FXTRUE)
          render = FXFALSE;
        else
          render = FXTRUE;
        break;
        
      case 'q':
      case 'Q':
        grGlideShutdown();
        exit(0);
        break;

      case 'T':
      case 't':
        if (texturing == FXFALSE) {
          printf("Turning ON texturing\n");
          ccFnc = GR_COLORCOMBINE_DECAL_TEXTURE;
          texturing = FXTRUE;
        } else {
          printf("Turning OFF texturing\n");
          ccFnc = GR_COLORCOMBINE_ITRGB;
          texturing = FXFALSE;
        }
        break;
        
      }
    }
    
    if (render) {
      y_angle += 2.f;
      if( y_angle > 360.0f )
        y_angle -= 360.0f;
    }

    frameCount++;
    if(frameCount < 0)
      frameCount = 0;
    if(numFrames == frameCount)
      break;
  }
  grGlideShutdown();
}
コード例 #13
0
ファイル: TEST26.C プロジェクト: grakidov/Render3D
void 
main( int argc, char **argv ) {
  int
    i,
    wWidth = 640, wHeight = 480; /* Screen width & height */
  
  GrMipMapId_t
    mmids[NUM_MIPMAPS];         /* The mipmaps with which we're testing. */
  GrHwConfiguration
    hwconfig;
  GrScreenResolution_t
    screenRes = GR_RESOLUTION_800x600;
  GrVertex
    vtx1, vtx2, vtx3, vtx4;
  int 
    numFrames = -1,
    frameCount = 0;

  if(argc > 2)
    if( strstr(argv[1], "-n"))
      numFrames = atoi(argv[2]);
    else
    {
      fprintf(stderr, "usage: test26 {-n numFrames}\n");
      exit(-1);
    }
  else if(argc > 1)
    if(strstr(argv[1], "-n"))
    {
      fprintf(stderr, "usage: test26 {-n numFrames}\n");
      exit(-1);
    }

  puts("TEST26:");
  puts("Tests texture mapping");
  if(numFrames == -1)
  {
    puts("Press a key to continue");
    getch();
  }
  grGlideInit();                /* Initialize glide library */

  if ( !grSstQueryHardware( &hwconfig ) ) {
    fprintf( stderr, "main: grSstQueryHardware failed!\n" );
    grGlideShutdown();
    exit( -1 );
  }
  grSstSelect( 0 );

  if ( !grSstOpen( screenRes,
                   GR_REFRESH_60Hz,
                   GR_COLORFORMAT_ABGR,
                   GR_ORIGIN_UPPER_LEFT,
                   GR_SMOOTHING_ENABLE,
                   2 ) )
  {
    fprintf( stderr, "main: grSstOpen failed!\n" );
    grGlideShutdown();
    exit( -1 );
  }

  /*
  ** load up texture maps
  */
  for (i = 0; i < NUM_MIPMAPS; i++)
    mmids[i] = doTexture("ramp.3df");

  guColorCombineFunction(GR_COLORCOMBINE_DECAL_TEXTURE);
  grTexCombineFunction(GR_TMU0, GR_TEXTURECOMBINE_DECAL);
  
  grBufferClear( 0xFFFF0000, 0, GR_WDEPTHVALUE_FARTHEST );  

  while (1) {
    grBufferClear( 0xFFFF0000, 0, GR_WDEPTHVALUE_FARTHEST );

    for (i = 0; i < NUM_MIPMAPS; i++) {
      /* upper-left-hand corner */
      vtx1.x        = 0.f + (i * 0.1f);
      vtx1.y        = 0.f + (i * 0.1f);
      vtx1.oow = 1.0f;
      vtx1.tmuvtx[0].sow = 0.f;
      vtx1.tmuvtx[0].tow = 0.f;
  
      /* upper-right-hand corner */
      vtx2.x        = 0.5f + (i * 0.1f);
      vtx2.y        = 0.f + (i * 0.1f);
      vtx2.oow = 1.0f;
      vtx2.tmuvtx[0].sow = 255.0f;
      vtx2.tmuvtx[0].tow = 0.f;
      
      /* lower-left-hand corner */
      vtx3.x        = 0.f + (i * 0.1f);
      vtx3.y        = 0.5f + (i * 0.1f);;
      vtx3.oow =  1.f;
      vtx3.tmuvtx[0].sow =  0.f;
      vtx3.tmuvtx[0].tow =  255.f;
      
      /* lower-right-hand corner */
      vtx4.x        = 0.5f + (i * 0.1f); ;
      vtx4.y        = 0.5f + (i * 0.1f);;
      vtx4.oow = 1.f;
      vtx4.tmuvtx[0].sow = 255.f;
      vtx4.tmuvtx[0].tow = 255.f;
  
      vtx1.x = WINSCALEX(vtx1.x);
      vtx1.y = WINSCALEY(vtx1.y);

      vtx2.x = WINSCALEX(vtx2.x);
      vtx2.y = WINSCALEY(vtx2.y);

      vtx3.x = WINSCALEX(vtx3.x);
      vtx3.y = WINSCALEY(vtx3.y);

      vtx4.x = WINSCALEX(vtx4.x);
      vtx4.y = WINSCALEY(vtx4.y);
      

      guTexSource(mmids[i]);

      grDrawTriangle( &vtx1, &vtx2, &vtx3 );
      grDrawTriangle( &vtx3, &vtx4, &vtx2 );
      
    } /* for (i ...) */

    while (grBufferNumPending() > 2);
    grBufferSwap( 1 );
    if (kbhit()) {
      getch();
      break;
    }
    frameCount++;
    if(frameCount < 0)
      frameCount = 0;
    if(frameCount == numFrames)
      break;
  } /* while (1) */
  grGlideShutdown();
} /* main */
コード例 #14
0
ファイル: test25.c プロジェクト: basecq/q2dos
void main( int argc, char **argv) {
  char match; 
  char **remArgs;
  int  rv;

  GrScreenResolution_t resolution = GR_RESOLUTION_640x480;
  float                scrWidth   = 640.0f;
  float                scrHeight  = 480.0f;
  int frames                      = -1;

  float
    minColor = 10.f,            /* Vertex min color */
    maxColor = 245.f;           /* Vertex max color */
    
  GrVertex
    localVerts[VERT_COUNT],     /* Vertices in world coordinates */
    texVerts[4];                /* Texture vertices for background */
    
  float
    alpha = 192.0f,             /* Alpha for blending tringle over background */
    y_angle = 0.0f;             /* rotation amount */
    
  int
    firstTime;                  /* Used for performance calculations */

  FxBool
    plugging = FXFALSE,         /* Show shameless plug */
    printPerf = FXFALSE,        /* Print performance numbers */
    lines = FXFALSE,            /* Draw lines instead of triangles */
    blend = FXFALSE,            /* Blend the triangle over the background */
    texturing = FXFALSE,        /* Texture the tiangle */
    antialias = FXTRUE,         /* Antialias the triangle? */
    bilinear = FXTRUE,          /* Perform bilinear filtering on the texture? */
    render = FXTRUE,            /* Draw? */
    backbuffer = FXTRUE,        /* Draw to backbuffer? */
    background = FXTRUE;        /* Draw background? */

  GrOriginLocation_t
    origin = GR_ORIGIN_LOWER_LEFT; /* Origin */

  FxU32
    swapDelay = 1,              /* Arg to grBufferSwap */
    trisDrawn,                  /* # triangles drawn */
    trisProcessed,              /* # triangles through pipeline */
    lastFrame,                  /* Number of last frame we did perf stats */
    frameNum = 0L;              /* id of each frame drawn */
    
  GrCullMode_t
    cullMode = GR_CULL_DISABLE; /* backface culling */
    
  FxU32 startAddress = 0, bgDecalAddress = 0, triDecalAddress = 0;

  GrTexInfo
    triDecal,                   /* Triangle decal texture */
    bgDecal;                    /* Background decal texture */
    
  Gu3dfInfo
    bgInfo,                     /* Info on background texture */
    triInfo;                    /* Info on triangle texture */
    
  GrColorCombineFnc_t
    ccFnc = GR_COLORCOMBINE_ITRGB; /* Start of w/ Gouraud shading */
    
  char
    *bgFileName = NULL,         /* Name of background texture file */
    *triFileName = NULL;        /* Name of triangle texture file */
    
  int
    frameCount = 0;

  FxU32 wrange[2];
  FxI32 state_size;
  void *oldState;

  /* Initialize Glide */
  grGlideInit();
  assert( hwconfig = tlVoodooType() );

  /* Process Command Line Arguments */
  while( rv = tlGetOpt( argc, argv, "nrbtea", &match, &remArgs ) ) {
    if ( rv == -1 ) {
      printf( "Unrecognized command line argument\n" );
      printf( "%s %s\n", name, usage );
      printf( "Available resolutions:\n%s\n",
             tlGetResolutionList() );
      return;
    }
    switch( match ) {
    case 'n':
      frames = atoi( remArgs[0] );
      break;
    case 'r':
      resolution = tlGetResolutionConstant( remArgs[0], 
                                           &scrWidth, 
                                           &scrHeight );
      break;
    case 'b':
      bgFileName = strdup( remArgs[0] );
      break;
    case 't':
      triFileName = strdup( remArgs[0] );
      break;
    case 'a':
      alpha = (float)atof( remArgs[0] );
      break;
    }
  }

  tlSetScreen( scrWidth, scrHeight );

  version = grGetString( GR_VERSION );
    
  printf( "%s:\n%s\n", name, purpose );
  printf( "%s\n", version );
  printf( "Resolution: %s\n", tlGetResolutionString( resolution ) );
  if ( frames == -1 ) {
    printf( "Press A Key To Begin Test.\n" );
    tlGetCH();
  }
    
  grSstSelect( 0 );
  assert( grSstWinOpen(tlGethWnd(),
                       resolution,
                       GR_REFRESH_60Hz,
                       GR_COLORFORMAT_ABGR,
                       origin,
                       2, 1 ) );

  grVertexLayout(GR_PARAM_XY,  GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE);
  grVertexLayout(GR_PARAM_RGB, GR_VERTEX_R_OFFSET << 2, GR_PARAM_ENABLE);
  grVertexLayout(GR_PARAM_A,   GR_VERTEX_A_OFFSET << 2, GR_PARAM_ENABLE);

  grGet(GR_WDEPTH_MIN_MAX, 8, wrange);  
  grGet(GR_GLIDE_STATE_SIZE, 4, &state_size);
  oldState = malloc(state_size);        

  tlConSet( 0.0f, 0.0f, 1.0f, 1.0f,
           80, 40, 0xffffff );

  if(frames == -1) {
    doHelp();
  }

  localVerts[0].x = 0.f;
  localVerts[0].y = 0.75f;
  localVerts[0].z = 0.0f;
  localVerts[0].tmuvtx[0].sow = 255.f;
  localVerts[0].tmuvtx[0].tow = 255.f;
  localVerts[0].oow = 1.f;  
  localVerts[0].r = maxColor;
  localVerts[0].g = minColor;
  localVerts[0].b = minColor;
  localVerts[0].a = 255.f;

  localVerts[1].x = -0.75f;
  localVerts[1].y = -0.75f;
  localVerts[1].z = 0.0f;
  localVerts[1].tmuvtx[0].sow = 0.f;
  localVerts[1].tmuvtx[0].tow = 255.f;
  localVerts[1].oow = 1.f;  
  localVerts[1].r = minColor;
  localVerts[1].g = maxColor;
  localVerts[1].b = minColor;
  localVerts[1].a = 255.f;

  localVerts[2].x = 0.75f;
  localVerts[2].y = -0.75f;
  localVerts[2].z = 0.0f;
  localVerts[2].tmuvtx[0].sow = 255.f;
  localVerts[2].tmuvtx[0].tow = 0.f;
  localVerts[2].oow = 1.f;  
  localVerts[2].r = minColor;
  localVerts[2].g = minColor;
  localVerts[2].b = maxColor;
  localVerts[2].a = 255.f;

  texVerts[0].x = 0.f;
  texVerts[0].y = 0.f;
  texVerts[0].a = 255.f;
  texVerts[0].oow = 1.f;
  texVerts[0].tmuvtx[0].sow = 0.f * texVerts[0].oow;
  texVerts[0].tmuvtx[0].tow = 255.f * texVerts[0].oow;

  texVerts[1].x = scrWidth;
  texVerts[1].y = 0.f;
  texVerts[1].a = 255.f;
  texVerts[1].oow = 1.f;
  texVerts[1].tmuvtx[0].sow = 255.f * texVerts[1].oow;
  texVerts[1].tmuvtx[0].tow = 255.f * texVerts[1].oow;

  texVerts[2].x = scrWidth;
  texVerts[2].y = scrHeight;
  texVerts[2].a = 255.f;
  texVerts[2].oow = 1.f;
  texVerts[2].tmuvtx[0].sow = 255.f * texVerts[2].oow;
  texVerts[2].tmuvtx[0].tow = 0.f * texVerts[2].oow;
  
  texVerts[3].x = 0.f;
  texVerts[3].y = scrHeight;
  texVerts[3].a = 255.f;
  texVerts[3].oow = 1.f;
  texVerts[3].tmuvtx[0].sow = 0.f * texVerts[3].oow;
  texVerts[3].tmuvtx[0].tow = 0.f * texVerts[3].oow;
  
  if (bgFileName == NULL)
    bgFileName = "miro.3df";
  if (triFileName == NULL)
    triFileName = "matt1.3df";
  
  /* Read in background texture file  */
  if ( gu3dfGetInfo( bgFileName, &bgInfo ) )  {
    bgInfo.data = malloc( bgInfo.mem_required );

    if ( bgInfo.data == 0 ) {
      fprintf( stderr, "out of memory for texture file %s\n", bgFileName );
      grGlideShutdown();
      exit( -1 );
    }

    if ( !gu3dfLoad( bgFileName, &bgInfo ) ) {
      fprintf( stderr, "could not load texture file %s\n", bgFileName );
      grGlideShutdown();
      exit( -1 );
    }

    bgDecal.smallLodLog2    = bgInfo.header.small_lod;
    bgDecal.largeLodLog2    = bgInfo.header.large_lod;
    bgDecal.aspectRatioLog2 = bgInfo.header.aspect_ratio;
    bgDecal.data            = bgInfo.data;
    bgDecal.format          = bgInfo.header.format;
    grTexDownloadMipMap( GR_TMU0, startAddress, GR_MIPMAPLEVELMASK_BOTH, &bgDecal);
    grTexMipMapMode(GR_TMU0, GR_MIPMAP_NEAREST, FXTRUE);
    grTexClampMode( GR_TMU0, GR_TEXTURECLAMP_WRAP, GR_TEXTURECLAMP_WRAP);
    grTexFilterMode( GR_TMU0, GR_TEXTUREFILTER_BILINEAR, GR_TEXTUREFILTER_BILINEAR );
    bgDecalAddress = startAddress;
    startAddress += grTexCalcMemRequired ( bgDecal.smallLodLog2, bgDecal.largeLodLog2, 
                                           bgDecal.aspectRatioLog2, bgDecal.format );
    free( bgInfo.data );
  } else {
    fprintf( stderr, "could not get info on %s\n", bgFileName );
    grGlideShutdown();
    exit( -1 );
  }
  
  if ( gu3dfGetInfo( triFileName, &triInfo ) )  {
    triInfo.data = malloc( triInfo.mem_required );
    
    if ( triInfo.data == 0 ) {
      fprintf( stderr, "out of memory for texture file  %s\n", triFileName );
      grGlideShutdown();
      exit( -1 );
    }
    
    if ( !gu3dfLoad( triFileName, &triInfo ) ) {
      fprintf( stderr, "could not load texture file %s\n", triFileName );
      grGlideShutdown();
      exit( -1 );
    }

    triDecal.smallLodLog2    = triInfo.header.small_lod;
    triDecal.largeLodLog2    = triInfo.header.large_lod;
    triDecal.aspectRatioLog2 = triInfo.header.aspect_ratio;
    triDecal.data            = triInfo.data;
    triDecal.format          = triInfo.header.format;
    grTexDownloadMipMap( GR_TMU0, startAddress, GR_MIPMAPLEVELMASK_BOTH, &triDecal);
    grTexMipMapMode(GR_TMU0, GR_MIPMAP_NEAREST, FXTRUE);
    grTexClampMode( GR_TMU0, GR_TEXTURECLAMP_WRAP, GR_TEXTURECLAMP_WRAP);
    grTexFilterMode( GR_TMU0, GR_TEXTUREFILTER_BILINEAR, GR_TEXTUREFILTER_BILINEAR );
    triDecalAddress = startAddress;
    free( triInfo.data );
  } else {
    fprintf( stderr, "could not get info on %s\n", triFileName );
    grGlideShutdown();
    exit( -1 );
  }

  grTexCombine( GR_TMU0, GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE,
                GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE );
  grRenderBuffer(backbuffer == FXTRUE ? GR_BUFFER_BACKBUFFER : GR_BUFFER_FRONTBUFFER);

  /* Set up alpha blending for AA and compositing... */
  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_ONE,
                       GR_BLEND_ZERO );
  grAlphaTestFunction( GR_CMP_ALWAYS );


  while ( 1 ) {
    Matrix rotm;
    GrVertex xformedVerts[VERT_COUNT];
    int i;

    
    MatMakeYRot( rotm, DEG2RAD( y_angle ) );
    
    if (resolution == GR_RESOLUTION_NONE) 
      tlGetResolutionConstant("0",
                              &scrWidth, 
                              &scrHeight );


    for( i = 0; i < VERT_COUNT; i++ ) {
      PointMatMult( &xformedVerts[i], &localVerts[i], rotm );
      xformedVerts[i].x = xformedVerts[i].x / ( xformedVerts[i].z + 2.0f );
      xformedVerts[i].y = xformedVerts[i].y / ( xformedVerts[i].z + 2.0f );
      xformedVerts[i].x *= scrWidth / 2.0f;
      xformedVerts[i].y *= scrHeight / 2.0f;
      xformedVerts[i].x += scrWidth / 2.0f;
      xformedVerts[i].y += scrHeight / 2.0f;
      xformedVerts[i].oow = 1.f / ((xformedVerts[i].z + 2) * scrHeight);
      xformedVerts[i].tmuvtx[0].sow *= xformedVerts[i].oow;
      xformedVerts[i].tmuvtx[0].tow *= xformedVerts[i].oow;
      SNAP_COORD( xformedVerts[i].x );
      SNAP_COORD( xformedVerts[i].y );
    }
    
    switch ( ccFnc )
      {
      case GR_COLORCOMBINE_ITRGB:
        grColorCombine( GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, GR_COMBINE_LOCAL_ITERATED, GR_COMBINE_OTHER_NONE, FXFALSE );
        break;
        
      case GR_COLORCOMBINE_DECAL_TEXTURE:
        grColorCombine( GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_ONE, GR_COMBINE_LOCAL_NONE, GR_COMBINE_OTHER_TEXTURE, FXFALSE );
        break;
        
      case GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB:
        grColorCombine( GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL, GR_COMBINE_LOCAL_ITERATED, GR_COMBINE_OTHER_TEXTURE, FXFALSE );
        break;
      }
    
    /*    grLfbBypassMode(GR_LFBBYPASS_ENABLE); */

    if (render == FXTRUE) {
      ++frameNum;
      if ((frameNum % NFRAMES) == 0) {
        if (printPerf) {
          if (!firstTime)  {
            GrSstPerfStats_t
              pStats;
            FxU32
              lfbWritePixels,
              nFrames = frameNum - lastFrame,
              fillPixels = nFrames * screenFulls[resolution],
              totFail;
            
            lastFrame = frameNum;

            grGet(GR_STATS_PIXELS_IN,             4, &pStats.pixelsIn);
            grGet(GR_STATS_PIXELS_CHROMA_FAIL,    4, &pStats.chromaFail);
            grGet(GR_STATS_PIXELS_DEPTHFUNC_FAIL, 4, &pStats.zFuncFail);
            grGet(GR_STATS_PIXELS_AFUNC_FAIL,     4, &pStats.aFuncFail);
            grGet(GR_STATS_PIXELS_OUT,            4, &pStats.pixelsOut);
            grGet(GR_STATS_TRIANGLES_IN,          4, &trisProcessed);
            grGet(GR_STATS_TRIANGLES_OUT,         4, &trisDrawn);
            
            totFail = pStats.chromaFail + pStats.zFuncFail +
              pStats.aFuncFail;  
            
            lfbWritePixels = pStats.pixelsOut - pStats.pixelsIn - fillPixels;

            tlConOutput("In the last %d frames:\n", nFrames);
            tlConOutput("      Pixels Processed:               %d\n",
                        pStats.pixelsIn);
            tlConOutput("      Chroma Failures:                %d\n",
                        pStats.chromaFail);
            tlConOutput("      Z Compare Failures:             %d\n",
                        pStats.zFuncFail);
            tlConOutput("      Alpha Compare Failures:         %d\n",
                        pStats.aFuncFail);
            tlConOutput("      Fast Fill Pixels:               %d\n",
                        fillPixels);
            tlConOutput("      LFB Write Pixels:               %d\n",
                        lfbWritePixels);                   
            tlConOutput("      Total Pixels Drawn:             %d\n",
                        pStats.pixelsOut);
            tlConOutput("      Triangles Processed             %d\n",
                        trisProcessed);
            tlConOutput("      Triangles Drawn                 %d\n",
                        trisDrawn);

            if (
                (pStats.pixelsOut - lfbWritePixels - fillPixels - pStats.pixelsIn) != totFail)
              tlConOutput("Error:  %d != %d\n",
                          pStats.pixelsOut - lfbWritePixels - fillPixels,
                          totFail);

            grReset(GR_STATS_PIXELS);
          } else {
            lastFrame = frameNum;
            grReset(GR_STATS_PIXELS);
            firstTime = 0;
          }
        }
      }

      grBufferClear( 0xffffffff, 0, (FxU16)wrange[1] );
    
      if (background == FXTRUE) {

        texVerts[0].x = 0.f;
        texVerts[0].y = 0.f;

        texVerts[1].x = scrWidth;
        texVerts[1].y = 0.f;

        texVerts[1].x = scrWidth;
        texVerts[1].y = 0.f;

        texVerts[2].x = scrWidth;
        texVerts[2].y = scrHeight;

        texVerts[3].x = 0.f;
        texVerts[3].y = scrHeight;

        grGlideGetState(oldState);

        grVertexLayout(GR_PARAM_Q,   GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
        grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);

        grAlphaBlendFunction(
                             GR_BLEND_ONE, GR_BLEND_ZERO,
                             GR_BLEND_ONE, GR_BLEND_ZERO);

        grColorCombine(
                       GR_COMBINE_FUNCTION_SCALE_OTHER,
                       GR_COMBINE_FACTOR_ONE,
                       GR_COMBINE_LOCAL_NONE,
                       GR_COMBINE_OTHER_TEXTURE, FXFALSE
                       );

        grTexSource( GR_TMU0, bgDecalAddress, GR_MIPMAPLEVELMASK_BOTH, &bgDecal );
        
        for (i = 0; i < NTRIS; i++) {
          grDrawTriangle(&texVerts[0], &texVerts[1], &texVerts[2]);
          grDrawTriangle(&texVerts[2], &texVerts[3], &texVerts[0]);
        }
        grGlideSetState(oldState);
        grClipWindow(0, 0, (FxU32) scrWidth, (FxU32) scrHeight);

      }

      if (texturing == FXTRUE)
        grTexSource( GR_TMU0, bgDecalAddress, GR_MIPMAPLEVELMASK_BOTH, &bgDecal );

      if (texturing)
        grTexSource( GR_TMU0, triDecalAddress, GR_MIPMAPLEVELMASK_BOTH, &triDecal );

      if (antialias == FXTRUE) {
        grEnable(GR_AA_ORDERED);
        if (lines == FXTRUE) {
          grDrawLine(&xformedVerts[0], &xformedVerts[1]);
          grDrawLine(&xformedVerts[1], &xformedVerts[2]);
          grDrawLine(&xformedVerts[2], &xformedVerts[0]);
        } else {
          grAADrawTriangle(
                           &xformedVerts[0],  &xformedVerts[1],
                           &xformedVerts[2], FXTRUE, FXTRUE, FXTRUE
                           );
        }
      } else {
        grDisable(GR_AA_ORDERED);
        if (lines == FXTRUE) {
          grDrawLine(&xformedVerts[0], &xformedVerts[1]);
          grDrawLine(&xformedVerts[1], &xformedVerts[2]);
          grDrawLine(&xformedVerts[2], &xformedVerts[0]);
        } else {          
          grDrawTriangle(
                         &xformedVerts[0], &xformedVerts[1],
                         &xformedVerts[2]
                         );
        }
      }

      if (plugging) 
        grSplash(0.f, 0.f, scrWidth / 5.f, scrHeight / 5.f, frameNum);
      
      if (backbuffer) {
        tlConRender();
        grBufferSwap( swapDelay );
      }
    }
    
    if (tlKbHit()) {
      char c = (char) tlGetCH();
      
      switch (c) {
      case 'a':
      case 'A':
        if (antialias == FXFALSE) {
          tlConOutput("Turning ON Antialiasing\n");
          antialias = FXTRUE;
        } else {
          tlConOutput("Turning OFF Antialiasing\n");
          antialias = FXFALSE;
        }
        break;
      case 'B':
      case 'b':
        if (bilinear == FXFALSE) {
          bilinear = FXTRUE;
          tlConOutput("Turning ON BiLinear blending\n");
          grTexFilterMode ( GR_TMU0, GR_TEXTUREFILTER_BILINEAR, GR_TEXTUREFILTER_BILINEAR );
        } else {
          bilinear = FXFALSE;
          tlConOutput("Turning OFF BiLinear blending\n");
          grTexFilterMode ( GR_TMU0, GR_TEXTUREFILTER_POINT_SAMPLED, 
                          GR_TEXTUREFILTER_POINT_SAMPLED );
        }
        break;

      case 'c':
      case 'C':
        if (blend == FXTRUE) {
                  int i;
          blend = FXFALSE;
                  for(i=0;i<VERT_COUNT;i++) localVerts[i].a = 255.0f;
        } else {
                  int i;
          blend = FXTRUE;
          for(i=0;i<VERT_COUNT;i++) localVerts[i].a = alpha;
        }
        break;

      case 'd':
      case 'D':
        tlConOutput("vtxa = (%.2f, %.2f), vtxb = (%.2f, %.2f), vtxc = (%.2f, %.2f)\n",
                    xformedVerts[0].x, xformedVerts[0].y,
                    xformedVerts[1].x, xformedVerts[1].y,
                    xformedVerts[2].x, xformedVerts[2].y
                    );
        break;

      case 'f':
      case 'F':
        if (backbuffer == FXTRUE) {
          backbuffer = FXFALSE;
          grRenderBuffer(GR_BUFFER_FRONTBUFFER);
        } else {
          backbuffer = FXTRUE;
          grRenderBuffer(GR_BUFFER_BACKBUFFER);
        }
        break;

      case 'g':
      case 'G':
#if 0
        grLfbBegin();

        grLfbWriteMode(GR_LFBWRITEMODE_565);
        grLfbOrigin(GR_ORIGIN_UPPER_LEFT);
        grLfbGetReadPtr(GR_BUFFER_FRONTBUFFER);
        tlConOutput("Press a key to get front buffer\n");
        while (!tlKbHit());
        c = (char) tlGetCH();
        guFbReadRegion(0,0,(int)wWidth,(int)scrHeight,scrnImage,(int)wWidth * sizeof(FxU16));
        tlConOutput("Press a key to put image in back buffer and swap\n");
        while (!tlKbHit());
        tlGetCH();

        grLfbGetWritePtr(GR_BUFFER_BACKBUFFER);
        guFbWriteRegion(0,0,(int)wWidth,(int)scrHeight,scrnImage,(int)wWidth * sizeof(FxU16));
        grBufferSwap(swapDelay);

        tlConOutput("Press a key to continue...\n");
        while (!tlKbHit());
        tlGetCH();

        grLfbEnd();
#endif
        break;

      case 'h':
      case 'H':
      case '?':
        doHelp();
        break;

      case 'i':
      case 'I':
        if (background == FXTRUE) {
          background = FXFALSE;
          tlConOutput("Turning off background\n");
        } else {
          tlConOutput("Turning on background\n");
          background = FXTRUE;
        }
        break;

      case 'l':
      case 'L':
        if (lines == FXTRUE) {
          lines = FXFALSE;
          tlConOutput("Turning OFF lines\n");
        } else {
          lines = FXTRUE;
          tlConOutput("Turning ON lines\n");
        }
        break;
      case 'm':
      case 'M':
        ccFnc = GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB;
        break;

      case 'n':
      case 'N':
        if (printPerf == FXFALSE) {
          printPerf = FXTRUE;
          firstTime = 1;
          grReset(GR_STATS_PIXELS);
          grReset(GR_STATS_TRIANGLES);
        } else {
          printPerf= FXFALSE;
        }
        break;

      case 'o':
      case 'O':
        if (origin == GR_ORIGIN_LOWER_LEFT)
          origin = GR_ORIGIN_UPPER_LEFT;
        else
          origin = GR_ORIGIN_LOWER_LEFT; 

        grSstOrigin(origin);
        break;

      case 'p':
      case 'P':
        if (render == FXTRUE)
          render = FXFALSE;
        else
          render = FXTRUE;
        break;
        
      case 'q':
      case 'Q':
      case 27:
        grGlideShutdown();
        exit(0);
        break;

      case 'r':
      case 'R':
        tlConOutput("Screen Resolution is %s\n", tlGetResolutionString( resolution ) );
        break;

      case 'S':
      case 's':
        if (cullMode == GR_CULL_DISABLE) {
          cullMode = GR_CULL_NEGATIVE;
          tlConOutput("Turning ON backface culling (hidden Surface removal)\n");
        } else  {
          cullMode = GR_CULL_DISABLE;
          tlConOutput("Turning OFF backface culling (hidden Surface removal)\n");
        }
        grCullMode(cullMode);
        break;
      case 'T':
      case 't':
        if (texturing == FXFALSE) {
          tlConOutput("Turning ON texturing\n");
          ccFnc = GR_COLORCOMBINE_DECAL_TEXTURE;
          texturing = FXTRUE;
          grVertexLayout(GR_PARAM_Q,   GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
          grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);
        } else {
          tlConOutput("Turning OFF texturing\n");
          ccFnc = GR_COLORCOMBINE_ITRGB;
          texturing = FXFALSE;
          grVertexLayout(GR_PARAM_Q,   GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_DISABLE);
          grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_DISABLE);
        }
        break;
      case 'u':
      case 'U':
        if (plugging == FXTRUE) {
          plugging = FXFALSE;
          grDisable(GR_SHAMELESS_PLUG);
        }
        else {
          plugging = FXTRUE;
          grEnable(GR_SHAMELESS_PLUG);
        }
        break;
        
      case '1':
      case '2':
      case '3':
      case '4':
      case '5':
      case '6':
      case '7':
      case '8':
      case '9':
      case '0':
        {
          char str[256];
          swapDelay = (int) c - 0x30;
          sprintf(str, "Swapdelay = %d\n", swapDelay);
          tlConOutput(str);
        }
        break;
      }
    }
    
    if (render) {
      y_angle += 2.f;
      if( y_angle > 360.0f )
        y_angle -= 360.0f;
    }
    frameCount++;
    if(frameCount < 0)
      frameCount = 0;
    if(frames == frameCount)
      break;
  }
  grGlideShutdown();
}
コード例 #15
0
ファイル: TEST44.C プロジェクト: grakidov/Render3D
void main( int argc, char *argv[] ) {
  char
    texFile[256],
    texFile1[256],
    texFile2[256];
  float
    theta;
  
  FxU32
    numTmus = 1;
  
  FxBool
    paused = FXFALSE;

  Gu3dfInfo
    info, info2;
  FxU32
    numFrames = 0xffffffff;
 
  puts("TEST44: Tests complex, multi-tmu textures\n");
  puts("Press a key to continue...\n");
  getch();
  puts("Press q to quit\n");

  /* Glide State Initialization */
  grGlideInit();
  grSstQueryHardware( &hwConfig );
  grSstSelect( 0 );
  grSstOpen( screenRes,
            GR_REFRESH_60Hz,
            GR_COLORFORMAT_ABGR,
            GR_ORIGIN_LOWER_LEFT,
            GR_SMOOTHING_ENABLE,
            2 );
  grColorCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,
                 GR_COMBINE_FACTOR_ONE,
                 GR_COMBINE_LOCAL_NONE,
                 GR_COMBINE_OTHER_TEXTURE,
                 FXFALSE );
  grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,
                 GR_COMBINE_FACTOR_ONE,
                 GR_COMBINE_LOCAL_NONE,
                 GR_COMBINE_OTHER_TEXTURE,
                 FXFALSE );
  grTexCombine( GR_TMU0,
               GR_COMBINE_FUNCTION_LOCAL,
               GR_COMBINE_FACTOR_ZERO,
               GR_COMBINE_FUNCTION_LOCAL,
               GR_COMBINE_FACTOR_ZERO,
               FXFALSE,
               FXFALSE );
  
  if ( hwConfig.SSTs[0].sstBoard.VoodooConfig.nTexelfx == 2 ) {
    printf( "Detected 2 TMUs\n" );
    grTexCombine( GR_TMU1,
                 GR_COMBINE_FUNCTION_LOCAL,
                 GR_COMBINE_FACTOR_ZERO,
                 GR_COMBINE_FUNCTION_LOCAL,
                 GR_COMBINE_FACTOR_ZERO,
                 FXFALSE,
                 FXFALSE );
    numTmus = 2;
  }
  
  /*------------------------------------------------------------------
    Deal With Arguments
    ------------------------------------------------------------------*/
  if ( numTmus == 1 ) {
    if ( argc < 2 ) {
      printf( "%s ", argv[0] );
      puts( usage_1tmu );
      grGlideShutdown();
      return;
    }
    argc--;argv++;
    while(argc) {
      if(strcmp(argv[0], "-n") == 0)  {
        argc--;argv++;
        if(argc)
          numFrames = atoi(argv[0]);
        else {
          puts( usage_1tmu );
          return;
        }
      }
      strcpy( texFile, argv[0] );
      strcpy( texFile1, argv[1] );
      argc--;argv++;
      argc--;argv++;
    }
  } else {
    if ( argc < 4 ) {
      printf( "%s ", argv[0] );
      puts( usage2tmu );
      grGlideShutdown();
      return;
    }
    argc--;argv++;
    while(argc) {
      if(strcmp(argv[0], "-n") == 0) {
        argc--;argv++;
        if(argc)
          numFrames = atoi(argv[0]);
        else {
          puts( usage_1tmu );
          return;
        }
      }
      strcpy( texFile, argv[0] );    
      strcpy( texFile1, argv[1]);
      strcpy( texFile2, argv[2] );
      argc -= 3;
      argv += 3;
    }
  }
  
  grAlphaBlendFunction( GR_BLEND_ONE, GR_BLEND_ZERO,
                       GR_BLEND_ONE, GR_BLEND_ZERO );
  
  grDepthBufferMode( GR_DEPTHBUFFER_DISABLE );
  grDepthBufferFunction( GR_CMP_LEQUAL );
  grDepthMask( FXFALSE );
  
  grCullMode( GR_CULL_DISABLE );
  
  grBufferClear( 0x0, 0x0, 0x0 );
  
  /*------------------------------------------------------------------
    Load Texture(s)
    ------------------------------------------------------------------*/
  if ( !gu3dfGetInfo( texFile, &info ) ) {
    printf( "Couldn't load %s.\n", texFile );
    return;
  }
  info.data = calloc( info.mem_required, 1 );
  gu3dfLoad( texFile, &info );
  
  texInfo.smallLod    = info.header.small_lod;
  texInfo.largeLod    = info.header.large_lod;
  texInfo.aspectRatio = info.header.aspect_ratio;
  texInfo.format      = info.header.format;
  texInfo.data        = info.data;
  
  if ( texInfo.format == GR_TEXFMT_YIQ_422 ||
      texInfo.format == GR_TEXFMT_AYIQ_8422 ) {
    puts( "*******************YIQ TEXTURE(TMU0)***************" );
    nccTable = info.table.nccTable;
    hasTable = FXTRUE;
  }
  
  if ( texInfo.format == GR_TEXFMT_P_8 ||
      texInfo.format == GR_TEXFMT_AP_88 ) {
    puts( "*******************PAL TEXTURE(TMU0)***************" );
    pal0 = info.table.palette;
   hasPalette = FXTRUE;
  }

  /* ++++ */
  if ( !gu3dfGetInfo( texFile1, &info ) ) {
    printf( "Couldn't load %s.\n", texFile1 );
    return;
  }
  info.data = calloc( info.mem_required, 1 );
  gu3dfLoad( texFile1, &info );
  
  texInfo1.smallLod    = info.header.small_lod;
  texInfo1.largeLod    = info.header.large_lod;
  texInfo1.aspectRatio = info.header.aspect_ratio;
  texInfo1.format      = info.header.format;
  texInfo1.data        = info.data;
  
  if ( texInfo1.format == GR_TEXFMT_YIQ_422 ||
      texInfo1.format == GR_TEXFMT_AYIQ_8422 ) {
    puts( "*******************YIQ TEXTURE(TMU0)***************" );
    nccTable = info.table.nccTable;
    hasTable = FXTRUE;
  }
  
  if ( texInfo1.format == GR_TEXFMT_P_8 ||
      texInfo1.format == GR_TEXFMT_AP_88 ) {
    puts( "*******************PAL TEXTURE(TMU0)***************" );
    pal0 = info.table.palette;
    hasPalette1 = FXTRUE;
  }


  /* ++++ */

  if ( numTmus == 2 ) {
    if ( !gu3dfGetInfo( texFile2, &info2 ) ) {
      printf( "Couldn't load %s.\n", texFile2 );
      return;
    }
    info2.data = calloc( info2.mem_required, 1 );
    gu3dfLoad( texFile2, &info2 );
    
    texInfo2.smallLod    = info2.header.small_lod;
    texInfo2.largeLod    = info2.header.large_lod;
    texInfo2.aspectRatio = info2.header.aspect_ratio;
    texInfo2.format      = info2.header.format;
    texInfo2.data        = info2.data;
    
    if ( texInfo2.format == GR_TEXFMT_YIQ_422 ||
        texInfo2.format == GR_TEXFMT_AYIQ_8422 ) {
      puts( "*******************YIQ TEXTURE(TMU1)***************" );
      nccTable2 = info2.table.nccTable;
      hasTable2 = FXTRUE;
    }
    if ( texInfo2.format == GR_TEXFMT_P_8 ||
        texInfo2.format == GR_TEXFMT_AP_88 ) {
      puts( "*******************PAL TEXTURE(TMU1)***************" );
      pal2 = info2.table.palette;
      hasPalette2 = FXTRUE;
    }
  }
  
  grHints(GR_HINT_STWHINT, GR_STWHINT_W_DIFF_TMU0 |
          GR_STWHINT_ST_DIFF_TMU0 | GR_STWHINT_W_DIFF_TMU1 |
          GR_STWHINT_ST_DIFF_TMU1);
  
  
  /*------------------------------------------------------------------
    Allocate Texture RAM
    ------------------------------------------------------------------*/
  tmu0Tex0Address = startAddress =
    nextAddress = grTexMinAddress( GR_TMU0 );
  tmu0Tex1Address = nextAddress  = startAddress +
    grTexTextureMemRequired( GR_MIPMAPLEVELMASK_BOTH, &texInfo );
  
  
  printf( "tex0: tmu0Tex0Address: %d tmu0Tex1Address %d\n",
         tmu0Tex0Address, tmu0Tex1Address);
  
  if ( nextAddress > grTexMaxAddress( GR_TMU0 ) ) {
    printf( "Texture memory exhausted.\n" );
    return;
  }
  
  if ( numTmus == 2 ) {
    startAddress2 =  nextAddress2 = grTexMinAddress( GR_TMU1 );
    nextAddress2  = startAddress2 + 
      grTexTextureMemRequired( GR_MIPMAPLEVELMASK_BOTH,
                              &texInfo2 );
    printf( "tex1: startAddress: %d nextAddress %d\n", startAddress2, nextAddress2 );
  }
  
  /*------------------------------------------------------------------
    Download Texture(s)
    ------------------------------------------------------------------*/
  grTexDownloadMipMap( GR_TMU0,
                      tmu0Tex0Address,
                      GR_MIPMAPLEVELMASK_BOTH,
                      &texInfo );
  /* ---- */
  grTexDownloadMipMap( GR_TMU0,
                      tmu0Tex1Address,
                      GR_MIPMAPLEVELMASK_BOTH,
                      &texInfo1 );


  /* ---- */

  if ( numTmus == 2 ) {
    grTexDownloadMipMap( GR_TMU1,
                        startAddress2,
                        GR_MIPMAPLEVELMASK_BOTH,
                        &texInfo2 );
    if ( hasTable2 ) {
      grTexNCCTable( GR_TMU1, GR_NCCTABLE_NCC0 );
      grTexDownloadTable( GR_TMU1,
                         GR_TEXTABLE_NCC0,
                         &nccTable2 );
    }

    if ( hasPalette2 ) {
      grTexDownloadTable( GR_TMU1,
                         GR_TEXTABLE_PALETTE,
                         &pal2 );
    }
  }
  
  /*------------------------------------------------------------------
    Set up Texture Params and Set Texture As Current
    ------------------------------------------------------------------*/
  grTexFilterMode( GR_TMU0,
                  GR_TEXTUREFILTER_BILINEAR, 
                  GR_TEXTUREFILTER_BILINEAR );
  grTexClampMode( GR_TMU0,
                 GR_TEXTURECLAMP_WRAP,
                 GR_TEXTURECLAMP_WRAP );
  grTexMipMapMode( GR_TMU0,
                  GR_MIPMAP_NEAREST,
                  FXFALSE );
  grTexSource( GR_TMU0,
              startAddress,
              GR_MIPMAPLEVELMASK_BOTH,
              &texInfo );
  


  if ( numTmus == 2 ) {
    grTexFilterMode( GR_TMU1,
                    GR_TEXTUREFILTER_BILINEAR, 
                    GR_TEXTUREFILTER_BILINEAR );
    grTexClampMode( GR_TMU1,
                   GR_TEXTURECLAMP_WRAP,
                   GR_TEXTURECLAMP_WRAP );
    grTexMipMapMode( GR_TMU1,
                    GR_MIPMAP_NEAREST,
                    FXFALSE );
    grTexSource( GR_TMU1,
                startAddress2,
                GR_MIPMAPLEVELMASK_BOTH, 
                &texInfo2 );
  }
  
  if ( numTmus == 2 ) {
    grTexCombine( GR_TMU1,
                  GR_COMBINE_FUNCTION_LOCAL,
                  GR_COMBINE_FACTOR_NONE,
                  GR_COMBINE_FUNCTION_LOCAL,
                  GR_COMBINE_FACTOR_NONE,
                  FXFALSE,
                  FXFALSE );

    grTexCombine( GR_TMU0,
                  GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
                  GR_COMBINE_FACTOR_ONE, 
                  GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
                  GR_COMBINE_FACTOR_ONE,
                  FXFALSE,
                  FXFALSE ); 
  }
  
#define INC 0.5f
  
  theta = 0.f;
  while (1 && numFrames) {
    if (paused == FXFALSE) {
      theta += INC;
      if (theta > 180.f)
        theta -= 180.f;
    }

    square(0.f, 0.f, 640.3f, 480.f, DEG2RAD(theta));

    grBufferSwap( 1 );

    if (kbhit()) {
      char c;
      c = getch();

      switch (c) {
      case '-':
        theta -= INC;
        break;

      case '+':
        theta += INC;
        break;

      case 'd':
      case 'D':
        printf("theta = %3.1f\n", theta);
        break;

      case 'P':
      case 'p':
        if (paused == FXFALSE)
          paused = FXTRUE;
        else
          paused = FXFALSE;
        break;

      case 'q':
      case 'Q':
      case 27:
        grGlideShutdown();
        exit(0);
        break;
      }
    } /* input switch */
    if(numFrames != -1)
      numFrames--;
  } /* render loop */
}/* main */
コード例 #16
0
ファイル: test29.c プロジェクト: basecq/q2dos
void main(int argc, char **argv) {
  char match; 
  char **remArgs;
  int  rv;

  GrScreenResolution_t resolution = GR_RESOLUTION_640x480;
  float                scrWidth   = 640.0f;
  float                scrHeight  = 480.0f;
  int frames                      = -1;
  FxBool               scrgrab = FXFALSE;
  char                 filename[256];
  FxU32                wrange[2];

  GrLOD_t              largeLod   = GR_LOD_LOG2_256;
  GrLOD_t              smallLod   = GR_LOD_LOG2_1;
  GrTexTable_t         curPalType = GR_TEXTABLE_PALETTE;
  FxU32                compBits   = 0x08UL;
  FxBool               singleTexP = FXFALSE;
  FxBool               extMirrorP = FXFALSE;
  FxBool               extPalP    = FXFALSE;
  float                minTexCoor = 0.0f;
  float                maxTexCoor = 256.0f;

  /* Initialize Glide */
  grGlideInit();
  assert(hwconfig = tlVoodooType());

  /* Process Command Line Arguments */
  while(rv = tlGetOpt(argc, argv, "dlmnprs", &match, &remArgs)) {
    if (rv == -1) {
      printf("Unrecognized command line argument\n");
      printf("%s %s\n", name, usage);
      printf("Available resolutions:\n%s\n",
              tlGetResolutionList());
      return;
    }
    switch(match) {
    case 'd':
      scrgrab = FXTRUE;
      frames = 1;
      strcpy(filename, remArgs[0]);
      break;
    case 'l':
      if (sscanf(remArgs[0], "%d,%d", &smallLod, &largeLod) != 2) {
        largeLod = GR_LOD_LOG2_256;
        smallLod = GR_LOD_LOG2_1;
      } else {
        GrLOD_t
          maxLod,
          lodShift;

        if (grGet(GR_MAX_TEXTURE_SIZE, sizeof(maxLod), &maxLod) == 0) {
          largeLod = GR_LOD_LOG2_256;
          smallLod = GR_LOD_LOG2_1;
        } else {
          lodShift = 0;
          while((0x01 << lodShift) != maxLod) lodShift++;
          if (largeLod > lodShift) largeLod = lodShift;
        }
      }
      break;
    case 'm':
      extMirrorP = FXTRUE;
      break;
    case 'n':
      frames = atoi(remArgs[0]);
      break;
    case 'p':
      extPalP = FXTRUE;
      break;
    case 'r':
      resolution = tlGetResolutionConstant(remArgs[0], 
                                           &scrWidth, 
                                           &scrHeight);
      break;
    case 's':
      singleTexP = FXTRUE;
      break;
    }
  }

  tlSetScreen(scrWidth, scrHeight);

  version = grGetString(GR_VERSION);

  printf("%s:\n%s\n", name, purpose);
  printf("%s\n", version);
  printf("Resolution: %s\n", tlGetResolutionString(resolution));
  if (frames == -1) {
    printf("Press A Key To Begin Test.\n");
    tlGetCH();
  }
    
  grSstSelect(0);
  assert(grSstWinOpen(tlGethWnd(),
                      resolution,
                      GR_REFRESH_60Hz,
                      GR_COLORFORMAT_ABGR,
                      GR_ORIGIN_UPPER_LEFT,
                      2, 1));
    
  tlConSet(0.0f, 0.0f, 1.0f, 1.0f, 
            60, 30, 0xffffff);

  /* Set up Render State */
  grGet(GR_WDEPTH_MIN_MAX, 8, wrange);  
  grVertexLayout(GR_PARAM_XY,  0, GR_PARAM_ENABLE);
  grVertexLayout(GR_PARAM_Q,   GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
  grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);

  grColorCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,
                 GR_COMBINE_FACTOR_ONE,
                 GR_COMBINE_LOCAL_CONSTANT,
                 GR_COMBINE_OTHER_TEXTURE,
                 FXFALSE);
  grTexCombine(GR_TMU0,
               GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_ONE,
               GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_ONE,
               FXFALSE, FXFALSE);

  /* Load texture data into system ram */
  if (!singleTexP) {
    FxI32 numTmu = 0;

    if (grGet(GR_NUM_TMU, sizeof(numTmu), &numTmu) && (numTmu > 1)) {
      TlTexture  texture;
      
      assert(tlLoadTexture("decal1.3df", 
                           &texture.info, 
                           &texture.tableType, 
                           &texture.tableData));
      /* Download texture data to TMU */
      grTexDownloadMipMap(GR_TMU1,
                          grTexMinAddress(GR_TMU1),
                          GR_MIPMAPLEVELMASK_BOTH,
                          &texture.info);
      if (texture.tableType != NO_TABLE) {
        grTexDownloadTable(texture.tableType,
                           &texture.tableData);
      }
      grTexSource(GR_TMU1,
                  grTexMinAddress(GR_TMU1),
                  GR_MIPMAPLEVELMASK_BOTH,
                  &texture.info);

      grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_ENABLE);

      grTexCombine(GR_TMU1,
                   GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_ONE,
                   GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_ONE,
                   FXFALSE, FXFALSE);
      grTexCombine(GR_TMU0,
                   GR_COMBINE_FUNCTION_BLEND_OTHER, GR_COMBINE_FACTOR_LOCAL,
                   GR_COMBINE_FUNCTION_BLEND_OTHER, GR_COMBINE_FACTOR_LOCAL,
                   FXFALSE, FXFALSE);
    }    
  }

  if (extMirrorP || extPalP) {
    const char* extString = grGetString(GR_EXTENSION);
    const char* tempStr = extString;
    
    while(tempStr != NULL) {
      const char* keyList[] = {
        "TEXMIRROR",
        "PALETTE6666"
      };
      
      if (extMirrorP && 
          !singleTexP && 
          (strncmp(tempStr, keyList[0], strlen(keyList[0])) == 0)) {
        grTexClampMode(GR_TMU0, 
                       GR_TEXTURECLAMP_MIRROR_EXT, 
                       GR_TEXTURECLAMP_MIRROR_EXT);
        minTexCoor = -256.0f;
        maxTexCoor =  512.0f;
      }
      
      if (extPalP && 
          (strncmp(tempStr, keyList[1], strlen(keyList[1])) == 0)) {
        curPalType = GR_TEXTABLE_PALETTE_6666_EXT;
        compBits = 0x06UL;
      }
      
      tempStr = strchr(tempStr, ' ');
      if (tempStr != NULL) tempStr++;
    }
  }
  
  {
    GuTexPalette texPal;
    GrTexInfo texInfo;
    unsigned char* texData = NULL, *tmp;
    int i, j, k;

    i = 0;
    while(i < 256) {
      const FxU32 compVal = (FxU32)(i * (0x01UL << compBits) / 256.0f);

      texPal.data[i] = ((compVal << (compBits * 2)) |
                        (compVal << (compBits * 1)) |
                        (compVal << (compBits * 0)));
      i++;
    }

    /* Download this in a sequential way to test the palette download */
    i = 0;
    while(i < 256) {
      const int max = i + (rand() % 10);
      const int end = MIN(max, 255);

      grTexDownloadTablePartial(curPalType, &texPal, i, end);
      i = end + 1;
    }

    i = 0;
    for(k = largeLod; k >= smallLod; k--) {
      i += ((0x01 << k) * (0x01 << k));
    }
    texData = (unsigned char*)malloc(i * 2);
    if (texData == NULL) {
      printf("Unable to allocate texture data.\n");
      goto __errExit;
    }

    /* Download dumb palettized texture */
    texInfo.smallLodLog2 = smallLod;
    texInfo.largeLodLog2 = largeLod;
    texInfo.aspectRatioLog2 = GR_ASPECT_LOG2_1x1;
    texInfo.format = GR_TEXFMT_P_8;
    texInfo.data = (void*)texData;
    
    for(k = texInfo.largeLodLog2; k >= texInfo.smallLodLog2; k--) {
      const int texDim = (0x01 << k);
      const float levelStep = (256.0f / texDim);
      tmp=texData;

      for(i = 0; i < texDim; i++) {
        for(j = 0; j < texDim; j++) {
          *tmp++ = (FxU8)(levelStep * i); 
        }
      }
    }

    grTexDownloadMipMap(GR_TMU0, 0, GR_MIPMAPLEVELMASK_BOTH, &texInfo);
    grTexSource(GR_TMU0, 0, GR_MIPMAPLEVELMASK_BOTH, &texInfo);

    free((void*)texData);
  }
  
  tlConOutput("Press a key to quit\n");
  while(frames-- && tlOkToRender()) {
    GrVertex vtxA, vtxB, vtxC;

    if (hwconfig == TL_VOODOORUSH) {
      tlGetDimsByConst(resolution,
                       &scrWidth, 
                       &scrHeight);
        
      grClipWindow(0, 0, (FxU32) scrWidth, (FxU32) scrHeight);
    }

    grBufferClear(0xFF00FF00, 0xFF, wrange[1]);

    /* Triangle w/ texture ramp going across and down. */
    vtxA.oow = 
    vtxB.oow =
    vtxC.oow = 1.0f;

    {
      vtxA.x = tlScaleX(0.2f), vtxA.y = tlScaleY(0.2f);
      vtxA.tmuvtx[0].sow = minTexCoor;
      vtxA.tmuvtx[0].tow = minTexCoor;
      vtxA.tmuvtx[1].sow = 0.0f;
      vtxA.tmuvtx[1].tow = 0.0f;
      
      vtxB.x = tlScaleX(0.8f), vtxB.y = tlScaleY(0.2f);
      vtxB.tmuvtx[0].sow = maxTexCoor;
      vtxB.tmuvtx[0].tow = minTexCoor;
      vtxB.tmuvtx[1].sow = 255.0f;
      vtxB.tmuvtx[1].tow = 0.0f;
      
      vtxC.x = tlScaleX(0.8f), vtxC.y = tlScaleY(0.8f);
      vtxC.tmuvtx[0].sow = maxTexCoor;
      vtxC.tmuvtx[0].tow = maxTexCoor;
      vtxC.tmuvtx[1].sow = 255.0f;
      vtxC.tmuvtx[1].tow = 255.0f;

      grDrawTriangle(&vtxA, &vtxB, &vtxC);
    }

    {
      vtxA.x = tlScaleX(0.2f), vtxA.y = tlScaleY(0.2f);
      vtxA.tmuvtx[0].sow = minTexCoor;
      vtxA.tmuvtx[0].tow = minTexCoor;
      vtxA.tmuvtx[1].sow = 0.0f;
      vtxA.tmuvtx[1].tow = 0.0f;
      
      vtxB.x = tlScaleX(0.8f), vtxB.y = tlScaleY(0.8f);
      vtxB.tmuvtx[0].sow = maxTexCoor;
      vtxB.tmuvtx[0].tow = maxTexCoor;
      vtxB.tmuvtx[1].sow = 255.0f;
      vtxB.tmuvtx[1].tow = 255.0f;
      
      vtxC.x = tlScaleX(0.2f), vtxC.y = tlScaleY(0.8f);
      vtxC.tmuvtx[0].sow = minTexCoor;
      vtxC.tmuvtx[0].tow = maxTexCoor;
      vtxC.tmuvtx[1].sow = 0.0f;
      vtxC.tmuvtx[1].tow = 255.0f;
      
      grDrawTriangle(&vtxA, &vtxB, &vtxC);
    }

    tlConRender();
    grBufferSwap(1);

    /* grab the frame buffer */
    if (scrgrab) {
      if (!tlScreenDump(filename, (FxU16)scrWidth, (FxU16)scrHeight))
        printf("Cannot open %s\n", filename);
      scrgrab = FXFALSE;
    }

    if (tlKbHit()) frames = 0;
  }

__errExit:    
  grGlideShutdown();
}
コード例 #17
0
ファイル: TEST29.C プロジェクト: grakidov/Render3D
void
main( int argc, char **argv )
{
  float color = 255.f;

  float
    wWidth, wHeight;
  GrScreenResolution_t
    screenRes;

  GrVertex
    vtx1, vtx2, vtx3;
  
  int
    frameCount = 0,
    numFrames = -1,
    i;

  wWidth = 640.f;
  wHeight = 480.f;
  screenRes = GR_RESOLUTION_640x480;
  
  if (argc > 1) {
    for(i = 1; i < argc; i++) {
      if (strstr(argv[1], "320x200")) {
        wWidth = 320.f; wHeight = 200.f;
        screenRes = GR_RESOLUTION_320x200;
      } else if (strstr(argv[i], "320x240")) {
        wWidth = 320.f; wHeight = 240.f;
        screenRes = GR_RESOLUTION_320x240;
      } else if (strstr(argv[i], "400x256")) {
        wWidth = 400.f; wHeight = 256.f;
        screenRes = GR_RESOLUTION_400x256;
      } else if (strstr(argv[i], "512x384")) {
        wWidth = 512.f; wHeight = 384.f;
        screenRes = GR_RESOLUTION_512x384;
      } else if (strstr(argv[i], "640x480")) {
        wWidth = 640.f; wHeight = 480.f;
        screenRes = GR_RESOLUTION_640x480;
      } else if (strstr(argv[i], "800x600")) {
        wWidth = 800.f; wHeight = 600.f;
        screenRes = GR_RESOLUTION_800x600;
      } else if (strstr(argv[i], "640x200")) {
        wWidth = 640.f; wHeight = 200.f;
        screenRes = GR_RESOLUTION_640x200;
      } else if (strstr(argv[i], "640x350")) {
        wWidth = 640.f; wHeight = 350.f;
        screenRes = GR_RESOLUTION_640x350;
      } else if (strstr(argv[i], "640x400")) {
        wWidth = 640.f; wHeight = 400.f;
        screenRes = GR_RESOLUTION_640x400;
      } else if (strstr(argv[i], "960x720")) {
        wWidth = 960.f; wHeight = 720.f;
        screenRes = GR_RESOLUTION_960x720;
      } else if (strstr(argv[i], "-n")) {
        if(argc > i + 1) {
          numFrames = atoi(argv[i + 1]);
          i++;
        } else {
          fprintf(stderr, "Usage: test29 {320x200|320x240|400x256|512x384|640x480|800x600|640x200|640x350|640x400|960x720} {-n numFrames}\n");    
          exit(-1);
        }
      } else {
        fprintf(stderr, "Usage: test29 {320x200|320x240|400x256|512x384|640x480|800x600|640x200|640x350|640x400|960x720} {-n numFrames}\n");
      exit(-1);
      }
    }
  }

  puts( "\nTEST29:" );
  puts( "renders a Gouraud shaded triangle bigger than the screen with clipping" );
  if(numFrames == -1)
  {
    puts( "press a key to continue" );
    getch();
  }

  grGlideInit();

  if ( !grSstQueryHardware( &hwconfig ) )
  {
    fprintf( stderr, "main: grSstQueryHardware failed!\n" );
    grGlideShutdown();
    exit( -1 );
  }

  /*
  ** Select SST 0
  */
  grSstSelect( 0 );

  /*
  ** Open up the hardware
  */
  if ( !grSstOpen( screenRes,
                   GR_REFRESH_60Hz,
                   GR_COLORFORMAT_ABGR,
                   GR_ORIGIN_LOWER_LEFT,
                   GR_SMOOTHING_ENABLE,
                   2 ) )
  {
    fprintf( stderr, "main: grSstOpen failed!\n" );
    grGlideShutdown();
    exit( -1 );
  }

  guColorCombineFunction( GR_COLORCOMBINE_ITRGB );
  
  vtx1.x   = -2000.f;
  vtx1.y   = 2000.f;
  vtx1.r   = color;
  vtx1.g   = 0.f;
  vtx1.b   = 0.f;
  vtx2.x   = 2000.f;
  vtx2.y   = 2000.f;
  vtx2.r   = 0.f;
  vtx2.g   = color;
  vtx2.b   = 0.f;
  vtx3.x   = 320.f;
  vtx3.y   = -2000.f;
  vtx3.r   = 0.f;
  vtx3.g   = 0.f;
  vtx3.b   = color;
  
  vtx1.x = WINSCALEX(vtx1.x);
  vtx1.y = WINSCALEY(vtx1.y);
  
  vtx2.x = WINSCALEX(vtx2.x);
  vtx2.y = WINSCALEY(vtx2.y);
  
  vtx3.x = WINSCALEX(vtx3.x);
  vtx3.y = WINSCALEY(vtx3.y);
  
  while ( 1 ) {
    grBufferClear( 0, 0, GR_WDEPTHVALUE_FARTHEST );
    
    guDrawTriangleWithClip( &vtx1, &vtx2, &vtx3 );
    
    grBufferSwap( 1 );
    if (kbhit()) {
      getch();
      break;
    }
    frameCount++;
    if(frameCount < 0)
      frameCount = 0;
    if(frameCount == numFrames)
      break;
  }
  grGlideShutdown();
}
コード例 #18
0
/*
 * Create a new FX/Mesa context and return a handle to it.
 */
fxMesaContext GLAPIENTRY
fxMesaCreateContext(GLuint win,
		    GrScreenResolution_t res,
		    GrScreenRefresh_t ref, const GLint attribList[])
{
 fxMesaContext fxMesa = NULL;
 GLcontext *ctx = NULL, *shareCtx = NULL;
 struct dd_function_table functions;

 int i;
 const char *str;
 int sliaa, numSLI, samplesPerChip;
 struct SstCard_St *voodoo;
 struct tdfx_glide *Glide;

 GLboolean aux;
 GLboolean doubleBuffer;
 GLuint colDepth;
 GLuint depthSize, alphaSize, stencilSize, accumSize;
 GLuint redBits, greenBits, blueBits, alphaBits;
 GrPixelFormat_t pixFmt;
   
 if (TDFX_DEBUG & VERBOSE_DRIVER) {
    fprintf(stderr, "fxMesaCreateContext(...)\n");
 }

 /* Okay, first process the user flags */
 aux = GL_FALSE;
 doubleBuffer = GL_FALSE;
 colDepth = 16;
 depthSize = alphaSize = stencilSize = accumSize = 0;

 i = 0;
 while (attribList[i] != FXMESA_NONE) {
       switch (attribList[i]) {
              case FXMESA_COLORDEPTH:
	           colDepth = attribList[++i];
	           break;
              case FXMESA_DOUBLEBUFFER:
	           doubleBuffer = GL_TRUE;
	           break;
              case FXMESA_ALPHA_SIZE:
	           if ((alphaSize = attribList[++i])) {
	              aux = GL_TRUE;
                   }
	           break;
              case FXMESA_DEPTH_SIZE:
	           if ((depthSize = attribList[++i])) {
	              aux = GL_TRUE;
                   }
	           break;
              case FXMESA_STENCIL_SIZE:
	           stencilSize = attribList[++i];
	           break;
              case FXMESA_ACCUM_SIZE:
	           accumSize = attribList[++i];
	           break;
              /* XXX ugly hack here for sharing display lists */
              case FXMESA_SHARE_CONTEXT:
                   shareCtx = (GLcontext *)attribList[++i];
	           break;
              default:
                   fprintf(stderr, "fxMesaCreateContext: ERROR: wrong parameter (%d) passed\n", attribList[i]);
	           return NULL;
       }
       i++;
 }

 if (!fxQueryHardware()) {
    str = "no Voodoo hardware!";
    goto errorhandler;
 }

 grSstSelect(glbCurrentBoard);
 /*grEnable(GR_OPENGL_MODE_EXT);*/ /* [koolsmoky] */
 voodoo = &glbHWConfig.SSTs[glbCurrentBoard];

 fxMesa = (fxMesaContext)CALLOC_STRUCT(tfxMesaContext);
 if (!fxMesa) {
    str = "private context";
    goto errorhandler;
 }

 if (getenv("MESA_FX_INFO")) {
    fxMesa->verbose = GL_TRUE;
 }

 fxMesa->type = voodoo->type;
 fxMesa->HavePalExt = voodoo->HavePalExt && !getenv("MESA_FX_IGNORE_PALEXT");
 fxMesa->HavePixExt = voodoo->HavePixExt && !getenv("MESA_FX_IGNORE_PIXEXT");
 fxMesa->HaveTexFmt = voodoo->HaveTexFmt && !getenv("MESA_FX_IGNORE_TEXFMT");
 fxMesa->HaveCmbExt = voodoo->HaveCmbExt && !getenv("MESA_FX_IGNORE_CMBEXT");
 fxMesa->HaveMirExt = voodoo->HaveMirExt && !getenv("MESA_FX_IGNORE_MIREXT");
 fxMesa->HaveTexUma = voodoo->HaveTexUma && !getenv("MESA_FX_IGNORE_TEXUMA");
 fxMesa->Glide = glbHWConfig.Glide;
 Glide = &fxMesa->Glide;
 fxMesa->HaveTexus2 = Glide->txImgQuantize &&
                      Glide->txMipQuantize &&
                      Glide->txPalToNcc && !getenv("MESA_FX_IGNORE_TEXUS2");

 /* Determine if we need vertex swapping, RGB order and SLI/AA */
 sliaa = 0;
 switch (fxMesa->type) {
        case GR_SSTTYPE_VOODOO:
        case GR_SSTTYPE_SST96:
        case GR_SSTTYPE_Banshee:
             fxMesa->bgrOrder = GL_TRUE;
             fxMesa->snapVertices = (getenv("MESA_FX_NOSNAP") == NULL);
             break;
        case GR_SSTTYPE_Voodoo2:
             fxMesa->bgrOrder = GL_TRUE;
             fxMesa->snapVertices = GL_FALSE;
             break;
        case GR_SSTTYPE_Voodoo4:
        case GR_SSTTYPE_Voodoo5:
             /* number of SLI units and AA Samples per chip */
             if ((str = Glide->grGetRegistryOrEnvironmentStringExt("SSTH3_SLI_AA_CONFIGURATION")) != NULL) {
                sliaa = atoi(str);
             }
        case GR_SSTTYPE_Voodoo3:
        default:
             fxMesa->bgrOrder = GL_FALSE;
             fxMesa->snapVertices = GL_FALSE;
             break;
 }
 /* XXX todo - Add the old SLI/AA settings for Napalm. */
 switch(voodoo->numChips) {
 case 4: /* 4 chips */
   switch(sliaa) {
   case 8: /* 8 Sample AA */
     numSLI         = 1;
     samplesPerChip = 2;
     break;
   case 7: /* 4 Sample AA */
     numSLI         = 1;
     samplesPerChip = 1;
     break;
   case 6: /* 2 Sample AA */
     numSLI         = 2;
     samplesPerChip = 1;
     break;
   default:
     numSLI         = 4;
     samplesPerChip = 1;
   }
   break;
 case 2: /* 2 chips */
   switch(sliaa) {
   case 4: /* 4 Sample AA */
     numSLI         = 1;
     samplesPerChip = 2;
     break;
   case 3: /* 2 Sample AA */
     numSLI         = 1;
     samplesPerChip = 1;
     break;
   default:
     numSLI         = 2;
     samplesPerChip = 1;
   }
   break;
 default: /* 1 chip */
   switch(sliaa) {
   case 1: /* 2 Sample AA */
     numSLI         = 1;
     samplesPerChip = 2;
     break;
   default:
     numSLI         = 1;
     samplesPerChip = 1;
   }
 }

 fxMesa->fsaa = samplesPerChip * voodoo->numChips / numSLI; /* 1:noFSAA, 2:2xFSAA, 4:4xFSAA, 8:8xFSAA */

 switch (fxMesa->colDepth = colDepth) {
   case 15:
     redBits   = 5;
     greenBits = 5;
     blueBits  = 5;
     alphaBits = depthSize ? 1 : 8;
     switch(fxMesa->fsaa) {
       case 8:
         pixFmt = GR_PIXFMT_AA_8_ARGB_1555;
         break;
       case 4:
         pixFmt = GR_PIXFMT_AA_4_ARGB_1555;
         break;
       case 2:
         pixFmt = GR_PIXFMT_AA_2_ARGB_1555;
         break;
       default:
         pixFmt = GR_PIXFMT_ARGB_1555;
     }
     break;
   case 16:
     redBits   = 5;
     greenBits = 6;
     blueBits  = 5;
     alphaBits = depthSize ? 0 : 8;
     switch(fxMesa->fsaa) {
       case 8:
         pixFmt = GR_PIXFMT_AA_8_RGB_565;
         break;
       case 4:
         pixFmt = GR_PIXFMT_AA_4_RGB_565;
         break;
       case 2:
         pixFmt = GR_PIXFMT_AA_2_RGB_565;
         break;
       default:
         pixFmt = GR_PIXFMT_RGB_565;
     }
     break;
   case 24:
     fxMesa->colDepth = 32;
   case 32:
     redBits   = 8;
     greenBits = 8;
     blueBits  = 8;
     alphaBits = 8;
     switch(fxMesa->fsaa) {
       case 8:
         pixFmt = GR_PIXFMT_AA_8_ARGB_8888;
         break;
       case 4:
         pixFmt = GR_PIXFMT_AA_4_ARGB_8888;
         break;
       case 2:
         pixFmt = GR_PIXFMT_AA_2_ARGB_8888;
         break;
       default:
         pixFmt = GR_PIXFMT_ARGB_8888;
     }
     break;
   default:
     str = "pixelFormat";
     goto errorhandler;
 }

 /* Tips:
  * 1. we don't bother setting/checking AUX for stencil, because we'll decide
  *    later whether we have HW stencil, based on depth buffer (thus AUX is
  *    properly set)
  * 2. when both DEPTH and ALPHA are enabled, depth should win. However, it is
  *    not clear whether 15bpp and 32bpp require AUX alpha buffer. Furthermore,
  *    alpha buffering is required only if destination alpha is used in alpha
  *    blending; alpha blending modes that do not use destination alpha can be
  *    used w/o alpha buffer.
  * 3. `alphaBits' is what we can provide
  *    `alphaSize' is what app requests
  *    if we cannot provide enough bits for alpha buffer, we should fallback to
  *    SW alpha. However, setting `alphaBits' to `alphaSize' might confuse some
  *    of the span functions...
  */

 fxMesa->haveHwAlpha = GL_FALSE;
 if (alphaSize && (alphaSize <= alphaBits)) {
    alphaSize = alphaBits;
    fxMesa->haveHwAlpha = GL_TRUE;
 }

 fxMesa->haveHwStencil = (fxMesa->HavePixExt && stencilSize && depthSize == 24);

 fxMesa->haveZBuffer = depthSize > 0;
 fxMesa->haveDoubleBuffer = doubleBuffer;
 fxMesa->haveGlobalPaletteTexture = GL_FALSE;
 fxMesa->board = glbCurrentBoard;

 fxMesa->haveTwoTMUs = (voodoo->nTexelfx > 1);

 if ((str = Glide->grGetRegistryOrEnvironmentStringExt("FX_GLIDE_NUM_TMU"))) {
    if (atoi(str) <= 1) {
       fxMesa->haveTwoTMUs = GL_FALSE;
    }
 }

 if ((str = Glide->grGetRegistryOrEnvironmentStringExt("FX_GLIDE_SWAPPENDINGCOUNT"))) {
    fxMesa->maxPendingSwapBuffers = atoi(str);
    if (fxMesa->maxPendingSwapBuffers > 6) {
       fxMesa->maxPendingSwapBuffers = 6;
    } else if (fxMesa->maxPendingSwapBuffers < 0) {
       fxMesa->maxPendingSwapBuffers = 0;
    }
 } else {
    fxMesa->maxPendingSwapBuffers = 2;
 }

 if ((str = Glide->grGetRegistryOrEnvironmentStringExt("FX_GLIDE_SWAPINTERVAL"))) {
    fxMesa->swapInterval = atoi(str);
 } else {
    fxMesa->swapInterval = 0;
 }

 BEGIN_BOARD_LOCK();
 if (fxMesa->HavePixExt) {
    fxMesa->glideContext = Glide->grSstWinOpenExt((FxU32)win, res, ref,
                                                  GR_COLORFORMAT_ABGR, GR_ORIGIN_LOWER_LEFT,
                                                  pixFmt,
                                                  2, aux);
 } else if (pixFmt == GR_PIXFMT_RGB_565) {
    fxMesa->glideContext = grSstWinOpen((FxU32)win, res, ref,
                                        GR_COLORFORMAT_ABGR, GR_ORIGIN_LOWER_LEFT,
                                        2, aux);
 } else {
    fxMesa->glideContext = 0;
 }
 END_BOARD_LOCK();
 if (!fxMesa->glideContext) {
    str = "grSstWinOpen";
    goto errorhandler;
 }

   /* screen */
   fxMesa->screen_width = FX_grSstScreenWidth();
   fxMesa->screen_height = FX_grSstScreenHeight();

   /* window inside screen */
   fxMesa->width = fxMesa->screen_width;
   fxMesa->height = fxMesa->screen_height;

   /* scissor inside window */
   fxMesa->clipMinX = 0;
   fxMesa->clipMaxX = fxMesa->width;
   fxMesa->clipMinY = 0;
   fxMesa->clipMaxY = fxMesa->height;

   if (fxMesa->verbose) {
      FxI32 tmuRam, fbRam;

      /* Not that it matters, but tmuRam and fbRam change after grSstWinOpen. */
      tmuRam = voodoo->tmuConfig[GR_TMU0].tmuRam;
      fbRam  = voodoo->fbRam;
      BEGIN_BOARD_LOCK();
      grGet(GR_MEMORY_TMU, 4, &tmuRam);
      grGet(GR_MEMORY_FB, 4, &fbRam);
      END_BOARD_LOCK();

      fprintf(stderr, "Voodoo Using Glide %s\n", grGetString(GR_VERSION));
      fprintf(stderr, "Voodoo Board: %d/%d, %s, %d GPU\n",
                      fxMesa->board + 1,
                      glbHWConfig.num_sst,
                      grGetString(GR_HARDWARE),
                      voodoo->numChips);
      fprintf(stderr, "Voodoo Memory: FB = %ld, TM = %d x %ld\n",
                      fbRam,
                      voodoo->nTexelfx,
                      tmuRam);
      fprintf(stderr, "Voodoo Screen: %dx%d:%d %s, %svertex snapping\n",
	              fxMesa->screen_width,
                      fxMesa->screen_height,
                      colDepth,
                      fxMesa->bgrOrder ? "BGR" : "RGB",
                      fxMesa->snapVertices ? "" : "no ");
   }

  sprintf(fxMesa->rendererString, "Mesa %s v0.63 %s%s",
          grGetString(GR_RENDERER),
          grGetString(GR_HARDWARE),
          ((fxMesa->type < GR_SSTTYPE_Voodoo4) && (voodoo->numChips > 1)) ? " SLI" : "");

   fxMesa->glVis = _mesa_create_visual(GL_TRUE,		/* RGB mode */
				       doubleBuffer,
				       GL_FALSE,	/* stereo */
				       redBits,		/* RGBA.R bits */
				       greenBits,	/* RGBA.G bits */
				       blueBits,	/* RGBA.B bits */
				       alphaSize,	/* RGBA.A bits */
				       0,		/* index bits */
				       depthSize,	/* depth_size */
				       stencilSize,	/* stencil_size */
				       accumSize,
				       accumSize,
				       accumSize,
				       alphaSize ? accumSize : 0,
                                       1);
   if (!fxMesa->glVis) {
      str = "_mesa_create_visual";
      goto errorhandler;
   }

   _mesa_init_driver_functions(&functions);
   ctx = fxMesa->glCtx = _mesa_create_context(fxMesa->glVis, shareCtx,
					      &functions, (void *) fxMesa);
   if (!ctx) {
      str = "_mesa_create_context";
      goto errorhandler;
   }


   if (!fxDDInitFxMesaContext(fxMesa)) {
      str = "fxDDInitFxMesaContext";
      goto errorhandler;
   }


   fxMesa->glBuffer = _mesa_create_framebuffer(fxMesa->glVis);
#if 0
/* XXX this is a complete mess :(
 *	_mesa_add_soft_renderbuffers
 *	driNewRenderbuffer
 */
					       GL_FALSE,	/* no software depth */
					       stencilSize && !fxMesa->haveHwStencil,
					       fxMesa->glVis->accumRedBits > 0,
					       alphaSize && !fxMesa->haveHwAlpha);
#endif
   if (!fxMesa->glBuffer) {
      str = "_mesa_create_framebuffer";
      goto errorhandler;
   }

   glbTotNumCtx++;

   /* install signal handlers */
#if defined(__linux__)
   /* Only install if environment var. is not set. */
   if (!getenv("MESA_FX_NO_SIGNALS")) {
      signal(SIGINT, cleangraphics_handler);
      signal(SIGHUP, cleangraphics_handler);
      signal(SIGPIPE, cleangraphics_handler);
      signal(SIGFPE, cleangraphics_handler);
      signal(SIGBUS, cleangraphics_handler);
      signal(SIGILL, cleangraphics_handler);
      signal(SIGSEGV, cleangraphics_handler);
      signal(SIGTERM, cleangraphics_handler);
   }
#endif

   return fxMesa;

errorhandler:
 if (fxMesa) {
    if (fxMesa->glideContext) {
       grSstWinClose(fxMesa->glideContext);
       fxMesa->glideContext = 0;
    }

    if (fxMesa->state) {
       FREE(fxMesa->state);
    }
    if (fxMesa->fogTable) {
       FREE(fxMesa->fogTable);
    }
    if (fxMesa->glBuffer) {
       _mesa_unreference_framebuffer(&fxMesa->glBuffer);
    }
    if (fxMesa->glVis) {
       _mesa_destroy_visual(fxMesa->glVis);
    }
    if (fxMesa->glCtx) {
       _mesa_destroy_context(fxMesa->glCtx);
    }
    FREE(fxMesa);
 }

 fprintf(stderr, "fxMesaCreateContext: ERROR: %s\n", str);
 return NULL;
}
コード例 #19
0
ファイル: test39.c プロジェクト: basecq/q2dos
int
main(int argc, char **argv) 
{
  char match; 
  char **remArgs;
  int  rv = -1;

  GrScreenResolution_t resolution = GR_RESOLUTION_640x480;
  float                scrWidth   = 640.0f;
  float                scrHeight  = 480.0f;
  int frames                      = -1;
  FxBool               scrgrab = FXFALSE;
  char                 filename[256];
  FxU32                wrange[2];

  FxU32
    multiBaseMode = 0, 
    minTexSize = 1,
    maxTexSize = 256;

  const TlVertex3D 
    srcVerts[4] = 
  {
    { -0.5f, 0.0f,  0.5f, 1.0f, 0.0f, 0.0f },
    {  0.5f, 0.0f,  0.5f, 1.0f, 1.0f, 0.0f },
    { -0.5f, 0.0f, -0.5f, 1.0f, 0.0f, 1.0f },
    {  0.5f, 0.0f, -0.5f, 1.0f, 1.0f, 1.0f }
  };

  /* Initialize Glide */
  grGlideInit();
  if ((hwconfig = tlVoodooType()) == 0) {
    printf("Error getting 3Dfx hw type.\n");
    exit(-1);
  }
  /* Process Command Line Arguments */
  while(rv = tlGetOpt(argc, argv, "dmnrx", &match, &remArgs)) {
    if (rv == -1) {
      printf("Unrecognized command line argument\n");
      printf("%s %s\n", name, usage);
      printf("Available resolutions:\n%s\n",
              tlGetResolutionList());
      exit(-1);
    }

    switch(match) {
    case 'd':
      scrgrab = FXTRUE;
      if (scrgrab) {
        frames = 1;
        strcpy(filename, remArgs[0]);
      }
      break;
    case 'm':
      /* Do we want to test larger sizes if the hw supports it? */
      if (!grGet(GR_MAX_TEXTURE_SIZE, sizeof(maxTexSize), (FxI32 *)&maxTexSize)) {
        printf("grGet(GR_MAX_TEXTURE_SIZE) failed.\n");
        exit(-1);
      }
      break;
    case 'n':
      if (remArgs[0] != NULL) frames = atoi(remArgs[0]);
      break;
    case 'r':
      if (remArgs[0] != NULL) resolution = tlGetResolutionConstant(remArgs[0], 
                                                                   &scrWidth, 
                                                                   &scrHeight);
      break;
    }
  }

  tlSetScreen(scrWidth, scrHeight);

  version = grGetString(GR_VERSION);

  printf("%s:\n%s\n", name, purpose);
  printf("%s\n", version);
  printf("Resolution: %s\n", tlGetResolutionString(resolution));
  if (frames == -1) {
    printf("Press A Key To Begin Test.\n");
    tlGetCH();
  }
    
  grSstSelect(0);
  if (grSstWinOpen(tlGethWnd(),
                   resolution,
                   GR_REFRESH_60Hz,
                   GR_COLORFORMAT_ABGR,
                   GR_ORIGIN_UPPER_LEFT,
                   2, 1) == 0) {
    printf("grSstWinOpen failed.\n");
    goto __errExit;
  }
    
  tlConSet(0.0f, 0.0f, 1.0f, 1.0f, 
           60, 30, 0xffffff);

  /* Set up Render State */
  grGet(GR_WDEPTH_MIN_MAX, 8, (FxI32 *)wrange);  
  grVertexLayout(GR_PARAM_XY,  0, GR_PARAM_ENABLE);
  grVertexLayout(GR_PARAM_Q,   GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
  grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);

  grColorCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,
                 GR_COMBINE_FACTOR_ONE,
                 GR_COMBINE_LOCAL_CONSTANT,
                 GR_COMBINE_OTHER_TEXTURE,
                 FXFALSE);
  grTexCombine(GR_TMU0,
               GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_ONE,
               GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_ONE,
               FXFALSE, FXFALSE);

  /* Generate texture */
  {
    GrLOD_t 
      largeLod, 
      smallLod;
    FxU16* 
      texData = NULL;
    FxU32 
      totalMapSize,
      curMapSize;

    /* There's some closed form of this series thing, but I forget
     * what it is and am way to lazy to actually go look it up. This
     * is only a glide test after all.  
     */
    totalMapSize = 0;
    curMapSize = maxTexSize;
    while(curMapSize > 0) {
      totalMapSize += (curMapSize * curMapSize) * sizeof(FxU16);
      curMapSize >>= 1;
    }
    texData = (FxU16*)malloc(totalMapSize * sizeof(*texData));
    if (texData == NULL) {
      printf("Unable to allocate texture data.\n");
      exit(-1);
    }

    /* Figure out the supported log2(lod size) */
    largeLod = GR_LOD_LOG2_1;
    while((0x01UL << largeLod) != maxTexSize) largeLod++;

    smallLod = GR_LOD_LOG2_1;
    while((0x01UL << smallLod) != minTexSize) smallLod++;
    
    /* Build simple texture w/ a different color for each map to help
     * distinguish the different maps when mipmapping. Additionally,
     * add a 'border' so that we can see if the start of the texture
     * gets mucked up due to an incorrect start address.
     */
    {
      FxU16 
        colorVal = 0xF800,
        *curTexPtr = texData;
      FxU32 
        i, j,
        colorShift = (16 / largeLod);

      curMapSize = maxTexSize;
      while(curMapSize > 0) {
        for(j = 0; j < curMapSize; j++) *curTexPtr++ = 0xFFFF;
        for(i = 1; i < curMapSize - 1; i++) {
          *curTexPtr++ = 0xFFFF;
          for(j = 1; j < curMapSize - 1; j++) {
            *curTexPtr++ = colorVal;
          }
          *curTexPtr++ = 0xFFFF;
        }
        for(j = 0; j < curMapSize; j++) *curTexPtr++ = 0xFFFF;
        
        curMapSize >>= 1;
        colorVal >>= colorShift;
      }
    }

    {
      GrTexInfo texInfo = {
        GR_LOD_LOG2_1,
        0,
        GR_ASPECT_LOG2_1x1,
        GR_TEXFMT_RGB_565,
        0
      };
      FxU32 
        curTexAddr = 0x00UL,
        texMultiBaseOffset;
      
      texInfo.largeLodLog2 = largeLod;
      texInfo.data = texData;
      
      /* Determine the hw texture alignment and generate some random
       * offset for the texture base addressing.  
       */
      {
        FxU32 
          texAlign,
          maxTexMem = grTexMaxAddress(GR_TMU0),
          maxTexSize = grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, 
                                               &texInfo);

        if (!grGet(GR_TEXTURE_ALIGN, sizeof(texAlign), (FxI32 *)&texAlign)) {
          printf("grGet(GR_TEXTURE_ALIGN): Failed!\n");
          exit(-1);
        }
        texAlign <<= 3UL;

        /* Get some offset that has to be smaller than the amount of
         * texxture space we have left divided by the # of times
         * that we're going to add it in.
         */
        do {
          texMultiBaseOffset = rand();
        } while ((texMultiBaseOffset < 0x1000UL) ||
                 (texMultiBaseOffset > ((maxTexMem - maxTexSize) / 4)));

        texMultiBaseOffset = (texMultiBaseOffset + texAlign) & ~(texAlign - 1UL);
      }

      /* Download the texture to the multibase address specified by
       * the current mode. We play a few games w/ offsetting the
       * texture start address by texMultiBaseOffset to try to make
       * sure that multi-base actually works inside of glide.  
       */

        /* Mmmm... multibase */
        grTexMultibase(GR_TMU0, FXTRUE);

        /* Download and set the base addresses in descending map size
         * order offsetting by some dorky amount as we go.
         */
        texInfo.smallLodLog2 = GR_LOD_LOG2_256;
        texInfo.largeLodLog2 = largeLod;
        
        grTexDownloadMipMap(GR_TMU0, 
                            curTexAddr, 
                            GR_MIPMAPLEVELMASK_BOTH, 
                            &texInfo);
        grTexMultibaseAddress(GR_TMU0, 
                              GR_TEXBASE_256, 
                              curTexAddr, 
                              GR_MIPMAPLEVELMASK_BOTH, 
                              &texInfo);

        curTexAddr += (texMultiBaseOffset +
                       grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, 
                                               &texInfo));
        texInfo.data = (void*)((FxU8*)texInfo.data + 
                               grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, 
                                                       &texInfo));

        texInfo.smallLodLog2 = GR_LOD_LOG2_128;
        texInfo.largeLodLog2 = GR_LOD_LOG2_128;

        grTexDownloadMipMap(GR_TMU0, 
                            curTexAddr, 
                            GR_MIPMAPLEVELMASK_BOTH, 
                            &texInfo);
        grTexMultibaseAddress(GR_TMU0, 
                              GR_TEXBASE_128, 
                              curTexAddr, 
                              GR_MIPMAPLEVELMASK_BOTH, 
                              &texInfo);

        curTexAddr += (texMultiBaseOffset +
                       grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, 
                                               &texInfo));
        texInfo.data = (void*)((FxU8*)texInfo.data + 
                               grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, 
                                                       &texInfo));

        texInfo.smallLodLog2 = GR_LOD_LOG2_64;
        texInfo.largeLodLog2 = GR_LOD_LOG2_64;
        
        grTexDownloadMipMap(GR_TMU0, 
                            curTexAddr, 
                            GR_MIPMAPLEVELMASK_BOTH, 
                            &texInfo);
        grTexMultibaseAddress(GR_TMU0, 
                              GR_TEXBASE_64, 
                              curTexAddr, 
                              GR_MIPMAPLEVELMASK_BOTH, 
                              &texInfo);

        curTexAddr += (texMultiBaseOffset +
                       grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, 
                                               &texInfo));
        texInfo.data = (void*)((FxU8*)texInfo.data + 
                               grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, 
                                                       &texInfo));

        texInfo.smallLodLog2 = GR_LOD_LOG2_1;
        texInfo.largeLodLog2 = GR_LOD_LOG2_32;
        
        grTexDownloadMipMap(GR_TMU0, 
                            curTexAddr, 
                            GR_MIPMAPLEVELMASK_BOTH, 
                            &texInfo);
        grTexMultibaseAddress(GR_TMU0, 
                              GR_TEXBASE_32_TO_1, 
                              curTexAddr, 
                              GR_MIPMAPLEVELMASK_BOTH, 
                              &texInfo);

      /* Source the whole texture. The large map start will reset
       * baseAddr0, but that should be fine since we did not adjust
       * its address because it came first.  
       */
      texInfo.smallLodLog2 = GR_LOD_LOG2_1;
      texInfo.largeLodLog2 = largeLod;
      
      grTexSource(GR_TMU0, 
                  0x00UL, 
                  GR_MIPMAPLEVELMASK_BOTH, 
                  &texInfo);
    }

    free((void*)texData);
  }

  grTexMipMapMode(GR_TMU0,
                  GR_MIPMAP_NEAREST,
                  FXFALSE);

  tlConOutput("Press a key to quit\n");
  while(frames-- && tlOkToRender()) {
    static float 
      curOOW = 1.0f;

    if (hwconfig == TL_VOODOORUSH) {
      tlGetDimsByConst(resolution,
                       &scrWidth, 
                       &scrHeight);
        
      grClipWindow(0, 0, (FxU32) scrWidth, (FxU32) scrHeight);
    }

    grBufferClear(0x808080, 0xFF, wrange[1]);

    {
      static float
        distance = 1.0f,
        dDelta   = 0.1f;
      TlVertex3D 
        xfVerts[4],
        prjVerts[4];
      GrVertex 
        vtxA, 
        vtxB, 
        vtxC,
        vtxD;

      /*---- 
        A-B
        |\|
        C-D
        -----*/
      vtxA.oow = 1.0f;
      vtxB = vtxC = vtxD = vtxA;

#define MAX_DIST 30.5f
#define MIN_DIST 1.0f

      distance += dDelta;
      if (distance > MAX_DIST || 
           distance < MIN_DIST) { 
        dDelta *= -1.0f;
        distance += dDelta;
      }

      tlSetMatrix(tlIdentity());
      tlMultMatrix(tlXRotation(-20.0f));
      tlMultMatrix(tlTranslation(0.0f, -0.3f, distance));

      tlTransformVertices(xfVerts, srcVerts, 4);
      tlProjectVertices(prjVerts, xfVerts, 4);

      vtxA.x = tlScaleX(prjVerts[0].x);
      vtxA.y = tlScaleY(prjVerts[0].y);
      vtxA.oow = 1.0f / prjVerts[0].w;
      vtxA.tmuvtx[0].sow = prjVerts[0].s * 255.0f * vtxA.oow;
      vtxA.tmuvtx[0].tow = prjVerts[0].t * 255.0f * vtxA.oow;

      vtxB.x = tlScaleX(prjVerts[1].x);
      vtxB.y = tlScaleY(prjVerts[1].y); 
      vtxB.oow = 1.0f / prjVerts[1].w;
      vtxB.tmuvtx[0].sow = prjVerts[1].s * 255.0f * vtxB.oow;
      vtxB.tmuvtx[0].tow = prjVerts[1].t * 255.0f * vtxB.oow;
        
      vtxC.x = tlScaleX(prjVerts[2].x);
      vtxC.y = tlScaleY(prjVerts[2].y);
      vtxC.oow = 1.0f / prjVerts[2].w;
      vtxC.tmuvtx[0].sow = prjVerts[2].s * 255.0f * vtxC.oow;
      vtxC.tmuvtx[0].tow = prjVerts[2].t * 255.0f * vtxC.oow;

      vtxD.x = tlScaleX(prjVerts[3].x); 
      vtxD.y = tlScaleY(prjVerts[3].y);
      vtxD.oow = 1.0f / prjVerts[3].w;
      vtxD.tmuvtx[0].sow = prjVerts[3].s * 255.0f * vtxD.oow;
      vtxD.tmuvtx[0].tow = prjVerts[3].t * 255.0f * vtxD.oow;

      grDrawTriangle(&vtxA, &vtxB, &vtxD);
      grDrawTriangle(&vtxA, &vtxD, &vtxC);
    }

    tlConRender();
    grBufferSwap(1);

    /* grab the frame buffer */
    if (scrgrab) {
      if (!tlScreenDump(filename, (FxU16)scrWidth, (FxU16)scrHeight))
        printf("Cannot open %s\n", filename);
      scrgrab = FXFALSE;
    }

    if (tlKbHit()) {
      char curKey = tlGetCH();

      switch(curKey) {
      default:
        frames = 0;
        break;
      }
    }
  }
  rv = 0;

 __errExit:    
  grGlideShutdown();

  return rv;
}
コード例 #20
0
ファイル: test13.c プロジェクト: OS2World/LIB-Glide-2
void main( int argc, char **argv) {
    char match;
    char **remArgs;
    int  rv;

    GrScreenResolution_t resolution = GR_RESOLUTION_640x480;
    float                scrWidth   = 640.0f;
    float                scrHeight  = 480.0f;
    int frames                      = -1;
    FxBool               scrgrab = FXFALSE;
    char                 filename[256];

    /* Process Command Line Arguments */
    while( rv = tlGetOpt( argc, argv, "nrd", &match, &remArgs ) ) {
        if ( rv == -1 ) {
            printf( "Unrecognized command line argument\n" );
            printf( "%s %s\n", name, usage );
            printf( "Available resolutions:\n%s\n",
                    tlGetResolutionList() );
            return;
        }
        switch( match ) {
        case 'n':
            frames = atoi( remArgs[0] );
            break;
        case 'r':
            resolution = tlGetResolutionConstant( remArgs[0],
                                                  &scrWidth,
                                                  &scrHeight );
            break;
        case 'd':
            scrgrab = FXTRUE;
            frames = 1;
            strcpy(filename, remArgs[0]);
            break;
        }
    }

    tlSetScreen( scrWidth, scrHeight );

    grGlideGetVersion( version );

    printf( "%s:\n%s\n", name, purpose );
    printf( "%s\n", version );
    printf( "Resolution: %s\n", tlGetResolutionString( resolution ) );
    if ( frames == -1 ) {
        printf( "Press A Key To Begin Test.\n" );
        tlGetCH();
    }

    /* Initialize Glide */
    grGlideInit();
    assert( grSstQueryHardware( &hwconfig ) );
    grSstSelect( 0 );
    assert( grSstWinOpen( 0,
                          resolution,
                          GR_REFRESH_60Hz,
                          GR_COLORFORMAT_ABGR,
                          GR_ORIGIN_UPPER_LEFT,
                          2, 1 ) );

    tlConSet( 0.0f, 0.0f, 1.0f, 0.5f,
              60, 15, 0xffffff );

    /* Set up Render State - iterated alpha + constant color */
    grColorCombine( GR_COMBINE_FUNCTION_LOCAL,
                    GR_COMBINE_FACTOR_NONE,
                    GR_COMBINE_LOCAL_CONSTANT,
                    GR_COMBINE_OTHER_NONE,
                    FXFALSE );
    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 );

#define RED  0x000000ff
#define BLUE 0x00ff0000

    tlConOutput( "Press any key to quit\n" );
    while( frames-- && tlOkToRender()) {
        GrVertex vtxA, vtxB, vtxC;

        if (hwconfig.SSTs[0].type == GR_SSTTYPE_SST96) {
            tlGetDimsByConst(resolution,
                             &scrWidth,
                             &scrHeight );

            grClipWindow(0, 0, (FxU32) scrWidth, (FxU32) scrHeight);
        }

        grBufferClear( 0x00, 0, 0 );

        vtxA.x = tlScaleX( 0.5f ), vtxA.y = tlScaleY( 0.1f );
        vtxB.x = tlScaleX( 0.8f ), vtxB.y = tlScaleY( 0.9f );
        vtxC.x = tlScaleX( 0.2f ), vtxC.y = tlScaleY( 0.9f );
        vtxA.a = vtxB.a = vtxC.a = 255.0f;

        grConstantColorValue( RED );
        grDrawTriangle( &vtxA, &vtxB, &vtxC );

        grSstOrigin( GR_ORIGIN_LOWER_LEFT );

        vtxA.a = 0.0f;
        grConstantColorValue( BLUE );
        grDrawTriangle( &vtxA, &vtxB, &vtxC );

        grSstOrigin( GR_ORIGIN_UPPER_LEFT );

        tlConRender();
        grBufferSwap( 1 );

        /* grab the frame buffer */
        if (scrgrab) {
            if (!tlScreenDump(filename, (FxU16)scrWidth, (FxU16)scrHeight))
                printf( "Cannot open %s\n", filename);
            scrgrab = FXFALSE;
        }

        while( tlKbHit() ) {
            switch( tlGetCH() ) {
            default:
                frames = 0;
                break;
            }
        }
    }

    grGlideShutdown();
    return;
}
コード例 #21
0
ファイル: test28.c プロジェクト: basecq/q2dos
void main( int argc, char **argv) {
    char match; 
    char **remArgs;
    int  rv;

    GrScreenResolution_t resolution = GR_RESOLUTION_640x480;
    float                scrWidth   = 640.0f;
    float                scrHeight  = 480.0f;
#define NVERT 5
    GrVertex vtx[NVERT];
    int index[NVERT];
    int frames                      = -1;
    int i, idx;
#define NHUE 360
    RGB hues[NHUE];
    FxU32 wrange[2];
    GrContext_t          gc = 0;
    
    /* Initialize Glide */
    grGlideInit();
    assert( hwconfig = tlVoodooType() );

    /* Process Command Line Arguments */
    while( rv = tlGetOpt( argc, argv, "nr", &match, &remArgs ) ) {
        if ( rv == -1 ) {
            printf( "Unrecognized command line argument\n" );
            printf( "%s %s\n", name, usage );
            printf( "Available resolutions:\n%s\n",
                    tlGetResolutionList() );
            return;
        }
        switch( match ) {
        case 'n':
            frames = atoi( remArgs[0] );
            break;
        case 'r':
            resolution = tlGetResolutionConstant( remArgs[0], 
                                                  &scrWidth, 
                                                  &scrHeight );
            break;
        }
    }

    tlSetScreen( scrWidth, scrHeight );

    version = grGetString( GR_VERSION );

    printf( "%s:\n%s\n", name, purpose );
    printf( "%s\n", version );
    printf( "Resolution: %s\n", tlGetResolutionString( resolution ) );
    if ( frames == -1 ) {
        printf( "Press A Key To Begin Test.\n" );
        tlGetCH();
    }
    
    grSstSelect( 0 );
    gc = grSstWinOpen(tlGethWnd(),
                      resolution,
                      GR_REFRESH_60Hz,
                      GR_COLORFORMAT_ABGR,
                      GR_ORIGIN_UPPER_LEFT,
                      2, 1 );
    if (!gc) {
      printf("Could not allocate glide fullscreen context.\n");
      goto __errExit;
    }
    
    tlConSet( 0.0f, 0.0f, 1.0f, 1.0f, 
              60, 30, 0xffffff );

    /* Set up Render State - gouraud shading */
    grGet(GR_WDEPTH_MIN_MAX, 8, (FxI32 *)wrange);  
    grVertexLayout(GR_PARAM_XY,  0, GR_PARAM_ENABLE);
    grVertexLayout(GR_PARAM_RGB, GR_VERTEX_R_OFFSET << 2, GR_PARAM_ENABLE);

    grColorCombine( GR_COMBINE_FUNCTION_LOCAL,
                    GR_COMBINE_FACTOR_NONE,
                    GR_COMBINE_LOCAL_ITERATED,
                    GR_COMBINE_OTHER_NONE,
                    FXFALSE );

    tlConOutput( "Press a key to quit\n" );

    /* init a table of hues */
    for (i=0; i<NHUE; i++) {
      const float theta = i * 360.0f / NHUE;
      hlsToRGB( theta, 0.4f, 0.5f, &hues[i]);
    }

    /* assign hues to vertices */
    for (i=0; i<NVERT; i++) {
        vtx[i].r = hues[PHASE(0, i*(NHUE / NVERT), NHUE)].r;
        vtx[i].g = hues[PHASE(0, i*(NHUE / NVERT), NHUE)].g;
        vtx[i].b = hues[PHASE(0, i*(NHUE / NVERT), NHUE)].b;
    }
#if 1
    /*
     * Force polygon RGB values to be planar... note overflow!
     * this is deliberate as a sanity check
     */
    vtx[3].r = 235.519f; vtx[3].g = 51.001f; vtx[3].b = 115.721f;
    vtx[4].r = 298.559f; vtx[4].g = -12.039f; vtx[4].b = 91.0f;
#endif

    while( frames-- && tlOkToRender()) {

        tlGetDimsByConst(resolution,
                         &scrWidth, 
                         &scrHeight );
        
        grClipWindow(0, 0, (FxU32) scrWidth, (FxU32) scrHeight);

        grBufferClear( 0x00, 0, wrange[1] );

        /* generate a equilateral polygon */
        for (i=0; i<NVERT; i++) {
          double theta = 2.0 * PI * i / (double) NVERT;
          
          vtx[i].x = tlScaleX((float)((cos(theta) / 4.0) + 0.5));
          vtx[i].y = tlScaleY((float)((sin(theta) / 4.0) + 0.5));
          
          index[i] = i;
        }

        idx = 30 /* (-frames) % NHUE */;

#if 1
        /* cyclical permutation: turn off to see just one set of triangles */
        for (i=0; i<NVERT; i++) {
            index[i] = (index[i] + 1) % NVERT;
        }
#endif

        grDrawVertexArrayContiguous(GR_POLYGON, NVERT, vtx, sizeof(GrVertex));

        tlConRender();
        grBufferSwap( 1 );
        if ( tlKbHit() ) frames = 0;
    }

 __errExit:    
    grGlideShutdown();
    return;
}
コード例 #22
0
ファイル: TEST39.C プロジェクト: grakidov/Render3D
void main( int argc, char *argv[] ) {
    
    /*------------------------------------------------------------------
      Data
      ------------------------------------------------------------------*/
    char texFile[256];
    char texFile_2[256];

    FxU32        startAddress,nextAddress;
    FxU32        startAddress_2, nextAddress_2;
    GrTexInfo    texInfo, texInfo_2;
    Gu3dfInfo    info, info_2;
    GuNccTable   nccTable, nccTable_2;
    GuTexPalette pal, pal_2;
    FxBool       hasTable   = FXFALSE,
                 hasTable_2 = FXFALSE;
    FxBool       hasPalette = FXFALSE,
                 hasPalette_2 = FXFALSE;
    FxU32        numTmus = 1;
    FxU32        automate;
    FxU32        numFrames = -1;
    /*------------------------------------------------------------------
      Glide State Initialization 
      ------------------------------------------------------------------*/
    grGlideInit();
    grSstQueryHardware( &hwConfig );
    grSstSelect( 0 );
    grSstOpen( screenRes,
               GR_REFRESH_60Hz,
               GR_COLORFORMAT_ABGR,
               GR_ORIGIN_LOWER_LEFT,
               GR_SMOOTHING_ENABLE,
               2 );
    grColorCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,
                    GR_COMBINE_FACTOR_ONE,
                    GR_COMBINE_LOCAL_NONE,
                    GR_COMBINE_OTHER_TEXTURE,
                    FXFALSE );
    grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,
                    GR_COMBINE_FACTOR_ONE,
                    GR_COMBINE_LOCAL_NONE,
                    GR_COMBINE_OTHER_TEXTURE,
                    FXFALSE );
    grTexCombine( GR_TMU0,
                  GR_COMBINE_FUNCTION_LOCAL,
                  GR_COMBINE_FACTOR_ZERO,
                  GR_COMBINE_FUNCTION_LOCAL,
                  GR_COMBINE_FACTOR_ZERO,
                  FXFALSE,
                  FXFALSE );

    if ( hwConfig.SSTs[0].sstBoard.VoodooConfig.nTexelfx == 2 ) {
        printf( "Detected 2 TMUs\n" );
        grTexCombine( GR_TMU1,
                      GR_COMBINE_FUNCTION_LOCAL,
                      GR_COMBINE_FACTOR_ZERO,
                      GR_COMBINE_FUNCTION_LOCAL,
                      GR_COMBINE_FACTOR_ZERO,
                      FXFALSE,
                      FXFALSE );
         numTmus = 2;
    }

    /*------------------------------------------------------------------
      Deal With Arguments
      ------------------------------------------------------------------*/
    if ( numTmus == 1 ) {
        if ( argc < 2 ) {
            puts( usage_1tmu );
            grGlideShutdown();
            return;        
        }
        else
        {
          if(strstr(argv[1], "-n"))
          {
            automate = 1;
	    numFrames = atoi(argv[2]);
            if(argc >= 4)  
              strcpy( texFile, argv[3] );    
            else
            {
              puts( usage_1tmu );
              grGlideShutdown();
              return;        
            }
          }
          else
          {
            strcpy( texFile, argv[1] );    
            if(argc > 3)
              if(strstr(argv[2], "-n"))
	      {
                automate = 1;
		numFrames = atoi(argv[3]);
	      }
              else 
              {
                puts( usage_1tmu );
                grGlideShutdown();
                return;    
              }    
          }
        } 
    }
    else
    {
      if(argc >= 3)
      {
	if(strstr(argv[1], "-n"))
	{
	  automate = 1;
	  if(argc >= 5)  
	  {
	    strcpy( texFile, argv[3] );    
	    strcpy( texFile_2, argv[4] );    
	  }
	  else
	  {
	    puts( usage_2tmu );
	    grGlideShutdown();
	    return;        
	  }
	}
	else
	{
	  strcpy( texFile, argv[1] );    
	  strcpy( texFile_2, argv[2] );    
	  if(argc >= 4)
	    if(strstr(argv[3], "-n"))
	      automate = 1;
	    else 
	    {
	      puts( usage_2tmu );
	      grGlideShutdown();
	      return;    
	    }    
	}
      }
      else
      {
	puts( usage_2tmu );
	grGlideShutdown();
	return;    
      }    
    }
    
    grAlphaBlendFunction( GR_BLEND_ONE, GR_BLEND_ZERO,
                          GR_BLEND_ONE, GR_BLEND_ZERO );

    grDepthBufferMode( GR_DEPTHBUFFER_DISABLE );
    grDepthBufferFunction( GR_CMP_LEQUAL );
    grDepthMask( FXFALSE );

    grCullMode( GR_CULL_DISABLE );

    grBufferClear( 0x0, 0x0, 0x0 );

    /*------------------------------------------------------------------
      Load Texture(s)
      ------------------------------------------------------------------*/
    if ( !gu3dfGetInfo( texFile, &info ) ) {
        printf( "Couldn't load %s.\n", texFile );
        return;
    }
    info.data = calloc( info.mem_required, 1 );
    gu3dfLoad( texFile, &info );

    texInfo.smallLod    = info.header.small_lod;
    texInfo.largeLod    = info.header.large_lod;
    texInfo.aspectRatio = info.header.aspect_ratio;
    texInfo.format      = info.header.format;
    texInfo.data        = info.data;

    if ( texInfo.format == GR_TEXFMT_YIQ_422 ||
         texInfo.format == GR_TEXFMT_AYIQ_8422 ) {
        puts( "*******************YIQ TEXTURE(TMU0)***************" );
        nccTable = info.table.nccTable;
        hasTable = FXTRUE;
    }

    if ( texInfo.format == GR_TEXFMT_P_8 ||
         texInfo.format == GR_TEXFMT_AP_88 ) {
        puts( "*******************PAL TEXTURE(TMU0)***************" );
        pal = info.table.palette;
        hasPalette = FXTRUE;
    }

    if ( numTmus == 2 ) {
        if ( !gu3dfGetInfo( texFile_2, &info_2 ) ) {
            printf( "Couldn't load %s.\n", texFile_2 );
            return;
        }
        info_2.data = calloc( info_2.mem_required, 1 );
        gu3dfLoad( texFile_2, &info_2 );
    
        texInfo_2.smallLod    = info_2.header.small_lod;
        texInfo_2.largeLod    = info_2.header.large_lod;
        texInfo_2.aspectRatio = info_2.header.aspect_ratio;
        texInfo_2.format      = info_2.header.format;
        texInfo_2.data        = info_2.data;
    
        if ( texInfo_2.format == GR_TEXFMT_YIQ_422 ||
             texInfo_2.format == GR_TEXFMT_AYIQ_8422 ) {
            puts( "*******************YIQ TEXTURE(TMU1)***************" );
            nccTable_2 = info_2.table.nccTable;
            hasTable_2 = FXTRUE;
        }
        if ( texInfo_2.format == GR_TEXFMT_P_8 ||
             texInfo_2.format == GR_TEXFMT_AP_88 ) {
            puts( "*******************PAL TEXTURE(TMU1)***************" );
            pal_2 = info_2.table.palette;
            hasPalette_2 = FXTRUE;
        }
    }


    /*------------------------------------------------------------------
      Allocate Texture RAM
      ------------------------------------------------------------------*/
    startAddress =  nextAddress = grTexMinAddress( GR_TMU0 );
    nextAddress  = startAddress + grTexTextureMemRequired( GR_MIPMAPLEVELMASK_BOTH,
                                                           &texInfo );

    printf( "tex0: startAddress: %d nextAddress %d\n", startAddress, nextAddress );

    if ( nextAddress > grTexMaxAddress( GR_TMU0 ) ) {
        printf( "Texture memory exhausted.\n" );
        return;
    }

    if ( numTmus == 2 ) {
        startAddress_2 =  nextAddress_2 = grTexMinAddress( GR_TMU1 );
        nextAddress_2  = startAddress_2 + 
                         grTexTextureMemRequired( GR_MIPMAPLEVELMASK_BOTH,
                                                  &texInfo_2 );
        printf( "tex1: startAddress: %d nextAddress %d\n", startAddress_2, nextAddress_2 );
    }

    /*------------------------------------------------------------------
      Download Texture(s)
      ------------------------------------------------------------------*/
    grTexDownloadMipMap( GR_TMU0,
                         startAddress,
                         GR_MIPMAPLEVELMASK_BOTH,
                         &texInfo );
    if ( hasTable ) {
        grTexNCCTable( GR_TMU0, GR_NCCTABLE_NCC1 );
        grTexDownloadTable( GR_TMU0,
                            GR_TEXTABLE_NCC1,
                            &nccTable );
    }
    if ( hasPalette ) {
        grTexDownloadTable( GR_TMU0,
                            GR_TEXTABLE_PALETTE,
                            &pal );
    }

    if ( numTmus == 2 ) {
        grTexDownloadMipMap( GR_TMU1,
                             startAddress_2,
                             GR_MIPMAPLEVELMASK_BOTH,
                             &texInfo_2 );
        if ( hasTable_2 ) {
            grTexNCCTable( GR_TMU1, GR_NCCTABLE_NCC0 );
            grTexDownloadTable( GR_TMU1,
                                GR_TEXTABLE_NCC0,
                                &nccTable_2 );
        }

        if ( hasPalette_2 ) {
            grTexDownloadTable( GR_TMU1,
                                GR_TEXTABLE_PALETTE,
                                &pal_2 );
        }
    }

    /*------------------------------------------------------------------
      Set up Texture Params and Set Texture As Current
      ------------------------------------------------------------------*/
    grTexFilterMode( GR_TMU0,
                     GR_TEXTUREFILTER_BILINEAR, 
                     GR_TEXTUREFILTER_BILINEAR );
    grTexClampMode( GR_TMU0,
                    GR_TEXTURECLAMP_WRAP,
                    GR_TEXTURECLAMP_WRAP );
    grTexMipMapMode( GR_TMU0,
                     GR_MIPMAP_NEAREST,
                     FXFALSE );
    grTexSource( GR_TMU0,
                 startAddress,
                 GR_MIPMAPLEVELMASK_BOTH,
                 &texInfo );

    if ( numTmus == 2 ) {
        grTexFilterMode( GR_TMU1,
                         GR_TEXTUREFILTER_BILINEAR, 
                         GR_TEXTUREFILTER_BILINEAR );
        grTexClampMode( GR_TMU1,
                        GR_TEXTURECLAMP_WRAP,
                        GR_TEXTURECLAMP_WRAP );
        grTexMipMapMode( GR_TMU1,
                         GR_MIPMAP_NEAREST,
                         FXFALSE );
        grTexSource( GR_TMU1,
                     startAddress_2,
                     GR_MIPMAPLEVELMASK_BOTH, 
                     &texInfo_2 );
    }


    /*------------------------------------------------------------------
      Render Triangles
      ------------------------------------------------------------------*/

    puts("TEST39:\n");
    puts("Tests the grTex routines\n");
    if(!automate)
    {
      puts("Press any key to continue\n");
      getch();
    }
    while(numFrames)
    {
      square(    0.0f,   0.0f, 256.0f, 256.0f );
      square(  255.0f,   0.0f, 128.0f, 128.0f );
      square(  382.0f,   0.0f,  64.0f,  64.0f );
      square(  445.0f,   0.0f,  32.0f,  32.0f );
      square(  476.0f,   0.0f,  16.0f,  16.0f );
      square(  491.0f,   0.0f,   8.0f,   8.0f );
      square(  498.0f,   0.0f,   4.0f,   4.0f );
      square(  501.0f,   0.0f,   2.0f,   2.0f );
      square(  502.0f,   0.0f,   1.0f,   1.0f );


      if ( numTmus == 2 ) {
        grTexCombine( GR_TMU0,
                      GR_COMBINE_FUNCTION_SCALE_OTHER,
                      GR_COMBINE_FACTOR_ONE,
                      GR_COMBINE_FUNCTION_SCALE_OTHER,
                      GR_COMBINE_FACTOR_ONE,
                      FXFALSE,
                      FXFALSE );
	
        grTexCombine( GR_TMU1,
                      GR_COMBINE_FUNCTION_LOCAL,
                      GR_COMBINE_FACTOR_ZERO,
                      GR_COMBINE_FUNCTION_LOCAL,
                      GR_COMBINE_FACTOR_ZERO,
                      FXFALSE,
                      FXFALSE );
	
        square(    0.0f,  300.0f, 256.0f, 256.0f );
        square(  255.0f,  300.0f, 128.0f, 128.0f );
        square(  382.0f,  300.0f,  64.0f,  64.0f );
        square(  445.0f,  300.0f,  32.0f,  32.0f );
        square(  476.0f,  300.0f,  16.0f,  16.0f );
        square(  491.0f,  300.0f,   8.0f,   8.0f );
        square(  498.0f,  300.0f,   4.0f,   4.0f );
        square(  501.0f,  300.0f,   2.0f,   2.0f );
        square(  502.0f,  300.0f,   1.0f,   1.0f );
      }


      grBufferSwap( 1 );    

      if(numFrames > 0)
	numFrames--;

      if(kbhit()) {
	getch();
	break;
      }
    } 
    grGlideShutdown();

    return;
}
コード例 #23
0
ファイル: 3dfx.c プロジェクト: gameplayer22/d2x-1
int _3dfx_Init( void )
{
   int         i;

   mprintf( ( 0, "Initializing 3Dfx Interactive Voodoo Graphics hardware\n" ) );
   grGlideInit();
   grErrorSetCallback( MyErrorHandler );

   if ( !grSstQueryHardware( &hwconfig ) )
   {
      mprintf( ( 0, "3Dfx Interactive Voodoo Graphics not found!" ) );
      return 0;
   }
   grSstSelect( 0 );
   if ( !grSstOpen( GR_RESOLUTION_640x480,
                    GR_REFRESH_60Hz,
                    GR_COLORFORMAT_ARGB,
                    GR_ORIGIN_UPPER_LEFT,
                    GR_SMOOTHING_ENABLE,
                    2 ) )
   {
      mprintf( ( 0, "3Dfx Interactive Voodoo Graphics not opened!" ) );
      return 0;
   }

   if ( getenv( "GLIDE_OFF" ) != 0 )
   {
      mprintf( ( 0, "3Dfx Interactive Voodoo Graphics disabled!" ) );
      return 0;
   }

   grDepthBufferMode( GR_DEPTHBUFFER_DISABLE );
   grBufferClear( 0x00000000, 0, 0 );
   grCullMode( GR_CULL_DISABLE );

   /*
   ** configure environment variable controlled options
   */
   if ( getenv( "GLIDE_NO_BILINEAR" ) )
      _3dfx_no_bilinear = 1;
   if ( getenv( "GLIDE_NO_DDRAW" ) )
      _3dfx_skip_ddraw = 1;
   if ( getenv( "GLIDE_NO_TEXTURE" ) )
      _3dfx_no_texture = 1;
   if ( getenv( "GLIDE_NO_TRANSPARENCY" ) )
      _3dfx_allow_transparency = 0;
   else
      _3dfx_allow_transparency = 1;
   if ( getenv( "GLIDE_NO_SYNC" ) )
      _3dfx_should_sync = 0;
   else
      _3dfx_should_sync = 1;

   /*
   ** allocate texture memory
   */
   for ( i = 0; i < MAX_BITMAP_FILES; i++ )
   {
      _3dfx_texture_info[i].handle = GR_NULL_MIPMAP_HANDLE;
   }

   _3dfx_current_handle = 0;
   for ( i = 0; i < _3DFX_MAX_HANDLES; i++ )
   {
      GrMipMapId_t id;

      id = grTexAllocateMemory( GR_TMU0,
                                GR_MIPMAPLEVELMASK_BOTH,
                                64, 64,
                                GR_TEXFMT_ARGB_1555,
                                GR_MIPMAP_NEAREST,
                                GR_LOD_1, GR_LOD_64,
                                GR_ASPECT_1x1,
                                GR_TEXTURECLAMP_WRAP, GR_TEXTURECLAMP_WRAP,
                                GR_TEXTUREFILTER_BILINEAR, _3dfx_no_bilinear ? GR_TEXTUREFILTER_POINT_SAMPLED : GR_TEXTUREFILTER_BILINEAR,
                                1.0F,
                                FXFALSE );

      if ( id == GR_NULL_MIPMAP_HANDLE )
      {
         mprintf( ( 0, "            - unexpected null mmid returned\n" ) );
         exit( 1 );
      }
   }

   return 1;
}
コード例 #24
0
ファイル: test31.c プロジェクト: basecq/q2dos
void
main( int argc, char **argv)
{
  char
    match, 
    **remArgs,
    *args = "nrd",
    filename[256];
  int
    frames = -1,
    rv;
  float
    scrWidth   = 640.f,
    scrHeight  = 480.f;
  FxBool
    scrgrab = FXFALSE;

  GrScreenResolution_t
    resolution = GR_RESOLUTION_640x480;

  FxI32    listType = -1;
  FxBool   aaenable = FXFALSE;
  FxBool   packedrgb = FXFALSE;
  FxBool   varraycont = FXFALSE;
  GrVertex vtxList[4];
  void     *vtxListArray[6];
  GrVertex vtxListCont[6];
  FxU32    wrange[2];
  
  /* Initialize Glide */
  grGlideInit();
  assert( hwconfig = tlVoodooType() );

  /* Process Command Line Arguments */
  while( rv = tlGetOpt( argc, argv, args, &match, &remArgs ) ) {
    if ( rv == -1 ) {
      printf( "Unrecognized command line argument\n" );
      printf( "%s %s\n", name, usage );
      printf( "Available resolutions:\n%s\n",
             tlGetResolutionList() );
      return;
    }
    switch( match ) {
    case 'n':
      frames = atoi( remArgs[0] );
      break;
    case 'r':
      resolution = tlGetResolutionConstant( remArgs[0], 
                                           &scrWidth, 
                                           &scrHeight );
      break;
    case 'd':
      scrgrab = FXTRUE;
      frames = 1;
      strcpy(filename, remArgs[0]);
      break;

    }
  }
  
  tlSetScreen( scrWidth, scrHeight );
  
  version = grGetString( GR_VERSION );
  
  printf( "%s:\n%s\n", name, purpose );
  printf( "%s\n", version );
  printf( "Resolution: %s\n", tlGetResolutionString( resolution ) );
  if ( frames == -1 ) {
    printf( "Press A Key To Begin Test.\n" );
    tlGetCH();
  }
  
  grSstSelect( 0 );
  assert( grSstWinOpen(tlGethWnd(),
                       resolution,
                       GR_REFRESH_60Hz,
                       GR_COLORFORMAT_ABGR,
                       GR_ORIGIN_UPPER_LEFT,
                       2, 1 ) );  

  tlConSet( 0.f, 0.f, 1.f, 1.f, 
           60, 30, 0xffffff );
  
  /* Set up Render State - gouraud shading */
  grVertexLayout(GR_PARAM_XY,  GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE);
  grVertexLayout(GR_PARAM_RGB, GR_VERTEX_R_OFFSET << 2, GR_PARAM_ENABLE);
  grGet(GR_WDEPTH_MIN_MAX, 8, wrange);  

  grColorCombine( GR_COMBINE_FUNCTION_LOCAL,
                 GR_COMBINE_FACTOR_NONE,
                 GR_COMBINE_LOCAL_ITERATED,
                 GR_COMBINE_OTHER_NONE,
                 FXFALSE );

  grCullMode(GR_CULL_DISABLE);

  if(frames == -1) {
    doHelp();
  }


  /*
  ** data 
  */
  {
    vtxList[0].x = tlScaleX( 0.3f ), vtxList[0].y = tlScaleY( 0.3f );
    vtxList[0].r = 255.f, vtxList[0].g = 0.f, vtxList[0].b = 0.f, vtxList[0].a = 255.f;
    
    vtxList[1].x = tlScaleX( 0.8f ), vtxList[1].y = tlScaleY( 0.4f );
    vtxList[1].r = 0.f, vtxList[1].g = 255.f, vtxList[1].b = 0.f, vtxList[1].a = 255.f;
    
    vtxList[2].x = tlScaleX( 0.5f ), vtxList[2].y = tlScaleY( 0.8f );
    vtxList[2].r = 0.f, vtxList[2].g = 0.f, vtxList[2].b = 255.f, vtxList[2].a = 255.f;
    
    vtxList[3].x = tlScaleX( 0.9f ), vtxList[3].y = tlScaleY( 0.8f );
    vtxList[3].r = 0.f, vtxList[3].g = 0.f, vtxList[3].b = 255.f, vtxList[3].a = 255.f;
    
    vtxListCont[0] = vtxList[0];
    vtxListCont[1] = vtxList[1];
    vtxListCont[2] = vtxList[2];
    vtxListCont[3] = vtxList[3];
  }
  
  while( frames-- && tlOkToRender()) {
      
    tlConClear();
    tlConOutput( "Press a key to quit\n" );
    if (aaenable)
      tlConOutput("Antialiasing ON\n");
    else
      tlConOutput("Antialiasing OFF\n");
    if (packedrgb)
      tlConOutput("Packed Color ON\n");
    else
      tlConOutput("Packed Color OFF\n");
    if (listType >= 0) {
      if (varraycont)
        tlConOutput("grDrawVertexArrayContiguous\n");
      else
        tlConOutput("grDrawVertexArray\n");
      switch (listType) {
      case GR_POINTS:
        tlConOutput("POINTS\n");
        break;
      case GR_LINE_STRIP:
        tlConOutput("LINE STRIP\n");
        break;
      case GR_LINES:
        tlConOutput("LINES\n");
        break;
      case GR_POLYGON:
        tlConOutput("POLYGON\n");
        break;
      case GR_TRIANGLE_STRIP:
        tlConOutput("TRIANGLE STRIP\n");
        break;
      case GR_TRIANGLE_FAN:
        tlConOutput("TRIANGLE FAN\n");
        break;
      case GR_TRIANGLES:
        tlConOutput("TRIANGLES\n");
        break;
      }
    }
    else
      tlConOutput("grDrawTriangle\n");

    if (hwconfig == TL_VOODOORUSH) {
      tlGetDimsByConst(resolution,
                       &scrWidth, 
                       &scrHeight );
        
      grClipWindow(0, 0, (FxU32) scrWidth, (FxU32) scrHeight);
    }
    grRenderBuffer( GR_BUFFER_BACKBUFFER );
    
    grBufferClear( 0x00, 0, wrange[1] );

    switch (listType) {
    case GR_POINTS:
    case GR_LINE_STRIP:
    case GR_LINES:
    case GR_POLYGON:
    case GR_TRIANGLE_STRIP:
    case GR_TRIANGLE_FAN:
      if (varraycont)
        grDrawVertexArrayContiguous(listType, 4, vtxListCont, sizeof(GrVertex));
      else
        grDrawVertexArray(listType, 4, vtxListArray);
      break;
    case GR_TRIANGLES:
      if (varraycont)
        grDrawVertexArrayContiguous(listType, 6, vtxListCont, sizeof(GrVertex));
      else
        grDrawVertexArray(listType, 6, vtxListArray);
      break;
    default:
      if (aaenable)
        grAADrawTriangle(vtxList, vtxList+1, vtxList+2, FXTRUE, FXTRUE, FXTRUE);
      else
        grDrawTriangle(vtxList, vtxList+1, vtxList+2);
    }

    tlConRender();
    grBufferSwap( 1 );
    
    /* grab the frame buffer */
    if (scrgrab) {
      if (!tlScreenDump(filename, (FxU16)scrWidth, (FxU16)scrHeight))
        printf( "Cannot open %s\n", filename);
      scrgrab = FXFALSE;
    }

    while( tlKbHit() ) {
      FxU32 key;
      switch( key = tlGetCH() ) {
      case 'c':
      case 'C':
        varraycont = !varraycont;
        break;
      case 't':
      case 'T':
        listType = -1;
        break;
      case 'a':
      case 'A':
        aaenable = !aaenable;
        if (aaenable) {
          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 );
          grEnable(GR_AA_ORDERED);
          if (!packedrgb)
            grVertexLayout(GR_PARAM_A,
                           GR_VERTEX_A_OFFSET << 2,
                           GR_PARAM_ENABLE);
        }
        else {
          grAlphaCombine(GR_COMBINE_FUNCTION_SCALE_OTHER,
                         GR_COMBINE_FACTOR_ONE,
                         GR_COMBINE_LOCAL_NONE,
                         GR_COMBINE_OTHER_CONSTANT,
                         FXFALSE);
          grAlphaBlendFunction(GR_BLEND_ONE , GR_BLEND_ZERO, 
                               GR_BLEND_ONE, GR_BLEND_ZERO);
          grDisable(GR_AA_ORDERED);
          if (!packedrgb)
            grVertexLayout(GR_PARAM_A,
                           GR_VERTEX_A_OFFSET << 2,
                           GR_PARAM_DISABLE);
        }
        break;
      case 'p':
      case 'P':
        packedrgb = !packedrgb;
        if (packedrgb) {
          grVertexLayout(GR_PARAM_PARGB,   GR_VERTEX_R_OFFSET << 2, GR_PARAM_ENABLE);
          *(FxU32*)&vtxList[0].r = 0xff0000ff;
          *(FxU32*)&vtxList[1].r = 0xff00ff00;
          *(FxU32*)&vtxList[2].r = 0xffff0000;
          *(FxU32*)&vtxList[3].r = 0xffff0000;
          *(FxU32*)&vtxList[4].r = 0xff00ff00;
          *(FxU32*)&vtxList[5].r = 0xff0000ff;
        }
        else {
          grVertexLayout(GR_PARAM_RGB, GR_VERTEX_R_OFFSET << 2, GR_PARAM_ENABLE);
          if (aaenable)
            grVertexLayout(GR_PARAM_A,   GR_VERTEX_A_OFFSET << 2, GR_PARAM_ENABLE);
          vtxList[0].r = 255.f, vtxList[0].g = 0.f, vtxList[0].b = 0.f, vtxList[0].a = 255.f;
          vtxList[1].r = 0.f, vtxList[1].g = 255.f, vtxList[1].b = 0.f, vtxList[1].a = 255.f;
          vtxList[2].r = 0.f, vtxList[2].g = 0.f, vtxList[2].b = 255.f, vtxList[2].a = 255.f;
          vtxList[3].r = 0.f, vtxList[3].g = 0.f, vtxList[3].b = 255.f, vtxList[3].a = 255.f;
          vtxList[4].r = 0.f, vtxList[4].g = 255.f, vtxList[4].b = 0.f, vtxList[4].a = 255.f;
          vtxList[5].r = 0.f, vtxList[5].g = 0.f, vtxList[5].b = 255.f, vtxList[5].a = 255.f;
        }
        switch (listType) {
        case 0:
        case 1:
        case 2:
        case 4:
          vtxListCont[0] = vtxList[0]; vtxListCont[1] = vtxList[1];
          vtxListCont[2] = vtxList[2]; vtxListCont[3] = vtxList[3];
          break;
        case 3:
        case 5:
          vtxListCont[0] = vtxList[1]; vtxListCont[1] = vtxList[0];
          vtxListCont[2] = vtxList[2]; vtxListCont[3] = vtxList[3];
          break;
        case 6:
          vtxListCont[0] = vtxList[1]; vtxListCont[1] = vtxList[0]; vtxListCont[2] = vtxList[2]; 
          vtxListCont[3] = vtxList[1]; vtxListCont[4] = vtxList[2]; vtxListCont[5] = vtxList[3];
          break;
        }
        break;
      case '0':
      case '1':
      case '2':
      case '4':
        listType =  key - '0';
        vtxListArray[0] = (void *)&vtxList[0]; vtxListArray[1] = (void *)&vtxList[1];
        vtxListArray[2] = (void *)&vtxList[2]; vtxListArray[3] = (void *)&vtxList[3];
        vtxListCont[0] = vtxList[0]; vtxListCont[1] = vtxList[1];
        vtxListCont[2] = vtxList[2]; vtxListCont[3] = vtxList[3];
        break;
      case '3':
      case '5':
        listType =  key - '0';
        vtxListArray[0] = (void *)&vtxList[1]; vtxListArray[1] = (void *)&vtxList[0];
        vtxListArray[2] = (void *)&vtxList[2]; vtxListArray[3] = (void *)&vtxList[3];
        vtxListCont[0] = vtxList[1]; vtxListCont[1] = vtxList[0];
        vtxListCont[2] = vtxList[2]; vtxListCont[3] = vtxList[3];
        break;
      case '6':
        listType =  key - '0';
        vtxListArray[0] = (void *)&vtxList[1]; vtxListArray[1] = (void *)&vtxList[0];
        vtxListArray[2] = (void *)&vtxList[2];
        vtxListArray[3] = (void *)&vtxList[1]; vtxListArray[4] = (void *)&vtxList[2];
        vtxListArray[5] = (void *)&vtxList[3];
        vtxListCont[0] = vtxList[1]; vtxListCont[1] = vtxList[0]; vtxListCont[2] = vtxList[2]; 
        vtxListCont[3] = vtxList[1]; vtxListCont[4] = vtxList[2]; vtxListCont[5] = vtxList[3];
        break;
      default:
        frames = 0;
        break;
      }
    }
  }
  
  grGlideShutdown();
  return;
} /* main */
コード例 #25
0
ファイル: TEST35.C プロジェクト: grakidov/Render3D
/* convinient initialization function */
void initGlide(int argc, char** argv)
{
  GrScreenResolution_t
    screenRes;
  int 
    i;

  wWidth = 640.f;
  wHeight = 480.f;

  screenRes = GR_RESOLUTION_640x480;

  /* Let the user specify a resolution on the command line 
     and save the resolution in wWidth and wHeight */
  if (argc > 1) {
    for(i = 1; i < argc; i++) {
      if (strstr(argv[i], "320x200")) {
        wWidth = 320.f; wHeight = 200.f;
        screenRes = GR_RESOLUTION_320x200;
      } else if (strstr(argv[i], "320x240")) {
        wWidth = 320.f; wHeight = 240.f;
        screenRes = GR_RESOLUTION_320x240;
      } else if (strstr(argv[i], "400x256")) {
        wWidth = 400.f; wHeight = 256.f;
        screenRes = GR_RESOLUTION_400x256;
      } else if (strstr(argv[i], "512x384")) {
        wWidth = 512.f; wHeight = 384.f;
        screenRes = GR_RESOLUTION_512x384;
      } else if (strstr(argv[i], "640x480")) {
        wWidth = 640.f; wHeight = 480.f;
        screenRes = GR_RESOLUTION_640x480;
      } else if (strstr(argv[i], "800x600")) {
        wWidth = 800.f; wHeight = 600.f;
        screenRes = GR_RESOLUTION_800x600;
      } else if (strstr(argv[i], "640x200")) {
        wWidth = 640.f; wHeight = 200.f;
        screenRes = GR_RESOLUTION_640x200;
      } else if (strstr(argv[i], "640x350")) {
        wWidth = 640.f; wHeight = 350.f;
        screenRes = GR_RESOLUTION_640x350;
      } else if (strstr(argv[i], "640x400")) {
        wWidth = 640.f; wHeight = 400.f;
        screenRes = GR_RESOLUTION_640x400;
      } else if (strstr(argv[i], "960x720")) {
        wWidth = 960.f; wHeight = 720.f;
        screenRes = GR_RESOLUTION_960x720;
      } else if (strstr(argv[i], "-n")) {
        if(argc > i + 1) {
          numFrames = atoi(argv[i + 1]);
          i++;
        } else {
          fprintf(stderr, "Usage: test33 {320x200|320x240|400x256|512x384|640x480|800x600|640x200|640x350|640x400|960x720} {-n numFrames}");
          exit(-1);  
        }
      } else {
        fprintf(stderr, "Usage: test33 {320x200|320x240|400x256|512x384|640x480|800x600|640x200|640x350|640x400|960x720} {-n numFrames}");
        exit(-1);  
      }
    }
  }

  /* Describe the program */
  puts( "\nTEST35: (expanding cliping window)" );
  puts( "Clipping test" );
  if(numFrames == -1)
  {
    puts( "press a key to begin" );
    getch();
  }


  /* Startup glide */
  grGlideInit();

  /* Get the hardware configuration */
  if ( !grSstQueryHardware( &hwconfig ) )
  {
     fprintf( stderr, "grQuery failed!" );
     exit( -1 );
  }

  /* Select the correct sst */
  grSstSelect( 0 );

  /* Open the device */
  if ( !grSstOpen( screenRes,
                   GR_REFRESH_60Hz,
                   GR_COLORFORMAT_ABGR,
                   GR_ORIGIN_LOWER_LEFT,
                   GR_SMOOTHING_ENABLE,
                   2 ) )
  {
     fprintf( stderr, "grOpen failed!" );
     grGlideShutdown();
     exit( -1 );
  }
  
  
  /* Setup for iterrated color */
  grColorCombine(GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE,
                 GR_COMBINE_LOCAL_ITERATED, GR_COMBINE_OTHER_NONE,
                 FXFALSE);

}
コード例 #26
0
ファイル: test22.c プロジェクト: grakidov/Render3D
void main( int argc, char **argv) {
    char match; 
    char **remArgs;
    int  rv;

    GrScreenResolution_t resolution = GR_RESOLUTION_640x480;
    float                scrWidth   = 640.0f;
    float                scrHeight  = 480.0f;
    int frames                      = -1;

    TlTexture  baseTexture;
    unsigned long baseTextureAddr;
    TlTexture  lightTexture;
    unsigned long lightTextureAddr;

    int                  ftsize = 0;
    GrFog_t              *fogtable = NULL;

    TlVertex3D srcVerts[4];
    float      distance, dDelta;
    FxU32      zrange[2];

    /* Process Command Line Arguments */
    while( rv = tlGetOpt( argc, argv, "nr", &match, &remArgs ) ) {
        if ( rv == -1 ) {
            printf( "Unrecognized command line argument\n" );
            printf( "%s %s\n", name, usage );
            printf( "Available resolutions:\n%s\n",
                    tlGetResolutionList() );
            return;
        }
        switch( match ) {
        case 'n':
            frames = atoi( remArgs[0] );
            break;
        case 'r':
            resolution = tlGetResolutionConstant( remArgs[0], 
                                                  &scrWidth, 
                                                  &scrHeight );
            break;
        }
    }

    tlSetScreen( scrWidth, scrHeight );

    version = grGetString( GR_VERSION );

    printf( "%s:\n%s\n", name, purpose );
    printf( "%s\n", version );
    printf( "Resolution: %s\n", tlGetResolutionString( resolution ) );
    if ( frames == -1 ) {
        printf( "Press A Key To Begin Test.\n" );
        tlGetCH();
    }
    
    /* Initialize Glide */
    grGlideInit();
    assert( hwconfig = tlVoodooType() );

    grSstSelect( 0 );
    assert( grSstWinOpen( 0,
                      resolution,
                      GR_REFRESH_60Hz,
                      GR_COLORFORMAT_ABGR,
                      GR_ORIGIN_LOWER_LEFT,
                      2, 1 ) );
    
    tlConSet( 0.0f, 0.0f, 1.0f, 0.5f, 
              60, 15, 0xffffff );
    
    /* Set up Render State - decal - bilinear - nearest mipmapping - fogging */
    grGet(GR_ZDEPTH_MIN_MAX, 8, zrange);  
    grGet(GR_FOG_TABLE_ENTRIES, 4, &ftsize);
    fogtable = malloc(sizeof(GrFog_t)*ftsize);
    assert(fogtable);

    grVertexLayout(GR_PARAM_XY,  0, GR_PARAM_ENABLE);
    grVertexLayout(GR_PARAM_Q,   GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
    grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);

    grColorCombine( GR_COMBINE_FUNCTION_SCALE_OTHER,
                    GR_COMBINE_FACTOR_ONE,
                    GR_COMBINE_LOCAL_NONE,
                    GR_COMBINE_OTHER_TEXTURE,
                    FXFALSE );
    grTexMipMapMode( GR_TMU0,
                     GR_MIPMAP_NEAREST,
                     FXFALSE );
    grTexFilterMode( GR_TMU0,
                     GR_TEXTUREFILTER_BILINEAR,
                     GR_TEXTUREFILTER_BILINEAR );
    grFogColorValue( 0x404040 );
    guFogGenerateExp( fogtable, .2f );
    grFogTable( fogtable );

    /* Load texture data into system ram */
    assert( tlLoadTexture( "decal1.3df", 
                           &baseTexture.info, 
                           &baseTexture.tableType, 
                           &baseTexture.tableData ) );
    assert( tlLoadTexture( "light.3df", 
                           &lightTexture.info, 
                           &lightTexture.tableType, 
                           &lightTexture.tableData ) );

    /* Download texture data to TMU */
    baseTextureAddr = grTexMinAddress( GR_TMU0 );
    grTexDownloadMipMap( GR_TMU0,
                         baseTextureAddr,
                         GR_MIPMAPLEVELMASK_BOTH,
                         &baseTexture.info );
    if ( baseTexture.tableType != NO_TABLE ) {
        grTexDownloadTable( baseTexture.tableType,
                            &baseTexture.tableData );
    }

    lightTextureAddr = 
        baseTextureAddr +
        grTexTextureMemRequired( GR_MIPMAPLEVELMASK_BOTH,
                                 &baseTexture.info );
    grTexDownloadMipMap( GR_TMU0,
                         lightTextureAddr,
                         GR_MIPMAPLEVELMASK_BOTH,
                         &lightTexture.info );
    if ( lightTexture.tableType != NO_TABLE ) {
        grTexDownloadTable( lightTexture.tableType,
                            &lightTexture.tableData );
    }

    /* Initialize Source 3D data - Rectangle on X/Z Plane 
       Centered about Y Axis

       0--1  Z+
       |  |  |
       2--3   - X+

     */
    srcVerts[0].x = -0.5f, srcVerts[0].y = 0.0f, srcVerts[0].z =  0.5f, srcVerts[0].w = 1.0f;
    srcVerts[1].x =  0.5f, srcVerts[1].y = 0.0f, srcVerts[1].z =  0.5f, srcVerts[1].w = 1.0f;
    srcVerts[2].x = -0.5f, srcVerts[2].y = 0.0f, srcVerts[2].z = -0.5f, srcVerts[2].w = 1.0f;
    srcVerts[3].x =  0.5f, srcVerts[3].y = 0.0f, srcVerts[3].z = -0.5f, srcVerts[3].w = 1.0f;

    srcVerts[0].s = 0.0f, srcVerts[0].t = 0.0f;
    srcVerts[1].s = 1.0f, srcVerts[1].t = 0.0f;
    srcVerts[2].s = 0.0f, srcVerts[2].t = 1.0f;
    srcVerts[3].s = 1.0f, srcVerts[3].t = 1.0f;

#define RED  0x000000ff
#define BLUE 0x00ff0000

#define MAX_DIST 10.0f
#define MIN_DIST 1.0f

    distance = 1.0f;
    dDelta   = 0.05f;

    tlConOutput( "Press any key to quit\n\n" );
    while( frames-- && tlOkToRender()) {
        GrVertex vtxA, vtxB, vtxC, vtxD;
        TlVertex3D xfVerts[4];
        TlVertex3D prjVerts[4];

        if (hwconfig == TL_VOODOORUSH) {
          tlGetDimsByConst(resolution,
                           &scrWidth, 
                           &scrHeight );
        
          grClipWindow(0, 0, (FxU32) scrWidth, (FxU32) scrHeight);
        }

        grBufferClear( 0x00404040, 0, zrange[1] );

        /* 3D Transformations */
        /*---- 
          A-B
          |\|
          C-D
          -----*/
        vtxA.oow = 1.0f;
        vtxB = vtxC = vtxD = vtxA;

        distance += dDelta;
        if ( distance > MAX_DIST || 
             distance < MIN_DIST ) { 
            dDelta *= -1.0f;
            distance += dDelta;
        }

        tlSetMatrix( tlIdentity() );
        tlMultMatrix( tlXRotation( -90.0f ) );
        tlMultMatrix( tlTranslation( 0.0f, 0.0f, distance ) );

        tlTransformVertices( xfVerts, srcVerts, 4 );
        tlProjectVertices( prjVerts, xfVerts, 4 );

        vtxA.x = tlScaleX( prjVerts[0].x );
        vtxA.y = tlScaleY( prjVerts[0].y );
        vtxA.oow = 1.0f / prjVerts[0].w;

        vtxB.x = tlScaleX( prjVerts[1].x );
        vtxB.y = tlScaleY( prjVerts[1].y ); 
        vtxB.oow = 1.0f / prjVerts[1].w;
        
        vtxC.x = tlScaleX( prjVerts[2].x );
        vtxC.y = tlScaleY( prjVerts[2].y );
        vtxC.oow = 1.0f / prjVerts[2].w;

        vtxD.x = tlScaleX( prjVerts[3].x ); 
        vtxD.y = tlScaleY( prjVerts[3].y );
        vtxD.oow = 1.0f / prjVerts[3].w;

        vtxA.tmuvtx[0].sow = prjVerts[0].s * 255.0f * vtxA.oow;
        vtxA.tmuvtx[0].tow = prjVerts[0].t * 255.0f * vtxA.oow;

        vtxB.tmuvtx[0].sow = prjVerts[1].s * 255.0f * vtxB.oow;
        vtxB.tmuvtx[0].tow = prjVerts[1].t * 255.0f * vtxB.oow;

        vtxC.tmuvtx[0].sow = prjVerts[2].s * 255.0f * vtxC.oow;
        vtxC.tmuvtx[0].tow = prjVerts[2].t * 255.0f * vtxC.oow;

        vtxD.tmuvtx[0].sow = prjVerts[3].s * 255.0f * vtxD.oow;
        vtxD.tmuvtx[0].tow = prjVerts[3].t * 255.0f * vtxD.oow;

        /* Render First Pass */
        grTexCombine( GR_TMU0,
                      GR_COMBINE_FUNCTION_LOCAL,
                      GR_COMBINE_FACTOR_NONE,
                      GR_COMBINE_FUNCTION_LOCAL,
                      GR_COMBINE_FACTOR_NONE,
                      FXFALSE,
                      FXFALSE );
        grAlphaBlendFunction( GR_BLEND_ONE, GR_BLEND_ZERO,
                              GR_BLEND_ONE, GR_BLEND_ZERO );
        grTexSource( GR_TMU0,
                     baseTextureAddr,
                     GR_MIPMAPLEVELMASK_BOTH,
                     &baseTexture.info );

        grFogMode( GR_FOG_ADD2 | GR_FOG_WITH_TABLE_ON_W );

        grDrawTriangle( &vtxA, &vtxB, &vtxD );
        grDrawTriangle( &vtxA, &vtxD, &vtxC );

        /* Render Second Pass */
        grAlphaBlendFunction( GR_BLEND_ONE, GR_BLEND_PREFOG_COLOR,
                              GR_BLEND_ZERO, GR_BLEND_ZERO );
        grTexSource( GR_TMU0,
                     lightTextureAddr,
                     GR_MIPMAPLEVELMASK_BOTH,
                     &lightTexture.info );

        grFogMode( GR_FOG_MULT2 | GR_FOG_WITH_TABLE_ON_W );

        grDrawTriangle( &vtxA, &vtxB, &vtxD );
        grDrawTriangle( &vtxA, &vtxD, &vtxC );

        tlConRender();
        grBufferSwap( 1 );
        grFinish();
        
        while( tlKbHit() ) {
            switch( tlGetCH() ) {
            default:
                frames = 0;
                break;
            }
        }
    }
    
    grGlideShutdown();
    free(fogtable);
    return;
}
コード例 #27
0
ファイル: GMain.c プロジェクト: 5432935/genesis3d
//==============================================================================
//==============================================================================
geBoolean GMain_Startup(DRV_DriverHook *Hook)
{
 
	int32			VidMode;

	//SetEnvironmentVariable("SST_GAMMA", "1.0");

	switch(Hook->Mode)
	{
		case 0:
		{
			ClientWindow.Width = 512;
			ClientWindow.Height = 384;
			VidMode = GR_RESOLUTION_512x384;
			break;
		}
		case 1:
		{
			ClientWindow.Width = 640;
			ClientWindow.Height = 480;
			VidMode = GR_RESOLUTION_640x480;
			break;
		}
		case 2:
		{
			ClientWindow.Width = 800;
			ClientWindow.Height = 600;
			VidMode = GR_RESOLUTION_800x600;
			break;
		}
		case 3:
		{
			ClientWindow.Width = 1024;
			ClientWindow.Height = 768;
			VidMode = GR_RESOLUTION_1024x768;
			break;
		}
		default:
		{
			SetLastDrvError(DRV_ERROR_NULL_WINDOW, "GLIDE_DrvInit:  Invalid display mode.");
			return FALSE;
		}
	}

	ClientWindow.hWnd = Hook->hWnd;

	// Go full-screen so we won't lose the mouse
	{
		RECT	DeskTop;

		// Save the old window size
		GetWindowRect(ClientWindow.hWnd, &OldWindow);

		// Get the size of the desktop
		GetWindowRect(GetDesktopWindow(), &DeskTop);

		// Resize the window to the size of the desktop
		MoveWindow(ClientWindow.hWnd, DeskTop.left-4, DeskTop.top-40, DeskTop.right+20, DeskTop.bottom+20, TRUE);

		// Center the mouse
		SetCursorPos(ClientWindow.Width / 2, ClientWindow.Height / 2);
	}

	// initialize the Glide library 
	grGlideInit();

	// Get the info about this board
	if (!GMain_GetBoardInfo(&g_BoardInfo))
		return FALSE;

	if (g_BoardInfo.NumTMU <= 0)
	{
		SetLastDrvError(DRV_ERROR_INIT_ERROR, "GLIDE_DrvInit:  Not enough texture mapping units.");
		return GE_FALSE;
	}

	// select the current graphics system 
	grSstSelect(0);

	// initialize and open the graphics system 
	if (!grSstWinOpen( (U32)ClientWindow.hWnd,
              VidMode,
              GR_REFRESH_60Hz,
              GR_COLORFORMAT_ABGR,
              GR_ORIGIN_UPPER_LEFT,
              2, 1 ))
	{
		SetLastDrvError(DRV_ERROR_INIT_ERROR, "GLIDE_DrvInit:  grSstWinOpen failed.");
		return GE_FALSE;
	}

	// We know that GLIDE will be in 5-6-5 mode...
	ClientWindow.R_shift = 5+6;
	ClientWindow.G_shift = 5;
	ClientWindow.B_shift = 0;

	ClientWindow.R_mask = 0xf800;
	ClientWindow.G_mask = 0x07e0;
	ClientWindow.B_mask = 0x001f;

	ClientWindow.R_width = 5;
	ClientWindow.G_width = 6;
	ClientWindow.B_width = 5;

	SetLastDrvError(DRV_ERROR_NONE, "GMain_Startup:  No error.");

	if (!GTHandle_Startup())
	{
		SetLastDrvError(DRV_ERROR_GENERIC, "GMain_Startup:  GTHandle_Startup failed...\n");
		return GE_FALSE;
	}
	
	if (!GMain_InitGlideRegisters())
	{
		SetLastDrvError(DRV_ERROR_GENERIC, "GMain_Startup:  GMain_InitGlideRegisters failed...\n");
		return GE_FALSE;
	}

	// Init the 3d display
	//grSstControl(GR_CONTROL_ACTIVATE);
	grGammaCorrectionValue(1.0f);

	return GE_TRUE;
}
コード例 #28
0
ファイル: TEST42.C プロジェクト: grakidov/Render3D
void
main( int argc, char **argv ) {
  float color = 255.f;
  int
    i, j, num_sst, jj,
    numFrames = -1,
    frameCount = 0;
  char
    *texFileNames[2];
  float
    wWidth, wHeight;

  GrMipMapId_t
    mipmaps[2];
  GrScreenResolution_t
    screenRes;
  GrVertex
    vtx1, vtx2, vtx3;
    
  texFileNames[0] = "bfly.3df";
  texFileNames[1] = "lava.3df";

  wWidth = 640.f;
  wHeight = 480.f;
  screenRes = GR_RESOLUTION_640x480;

  if (argc > 1) {
    for(i = 1; i < argc; i++) {
      if (strstr(argv[i], "320x200")) {
        wWidth = 320.f; wHeight = 200.f;
        screenRes = GR_RESOLUTION_320x200;
      } else if (strstr(argv[i], "320x240")) {
        wWidth = 320.f; wHeight = 240.f;
        screenRes = GR_RESOLUTION_320x240;
      } else if (strstr(argv[i], "400x256")) {
        wWidth = 400.f; wHeight = 256.f;
        screenRes = GR_RESOLUTION_400x256;
      } else if (strstr(argv[i], "512x384")) {
        wWidth = 512.f; wHeight = 384.f;
	screenRes = GR_RESOLUTION_512x384;
      } else if (strstr(argv[i], "640x480")) {
        wWidth = 640.f; wHeight = 480.f;
        screenRes = GR_RESOLUTION_640x480;
      } else if (strstr(argv[i], "800x600")) {
        wWidth = 800.f; wHeight = 600.f;
        screenRes = GR_RESOLUTION_800x600;
      } else if (strstr(argv[i], "640x200")) {
        wWidth = 640.f; wHeight = 200.f;
        screenRes = GR_RESOLUTION_640x200;
      } else if (strstr(argv[i], "640x350")) {
        wWidth = 640.f; wHeight = 350.f;
        screenRes = GR_RESOLUTION_640x350;
      } else if (strstr(argv[i], "640x400")) {
        wWidth = 640.f; wHeight = 400.f;
        screenRes = GR_RESOLUTION_640x400;
      } else if (strstr(argv[i], "960x720")) {
        wWidth = 960.f; wHeight = 720.f;
        screenRes = GR_RESOLUTION_960x720;
      } else if(strstr(argv[i], "-n")) {
        if(argc > i + 1) {
          numFrames = atoi(argv[ i + 1]);
          i++;
        } else {
          fprintf(stderr, "Usage: test42 {320x200|320x240|400x256|512x384|640x480|800x600|640x200|640x350|640x400|960x720} {-n numFrames}");
          exit(-1);
        }
      } else {
        fprintf(stderr, "Usage: test42 {320x200|320x240|400x256|512x384|640x480|800x600|640x200|640x350|640x400|960x720} {-n numFrames}\n");
        exit(-1);
      }
    }
  }

  puts( "\nTEST42:" );
  puts( "renders a Gouraud-modulated, textured triangle on each screen" );
  if(numFrames == -1) {
    puts( "press a key to continue" );
    getch();
  }

  grGlideInit();

  if ( !grSstQueryHardware( &hwconfig ) ) {
    fprintf( stderr, "main: grSstQueryHardware failed!\n" );
    grGlideShutdown();
    exit( -1 );
  }

  for (i = 0; i < hwconfig.num_sst; i++) {
    if (hwconfig.SSTs[i].type != GR_SSTTYPE_VOODOO) {
      fprintf(stderr, "Somebody needs to update this program!\n");
      grGlideShutdown();
      exit( -1 );
    } else
      printf("SST %d: 3Dfx Voodoo Graphics:\n", 1);

    printf("    Pixelfx Revision %d, %d MB Frame Buffer RAM\n",
           hwconfig.SSTs[i].sstBoard.VoodooConfig.fbiRev,
           hwconfig.SSTs[i].sstBoard.VoodooConfig.fbRam);
    for (j = 0; j < hwconfig.SSTs[i].sstBoard.VoodooConfig.nTexelfx; j++) {
      printf("          Texelfx %d: Revision %d, %d MB Texture RAM\n",
             j,
             hwconfig.SSTs[i].sstBoard.VoodooConfig.tmuConfig[j].tmuRev,
             hwconfig.SSTs[i].sstBoard.VoodooConfig.tmuConfig[j].tmuRam);
    }
  }
  num_sst = hwconfig.num_sst;

  for(jj=0; jj<num_sst; jj++) {
      /*
      ** Select SST
      */
      grSstSelect( jj );
    
      /*
      ** Open up the hardware
      */
      if ( !grSstOpen( screenRes,
                       GR_REFRESH_60Hz,
                       GR_COLORFORMAT_ABGR,
                       GR_ORIGIN_LOWER_LEFT,
                       GR_SMOOTHING_ENABLE,
                       2 ) )
      {
        fprintf( stderr, "main: grSstOpen failed for SST#%d!\n", jj );
        grGlideShutdown();
        exit( -1 );
      }
      guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB );
      grTexCombineFunction(GR_TMU0, GR_TEXTURECOMBINE_DECAL);
  }
  
  for (jj = 0; jj < num_sst; jj++) {
    Gu3dfInfo
      info;

    grSstSelect(jj);

    if ( gu3dfGetInfo(texFileNames[jj], &info)) {
      if ((info.data = malloc(info.mem_required)) == NULL) {
        fprintf(stderr, "couldn't allocate host memory for %s\n",
                texFileNames[jj]) ;
        grGlideShutdown();
        exit(-1);
      }
      if (!gu3dfLoad(texFileNames[jj], &info)) {
        fprintf(stderr, "Couldn't load %s\n", texFileNames[jj]);
        grGlideShutdown();
        exit(-1);
      }
      mipmaps[jj] = guTexAllocateMemory(0, 0x3,
                                        info.header.width,
                                        info.header.height,
                                        info.header.format,
                                        GR_MIPMAP_NEAREST_DITHER,
                                        info.header.small_lod,
                                        info.header.large_lod,
                                        info.header.aspect_ratio,
                                        GR_TEXTURECLAMP_CLAMP,
                                        GR_TEXTURECLAMP_CLAMP,
                                        GR_TEXTUREFILTER_BILINEAR,
                                        GR_TEXTUREFILTER_BILINEAR,
                                        0.f,
                                        FXFALSE);
      if (mipmaps[jj] == GR_NULL_MIPMAP_HANDLE) {
        fprintf(stderr, "could not allocate memory for %s\n",
                texFileNames[jj]);
        grGlideShutdown();
        exit(-1);
      }
      guTexDownloadMipMap( mipmaps[jj], info.data, &info.table.nccTable );

    } else {
      fprintf(stderr, "couldn't get info on %s\n", texFileNames[jj]);
      grGlideShutdown();
      exit(-1);
    }
      
    guTexSource(mipmaps[jj]);

  }

  vtx1.x        = 160.0F;
  vtx1.y        = 120.0F;
  vtx1.r        = (float) 0xff;
  vtx1.g        = 0.0F;
  vtx1.b        = 0.0F;
  vtx1.a        = 25.0F;
  vtx1.oow = 1.0F;
  vtx1.tmuvtx[0].sow = 0.0F;
  vtx1.tmuvtx[0].tow = 0.0F;
  
  vtx2.x        = 480.0F;
  vtx2.y        = 120.0F;
  vtx2.r        = 0.0F;
  vtx2.g        = (float) 0xff;
  vtx2.b        = 0.0F;
  vtx2.a        = 25.0F;
  vtx2.oow = 1.0F;
  vtx2.tmuvtx[0].sow = 255.0F;
  vtx2.tmuvtx[0].tow = 0.0F;
  
  vtx3.x        = 320.0F;
  vtx3.y        = 360.0F;
  vtx3.r        = 0.0F;
  vtx3.g        = 0.0F;
  vtx3.b        = (float) 0xff;
  vtx3.a        = 255.0F;
  vtx3.oow = 1.0F;
  vtx3.tmuvtx[0].sow = 128.0F;
  vtx3.tmuvtx[0].tow = 255.0F;
  
  while ( 1 ) {
    for(jj=0; jj<num_sst; jj++) {
      grSstSelect( jj );
      switch(jj & 0x3) {
        case 0:
            grBufferClear( 0xff0000, 0, GR_WDEPTHVALUE_FARTHEST );
            break;
        case 1:
            grBufferClear( 0xff, 0, GR_WDEPTHVALUE_FARTHEST );
            break;
        case 2:
            grBufferClear( 0xff00, 0, GR_WDEPTHVALUE_FARTHEST );
            break;
        default:
            grBufferClear( 0xff00ff, 0, GR_WDEPTHVALUE_FARTHEST );
            break;
      }
      grDrawTriangle( &vtx1, &vtx2, &vtx3 );
      grBufferSwap( 1 );
    }

    if (kbhit()) {
      getch();
      break;
    }
    frameCount++;
    if(frameCount < 0)
      frameCount = 0;
    if(frameCount == numFrames)
      break;
  }
  for(jj=0; jj<num_sst; jj++) {
    grSstSelect( jj );
    grGlideShutdown();
  }
}
コード例 #29
0
ファイル: TEST09.C プロジェクト: grakidov/Render3D
void
main(int argc, char **argv) {
  float
    wWidth, wHeight;
  GrScreenResolution_t
    screenRes;
  int 
    numFrames = -1,
    frameCount = 0;
  int
    i;

  wWidth = 640.f;
  wHeight = 480.f;
  screenRes = GR_RESOLUTION_640x480;

  if (argc > 1) {
    for(i = 1; i < argc; i++) {
      if (strstr(argv[i], "320x200")) {
        wWidth = 320.f; wHeight = 200.f;
        screenRes = GR_RESOLUTION_320x200;
      } else if (strstr(argv[i], "320x240")) {
        wWidth = 320.f; wHeight = 240.f;
        screenRes = GR_RESOLUTION_320x240;
      } else if (strstr(argv[i], "400x256")) {
        wWidth = 400.f; wHeight = 256.f;
        screenRes = GR_RESOLUTION_400x256;
      } else if (strstr(argv[i], "512x384")) {
        wWidth = 512.f; wHeight = 384.f;
        screenRes = GR_RESOLUTION_512x384;
      } else if (strstr(argv[i], "640x480")) {
        wWidth = 640.f; wHeight = 480.f;
        screenRes = GR_RESOLUTION_640x480;
      } else if (strstr(argv[i], "800x600")) {
        wWidth = 800.f; wHeight = 600.f;
        screenRes = GR_RESOLUTION_800x600;
      } else if (strstr(argv[i], "640x200")) {
        wWidth = 640.f; wHeight = 200.f;
        screenRes = GR_RESOLUTION_640x200;
      } else if (strstr(argv[i], "640x350")) {
        wWidth = 640.f; wHeight = 350.f;
        screenRes = GR_RESOLUTION_640x350;
      } else if (strstr(argv[i], "640x400")) {
        wWidth = 640.f; wHeight = 400.f;
        screenRes = GR_RESOLUTION_640x400;
      } else if (strstr(argv[i], "960x720")) {
        wWidth = 960.f; wHeight = 720.f;
        screenRes = GR_RESOLUTION_960x720;
      } else if (strstr(argv[i], "-n")) {
        if(argc > i + 1) {
          numFrames = atoi(argv[i + 1]);
          i++;
        } else {
          fprintf(stderr, "Usage: test09 {320x200|320x240|400x256|512x384|640x480|800x600|640x200|640x350|640x400|960x720} {-n numFrames}\n");
          exit(-1);
        }
      } else {
        fprintf(stderr, "Usage: test09 {320x200|320x240|400x256|512x384|640x480|800x600|640x200|640x350|640x400|960x720} {-n numFrames}\n");
        exit(-1);
      }
    }
  }
  puts( "\nTEST09:" );
  puts( "tests alpha blending" );
  if(numFrames == -1)
  {
    puts( "Press any key to continue" );
    getch();
  }


  grGlideInit();

  if ( !grSstQueryHardware( &hwconfig ) )
  {
    fprintf( stderr, "main: grSstQueryHardware failed!\n" );
    grGlideShutdown();
    exit( -1 );
  }

  /*
  ** Select SST 0
  */
  grSstSelect( 0 );

  /*
  ** Open up the hardware
  */ 
  if ( !grSstOpen( screenRes,
                   GR_REFRESH_60Hz,
                   GR_COLORFORMAT_ABGR,
                   GR_ORIGIN_LOWER_LEFT,
                   GR_SMOOTHING_ENABLE,
                   2 ) )
  {
    fprintf( stderr, "main: grSstOpen failed!\n" );
    grGlideShutdown();
    exit( -1 );
  }

  /*
  ** Configure Glide to test alpha blending
  */
  guAlphaSource( GR_ALPHASOURCE_CC_ALPHA );
  grAlphaBlendFunction( GR_BLEND_SRC_ALPHA, GR_BLEND_ONE_MINUS_SRC_ALPHA, GR_BLEND_ONE, GR_BLEND_ZERO );
  grColorCombine(
    GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_ONE, 
    GR_COMBINE_LOCAL_CONSTANT, GR_COMBINE_OTHER_NONE, FXFALSE);
  
  while ( 1 ) 
  {
    static GrVertex vtxlist[3];
    int i;

    grBufferClear( 0, 0, 0 );

    vtxlist[0].x   = 160.f;
    vtxlist[0].y   = 100.f;
    vtxlist[1].x   = 480.f;
    vtxlist[1].y   = 100.f;
    vtxlist[2].x   = 320.f;
    vtxlist[2].y   = 380.f;

    grConstantColorValue4(255.f, 0.f, 0.f, 255.f);
    grConstantColorValue( 0xFF0000FF );

    for (i = 0; i < 3; i++) {
        vtxlist[i].x = WINSCALEX(vtxlist[i].x);
        vtxlist[i].y = WINSCALEY(vtxlist[i].y);
    }
    grDrawTriangle( &vtxlist[0], &vtxlist[2], &vtxlist[1] );

    vtxlist[0].x   = 160.f;
    vtxlist[0].y   = 380.f;
    vtxlist[1].x   = 480.f;
    vtxlist[1].y   = 380.f;
    vtxlist[2].x   = 320.f;
    vtxlist[2].y   = 100.f;

    grConstantColorValue4(128.f, 255.f, 0.f, 0.f);
    grConstantColorValue( 0x80FF0000 );

    for (i = 0; i < 3; i++) {
      vtxlist[i].x = WINSCALEX(vtxlist[i].x);
      vtxlist[i].y = WINSCALEY(vtxlist[i].y);
    }
    grDrawTriangle( &vtxlist[0], &vtxlist[1], &vtxlist[2] );

    grBufferSwap( 0 );
    if (kbhit()) {
      getch();
      break;
    }
    frameCount++;
    if(frameCount < 0)
      frameCount = 0;
    if(frameCount == numFrames)
      break;
  }
  grGlideShutdown();
}
コード例 #30
0
ファイル: test37.c プロジェクト: basecq/q2dos
void 
main( int argc, char **argv) 
{
  GrScreenResolution_t resolution = GR_RESOLUTION_640x480;
  float                scrWidth   = 640.0f;
  float                scrHeight  = 480.0f;
  long val4[4];
  long * histbuffer;
  long histsize;
  const char * str;
  int ret;
  int i;
  int failures = 0;
  int warnings = 0;
  GrProc func;
  GrContext_t          gc = 0;
  
  /* Initialize Glide */
  grGlideInit();
  assert( hwconfig = tlVoodooType() );
  
  /* Process Command Line Arguments */
  tlSetScreen( scrWidth, scrHeight );
  
  version = grGetString( GR_VERSION );
  
  printf("Test 37 - grGet() Stress Test. All output goes to the Console.\n\n");
  tlGetCH ();
  
  /* Test the Num Boards Call before we do the win open*/
  TestGet("GR_NUM_BOARDS", GR_NUM_BOARDS, 1 , &val4[0], &failures);
  
  grSstSelect( 0 );
  gc = grSstWinOpen( tlGethWnd(),
                     resolution,
                     GR_REFRESH_60Hz,
                     GR_COLORFORMAT_ABGR,
                     GR_ORIGIN_UPPER_LEFT,
                     2, 1 );
  if (!gc) {
    printf("Could not allocate glide fullscreen context.\n");
    goto __errExit;
  }
  
  tlConSet( 0.0f, 0.0f, 1.0f, 1.0f, 
           60, 30, 0xffffff );
  
  /*do the 4 byte grGet()'s*/
  TestGet("GR_BITS_DEPTH", GR_BITS_DEPTH, 1 , &val4[0], &failures);
  if(val4[0]!=CORRECT_GR_BITS_DEPTH) {
    printf("WARNING : Value returned was not not equal to %d\n",CORRECT_GR_BITS_DEPTH);
    warnings++;
  }
  
  TestGet("GR_BITS_GAMMA", GR_BITS_GAMMA, 1 , &val4[0], &failures);
  if(val4[0]<CORRECT_GR_BITS_GAMMA) {
    printf("WARNING : Value returned was less than expected\n");
    warnings++;
  }
  
  TestGet("GR_FOG_TABLE_ENTRIES", GR_FOG_TABLE_ENTRIES, 1 , &val4[0], &failures);
  if(val4[0]<CORRECT_GR_FOG_TABLE_ENTRIES) {
    printf("WARNING : Value returned was less than expected\n");
    warnings++;
  }
  
  TestGet("GR_GAMMA_TABLE_ENTRIES", GR_GAMMA_TABLE_ENTRIES, 1 , &val4[0], &failures);
  if(val4[0]<CORRECT_GR_GAMMA_TABLE_ENTRIES) {
    printf("WARNING : Value returned was less than expected\n");
    warnings++;
  }
  
  TestGet("GR_IS_BUSY", GR_IS_BUSY, 1 , &val4[0], &failures);
  if(val4[0]!=FXTRUE && val4[0]!=FXFALSE) {
    printf("WARNING : Value returned was not FXTRUE or FXFALSE\n");
    warnings++;
  }
  
  TestGet("GR_LFB_PIXEL_PIPE", GR_LFB_PIXEL_PIPE, 1 , &val4[0], &failures);
  if(val4[0]!=FXTRUE && val4[0]!=FXFALSE) {
    printf("WARNING : Value returned was not FXTRUE or FXFALSE\n");
    warnings++;
  }
  
  TestGet("GR_MAX_TEXTURE_SIZE", GR_MAX_TEXTURE_SIZE, 1 , &val4[0], &failures);
  if(val4[0]<CORRECT_GR_MAX_TEXTURE_SIZE) {
    printf("WARNING : Value returned was less than expected\n");
    warnings++;
  }
  
  TestGet("GR_MAX_TEXTURE_ASPECT_RATIO", GR_MAX_TEXTURE_ASPECT_RATIO, 1 , &val4[0], &failures);
  if(val4[0]<CORRECT_GR_MAX_TEXTURE_ASPECT_RATIO) {
    printf("WARNING : Value returned was less than expected\n");
    warnings++;
  }
  
  TestGet("GR_NON_POWER_OF_TWO_TEXTURES", GR_NON_POWER_OF_TWO_TEXTURES, 1 , &val4[0], &failures);
  if(val4[0]!=FXTRUE && val4[0]!=FXFALSE) {
    printf("WARNING : Value returned was not FXTRUE or FXFALSE\n");
    warnings++;
  }
  
  TestGet("GR_NUM_FB", GR_NUM_FB, 1 , &val4[0], &failures);
  if(val4[0]>CORRECT_GR_NUM_FB) {
    printf("WARNING : Value returned was greater than %d\n",CORRECT_GR_NUM_FB);
    warnings++;
  }
  
  TestGet("GR_NUM_TMU", GR_NUM_TMU, 1 , &val4[0], &failures);
  if(val4[0]<CORRECT_GR_NUM_TMU) {
    printf("WARNING : Value returned was less than %d\n",CORRECT_GR_NUM_TMU);
    warnings++;
  }
  
  TestGet("GR_SUPPORTS_PASSTHRU", GR_SUPPORTS_PASSTHRU, 1 , &val4[0], &failures);
  if(val4[0]!=FXTRUE && val4[0]!=FXFALSE) {
    printf("WARNING : Value returned was not FXTRUE or FXFALSE\n");
    warnings++;
  }
  
  TestGet("GR_TEXTURE_ALIGN", GR_TEXTURE_ALIGN, 1 , &val4[0], &failures);
  if(val4[0]<CORRECT_GR_TEXTURE_ALIGN) {
    printf("WARNING : Value returned was less than expected\n");
    warnings++;
  }
  
  /*Now do the ones we cant verify*/
  TestGet("GR_GLIDE_STATE_SIZE", GR_GLIDE_STATE_SIZE, 1 , &val4[0], &failures);
  TestGet("GR_GLIDE_VERTEXLAYOUT_SIZE", GR_GLIDE_VERTEXLAYOUT_SIZE, 1 , &val4[0], &failures);
  TestGet("GR_MEMORY_FB", GR_MEMORY_FB, 1 , &val4[0], &failures);
  TestGet("GR_MEMORY_TMU", GR_MEMORY_TMU, 1 , &val4[0], &failures);
  TestGet("GR_MEMORY_UMA", GR_MEMORY_UMA, 1 , &val4[0], &failures);
  TestGet("GR_NUM_SWAP_HISTORY_BUFFER", GR_NUM_SWAP_HISTORY_BUFFER, 1 , &val4[0], &failures);
  TestGet("GR_PENDING_BUFFERSWAPS", GR_PENDING_BUFFERSWAPS, 1 , &val4[0], &failures);
  TestGet("GR_REVISION_FB", GR_REVISION_FB, 1 , &val4[0], &failures);
  TestGet("GR_REVISION_TMU", GR_REVISION_TMU, 1 , &val4[0], &failures);
  TestGet("GR_STATS_LINES", GR_STATS_LINES, 1 , &val4[0], &failures);
  TestGet("GR_STATS_PIXELS_AFUNC_FAIL", GR_STATS_PIXELS_AFUNC_FAIL, 1 , &val4[0], &failures);
  TestGet("GR_STATS_PIXELS_CHROMA_FAIL", GR_STATS_PIXELS_CHROMA_FAIL, 1 , &val4[0], &failures);
  TestGet("GR_STATS_PIXELS_DEPTHFUNC_FAIL", GR_STATS_PIXELS_DEPTHFUNC_FAIL, 1 , &val4[0], &failures);
  TestGet("GR_STATS_PIXELS_IN", GR_STATS_PIXELS_IN, 1 , &val4[0], &failures);
  TestGet("GR_STATS_PIXELS_OUT", GR_STATS_PIXELS_OUT, 1 , &val4[0], &failures);
  TestGet("GR_STATS_POINTS", GR_STATS_POINTS, 1 , &val4[0], &failures);
  TestGet("GR_STATS_TRIANGLES_IN", GR_STATS_TRIANGLES_IN, 1 , &val4[0], &failures);
  TestGet("GR_STATS_TRIANGLES_OUT", GR_STATS_TRIANGLES_OUT, 1 , &val4[0], &failures);
  
  /*Now do 8 byte grGet()'s*/
  TestGet("GR_WDEPTH_MIN_MAX", GR_WDEPTH_MIN_MAX, 2 , &val4[0], &failures);
  if(val4[0]>val4[1]) {
    printf("WARNING : Value[0] returned was greater than Value[1]\n");
    warnings++;
  }
  
  TestGet("GR_ZDEPTH_MIN_MAX", GR_ZDEPTH_MIN_MAX, 2 , &val4[0], &failures);
  if(val4[0]<val4[1]) {
    printf("WARNING : Value[0] returned was less than Value[1]\n");
    warnings++;
  }
  /*Now do the ones we cant verify*/
  TestGet("GR_FIFO_FULLNESS", GR_FIFO_FULLNESS, 2 , &val4[0], &failures);
  TestGet("GR_VIDEO_POSITION", GR_VIDEO_POSITION, 2 , &val4[0], &failures);
  
  
  
  /* Now do 16 byte grGet()*/
  TestGet("GR_BITS_RGBA", GR_BITS_RGBA, 4 , &val4[0], &failures);
  if((val4[0]!=CORRECT_GR_BITS_RGBA_R) | (val4[1]!=CORRECT_GR_BITS_RGBA_G) | 
     (val4[2]!=CORRECT_GR_BITS_RGBA_B) | (val4[3]!=CORRECT_GR_BITS_RGBA_A) ) {
    printf("WARNING : Values returned were not in range expected\n");
    warnings++;
  }
  
  TestGet("GR_VIEWPORT", GR_VIEWPORT, 4 , &val4[0], &failures);
  if((val4[0]!=CORRECT_GR_VIEWPORT_X) | (val4[1]!=CORRECT_GR_VIEWPORT_Y) |
     (val4[2]!=CORRECT_GR_VIEWPORT_WIDTH) |
     (val4[3]!=CORRECT_GR_VIEWPORT_HEIGHT)){
    printf("WARNING : Values returned were not in range expected\n");
    warnings++;
  }
  
  
  
  /* Now do the Swap History Test*/
  ret = grGet(GR_NUM_SWAP_HISTORY_BUFFER, sizeof(histsize), &histsize );
  
  if(ret==sizeof(histsize)) {
    histbuffer = malloc(histsize*sizeof(long));
    
    ret = grGet(GR_SWAP_HISTORY, histsize*sizeof(long), histbuffer );
    if(ret==(int)(histsize*sizeof(long)))
      printf("Success(%d) - ",ret);
    else {
      printf("Failed (%d) - ", ret);
      failures++;
    }
    
    printf("GR_SWAP_HISTORY Result = ");
    
    for(i=0;i<histsize;i++) {
      printf("%d ", histbuffer[i]);
    }
    printf("\n", histbuffer[i]);
    free(histbuffer);
  } else {
    printf("GR_NUM_SWAP_HISTORY_BUFFER failed, so unable to call GR_SWAP_HISTORY\n");   
  }
  
  /* Now Test The GetString Calls*/
  TestGetString("GR_HARDWARE", GR_HARDWARE, &failures);
  TestGetString("GR_RENDERER", GR_RENDERER, &failures);
  TestGetString("GR_VENDOR", GR_VENDOR, &failures);
  TestGetString("GR_VERSION", GR_VERSION, &failures);
  TestGetString("GR_EXTENSION", GR_EXTENSION, &failures);
  
  str = grGetString(GR_EXTENSION);
  
  if(strstr(str,"CHROMARANGE")) {
    /*try and do the getprocaddress calls for Chromarange*/
    func = grGetProcAddress ( "grChromaRangeModeExt");
    if(!func) {
      printf("GetProcAddress for grChromaRangeModeExt Failed\n");
      failures++;
    }     
    func = grGetProcAddress ( "grChromaRangeExt");
    if(!func) {
      printf("GetProcAddress for grChromaRangeExt Failed\n");
      failures++;
    }     
  }
  
  if(strstr(str,"TEXCHROMA")) {
    /* try and do the getprocaddress calls for TexChroma*/
    func = grGetProcAddress ( "grTexChromaModeExt");
    if(!func) {
      printf("GetProcAddress for grTexChromaModeExt Failed\n");
      failures++;
    }     
    func = grGetProcAddress ( "grTexChromaRangeExt");
    if(!func) {
      printf("GetProcAddress for grTexChromaRangeExt Failed\n");
      failures++;
    }     
  }
  
  if(failures)
    printf("\n%d failures encountered during this test\n",failures);
  else
    printf("\ntesting complete - no failures reported\n");
  
  if(warnings)
    printf("%d warnings encountered during this test\n",warnings);
  else
    printf("testing complete - no warnings reported\n");
  
 __errExit:    
  grGlideShutdown();
  
  return;
} /* main */