add :powertwo option

This commit is contained in:
David Rose 2006-09-05 19:42:07 +00:00
parent fc1c9ac134
commit cd8659ea2b
3 changed files with 41 additions and 0 deletions

View File

@ -430,6 +430,12 @@ describe_input_file() {
"also be overridden for a particular texture using the 'coverage' "
"keyword on the texture line.\n\n");
show_text(" :powertwo flag", 10,
"Specifies whether textures should be forced to a power of two "
"size when they are not placed within a palette. Use 1 for true, "
"to force textures to a power of two; or 0 to leave them exactly "
"the size they are specified. The default is true.\n\n");
show_text(" :round fraction fuzz", 10,
"When the coverage area is computed, it may optionally be "
"rounded up to the next sizeable unit before placing the "

View File

@ -77,6 +77,9 @@ read(istream &in, const string &filename) {
} else if (words[0] == ":coverage") {
okflag = parse_coverage_line(words);
} else if (words[0] == ":powertwo") {
okflag = parse_powertwo_line(words);
} else if (words[0] == ":imagetype") {
okflag = parse_imagetype_line(words);
@ -400,6 +403,37 @@ parse_coverage_line(const vector_string &words) {
return true;
}
////////////////////////////////////////////////////////////////////
// Function: TxaFile::parse_powertwo_line
// Access: Private
// Description: Handles the line in a .txa file that begins with the
// keyword ":powertwo" and indicates whether textures
// should by default be forced to a power of two.
////////////////////////////////////////////////////////////////////
bool TxaFile::
parse_powertwo_line(const vector_string &words) {
if (words.size() != 2) {
nout << "Exactly one parameter required for :powertwo, either a 0 "
<< "or a 1.\n";
return false;
}
int flag;
if (!string_to_int(words[1], flag)) {
nout << "Invalid powertwo flag: " << words[1] << "\n";
return false;
}
if (flag != 0 && flag != 1) {
nout << "Invalid powertwo flag: " << flag << "\n";
return false;
}
pal->_force_power_2 = (flag != 0);
return true;
}
////////////////////////////////////////////////////////////////////
// Function: TxaFile::parse_imagetype_line
// Access: Private

View File

@ -53,6 +53,7 @@ private:
bool parse_margin_line(const vector_string &words);
bool parse_background_line(const vector_string &words);
bool parse_coverage_line(const vector_string &words);
bool parse_powertwo_line(const vector_string &words);
bool parse_imagetype_line(const vector_string &words);
bool parse_shadowtype_line(const vector_string &words);
bool parse_round_line(const vector_string &words);