Browse Source

Added tools version info.

Branimir Karadžić 8 years ago
parent
commit
fab6630bf8
3 changed files with 121 additions and 55 deletions
  1. 41 16
      tools/geometryc/geometryc.cpp
  2. 24 5
      tools/shaderc/shaderc.cpp
  3. 56 34
      tools/texturev/texturev.cpp

+ 41 - 16
tools/geometryc/geometryc.cpp

@@ -21,6 +21,9 @@ namespace stl = tinystl;
 #include <forsyth-too/forsythtriangleorderoptimizer.h>
 #include <forsyth-too/forsythtriangleorderoptimizer.h>
 #include <ib-compress/indexbuffercompression.h>
 #include <ib-compress/indexbuffercompression.h>
 
 
+#define BGFX_GEOMETRYC_VERSION_MAJOR 1
+#define BGFX_GEOMETRYC_VERSION_MINOR 0
+
 #if 0
 #if 0
 #	define BX_TRACE(_format, ...) \
 #	define BX_TRACE(_format, ...) \
 		do { \
 		do { \
@@ -350,6 +353,23 @@ void write(bx::WriterI* _writer
 	}
 	}
 }
 }
 
 
+inline uint32_t rgbaToAbgr(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a)
+{
+	return (uint32_t(_r)<<0)
+		 | (uint32_t(_g)<<8)
+		 | (uint32_t(_b)<<16)
+		 | (uint32_t(_a)<<24)
+		 ;
+}
+
+struct GroupSortByMaterial
+{
+	bool operator()(const Group& _lhs, const Group& _rhs)
+	{
+		return _lhs.m_material < _rhs.m_material;
+	}
+};
+
 void help(const char* _error = NULL)
 void help(const char* _error = NULL)
 {
 {
 	if (NULL != _error)
 	if (NULL != _error)
@@ -358,9 +378,12 @@ void help(const char* _error = NULL)
 	}
 	}
 
 
 	fprintf(stderr
 	fprintf(stderr
-		, "geometryc, bgfx geometry compiler tool\n"
+		, "geometryc, bgfx geometry compiler tool, version %d.%d.%d.\n"
 		  "Copyright 2011-2017 Branimir Karadzic. All rights reserved.\n"
 		  "Copyright 2011-2017 Branimir Karadzic. All rights reserved.\n"
 		  "License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause\n\n"
 		  "License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause\n\n"
+		, BGFX_GEOMETRYC_VERSION_MAJOR
+		, BGFX_GEOMETRYC_VERSION_MINOR
+		, BGFX_API_VERSION
 		);
 		);
 
 
 	fprintf(stderr
 	fprintf(stderr
@@ -372,6 +395,8 @@ void help(const char* _error = NULL)
 
 
 		  "\n"
 		  "\n"
 		  "Options:\n"
 		  "Options:\n"
+		  "  -h, --help               Help.\n"
+		  "  -v, --version            Version information only.\n"
 		  "  -f <file path>           Input file path.\n"
 		  "  -f <file path>           Input file path.\n"
 		  "  -o <file path>           Output file path.\n"
 		  "  -o <file path>           Output file path.\n"
 		  "  -s, --scale <num>        Scale factor.\n"
 		  "  -s, --scale <num>        Scale factor.\n"
@@ -395,26 +420,26 @@ void help(const char* _error = NULL)
 		);
 		);
 }
 }
 
 
-inline uint32_t rgbaToAbgr(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a)
+int main(int _argc, const char* _argv[])
 {
 {
-	return (uint32_t(_r)<<0)
-		 | (uint32_t(_g)<<8)
-		 | (uint32_t(_b)<<16)
-		 | (uint32_t(_a)<<24)
-		 ;
-}
+	bx::CommandLine cmdLine(_argc, _argv);
 
 
-struct GroupSortByMaterial
-{
-	bool operator()(const Group& _lhs, const Group& _rhs)
+	if (cmdLine.hasArg('v', "version") )
 	{
 	{
-		return _lhs.m_material < _rhs.m_material;
+		fprintf(stderr
+			, "geometryc, bgfx geometry compiler tool, version %d.%d.%d.\n"
+			, BGFX_GEOMETRYC_VERSION_MAJOR
+			, BGFX_GEOMETRYC_VERSION_MINOR
+			, BGFX_API_VERSION
+			);
+		return EXIT_SUCCESS;
 	}
 	}
-};
 
 
-int main(int _argc, const char* _argv[])
-{
-	bx::CommandLine cmdLine(_argc, _argv);
+	if (cmdLine.hasArg('h', "help") )
+	{
+		help();
+		return EXIT_FAILURE;
+	}
 
 
 	const char* filePath = cmdLine.findOption('f');
 	const char* filePath = cmdLine.findOption('f');
 	if (NULL == filePath)
 	if (NULL == filePath)

+ 24 - 5
tools/shaderc/shaderc.cpp

@@ -12,14 +12,17 @@ extern "C"
 #include <fpp.h>
 #include <fpp.h>
 } // extern "C"
 } // extern "C"
 
 
