Add silent flag to disable progress output. Fixes issue 17.
This commit is contained in:
parent
dbe3546690
commit
4d0eaf93c4
@ -37,7 +37,6 @@
|
|||||||
|
|
||||||
struct MyOutputHandler : public nvtt::OutputHandler
|
struct MyOutputHandler : public nvtt::OutputHandler
|
||||||
{
|
{
|
||||||
MyOutputHandler() : total(0), progress(0), percentage(0), stream(NULL) {}
|
|
||||||
MyOutputHandler(const char * name) : total(0), progress(0), percentage(0), stream(new nv::StdOutputStream(name)) {}
|
MyOutputHandler(const char * name) : total(0), progress(0), percentage(0), stream(new nv::StdOutputStream(name)) {}
|
||||||
virtual ~MyOutputHandler() { delete stream; }
|
virtual ~MyOutputHandler() { delete stream; }
|
||||||
|
|
||||||
@ -46,7 +45,7 @@ struct MyOutputHandler : public nvtt::OutputHandler
|
|||||||
stream = new nv::StdOutputStream(name);
|
stream = new nv::StdOutputStream(name);
|
||||||
percentage = progress = 0;
|
percentage = progress = 0;
|
||||||
if (stream->isError()) {
|
if (stream->isError()) {
|
||||||
printf("Error opening '%s' for writting\n", name);
|
fprintf(stderr, "Error opening '%s' for writting\n", name);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -56,6 +55,10 @@ struct MyOutputHandler : public nvtt::OutputHandler
|
|||||||
{
|
{
|
||||||
total = t;
|
total = t;
|
||||||
}
|
}
|
||||||
|
virtual void setDisplayProgress(bool b)
|
||||||
|
{
|
||||||
|
verbose = b;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void mipmap(int size, int width, int height, int depth, int face, int miplevel)
|
virtual void mipmap(int size, int width, int height, int depth, int face, int miplevel)
|
||||||
{
|
{
|
||||||
@ -70,7 +73,7 @@ struct MyOutputHandler : public nvtt::OutputHandler
|
|||||||
|
|
||||||
progress += size;
|
progress += size;
|
||||||
int p = (100 * progress) / total;
|
int p = (100 * progress) / total;
|
||||||
if (p != percentage)
|
if (verbose && p != percentage)
|
||||||
{
|
{
|
||||||
percentage = p;
|
percentage = p;
|
||||||
printf("\r%d%%", percentage);
|
printf("\r%d%%", percentage);
|
||||||
@ -81,6 +84,7 @@ struct MyOutputHandler : public nvtt::OutputHandler
|
|||||||
int total;
|
int total;
|
||||||
int progress;
|
int progress;
|
||||||
int percentage;
|
int percentage;
|
||||||
|
bool verbose;
|
||||||
nv::StdOutputStream * stream;
|
nv::StdOutputStream * stream;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -138,6 +142,7 @@ int main(int argc, char *argv[])
|
|||||||
bool noMipmaps = false;
|
bool noMipmaps = false;
|
||||||
bool fast = false;
|
bool fast = false;
|
||||||
bool nocuda = false;
|
bool nocuda = false;
|
||||||
|
bool silent = false;
|
||||||
nvtt::Format format = nvtt::Format_BC1;
|
nvtt::Format format = nvtt::Format_BC1;
|
||||||
|
|
||||||
const char * externalCompressor = NULL;
|
const char * externalCompressor = NULL;
|
||||||
@ -224,6 +229,12 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Misc options
|
||||||
|
else if (strcmp("-silent", argv[i]) == 0)
|
||||||
|
{
|
||||||
|
silent = true;
|
||||||
|
}
|
||||||
|
|
||||||
else if (argv[i][0] != '-')
|
else if (argv[i][0] != '-')
|
||||||
{
|
{
|
||||||
input = argv[i];
|
input = argv[i];
|
||||||
@ -242,10 +253,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("NVIDIA Texture Tools - Copyright NVIDIA Corporation 2007\n\n");
|
||||||
|
|
||||||
if (input.isNull())
|
if (input.isNull())
|
||||||
{
|
{
|
||||||
printf("NVIDIA Texture Tools - Copyright NVIDIA Corporation 2007\n\n");
|
|
||||||
|
|
||||||
printf("usage: nvcompress [options] infile [outfile]\n\n");
|
printf("usage: nvcompress [options] infile [outfile]\n\n");
|
||||||
|
|
||||||
printf("Input options:\n");
|
printf("Input options:\n");
|
||||||
@ -282,13 +293,13 @@ int main(int argc, char *argv[])
|
|||||||
nv::DirectDrawSurface dds(input);
|
nv::DirectDrawSurface dds(input);
|
||||||
if (!dds.isValid())
|
if (!dds.isValid())
|
||||||
{
|
{
|
||||||
printf("The file '%s' is not a valid DDS file.\n", input.str());
|
fprintf(stderr, "The file '%s' is not a valid DDS file.\n", input.str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dds.isSupported() || dds.isTexture3D())
|
if (!dds.isSupported() || dds.isTexture3D())
|
||||||
{
|
{
|
||||||
printf("The file '%s' is not a supported DDS file.\n", input.str());
|
fprintf(stderr, "The file '%s' is not a supported DDS file.\n", input.str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,7 +336,7 @@ int main(int argc, char *argv[])
|
|||||||
nv::Image image;
|
nv::Image image;
|
||||||
if (!image.load(input))
|
if (!image.load(input))
|
||||||
{
|
{
|
||||||
printf("The file '%s' is not a supported image type.\n", input.str());
|
fprintf(stderr, "The file '%s' is not a supported image type.\n", input.str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,11 +407,12 @@ int main(int argc, char *argv[])
|
|||||||
MyOutputHandler outputHandler(output);
|
MyOutputHandler outputHandler(output);
|
||||||
if (outputHandler.stream->isError())
|
if (outputHandler.stream->isError())
|
||||||
{
|
{
|
||||||
printf("Error opening '%s' for writting\n", output.str());
|
fprintf(stderr, "Error opening '%s' for writting\n", output.str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
outputHandler.setTotal(nvtt::estimateSize(inputOptions, compressionOptions));
|
outputHandler.setTotal(nvtt::estimateSize(inputOptions, compressionOptions));
|
||||||
|
outputHandler.setDisplayProgress(!silent);
|
||||||
|
|
||||||
nvtt::OutputOptions outputOptions(&outputHandler, &errorHandler);
|
nvtt::OutputOptions outputOptions(&outputHandler, &errorHandler);
|
||||||
//nvtt::OutputOptions outputOptions(NULL, &errorHandler);
|
//nvtt::OutputOptions outputOptions(NULL, &errorHandler);
|
||||||
@ -426,6 +438,7 @@ int main(int argc, char *argv[])
|
|||||||
float diff_time = (float) (((double) end_time.QuadPart - (double) start_time.QuadPart) / freq);
|
float diff_time = (float) (((double) end_time.QuadPart - (double) start_time.QuadPart) / freq);
|
||||||
printf("\rtime taken: %.3f seconds\n", diff_time/1000);
|
printf("\rtime taken: %.3f seconds\n", diff_time/1000);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
clock_t end = clock();
|
clock_t end = clock();
|
||||||
printf("\rtime taken: %.3f seconds\n", float(end-start) / CLOCKS_PER_SEC);
|
printf("\rtime taken: %.3f seconds\n", float(end-start) / CLOCKS_PER_SEC);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user