Blog Code Forum

WebGL:WordPress

From Wiki.cyring.fr

Revision as of 23:07, 9 February 2013 by Cyril (Talk | contribs)
Jump to: navigation, search

functions.php

  1. <?php
  2.  
  3. function gPrimitive( $atts ) {
  4. 	extract(shortcode_atts(array(
  5. 		'id'		=> 'canvas.00000000',
  6. 		'style'		=> '',
  7. 		'width'		=> '640',
  8. 		'height'	=> '540',
  9. 		'rgba'		=> '0.0, 0.0, 0.0, 1.0'), $atts));
  10.  
  11.  
  12. 	$output	= '<script type="text/javascript" src="' . get_stylesheet_directory_uri() . '/glMatrix-min.js"></script>'
  13. 		. '<script type="text/javascript" src="' . get_stylesheet_directory_uri() . '/primitive.js"></script>';
  14.  
  15. 	$main	= '<script type="text/javascript">'
  16. 		. 'main("' . $id . '",' . $rgba .  ');'
  17. 		. '</script>';
  18.  
  19. 	$output	= sprintf( '%s<canvas id="%s" style="%s" width="%s" height="%s"></canvas>%s',
  20. 			    $output,     $id,       $style,    $width,     $height,      $main );
  21. 	return($output);
  22. }


  1. function twentyten_setup() {
  2. 	add_shortcode( 'primitive', 'gPrimitive' );
  3. }
  4.  
  5. ?>
Personal tools