Model loading and texturing
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
project(Couch)
|
||||
|
||||
file(GLOB shaders *.vert *.frag)
|
||||
list(
|
||||
TRANSFORM shaders
|
||||
APPEND .h
|
||||
OUTPUT_VARIABLE shader_header_files)
|
||||
macro(add_shader shaderfile)
|
||||
add_custom_command(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${shaderfile}.h
|
||||
COMMAND perl "${CMAKE_CURRENT_SOURCE_DIR}/makeheaders.pl" ${CMAKE_CURRENT_SOURCE_DIR}/${shaderfile} ${CMAKE_CURRENT_BINARY_DIR}/${shaderfile}.h
|
||||
DEPENDS ${shaderfile} makeheaders.pl
|
||||
)
|
||||
endmacro()
|
||||
|
||||
add_shader(flat.vert)
|
||||
add_shader(flat.frag)
|
||||
|
||||
add_custom_target(shader_headers
|
||||
BYPRODUCTS ${shader_header_files}
|
||||
COMMAND perl "${CMAKE_CURRENT_SOURCE_DIR}/makeheaders.pl"
|
||||
DEPENDS ${shaders} ${CMAKE_CURRENT_SOURCE_DIR}/makeheaders.pl)
|
||||
|
||||
add_dependencies(couch shader_headers)
|
||||
DEPENDS flat.vert.h flat.frag.h
|
||||
COMMENT "Generated shaders headers.")
|
||||
|
||||
@@ -1,33 +1,27 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
use File::Basename;
|
||||
|
||||
sub convert {
|
||||
my $filename = $1;
|
||||
|
||||
my $headerguard = "$filename.h";
|
||||
$headerguard =~ tr/a-z./A-Z_/;
|
||||
|
||||
my $constname = "$filename";
|
||||
$constname =~ tr/./_/;
|
||||
my ($filename, $outfilename) = @ARGV;
|
||||
|
||||
open my $fin, '<', $filename;
|
||||
open my $fout, '>', "$filename.h";
|
||||
|
||||
print $fout "#ifndef $headerguard \n#define $headerguard\nconst char * $constname = \n";
|
||||
my $headerguard = basename $outfilename;
|
||||
$headerguard =~ tr/a-z./A-Z_/;
|
||||
|
||||
while(my $line = <$fin>) {
|
||||
$line =~ s/\n/\\n/;
|
||||
print $fout "\"$line\"\n";
|
||||
}
|
||||
my $constname = basename "$filename";
|
||||
$constname =~ tr/./_/;
|
||||
|
||||
print $fout ";\n#endif // $headerguard\n";
|
||||
close $fin;
|
||||
close $fout;
|
||||
open(my $fin, '<', $filename) or die("Couldn't find $filename");
|
||||
open my $fout, '>', $outfilename;
|
||||
|
||||
print $fout "#ifndef $headerguard \n#define $headerguard\nconst char * $constname = \n";
|
||||
|
||||
while(my $line = <$fin>) {
|
||||
$line =~ s/\n/\\n/;
|
||||
print $fout "\"$line\"\n";
|
||||
}
|
||||
|
||||
opendir DIR, ".";
|
||||
while (readdir DIR) {
|
||||
if (/(.*\.(frag|vert))/) {
|
||||
convert;
|
||||
}
|
||||
}
|
||||
print $fout ";\n#endif // $headerguard\n";
|
||||
close $fin;
|
||||
close $fout;
|
||||
print "Generated $outfilename\n";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user