Texture converter executable (plus some others to launch it with specific settings)
This was SVN commit r1854.
This commit is contained in:
parent
4c6713b582
commit
10e1ce7511
42
source/tools/textureconv/launch/launch.c
Normal file
42
source/tools/textureconv/launch/launch.c
Normal file
@ -0,0 +1,42 @@
|
||||
#include <windows.h>
|
||||
|
||||
const char* ExeName = "textureconv.exe";
|
||||
const char* ExtraParams = "REPLACEMEREPLACEMEREPLACEMEREPLACEMEREPLACEMEREPLACEMEREPLACEMEREPLACEME";
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR pCmdLine, int nCmdShow)
|
||||
{
|
||||
static char Path[MAX_PATH];
|
||||
static char Prog[MAX_PATH];
|
||||
char *Srch;
|
||||
|
||||
LPSTR NewCmdLine;
|
||||
if (pCmdLine)
|
||||
{
|
||||
NewCmdLine = malloc(strlen(pCmdLine) + strlen(ExtraParams) + 2);
|
||||
if (!NewCmdLine)
|
||||
return 3;
|
||||
strcpy(NewCmdLine, ExtraParams);
|
||||
strcat(NewCmdLine, " ");
|
||||
strcat(NewCmdLine, pCmdLine);
|
||||
}
|
||||
else
|
||||
{
|
||||
NewCmdLine = (char*)ExtraParams;
|
||||
}
|
||||
|
||||
if (!GetModuleFileName(hInstance, Path, sizeof(Path)))
|
||||
return 1;
|
||||
|
||||
Srch = strrchr(Path, '\\');
|
||||
if (!Srch)
|
||||
return 2;
|
||||
Srch[0] = '\0';
|
||||
|
||||
strcpy(Prog, Path);
|
||||
strcat(Prog, "\\");
|
||||
strcat(Prog, ExeName);
|
||||
|
||||
ShellExecute(NULL, "open", Prog, NewCmdLine, Path, SW_SHOWNORMAL);
|
||||
|
||||
return 0;
|
||||
}
|
33
source/tools/textureconv/launch/makeexe.pl
Normal file
33
source/tools/textureconv/launch/makeexe.pl
Normal file
@ -0,0 +1,33 @@
|
||||
# Used to make variations of the launcher exe, which is necessary because drag-and-drop
|
||||
# onto .bat files appears to not run in the right directory (and so there's no way of it
|
||||
# finding the actual textureconv.exe)
|
||||
#
|
||||
# It just compiles launch.c, then replaces the REPLACEME string with other strings
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
my %settings = (
|
||||
TexConv_Normal => "",
|
||||
TexConv_WithAlpha => "-alphablock",
|
||||
TexConv_WithoutAlpha => "-noalphablock",
|
||||
TexConv_ToTGA => "-tga",
|
||||
);
|
||||
|
||||
system("cl /Od launch.c shell32.lib");
|
||||
die $? if $?;
|
||||
|
||||
open A, 'launch.exe' or die $!;
|
||||
binmode A;
|
||||
my $d = do { local $/; <A> };
|
||||
|
||||
my $str = "REPLACEMEREPLACEMEREPLACEMEREPLACEMEREPLACEMEREPLACEMEREPLACEMEREPLACEME";
|
||||
|
||||
for my $k (keys %settings) {
|
||||
die if length $settings{$k} > length $str;
|
||||
my $d2 = $d;
|
||||
$d2 =~ s/$str/ $settings{$k} . ("\0" x (length($str) - length($settings{$k}))) /e or die;
|
||||
open O, '>', "$k.exe" or die $!;
|
||||
binmode O;
|
||||
print O $d2;
|
||||
}
|
Loading…
Reference in New Issue
Block a user