Blog Code Forum

WebGL:WordPress

From Wiki.cyring.fr

(Difference between revisions)
Jump to: navigation, search
(Page créée avec « === functions.php === <syntaxhighlight lang="php" line start="1"> <?php function gPrimitive( $atts ) { extract(shortcode_atts(array( 'gid' => '', 'style' => '', 'w... »)
 
(2 intermediate revisions not shown)
Line 3: Line 3:
<?php
<?php
-
function gPrimitive( $atts ) {
+
function webglPrimitive( $atts ) {
extract(shortcode_atts(array(
extract(shortcode_atts(array(
-
'gid' => '',
+
'id' => 'canvas.00000000',
-
'style' => '',
+
'style' => '',
-
'width' => '640',
+
'width' => '640',
-
'height'=> '540',
+
'height' => '540',
-
'rgba' => '0.0, 0.0, 0.0, 1.0'), $atts));
+
'rgba' => '0.0, 0.0, 0.0, 1.0',
 +
'textured' => 'false'), $atts));
$output = '<script type="text/javascript" src="' . get_stylesheet_directory_uri() . '/glMatrix-min.js"></script>'
$output = '<script type="text/javascript" src="' . get_stylesheet_directory_uri() . '/glMatrix-min.js"></script>'
-
. '<script type="text/javascript" src="' . get_stylesheet_directory_uri() . '/webgl-utils.js"></script>'
 
. '<script type="text/javascript" src="' . get_stylesheet_directory_uri() . '/primitive.js"></script>';
. '<script type="text/javascript" src="' . get_stylesheet_directory_uri() . '/primitive.js"></script>';
$main = '<script type="text/javascript">'
$main = '<script type="text/javascript">'
-
. 'main("' . $gid . '",' . $rgba . ');'
+
. 'main("' . $id . '",' . $rgba . ',' . $textured . ');'
. '</script>';
. '</script>';
$output = sprintf( '%s<canvas id="%s" style="%s" width="%s" height="%s"></canvas>%s',
$output = sprintf( '%s<canvas id="%s" style="%s" width="%s" height="%s"></canvas>%s',
-
    $output,     $gid,     $style,    $width,    $height,     $main );
+
    $output,     $id,       $style,    $width,    $height,     $main );
return($output);
return($output);
 +
}
 +
</syntaxhighlight>
 +
<br />
 +
<syntaxhighlight lang="php" line start="1">
 +
function twentyten_setup() {
 +
add_shortcode( 'primitive', 'webglPrimitive' );
}
}
?>
?>
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 14:40, 28 February 2013

functions.php

  1. <?php
  2.  
  3. function webglPrimitive( $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',
  10. 		'textured'	=> 'false'), $atts));
  11.  
  12.  
  13. 	$output	= '<script type="text/javascript" src="' . get_stylesheet_directory_uri() . '/glMatrix-min.js"></script>'
  14. 		. '<script type="text/javascript" src="' . get_stylesheet_directory_uri() . '/primitive.js"></script>';
  15.  
  16. 	$main	= '<script type="text/javascript">'
  17. 		. 'main("' . $id . '",' . $rgba . ',' . $textured . ');'
  18. 		. '</script>';
  19.  
  20. 	$output	= sprintf( '%s<canvas id="%s" style="%s" width="%s" height="%s"></canvas>%s',
  21. 			    $output,     $id,       $style,    $width,     $height,      $main );
  22. 	return($output);
  23. }


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