Jump to content

OpenGL/Utah teapot: Difference between revisions

m
syntax highlighting fixup automation
m (Thundergnat moved page OpenGL/Utah Teapot to OpenGL/Utah teapot: capitalization policy)
m (syntax highlighting fixup automation)
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">
<lang C>
#include<gl/freeglut.h>
 
Line 60:
return 0;
}
</syntaxhighlight>
</lang>
 
=={{header|FreeBASIC}}==
<langsyntaxhighlight lang="freebasic">#include "fbgfx.bi"
#include once "GL/glut.bi"
 
Line 106:
glutDisplayFunc(@display)
init()
glutMainLoop()</langsyntaxhighlight>
 
=={{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.
<langsyntaxhighlight lang="go">package main
 
/*
Line 183:
C.glutMainLoop()
C.free(unsafe.Pointer(tlc))
}</langsyntaxhighlight>
 
=={{header|J}}==
Line 190:
<br>
Direct translation from C.
<langsyntaxhighlight Jlang="j">NB. Teapot using freeglut
require '~Projects/freeglut/gldefs.ijs'
 
Line 255:
glutMainLoop void
void
)</langsyntaxhighlight>
 
=={{header|Julia}}==
Makie implements OpenGL shading graphics as part of its plotting functionality. The files are from the University of Utah site.
<langsyntaxhighlight Julialang="julia">using Makie, FileIO, InfoZIP
 
if stat("newell_teaset/teapot.obj").size == 0
Line 270:
rotate!(scene, Quaternion(0.6, 0.2, 0.2, 4.0))
display(scene)
</syntaxhighlight>
</lang>
 
=={{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.
<langsyntaxhighlight lang="scala">// Kotlin Native v0.6
 
import kotlinx.cinterop.*
Line 334:
glutIdleFunc(staticCFunction(::onIdle))
glutMainLoop()
}</langsyntaxhighlight>
 
=={{header|Nim}}==
Line 340:
{{libheader|OpenGL}}
{{libheader|Nim bindings for OpenGL}}
<langsyntaxhighlight Nimlang="nim">import opengl, opengl/glut
 
var
Line 368:
glutDisplayFunc(display)
loadExtensions()
glutMainLoop()</langsyntaxhighlight>
 
=={{header|Ol}}==
{{libheader|GL}}{{libheader|GLU}}
<langsyntaxhighlight lang="lisp">
; initial data:
(define vertices '(
Line 487:
(for-each render Handle:)
(for-each render Spout:))
</syntaxhighlight>
</lang>
 
=={{header|Phix}}==
{{trans|C}}
<!--<langsyntaxhighlight Phixlang="phix">(notonline)-->
<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>
<!--</langsyntaxhighlight>-->
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" perl6line># 20210524 Raku programming solution
 
use NativeCall;
Line 639:
glutIdleFunc(&onIdle);
glutMainLoop();
</syntaxhighlight>
</lang>
 
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.
<langsyntaxhighlight lang="ecmascript">/* utah_teapot.wren */
 
var Rot = 0
Line 749:
Glut.displayFunc("GLCallbacks", "display()")
Glut.idleFunc("GLCallbacks", "onIdle()")
Glut.setOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS)</langsyntaxhighlight>
<br>
We now embed this Wren script in the following C program, compile and run it.
<langsyntaxhighlight lang="c">#include <stdlib.h>
#include <stdio.h>
#include <string.h>
Line 982:
free(script);
return 0;
}</langsyntaxhighlight>
 
{{out}}
10,333

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.