MCPcopy Create free account
hub / github.com/GPUOpen-Tools/compressonator / main

Function main

examples/sdk_example1/sdk_example1.cpp:76–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76int main(int argc, const char* argv[])
77{
78#ifdef _WIN32
79 double start_time = timeStampsec();
80#endif
81 if (argc < 5)
82 {
83 std::printf("Example1 SourceFile DestFile Format Quality\n");
84 std::printf("This example shows how to compress a single image\n");
85 std::printf("to a compression format using a quality setting\n");
86 std::printf("Quality is in the range of 0.0 to 1.0\n");
87 std::printf("When using DLL builds make sure the Compressonator_xx_DLL.dll is in exe path\n");
88 std::printf("Usage: Example1.exe ruby.dds ruby_bc7.dds BC7 0.05\n");
89 std::printf("this will generate a compressed ruby file in BC7 format\n");
90 return 0;
91 }
92
93 const char* pszSourceFile = argv[1];
94 const char* pszDestFile = argv[2];
95 CMP_FORMAT destFormat = ParseFormat(argv[3]);
96 CMP_FLOAT fQuality;
97
98 try
99 {
100 fQuality = std::stof(argv[4]);
101 if (fQuality < 0.0f)
102 {
103 fQuality = 0.0f;
104 std::printf("Warning: Quality setting is out of range using 0.0\n");
105 }
106 if (fQuality > 1.0f)
107 {
108 fQuality = 1.0f;
109 std::printf("Warning: Quality setting is out of range using 1.0\n");
110 }
111 }
112 catch (...)
113 {
114 std::printf("Error: Unable to process quality setting\n");
115 return -1;
116 }
117
118 if (destFormat == CMP_FORMAT_Unknown)
119 {
120 std::printf("Unsupported destination format\n");
121 return 0;
122 }
123
124 //==========================================
125 // Load Source Texture
126 //==========================================
127 CMP_Texture srcTexture;
128 if (!LoadDDSFile(pszSourceFile, srcTexture))
129 {
130 std::printf("Error loading source file!\n");
131 return 0;
132 }
133

Callers

nothing calls this directly

Calls 6

ParseFormatFunction · 0.85
LoadDDSFileFunction · 0.85
CMP_CalculateBufferSizeFunction · 0.85
CMP_ConvertTextureFunction · 0.85
SaveDDSFileFunction · 0.85
timeStampsecFunction · 0.70

Tested by

no test coverage detected