OpenGL: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: IupDestroy is now a function) |
(add FreeBASIC) |
||
Line 1,080: | Line 1,080: | ||
script? [IF] main [THEN] |
script? [IF] main [THEN] |
||
previous previous previous</lang> |
previous previous previous</lang> |
||
=={{header|FreeBASIC}}== |
|||
This is adapted from example OpenGL code that's included with FreeBASIC distributions. |
|||
<lang FreeBASIC>#include "fbgfx.bi" |
|||
#include once "GL/gl.bi" |
|||
#include once "GL/glu.bi" |
|||
screen 18, 16, , 2 |
|||
glViewport 0, 0, 640, 480 'Set the viewport |
|||
glMatrixMode GL_PROJECTION ' Select projection |
|||
glLoadIdentity ' Set this to default |
|||
gluPerspective 45.0, 640./480., 0.1, 100.0 ' Set perspective view options |
|||
glMatrixMode GL_MODELVIEW ' Set to modelview mode |
|||
glLoadIdentity ' ...and set it to default |
|||
glClearColor 0.5, 0.5, 0.5, 0.0 ' Set clearscreen color to middle grey |
|||
glShadeModel GL_SMOOTH ' set to smooth shading |
|||
glClearDepth 1.0 ' Allow the deletion of the depth buffer |
|||
glEnable GL_DEPTH_TEST ' turn on depth testing |
|||
glDepthFunc GL_LEQUAL ' The Type Of Depth Test To Do |
|||
glHint GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ' niceness tweaks |
|||
do |
|||
glClear GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT ' clear screen and depth |
|||
glLoadIdentity |
|||
glTranslatef 0.0f, 0.0f, -6.0f ' move camera back so we can see the triangle |
|||
glBegin GL_TRIANGLES ' Drawing Using Triangles |
|||
glColor3f 1.0f, 0.0f, 0.0f ' red |
|||
glVertex3f 0.0f, 1.0f, 0.0f ' Top |
|||
glColor3f 0.0f, 1.0f, 0.0f ' green |
|||
glVertex3f -1.0f,-1.0f, 0.0f ' Bottom Left |
|||
glColor3f 0.0f, 0.0f, 1.0f ' blue |
|||
glVertex3f 1.0f,-1.0f, 0.0f ' Bottom Right |
|||
glEnd ' Finished Drawing The Triangle |
|||
flip |
|||
loop while inkey = ""</lang> |
|||
=={{header|Go}}== |
=={{header|Go}}== |