- Hack in PNG backdrop loader
- Add 2 new backdrops from Terminator (http://wz2100.net/forum/index.php?topic=109.0) - Remove unused pal parameter from pie_PNGLoadMem() git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1075 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
a67ea65895
commit
977b2ee558
Binary file not shown.
After Width: | Height: | Size: 382 KiB |
Binary file not shown.
After Width: | Height: | Size: 647 KiB |
|
@ -44,9 +44,9 @@ static void wzpng_read_data(png_structp ctx, png_bytep area, png_size_t size)
|
|||
}
|
||||
}
|
||||
|
||||
BOOL pie_PNGLoadMem(char *pngimage, iSprite *s, iColour *pal)
|
||||
BOOL pie_PNGLoadMem(char *pngimage, iSprite *s)
|
||||
{
|
||||
unsigned int PNG_BYTES_TO_CHECK;
|
||||
unsigned int PNG_BYTES_TO_CHECK=4;
|
||||
png_structp png_ptr = NULL;
|
||||
png_infop info_ptr = NULL;
|
||||
|
||||
|
@ -56,8 +56,6 @@ BOOL pie_PNGLoadMem(char *pngimage, iSprite *s, iColour *pal)
|
|||
buf->buffer = pngimage;
|
||||
buf->length = 10000000;
|
||||
|
||||
PNG_BYTES_TO_CHECK = 4;
|
||||
|
||||
if (png_sig_cmp((png_byte*)pngimage, (png_size_t)0, PNG_BYTES_TO_CHECK)) {
|
||||
debug(LOG_3D, "pie_PNGLoadMem: Did not recognize PNG header in buffer");
|
||||
goto error;
|
||||
|
|
|
@ -203,8 +203,14 @@ extern void pie_GetResetCounts(SDWORD* pPieCount, SDWORD* pTileCount, SDWORD* pP
|
|||
extern void SetBSPObjectPos(SDWORD x,SDWORD y,SDWORD z);
|
||||
extern void SetBSPCameraPos(SDWORD x,SDWORD y,SDWORD z);
|
||||
|
||||
// PNG
|
||||
BOOL pie_PNGLoadMem(char *pngimage, iSprite *s, iColour *pal);
|
||||
/*!
|
||||
* Load a PNG from buffer pngimage into sprite
|
||||
*
|
||||
* \param pngimage Buffer to load from
|
||||
* \param sprite Sprite to read into
|
||||
* \return TRUE on success, FALSE otherwise
|
||||
*/
|
||||
BOOL pie_PNGLoadMem(char *pngimage, iSprite *sprite);
|
||||
|
||||
void SetBSPObjectRot(SDWORD Yaw, SDWORD Pitch);
|
||||
|
||||
|
|
|
@ -540,21 +540,20 @@ void pie_ResetBackDrop(void)
|
|||
}
|
||||
|
||||
|
||||
void pie_LoadBackDrop(SCREENTYPE screenType)
|
||||
void pie_LoadBackDrop(SCREENTYPE screenType)
|
||||
{
|
||||
UDWORD chooser0,chooser1;
|
||||
char backd[128];
|
||||
|
||||
//randomly load in a backdrop piccy.
|
||||
srand((unsigned)time( NULL ) );
|
||||
|
||||
chooser0 = 0;
|
||||
chooser1 = rand()%7;
|
||||
srand( (unsigned)time(NULL) + 17 ); // Use offset since time alone doesn't work very well
|
||||
|
||||
switch (screenType)
|
||||
{
|
||||
case SCREEN_RANDOMBDROP:
|
||||
sprintf(backd,"texpages/bdrops/%d%d-bdrop.jpg", chooser0, chooser1);
|
||||
if ( rand()%2 == 0 )
|
||||
sprintf(backd,"texpages/bdrops/0%i-bdrop.jpg", rand()%7); // Range: 0-6
|
||||
else
|
||||
sprintf(backd,"texpages/bdrops/wzlogo_%i.png", rand()%2 + 3); // Range: 3-4
|
||||
break;
|
||||
case SCREEN_COVERMOUNT:
|
||||
sprintf(backd,"texpages/bdrops/demo-bdrop.jpg");
|
||||
|
|
|
@ -395,18 +395,21 @@ static GLuint image_create_texture(char* filename) {
|
|||
#endif
|
||||
//=====================================================================
|
||||
|
||||
void screen_SetBackDropFromFile(char* filename)
|
||||
void screen_SetBackDropFromFile(char* filename)
|
||||
{
|
||||
pie_image image;
|
||||
iSprite imagePNG;
|
||||
BOOL imageLoaded = FALSE;
|
||||
char * buffer = NULL;
|
||||
unsigned int dummy = 0;
|
||||
|
||||
image_init(&image);
|
||||
|
||||
if (!image_load_from_jpg(&image, filename)) {
|
||||
if (!imageLoaded && !image_load_from_jpg(&image, filename)) {
|
||||
if (~backDropTexture == 0) {
|
||||
glGenTextures(1, &backDropTexture);
|
||||
}
|
||||
|
||||
pie_SetTexturePage(-1);
|
||||
glBindTexture(GL_TEXTURE_2D, backDropTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
|
||||
image.width, image.height,
|
||||
|
@ -416,9 +419,35 @@ void screen_SetBackDropFromFile(char* filename)
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
|
||||
imageLoaded = TRUE;
|
||||
}
|
||||
|
||||
image_delete(&image);
|
||||
|
||||
// HACK : We should use a resource handler here!
|
||||
if ( !imageLoaded && loadFile( filename, &buffer, &dummy ) && pie_PNGLoadMem( buffer, &imagePNG ) )
|
||||
{
|
||||
FREE(buffer);
|
||||
|
||||
if (~backDropTexture == 0) {
|
||||
glGenTextures(1, &backDropTexture);
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, backDropTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
|
||||
imagePNG.width, imagePNG.height,
|
||||
0, GL_RGBA, GL_UNSIGNED_BYTE, imagePNG.bmp);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
|
||||
free(imagePNG.bmp);
|
||||
|
||||
imageLoaded = TRUE;
|
||||
}
|
||||
}
|
||||
//===================================================================
|
||||
|
||||
|
@ -441,38 +470,37 @@ BOOL screen_GetBackDrop(void)
|
|||
//bitmap MUST be 512x512 for now. -Q
|
||||
void screen_Upload(UWORD* newBackDropBmp)
|
||||
{
|
||||
if(newBackDropBmp!=NULL)
|
||||
if(newBackDropBmp != NULL)
|
||||
{
|
||||
glGenTextures(1, &backDropTexture);
|
||||
pie_SetTexturePage(-1);
|
||||
glBindTexture(GL_TEXTURE_2D, backDropTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
|
||||
512,512,//backDropWidth, backDropHeight,
|
||||
glGenTextures(1, &backDropTexture);
|
||||
pie_SetTexturePage(-1);
|
||||
glBindTexture(GL_TEXTURE_2D, backDropTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
|
||||
512,512,//backDropWidth, backDropHeight,
|
||||
0, GL_RGB, GL_UNSIGNED_BYTE, newBackDropBmp);
|
||||
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
}
|
||||
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
pie_SetTexturePage(-1);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, backDropTexture);
|
||||
glColor3f(1, 1,1);
|
||||
glColor3f(1, 1, 1);
|
||||
|
||||
glBegin(GL_TRIANGLE_STRIP);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex2f(0, 0);
|
||||
glTexCoord2f(255, 0);
|
||||
glVertex2f(screenWidth, 0);
|
||||
glTexCoord2f(0, 255);
|
||||
glVertex2f(0, screenHeight);
|
||||
glTexCoord2f(255, 255);
|
||||
glVertex2f(screenWidth, screenHeight);
|
||||
glTexCoord2f(0, 0);
|
||||
glVertex2f(0, 0);
|
||||
glTexCoord2f(255, 0);
|
||||
glVertex2f(screenWidth, 0);
|
||||
glTexCoord2f(0, 255);
|
||||
glVertex2f(0, screenHeight);
|
||||
glTexCoord2f(255, 255);
|
||||
glVertex2f(screenWidth, screenHeight);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ int pie_ReloadTexPage(char *filename, char *pBuffer)
|
|||
s.height = _TEX_PAGE[i].tex.height;
|
||||
s.bmp = _TEX_PAGE[i].tex.bmp;
|
||||
|
||||
pie_PNGLoadMem(pBuffer, &s, NULL);
|
||||
pie_PNGLoadMem(pBuffer, &s);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
|
22
src/data.c
22
src/data.c
|
@ -745,7 +745,7 @@ BOOL dataIMGPAGELoad(char *pBuffer, UDWORD size, void **ppData)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!pie_PNGLoadMem(pBuffer, psSprite, NULL))
|
||||
if (!pie_PNGLoadMem(pBuffer, psSprite))
|
||||
{
|
||||
debug( LOG_ERROR, "IMGPAGE load failed" );
|
||||
return FALSE;
|
||||
|
@ -770,7 +770,7 @@ BOOL dataHWTERTILESLoad(char *pBuffer, UDWORD size, void **ppData)
|
|||
if (bTilesPCXLoaded)
|
||||
{
|
||||
debug( LOG_TEXTURE, "Reloading terrain tiles\n" );
|
||||
if(!pie_PNGLoadMem(pBuffer,&tilesPCX,NULL))
|
||||
if(!pie_PNGLoadMem(pBuffer,&tilesPCX))
|
||||
{
|
||||
debug( LOG_ERROR, "HWTERTILES reload failed" );
|
||||
return FALSE;
|
||||
|
@ -779,7 +779,7 @@ BOOL dataHWTERTILESLoad(char *pBuffer, UDWORD size, void **ppData)
|
|||
else
|
||||
{
|
||||
debug( LOG_TEXTURE, "Loading terrain tiles\n" );
|
||||
if(!pie_PNGLoadMem(pBuffer,&tilesPCX,NULL))
|
||||
if(!pie_PNGLoadMem(pBuffer,&tilesPCX))
|
||||
{
|
||||
debug( LOG_ERROR, "HWTERTILES load failed" );
|
||||
return FALSE;
|
||||
|
@ -933,7 +933,7 @@ BOOL bufferTexPageLoad(char *pBuffer, UDWORD size, void **ppData)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!pie_PNGLoadMem(pBuffer, psSprite, NULL))
|
||||
if (!pie_PNGLoadMem(pBuffer, psSprite))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -942,21 +942,7 @@ BOOL bufferTexPageLoad(char *pBuffer, UDWORD size, void **ppData)
|
|||
NewTexturePage->Texture=psSprite;
|
||||
NewTexturePage->Palette=psPal;
|
||||
|
||||
//Hack mar8 to load textures in order
|
||||
/* for(i=0;i<_TEX_INDEX;i++)
|
||||
{
|
||||
if (stricmp(texfile,_TEX_PAGE[i].name) != 0)
|
||||
{
|
||||
bFound = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!bFound)
|
||||
*/
|
||||
{
|
||||
pie_AddBMPtoTexPages(psSprite, texfile, 1, FALSE, TRUE);
|
||||
}
|
||||
//Hack end
|
||||
|
||||
*ppData = NewTexturePage;
|
||||
}
|
||||
|
|
|
@ -635,9 +635,7 @@ GAMECODE gameLoop(void)
|
|||
//so get a new backdrop
|
||||
quitting = TRUE;
|
||||
|
||||
{
|
||||
pie_LoadBackDrop(SCREEN_RANDOMBDROP);
|
||||
}
|
||||
pie_LoadBackDrop(SCREEN_RANDOMBDROP);
|
||||
}
|
||||
else //if in video mode esc kill video
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue