Content deleted Content added
Hervegirod (talk | contribs) m →External links: categorize |
Hervegirod (talk | contribs) |
||
Line 5:
All platform specific libraries (available from the [[Apple GL|AGL]] API for [[Mac OS X]], [[GLX]] for [[X Window System]], and [[WiggleWin32|WGL]] for [[Microsoft Windows]]) are also abstracted out to create a platform independent way of selecting [[Framebuffer]] attributes and performing platform specific Framebuffer operations.
==Example==
This examples shows how to draw a Polygon (without initialization or repaint code<ref>Borrowed from [http://nehe.gamedev.net/lesson.asp?index=01 Nehe tutorial], which are free to use elsewhere</ref>). Here is the reference [[C (programming language)|C]] implementation :
<pre>
int DrawGLScene(GLvoid) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units
glBegin(GL_TRIANGLES); //Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd();
glTranslatef(3.0f,0.0f,0.0f);
glBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left
glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right
glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd();
return TRUE;
}
Which translates to the following [[Java (programming language)|Java]] implementation :
<pre>
public void display(GLAutoDrawable gLDrawable) {
final GL gl = gLDrawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
gl.glTranslatef(-1.5f, 0.0f, -6.0f);
gl.glBegin(GL.GL_TRIANGLES); // Drawing Using Triangles
gl.glVertex3f(0.0f, 1.0f, 0.0f); // Top
gl.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
gl.glVertex3f(1.0f, -1.0f, 0.0f); // Bottom Right
gl.glEnd();
gl.glTranslatef(3.0f, 0.0f, 0.0f);
gl.glBegin(GL.GL_QUADS); // Draw A Quad
gl.glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left
gl.glVertex3f(1.0f, 1.0f, 0.0f); // Top Right
gl.glVertex3f(1.0f, -1.0f, 0.0f); // Bottom Right
gl.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
gl.glEnd();
gl.glFlush();
}
</pre>
== Implementations ==
|