WebGL:WordPress
From Wiki.cyring.fr
(Difference between revisions)
(One intermediate revision not shown) | |||
Line 3: | Line 3: | ||
<?php | <?php | ||
- | function | + | function webglPrimitive( $atts ) { |
extract(shortcode_atts(array( | extract(shortcode_atts(array( | ||
- | ' | + | '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)); | ||
Line 42: | Line 17: | ||
$main = '<script type="text/javascript">' | $main = '<script type="text/javascript">' | ||
- | . 'main("' . $ | + | . '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, | + | $output, $id, $style, $width, $height, $main ); |
return($output); | return($output); | ||
} | } | ||
Line 53: | Line 28: | ||
<syntaxhighlight lang="php" line start="1"> | <syntaxhighlight lang="php" line start="1"> | ||
function twentyten_setup() { | function twentyten_setup() { | ||
- | add_shortcode( 'primitive', ' | + | add_shortcode( 'primitive', 'webglPrimitive' ); |
} | } | ||
?> | ?> | ||
</syntaxhighlight> | </syntaxhighlight> |
Latest revision as of 14:40, 28 February 2013
functions.php
<?php
function webglPrimitive( $atts ) {
extract(shortcode_atts(array(
'id' => 'canvas.00000000',
'style' => '',
'width' => '640',
'height' => '540',
'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>'
. '<script type="text/javascript" src="' . get_stylesheet_directory_uri() . '/primitive.js"></script>';
$main = '<script type="text/javascript">'
. 'main("' . $id . '",' . $rgba . ',' . $textured . ');'
. '</script>';
$output = sprintf( '%s<canvas id="%s" style="%s" width="%s" height="%s"></canvas>%s',
$output, $id, $style, $width, $height, $main );
return($output);
}
function twentyten_setup() {
add_shortcode( 'primitive', 'webglPrimitive' );
}
?>