예제 #1
0
//don't mind if this is inefficient as it only
//gets called once per image anyway
void hrDrawFile(char* filename, sdword x, sdword y)
{
    udword handle;
    rectangle rect;
    lifheader* lif = trLIFFileLoad(filename, Pyrophoric);

    rndTextureEnable(TRUE);
    rndAdditiveBlends(FALSE);
    glEnable(GL_BLEND);

    glGenTextures(1, &handle);
    trClearCurrent();
    glBindTexture(GL_TEXTURE_2D, handle);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, lif->width, lif->height,
                 0, GL_RGBA, GL_UNSIGNED_BYTE, lif->data);
    
    // FIXME: there's no LiF scaling here, just translation of the image
    x = hrScaleMissionLoadingScreens
      ? feResRepositionScaledX(x)
      : feResRepositionCentredX(x);
      
    y = hrScaleMissionLoadingScreens
      ? feResRepositionScaledY(y)
      : feResRepositionCentredY(y);
    
    x -= lif->width  >> 1;
    y -= lif->height >> 1;
    rect.x0 = x;
    rect.y0 = y;
    rect.x1 = x + lif->width;
    rect.y1 = y + lif->height;
    hrRectSolidTextured2(&rect);

    glDeleteTextures(1, &handle);
    memFree(lif);

    glDisable(GL_BLEND);
}
예제 #2
0
void tutStartup(void)
{
sdword count;

	if(tutorial == 3)
	{
		tutInitialize();
		return;
	}

    tutorialdone = FALSE;
    if(tutRegion != NULL)
    {
        regChildInsert(tutRegion, &regRootRegion);
    }
    else
    {
        tutRegion = regChildAlloc(&regRootRegion, (sdword)&tutAtom, tutAtom.x, tutAtom.y, tutAtom.width, tutAtom.height, 0, 0);
        tutAtom.region = (void*)tutRegion;
        tutRegion->atom = &tutAtom;
        regDrawFunctionSet(tutRegion, tutExecute);
    }

    tutTitleFont  = frFontRegister(tutTitleFontName);
    tutMainFont  = frFontRegister(tutMainFontName);
    tutTipTitleFont  = frFontRegister(tutTipTitleFontName);
    tutTipFont  = frFontRegister(tutTipFontName);

    for(count = 0; count < NUM_BUTTON_TEXTURES; count++)
    {
        tutButtonTexture[count] = TR_InvalidInternalHandle;
        tutButtonImage[count] = NULL;
        tutButtonImage[count] = trLIFFileLoad(tutTextureNames[count], NonVolatile);
        dbgAssert(tutButtonImage[count] != NULL);
        tutButtonTexture[count] = trRGBTextureCreate((color *)tutButtonImage[count]->data, tutButtonImage[count]->width, tutButtonImage[count]->height, TRUE);
    }
}
예제 #3
0
파일: TradeMgr.c 프로젝트: rcarmo/homeworld
/*-----------------------------------------------------------------------------
    Name        : tmTechImageDraw
    Description : Loads in, decompresses and draws the tech picture.
    Inputs      : none
    Outputs     : loads in tmTechImage and creates tmTechTexture
    Return      : void
----------------------------------------------------------------------------*/
void tmTechImageDraw(featom *atom, regionhandle region)
{
    char      filename[128];
    sdword    index, lru = 0;
    real32    time=(real32)1.0e22;
    rectangle textureRect;

    tmTechImageRegion = region;

    feStaticRectangleDraw(region); //draw standard rectangle

    if (tmtechinfo != -1)
    {
        if (tmtechinfo != tmCurTechTexture)
        {
            for (index=0;index<TM_TOTALPICS;index++) // RM_TOTALPICS is the size of the cache
            {
                // Find least recently used texture
                if (pictures[index].timestamp < time)
                {
                    time = pictures[index].timestamp;
                    lru  = index;
                }
                // If already cached, use it and exit this routine
                if ( (pictures[index].tech==tmtechinfo) &&
                     (pictures[index].race==universe.curPlayerPtr->race) )
                {
                    tmTechTexturePrepare(index);
                    tmCurTechTexture = tmtechinfo;
                    tmCurTechImage = pictures[lru].techImage;
                    tmCurIndex = index;
                    pictures[index].timestamp = universe.totaltimeelapsed;

                    textureRect.x0=region->rect.x0+TM_TEXTURE_INSET;
                    textureRect.y0=region->rect.y0+TM_TEXTURE_INSET;
                    textureRect.x1=region->rect.x1-TM_TEXTURE_INSET;
                    textureRect.y1=region->rect.y1-TM_TEXTURE_INSET;

                    rndPerspectiveCorrection(FALSE);
                    primRectSolidTextured2(&textureRect);

                    //if(tmExtendedInfoActive)
                    //{
                    //    primRectTranslucent2(&textureRect, colRGBA(0, 0, 0, 128));
                    //    tmTechInfoDraw(region);
                    //}
                    return;
                }
            }

            // Build filename for loading texture from file
            strcpy(filename, TechImagePaths[universe.curPlayerPtr->race]);
            strcat(filename, TechTypeToString(tmtechinfo));
            strcat(filename,".lif");

            // Remove oldest (least recently used) texture from memory
            if (pictures[lru].techImage != NULL)
            {
                memFree(pictures[lru].techImage);
                pictures[lru].techImage = NULL;
            }
            if (pictures[lru].techTexture != TR_InvalidInternalHandle)
            {
                trRGBTextureDelete(pictures[lru].techTexture);
                pictures[lru].techTexture = TR_InvalidInternalHandle;
            }

            // Load the image into LRU cache
            pictures[lru].techImage = trLIFFileLoad(filename, NonVolatile);
            dbgAssertOrIgnore(pictures[lru].techImage->flags & TRF_Paletted);

            tmTechTexturePrepare(lru);
            tmCurTechTexture = tmtechinfo;
            tmCurTechImage = pictures[lru].techImage;
            pictures[lru].tech = tmtechinfo;
            pictures[lru].race = universe.curPlayerPtr->race;
            pictures[lru].timestamp = universe.totaltimeelapsed;
        }
        else
        {
            trPalettedTextureMakeCurrent(pictures[tmCurIndex].techTexture,
                                         pictures[tmCurIndex].techImage->palette);
        }

        textureRect.x0=region->rect.x0+TM_TEXTURE_INSET;
        textureRect.y0=region->rect.y0+TM_TEXTURE_INSET;
        textureRect.x1=region->rect.x1-TM_TEXTURE_INSET;
        textureRect.y1=region->rect.y1-TM_TEXTURE_INSET;

        rndPerspectiveCorrection(FALSE);
        primRectSolidTextured2(&textureRect);
    }
}