mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2024-11-24 03:15:40 +01:00
Start working on command line tool -- Currently just making sure that everything builds and links. Also rearranged some function definitions to better accomodate this.
This commit is contained in:
parent
cff862344f
commit
9e625a4065
@ -0,0 +1,18 @@
|
||||
|
||||
IF( MSVC )
|
||||
SET( SOURCES "src/clwin32.cpp" )
|
||||
ELSE()
|
||||
SET( SOURCES "src/clunix.cpp" )
|
||||
ENDIF()
|
||||
|
||||
INCLUDE_DIRECTORIES( ${TexC_SOURCE_DIR}/Core/include )
|
||||
INCLUDE_DIRECTORIES( ${TexC_SOURCE_DIR}/IO/include )
|
||||
|
||||
ADD_EXECUTABLE(
|
||||
tc
|
||||
${SOURCES}
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES( tc TexCompIO )
|
||||
TARGET_LINK_LIBRARIES( tc TexCompCore )
|
||||
TARGET_LINK_LIBRARIES( tc BPTCEncoder )
|
21
CLTool/src/clunix.cpp
Normal file
21
CLTool/src/clunix.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "TexComp.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
if(argc != 2) {
|
||||
fprintf(stderr, "Usage: %s <imagefile>\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ImageFile file (argv[1]);
|
||||
|
||||
SCompressionSettings settings;
|
||||
CompressedImage *ci = CompressImage(file, settings);
|
||||
|
||||
// Cleanup
|
||||
delete ci;
|
||||
return 0;
|
||||
}
|
3
CLTool/src/clwin32.cpp
Normal file
3
CLTool/src/clwin32.cpp
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
}
|
@ -4,3 +4,5 @@ PROJECT(TexC)
|
||||
ADD_SUBDIRECTORY(BPTCEncoder)
|
||||
ADD_SUBDIRECTORY(IO)
|
||||
ADD_SUBDIRECTORY(Core)
|
||||
|
||||
ADD_SUBDIRECTORY(CLTool)
|
||||
|
@ -20,6 +20,7 @@ class CompressedImage {
|
||||
|
||||
void InitData(const unsigned char *withData);
|
||||
public:
|
||||
CompressedImage();
|
||||
CompressedImage(
|
||||
const unsigned int width,
|
||||
const unsigned int height,
|
||||
|
@ -11,9 +11,8 @@ struct SCompressionSettings {
|
||||
int iNumThreads;
|
||||
};
|
||||
|
||||
extern void CompressImage(
|
||||
extern CompressedImage * CompressImage(
|
||||
const ImageFile &,
|
||||
CompressedImage &,
|
||||
const SCompressionSettings &settings
|
||||
);
|
||||
|
||||
|
@ -3,6 +3,13 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
CompressedImage::CompressedImage()
|
||||
: m_Width(0)
|
||||
, m_Height(0)
|
||||
, m_Format(ECompressionFormat(-1))
|
||||
, m_Data(0)
|
||||
{ }
|
||||
|
||||
CompressedImage::CompressedImage( const CompressedImage &other )
|
||||
: m_Width(other.m_Width)
|
||||
, m_Height(other.m_Height)
|
||||
|
@ -17,9 +17,8 @@ static void ReportError(const char *msg) {
|
||||
fprintf(stderr, "TexComp -- %s\n", msg);
|
||||
}
|
||||
|
||||
void CompressImage(
|
||||
CompressedImage * CompressImage(
|
||||
const ImageFile &img,
|
||||
CompressedImage &outImg,
|
||||
const SCompressionSettings &settings
|
||||
) {
|
||||
|
||||
@ -35,21 +34,25 @@ void CompressImage(
|
||||
|
||||
if(cmpDataSz == 0) {
|
||||
ReportError("Unknown compression format");
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CompressedImage *outImg = NULL;
|
||||
unsigned char *cmpData = new unsigned char[cmpDataSz];
|
||||
|
||||
CompressionFunc f = ChooseFuncFromSettings(settings);
|
||||
if(f) {
|
||||
(*f)(img.GetPixels(), cmpData, img.GetWidth(), img.GetHeight());
|
||||
outImg = CompressedImage(img.GetWidth(), img.GetHeight(), settings.format, cmpData);
|
||||
outImg = new CompressedImage(img.GetWidth(), img.GetHeight(), settings.format, cmpData);
|
||||
}
|
||||
else {
|
||||
ReportError("Could not find adequate compression function for specified settings");
|
||||
// return
|
||||
delete [] cmpData;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
delete [] cmpData;
|
||||
|
||||
return outImg;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user