From bb9abae3047f6b247d5f47df2511083db5990897 Mon Sep 17 00:00:00 2001 From: heshbaugh Date: Wed, 11 Apr 2012 16:35:41 -0300 Subject: [PATCH 1/2] Add automatic header guard generation. --- obj2opengl.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/obj2opengl.pl b/obj2opengl.pl index b658c5f..17565d6 100755 --- a/obj2opengl.pl +++ b/obj2opengl.pl @@ -429,6 +429,8 @@ sub writeOutput { open ( OUTFILE, ">$outFilename" ) || die "Can't create file $outFilename ... exiting\n"; + my $outTag = substr($outFilename, 2, length($outFilename) - 4); + print OUTFILE "/*\n"; print OUTFILE "created with obj2opengl.pl\n\n"; @@ -455,6 +457,9 @@ sub writeOutput { print OUTFILE "glDrawArrays(GL_TRIANGLES, 0, ".$object."NumVerts);\n"; print OUTFILE "*/\n\n"; + print OUTFILE "#ifndef $outTag" . "_h\n"; + print OUTFILE "#define $outTag" . "_h\n\n"; + # needed constant for glDrawArrays print OUTFILE "unsigned int ".$object."NumVerts = ".($numFaces * 3).";\n\n"; @@ -503,6 +508,7 @@ sub writeOutput { print OUTFILE "};\n\n"; } + print OUTFILE "#endif /* !$outTag" . "_h"; close OUTFILE; } From 0b65e3c9519f38ad29727b30c59cb09e61f55dff Mon Sep 17 00:00:00 2001 From: heshbaugh Date: Wed, 11 Apr 2012 16:36:37 -0300 Subject: [PATCH 2/2] Fixed typo with comment at end of header guard. --- obj2opengl.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/obj2opengl.pl b/obj2opengl.pl index 17565d6..71e530d 100755 --- a/obj2opengl.pl +++ b/obj2opengl.pl @@ -508,7 +508,7 @@ sub writeOutput { print OUTFILE "};\n\n"; } - print OUTFILE "#endif /* !$outTag" . "_h"; + print OUTFILE "#endif /* !$outTag" . "_h */"; close OUTFILE; }