Example #1
0
int R_SetSky(char *skyname)
{
    int i;
    int real_width, real_height;
    char *groupname;

    r_skyboxloaded = false;

    // set skyname to groupname if any
    skyname	= (groupname = TP_GetSkyGroupName(TP_MapName(), NULL)) ? groupname : skyname;

    if (!skyname || !skyname[0] || strchr(skyname, '.'))
    {
        // Empty name or contain dot(dot causing troubles with skipping part of the name as file extenson),
        // so do nothing.
        return 1;
    }

    for (i = 0; i < MAX_SKYBOXTEXTURES; i++)
    {
        byte *data;

        if (
            (data = GL_LoadImagePixels (va("env/%s%s", skyname, skybox_ext[i]), 0, 0, 0, &real_width, &real_height))
            || (data = GL_LoadImagePixels (va("gfx/env/%s%s", skyname, skybox_ext[i]), 0, 0, 0, &real_width, &real_height))
            || (data = GL_LoadImagePixels (va("env/%s_%s", skyname, skybox_ext[i]), 0, 0, 0, &real_width, &real_height))
            || (data = GL_LoadImagePixels (va("gfx/env/%s_%s", skyname, skybox_ext[i]), 0, 0, 0, &real_width, &real_height))
        )
        {
            skyboxtextures[i] = GL_LoadTexture(
                                    va("skybox:%s", skybox_ext[i]),
                                    real_width, real_height, data, TEX_NOCOMPRESS | TEX_MIPMAP, 4);
            // we shold free data from GL_LoadImagePixels()
            Q_free(data);
        }
        else
        {
            skyboxtextures[i] = 0; // GL_LoadImagePixels() fail to load anything
        }

        if (!skyboxtextures[i])
        {
            Com_Printf ("Couldn't load skybox \"%s\"\n", skyname);
            return 1;
        }
    }

    // everything was OK
    r_skyboxloaded = true;
    return 0;
}
Example #2
0
byte *Skin_PixelsLoad(char *name, int *max_w, int *max_h, int *bpp, int *real_width, int *real_height)
{
	byte *pic;

	*max_w = *max_h = *bpp = 0;

	// PCX skins loads different, so using TEX_NO_PCX
	if ((pic = GL_LoadImagePixels (name, 0, 0, TEX_NO_PCX, real_width, real_height))) {
		// No limit in gl.
		*max_w	= *real_width;
		*max_h	= *real_height;
		*bpp	= 4; // 32 bit.

		return pic;
	}

	if ((pic = Image_LoadPCX (NULL, name, 0, 0, real_width, real_height))) 
	{
		// PCX is limited.
		*max_w = 320;
		*max_h = 200;
		*bpp = 1; // 8 bit

		return pic;
	}

	return NULL;
}