/* =================== DrawMultitextured output = t0 * t1 or t0 + t1 t0 = most upstream according to spec t1 = most downstream according to spec =================== */ static void DrawMultitextured( shaderCommands_t *input, int stage ) { shaderStage_t *pStage; pStage = tess.xstages[stage]; GL_State( pStage->stateBits ); // this is an ugly hack to work around a GeForce driver // bug with multitexture and clip planes if ( backEnd.viewParms.isPortal ) { // This is not yet available in the current platform. Removing: //qglPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); } // // base // GX_SelectTexture( 0 ); // *********************** This call is not needed for the current implementation. Disabling: //qglTexCoordPointer( 2, GL_FLOAT, 0, input->svars.texcoords[0] ); R_BindAnimatedImage( &pStage->bundle[0] ); // // lightmap/secondary pass // GX_SelectTexture( 1 ); qgxEnableTexStage1(); // *********************** This call is not needed for the current implementation. Disabling: //qglEnableClientState( GL_TEXTURE_COORD_ARRAY ); if ( r_lightmap->integer ) { GX_TexEnv( GX_REPLACE ); } else { GX_TexEnv( tess.shader->multitextureEnv ); } // *********************** This call is not needed for the current implementation. Disabling: //qglTexCoordPointer( 2, GL_FLOAT, 0, input->svars.texcoords[1] ); R_BindAnimatedImage( &pStage->bundle[1] ); R_DrawElements( input->numIndexes, input->indexes ); // // disable texturing on TEXTURE1, then select TEXTURE0 // //qglDisableClientState( GL_TEXTURE_COORD_ARRAY ); qgxDisableTexStage1(); GX_SelectTexture( 0 ); }
int main(void) { GX_Init(GX_HRES_320, GX_VRES_240); GX_SetClearColor(GX_GRAY); GX_GetResolution(&res_w, &res_h); texture = GX_LoadTIM(kid_tim); GX_GetTextureDims(texture, &tex_w, &tex_h); for (int i = 0; i < 32; ++i) sprites[i].occupied = 0; InitSprite(50, 50, 0, 0, -1, 1); InitSprite(60, 30, 0, 0, 1, 1); InitSprite(120, 20, 0, 0, -1, -1); InitSprite(100, 80, 0, 0, 1, -1); while (1) { GX_Clear(); GX_SelectTexture(texture); for (int i = 0; i < 32; ++i) { sprite_t *spr = &sprites[i]; if (spr->occupied) { UpdateSprite(&sprites[i]); GX_DrawRectangleTextured( spr->x, spr->y, spr->w, spr->h, spr->tx, spr->ty ); } } GX_Sync(); } return 0; }
void RB_StageIteratorLightmappedMultitexture( void ) { shaderCommands_t *input; input = &tess; // // log this call // if ( r_logFile->integer ) { // don't just call LogComment, or we will get // a call to va() every frame! GLimp_LogComment( va("--- RB_StageIteratorLightmappedMultitexture( %s ) ---\n", tess.shader->name) ); } // // set face culling appropriately // GX_Cull( input->shader->cullType ); // // set color, pointers, and lock // GL_State( GLS_DEFAULT ); // ****************** Temporarily deactivating this call until the current renderer implements it: //qglVertexPointer( 3, GL_FLOAT, 16, input->xyz ); #ifdef REPLACE_MODE qglDisableClientState( GL_COLOR_ARRAY ); qglColor3f( 1, 1, 1 ); qglShadeModel( GL_FLAT ); #else // ****************** Temporarily deactivating this call until the current renderer implements it: /* qglEnableClientState( GL_COLOR_ARRAY ); qglColorPointer( 4, GL_UNSIGNED_BYTE, 0, tess.constantColor255 ); */ #endif // // select base stage // GX_SelectTexture( 0 ); // ****************** Temporarily deactivating this call until the current renderer implements it: //qglEnableClientState( GL_TEXTURE_COORD_ARRAY ); R_BindAnimatedImage( &tess.xstages[0]->bundle[0] ); // ****************** Temporarily deactivating this call until the current renderer implements it: //qglTexCoordPointer( 2, GL_FLOAT, 16, tess.texCoords[0][0] ); // // configure second stage // GX_SelectTexture( 1 ); qgxEnableTexStage1(); if ( r_lightmap->integer ) { GX_TexEnv( GX_REPLACE ); } else { GX_TexEnv( GX_MODULATE ); } R_BindAnimatedImage( &tess.xstages[0]->bundle[1] ); // ****************** Temporarily deactivating these calls until the current renderer implements them: /* qglEnableClientState( GL_TEXTURE_COORD_ARRAY ); qglTexCoordPointer( 2, GL_FLOAT, 16, tess.texCoords[0][1] ); */ // // lock arrays // /* if ( qglLockArraysEXT ) { qglLockArraysEXT(0, input->numVertexes); GLimp_LogComment( "glLockArraysEXT\n" ); } */ R_DrawElements( input->numIndexes, input->indexes ); // // disable texturing on TEXTURE1, then select TEXTURE0 // qgxDisableTexStage1(); // ****************** Temporarily deactivating this call until the current renderer implements it: //qglDisableClientState( GL_TEXTURE_COORD_ARRAY ); GX_SelectTexture( 0 ); #ifdef REPLACE_MODE GL_TexEnv( GL_MODULATE ); qglShadeModel( GL_SMOOTH ); #endif // // now do any dynamic lighting needed // if ( tess.dlightBits && tess.shader->sort <= SS_OPAQUE ) { ProjectDlightTexture(); } // // now do fog // if ( tess.fogNum && tess.shader->fogPass ) { RB_FogPass(); } // // unlock arrays // /* if ( qglUnlockArraysEXT ) { qglUnlockArraysEXT(); GLimp_LogComment( "glUnlockArraysEXT\n" ); } */ }