WebGL rotating F: Difference between revisions

Content added Content deleted
(Added Wren)
m (syntax highlighting fixup automation)
Line 15: Line 15:
=={{header|Julia}}==
=={{header|Julia}}==
Makie can use OpenGL as a backend for plotting (GLMakie). The code plots an 'F' as three rectangular solid-shaped scatter plots with overlapping markers, then rotates the resulting graph.
Makie can use OpenGL as a backend for plotting (GLMakie). The code plots an 'F' as three rectangular solid-shaped scatter plots with overlapping markers, then rotates the resulting graph.
<lang julia>using Colors
<syntaxhighlight lang="julia">using Colors
using GeometryBasics: Rect3f
using GeometryBasics: Rect3f
using GLMakie
using GLMakie
Line 36: Line 36:
sleep(0.25)
sleep(0.25)
end
end
</syntaxhighlight>
</lang>


=={{header|Phix}}==
=={{header|Phix}}==
You can run this online [http://phix.x10.mx/p2js/HelloF.htm here] (which gives me around 10% CPU load, with space toggling the timer for no extra load). No teapot, sorry.
You can run this online [http://phix.x10.mx/p2js/HelloF.htm here] (which gives me around 10% CPU load, with space toggling the timer for no extra load). No teapot, sorry.
<!--<lang Phix>(phixonline)-->
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #000080;font-style:italic;">--
<span style="color: #000080;font-style:italic;">--
-- demo\pGUI\HelloF.exw
-- demo\pGUI\HelloF.exw
Line 423: Line 423:
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<!--</lang>-->
<!--</syntaxhighlight>-->


=={{header|Wren}}==
=={{header|Wren}}==
Line 435: Line 435:


As with any Open GL aplication, the Wren code needs to be embedded in a host application which can communicate directly with the relevant libraries and which I've written here in C.
As with any Open GL aplication, the Wren code needs to be embedded in a host application which can communicate directly with the relevant libraries and which I've written here in C.
<lang ecmascript>/* webgl_rotating_F.wren */
<syntaxhighlight lang="ecmascript">/* webgl_rotating_F.wren */


import "./math" for Math
import "./math" for Math
Line 1,129: Line 1,129:
Glut.setOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS)
Glut.setOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS)
init.call()
init.call()
drawScene.call()</lang>
drawScene.call()</syntaxhighlight>
<br>
<br>
We now embed the above code in the following C program, compile and run.
We now embed the above code in the following C program, compile and run.
<lang c>/* gcc webgl_rotating_F.c -o webgl_rotating_F -lglut -lGLESv2 -lm -lwren */
<syntaxhighlight lang="c">/* gcc webgl_rotating_F.c -o webgl_rotating_F -lglut -lGLESv2 -lm -lwren */


#include <stdlib.h>
#include <stdlib.h>
Line 1,455: Line 1,455:
free(script);
free(script);
return 0;
return 0;
}</lang>
}</syntaxhighlight>