add texture-scale

This commit is contained in:
David Rose 2007-02-13 22:57:22 +00:00
parent fbd72a9000
commit 6aff5d74be
4 changed files with 13 additions and 3 deletions

View File

@ -74,6 +74,14 @@ ConfigVariableInt max_texture_dimension
"loaded from a file) will be automatically scaled down, if "
"necessary, so that neither dimension is larger than this value."));
ConfigVariableDouble texture_scale
("texture-scale", 1.0,
PRC_DESC("This is a global scale factor that is applied to each texture "
"as it is loaded from disk. For instance, a value of 0.5 will "
"reduce each texture to one-half its size in each dimension. This "
"scale factor is applied before textures-power-2 or "
"max-texture-dimension."));
ConfigVariableBool keep_texture_ram
("keep-texture-ram", false,
PRC_DESC("Set this to true to retain the ram image for each texture after it "

View File

@ -38,6 +38,7 @@ EXPCL_PANDA istream &operator >> (istream &in, AutoTextureScale &ats);
// Configure variables for gobj package.
extern EXPCL_PANDA ConfigVariableInt max_texture_dimension;
extern EXPCL_PANDA ConfigVariableDouble texture_scale;
extern EXPCL_PANDA ConfigVariableBool keep_texture_ram;
extern EXPCL_PANDA ConfigVariableBool preload_textures;
extern EXPCL_PANDA ConfigVariableBool compressed_textures;

View File

@ -1873,9 +1873,6 @@ unclean_set_num_rows(int n) {
bool any_changed = false;
int color_array = -1;
int orig_color_rows = -1;
for (size_t i = 0; i < _cdata->_arrays.size(); i++) {
if (_array_writers[i]->get_num_rows() != n) {
// Copy-on-write.

View File

@ -37,6 +37,7 @@
#include "bam.h"
#include "zStream.h"
#include "indent.h"
#include "cmath.h"
#include <stddef.h>
@ -2816,6 +2817,9 @@ consider_rescale(PNMImage &pnmimage, const string &name) {
int new_x_size = pnmimage.get_x_size();
int new_y_size = pnmimage.get_y_size();
new_x_size = (int)cfloor(new_x_size * texture_scale + 0.5);
new_y_size = (int)cfloor(new_y_size * texture_scale + 0.5);
switch (textures_power_2) {
case ATS_down:
new_x_size = down_to_power_2(new_x_size);