OpenGL/Utah teapot: Difference between revisions
m
→{{header|Wren}}: Minor tidy
(OpenGL/Utah Teapot in FreeBASIC) |
m (→{{header|Wren}}: Minor tidy) |
||
(2 intermediate revisions by one other user not shown) | |||
Line 10:
This implementation sticks to the task requirements and only shows the teapot, it's rotating, so you can enjoy it's magnificence from all possible viewpoints and perspectives.
<syntaxhighlight lang="c">
#include<gl/freeglut.h>
Line 60:
return 0;
}
</syntaxhighlight>
=={{header|FreeBASIC}}==
<
#include once "GL/glut.bi"
Line 106:
glutDisplayFunc(@display)
init()
glutMainLoop()</
=={{header|Go}}==
Line 113:
<br>
Although there are a number of third party Go bindings for OpenGL, the following uses 'cgo' to interface directly with the C libraries.
<
/*
Line 183:
C.glutMainLoop()
C.free(unsafe.Pointer(tlc))
}</
=={{header|J}}==
Line 190:
<br>
Direct translation from C.
<
require '~Projects/freeglut/gldefs.ijs'
Line 255:
glutMainLoop void
void
)</
=={{header|Julia}}==
Makie implements OpenGL shading graphics as part of its plotting functionality. The files are from the University of Utah site.
<
if stat("newell_teaset/teapot.obj").size == 0
Line 270:
rotate!(scene, Quaternion(0.6, 0.2, 0.2, 4.0))
display(scene)
</syntaxhighlight>
=={{header|Kotlin}}==
Line 284:
</pre>
You then need to compile the following Kotlin program, linking against opengl.klib, and run the resulting .kexe file to view the rotating teapot.
<
import kotlinx.cinterop.*
Line 334:
glutIdleFunc(staticCFunction(::onIdle))
glutMainLoop()
}</
=={{header|Nim}}==
Line 340:
{{libheader|OpenGL}}
{{libheader|Nim bindings for OpenGL}}
<
var
Line 368:
glutDisplayFunc(display)
loadExtensions()
glutMainLoop()</
=={{header|Ol}}==
{{libheader|GL}}{{libheader|GLU}}
<
; initial data:
(define vertices '(
Line 487:
(for-each render Handle:)
(for-each render Spout:))
</syntaxhighlight>
=={{header|Phix}}==
{{trans|C}}
<!--<
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- (freeglut, allocate, poke, OpenGL 1.0)</span>
<span style="color: #008080;">include</span> <span style="color: #000000;">GL</span><span style="color: #0000FF;">/</span><span style="color: #000000;">gl</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
Line 558:
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<!--</
To run this, you will need the freeglut package from [http://phix.x10.mx/pmwiki/pmwiki.php?n=Main.Freeglut-TheFreeOpenglUtilityToolkit PCAN]
=={{header|Raku}}==
{{trans|C}}
<syntaxhighlight lang="raku"
use NativeCall;
Line 639:
glutIdleFunc(&onIdle);
glutMainLoop();
</syntaxhighlight>
Output: [https://drive.google.com/file/d/1XdLJhCRZ79cwDBPD7XDoRFeNFKc94-kp/view (Offsite Media file) ]
Line 647:
{{libheader|FreeGLUT}}
As it's not currently possible for Wren-cli to access OpenGL directly, we embed a Wren script in a C application to complete this task. See the [[OpenGL#Wren]] task for some of the issues involved here.
<
var Rot = 0
Line 749:
Glut.displayFunc("GLCallbacks", "display()")
Glut.idleFunc("GLCallbacks", "onIdle()")
Glut.setOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS)</
<br>
We now embed this Wren script in the following C program, compile and run it.
<
#include <stdio.h>
#include <string.h>
Line 965:
vm = wrenNewVM(&config);
const char* module = "main";
const char* fileName = "
char *script = readFile(fileName);
WrenInterpretResult result = wrenInterpret(vm, module, script);
Line 982:
free(script);
return 0;
}</
{{out}}
|