C Programming/Mixing languages
From Wikibooks, the open-content textbooks collection
Contents |
[edit] Mixing Languages
[edit] Assembler
See also:
[edit] Cg
Make the main program ( for CPU) in C, which loads and run the Cg program ( for GPU ).[1][2][3]
[edit] Perl
To mix Perl and C, we can use the XS. XS is an interface description file format used to create an extension interface between Perl and C code (or a C library) which one wishes to use with Perl.
The basic procedure is very simple. We can create the necessary subdirectory structure by running "h2xs" application (e.g. "h2xs -A -n Modulename"). This will create - among others - a Makefile.PL, a .pm Perl module and a .xs XSUB file in the subdirectory tree. We can edit the .xs file by adding our code to that, let's say:
void
hello()
CODE:
printf("Hello, world!\n");
and we can successfully use our new command at Perl side, after running a "perl Makefile.PL" and "make".
Further details can be found on the perlxstut perldoc page.
[edit] Python
[edit] For further reading
[edit] References
- ↑ Lesson: 47 from NeHe Productions
- ↑ Cg Bumpmapping by Razvan Surdulescu at GameDev
- ↑ [http://www.fusionindustries.com/default.asp?page=cg-hlsl-faq | Cg & HLSL Shading Language FAQ by Fusion Industries]