Skip to content

Commit

Permalink
add support for finding the largest square image and resizing to that
Browse files Browse the repository at this point in the history
  • Loading branch information
bottiger1 committed May 25, 2021
1 parent 152bbb4 commit 053a46f
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions sln/vs2017/cubemaker/cubemaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ int main(int argc, char* argv[])

VTFLib::CVTFFile* faces[6]{};

int width = 0;
int height = 0;

for (int i = 0; i < 6; i++)
{
char name[256];
Expand All @@ -205,13 +208,24 @@ int main(int argc, char* argv[])
PressKeyToContinue();
std::terminate();
}
auto fWidth = faces[i]->GetWidth();
auto fHeight = faces[i]->GetHeight();
if (fWidth == fHeight && fWidth > width)
{
width = fWidth;
height = fHeight;
}
}

auto cubemap = VTFLib::CVTFFile();
auto width = faces[0]->GetWidth();
auto height = faces[0]->GetHeight();
if (width == 0)
{
printf("Failed to find a VTF with same width and height\n");
PressKeyToContinue();
std::terminate();
}

printf("assuming dimensions of %i x %i based on %sft.vtf \n", width, height, base_nopath);
printf("assuming dimensions of %i x %i based on largest square VTF \n", width, height);
auto cubemap = VTFLib::CVTFFile();

vlByte* main_buffer[6];
for (int i = 0; i < 6; i++)
Expand Down

0 comments on commit 053a46f

Please sign in to comment.