+#define BGFX_CHUNK_MAGIC_CSH BX_MAKEFOURCC('C', 'S', 'H', 0x2)
+#define BGFX_CHUNK_MAGIC_FSH BX_MAKEFOURCC('F', 'S', 'H', 0x4)
+#define BGFX_CHUNK_MAGIC_VSH BX_MAKEFOURCC('V', 'S', 'H', 0x4)
+
+#define BGFX_SHADERC_VERSION_MAJOR 1
+#define BGFX_SHADERC_VERSION_MINOR 0
+
 namespace bgfx
 namespace bgfx
 {
 {
 	bool g_verbose = false;
 	bool g_verbose = false;
 
 
-	#define BGFX_CHUNK_MAGIC_CSH BX_MAKEFOURCC('C', 'S', 'H', 0x2)
-	#define BGFX_CHUNK_MAGIC_FSH BX_MAKEFOURCC('F', 'S', 'H', 0x4)
-	#define BGFX_CHUNK_MAGIC_VSH BX_MAKEFOURCC('V', 'S', 'H', 0x4)
-
 	static const char* s_ARB_shader_texture_lod[] =
 	static const char* s_ARB_shader_texture_lod[] =
 	{
 	{
 		"texture2DLod",
 		"texture2DLod",
@@ -725,9 +728,12 @@ namespace bgfx
 		}
 		}
 
 
 		fprintf(stderr
 		fprintf(stderr
-			, "shaderc, bgfx shader compiler tool\n"
+			, "shaderc, bgfx shader compiler tool, version %d.%d.%d.\n"
 			  "Copyright 2011-2017 Branimir Karadzic. All rights reserved.\n"
 			  "Copyright 2011-2017 Branimir Karadzic. All rights reserved.\n"
 			  "License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause\n\n"
 			  "License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause\n\n"
+			, BGFX_SHADERC_VERSION_MAJOR
+			, BGFX_SHADERC_VERSION_MINOR
+			, BGFX_API_VERSION
 			);
 			);
 
 
 		fprintf(stderr
 		fprintf(stderr
@@ -735,6 +741,8 @@ namespace bgfx
 
 
 			  "\n"
 			  "\n"
 			  "Options:\n"
 			  "Options:\n"
+			  "  -h, --help                    Help.\n"
+			  "  -v, --version                 Version information only.\n"
 			  "  -f <file path>                Input file path.\n"
 			  "  -f <file path>                Input file path.\n"
 			  "  -i <include path>             Include path (for multiple paths use use -i multiple times).\n"
 			  "  -i <include path>             Include path (for multiple paths use use -i multiple times).\n"
 			  "  -o <file path>                Output file path.\n"
 			  "  -o <file path>                Output file path.\n"
@@ -774,6 +782,17 @@ namespace bgfx
 	{
 	{
 		bx::CommandLine cmdLine(_argc, _argv);
 		bx::CommandLine cmdLine(_argc, _argv);
 
 
+		if (cmdLine.hasArg('v', "version") )
+		{
+			fprintf(stderr
+				, "shaderc, bgfx shader compiler tool, version %d.%d.%d.\n"
+				, BGFX_SHADERC_VERSION_MAJOR
+				, BGFX_SHADERC_VERSION_MINOR
+				, BGFX_API_VERSION
+				);
+			return EXIT_SUCCESS;
+		}
+
 		if (cmdLine.hasArg('h', "help") )
 		if (cmdLine.hasArg('h', "help") )
 		{
 		{
 			help();
 			help();

+ 56 - 34
tools/texturev/texturev.cpp

@@ -35,6 +35,9 @@ namespace stl = tinystl;
 #include "fs_texture_cube.bin.h"
 #include "fs_texture_cube.bin.h"
 #include "fs_texture_sdf.bin.h"
 #include "fs_texture_sdf.bin.h"
 
 
+#define BGFX_TEXTUREV_VERSION_MAJOR 1
+#define BGFX_TEXTUREV_VERSION_MINOR 0
+
 static const bgfx::EmbeddedShader s_embeddedShaders[] =
 static const bgfx::EmbeddedShader s_embeddedShaders[] =
 {
 {
 	BGFX_EMBEDDED_SHADER(vs_texture),
 	BGFX_EMBEDDED_SHADER(vs_texture),
@@ -509,39 +512,6 @@ struct Interpolator
 	}
 	}
 };
 };
 
 
-void help(const char* _error = NULL)
-{
-	if (NULL != _error)
-	{
-		fprintf(stderr, "Error:\n%s\n\n", _error);
-	}
-
-	fprintf(stderr
-		, "texturev, bgfx texture viewer tool\n"
-		  "Copyright 2011-2017 Branimir Karadzic. All rights reserved.\n"
-		  "License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause\n\n"
-		);
-
-	fprintf(stderr
-		, "Usage: texturev <file path>\n"
-		  "\n"
-		  "Supported input file types:\n"
-		  );
-
-	for (uint32_t ii = 0; ii < BX_COUNTOF(s_supportedExt); ++ii)
-	{
-		fprintf(stderr, "    *.%s\n", s_supportedExt[ii]);
-	}
-
-	fprintf(stderr
-		, "\n"
-		  "Options:\n"
-		  "      --associate          Associate file extensions with texturev.\n"
-		  "\n"
-		  "For additional information, see https://github.com/bkaradzic/bgfx\n"
-		);
-}
-
 void associate()
 void associate()
 {
 {
 #if BX_PLATFORM_WINDOWS
 #if BX_PLATFORM_WINDOWS
@@ -628,10 +598,59 @@ void associate()
 #endif // BX_PLATFORM_WINDOWS
 #endif // BX_PLATFORM_WINDOWS
 }
 }
 
 
+void help(const char* _error = NULL)
+{
+	if (NULL != _error)
+	{
+		fprintf(stderr, "Error:\n%s\n\n", _error);
+	}
+
+	fprintf(stderr
+		, "texturev, bgfx texture viewer tool, version %d.%d.%d.\n"
+		  "Copyright 2011-2017 Branimir Karadzic. All rights reserved.\n"
+		  "License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause\n\n"
+		, BGFX_TEXTUREV_VERSION_MAJOR
+		, BGFX_TEXTUREV_VERSION_MINOR
+		, BGFX_API_VERSION
+		);
+
+	fprintf(stderr
+		, "Usage: texturev <file path>\n"
+		  "\n"
+		  "Supported input file types:\n"
+		  );
+
+	for (uint32_t ii = 0; ii < BX_COUNTOF(s_supportedExt); ++ii)
+	{
+		fprintf(stderr, "    *.%s\n", s_supportedExt[ii]);
+	}
+
+	fprintf(stderr
+		, "\n"
+		  "Options:\n"
+		  "  -h, --help               Help.\n"
+		  "  -v, --version            Version information only.\n"
+		  "      --associate          Associate file extensions with texturev.\n"
+		  "\n"
+		  "For additional information, see https://github.com/bkaradzic/bgfx\n"
+		);
+}
+
 int _main_(int _argc, char** _argv)
 int _main_(int _argc, char** _argv)
 {
 {
 	bx::CommandLine cmdLine(_argc, _argv);
 	bx::CommandLine cmdLine(_argc, _argv);
 
 
+	if (cmdLine.hasArg('v', "version") )
+	{
+		fprintf(stderr
+			, "texturev, bgfx texture viewer tool, version %d.%d.%d.\n"
+			, BGFX_TEXTUREV_VERSION_MAJOR
+			, BGFX_TEXTUREV_VERSION_MINOR
+			, BGFX_API_VERSION
+			);
+		return EXIT_SUCCESS;
+	}
+
 	if (cmdLine.hasArg('h', "help") )
 	if (cmdLine.hasArg('h', "help") )
 	{
 	{
 		help();
 		help();
@@ -776,9 +795,12 @@ int _main_(int _argc, char** _argv)
 				ImGui::SetWindowFontScale(1.0f);
 				ImGui::SetWindowFontScale(1.0f);
 
 
 				ImGui::Text(
 				ImGui::Text(
-					"texturev, bgfx texture viewer tool " ICON_KI_WRENCH "\n"
+					"texturev, bgfx texture viewer tool " ICON_KI_WRENCH ", version %d.%d.%d.\n"
 					"Copyright 2011-2017 Branimir Karadzic. All rights reserved.\n"
 					"Copyright 2011-2017 Branimir Karadzic. All rights reserved.\n"
 					"License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause\n"
 					"License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause\n"
+					, BGFX_TEXTUREV_VERSION_MAJOR
+					, BGFX_TEXTUREV_VERSION_MINOR
+					, BGFX_API_VERSION
 					);
 					);
 				ImGui::Separator();
 				ImGui::Separator();
 				ImGui::NextLine();
 				ImGui::NextLine();