Exemplo n.º 1
0
/**
 * @brief Apply brightness, saturation and contrast to the lightmap.
 */
static void R_FilterLightmap(r_pixel_t width, r_pixel_t height, byte *lightmap) {
	static r_image_t image = { .type = IT_LIGHTMAP };

	image.width = width;
	image.height = height;

	R_FilterImage(&image, GL_RGB, lightmap);
}
Exemplo n.º 2
0
/*
 * @brief Loads the image by the specified name.
 */
r_image_t *R_LoadImage(const char *name, r_image_type_t type) {
	r_image_t *image;
	char key[MAX_QPATH];

	if (!name || !name[0]) {
		Com_Error(ERR_DROP, "NULL name\n");
	}

	StripExtension(name, key);

	if (!(image = (r_image_t *) R_FindMedia(key))) {

		SDL_Surface *surf;
		if (Img_LoadImage(key, &surf)) { // attempt to load the image
			image = (r_image_t *) R_AllocMedia(key, sizeof(r_image_t));

			image->media.Retain = R_RetainImage;
			image->media.Free = R_FreeImage;

			image->width = surf->w;
			image->height = surf->h;
			image->type = type;

			if (image->type == IT_NORMALMAP) {
				R_LoadHeightmap(name, surf);
			}

			if (image->type & IT_MASK_FILTER) {
				R_FilterImage(image, GL_RGBA, surf->pixels);
			}

			R_UploadImage(image, GL_RGBA, surf->pixels);

			SDL_FreeSurface(surf);
		} else {
			Com_Debug("Couldn't load %s\n", key);
			image = r_image_state.null;
		}
	}

	return image;
}