Programming AmigaOS in C

3D Graphics

Up until 1998, the Amiga's graphics was primarily bitmapped two dimensional (2D) graphics where objects could be viewed on a flat surface and they could move up and down or left or right ie x,y. The current chipsets from OCS to AGA could handle them very well. Then in the mid-90s, the 3D graphics cards were coming out to provide the third dimension - depth, so you can go into screen, have perspective, look around objects from the side, top and bottom.
The first new 3D graphics cards were the CyberVision and BlizzardVision which have the Permedia 2 graphics chipset which supports higher resolution retargetable graphics (RTG) and 3D graphics. Since AmigaOS did not have any official 3D graphics functionality, a number of libraries and drivers were produced:

* StormMESA - a Khronos-compliant OpenGL implementation for 3D graphics. See Mesa.
* Warp3D - a closed source API by Haage & Partner for Amiga systems with 68040 or better and 3D card. See Warp3D.
* CyberGL - Phase 5 library for AmigaOS. See Aminet.
* MiniGL - A subset of the standard OpenGL 3D graphics libraries supported, now the standard for AmigaOS. The game Quake was written using MiniGL.

You can find the libraries, drivers and developer tools on Aminet and in the AmigaOS 4 SDK.

* Warp3D-4.2a - Warp3D Libraries and device
* Warp3DDev - Warp 3D Docs, Source and headers
* Wazp3D - A CPU only implementation of Warp3D e.g. Winuae
* MiniGL, MiniGL_data - MiniGL documentation, libraries, headers, source and demos.

* Cow3D - Cow3D source and demo.
* CubeBM - Colorful rotating 3D cube source and demo

a) How to use MiniGL

MiniGL uses the Warp3D libraries and device drivers to work along with the above developer files.
You will need to include the mgl/gl.h header file for accees to MiniGL function prototypes and definitions.

Make sure that Warp3D.Library is opened using the OpenLibrary() function.

Here is some sample code that draws a 3D Box.

static void drawCube(void)
{
 glBegin(GL_QUADS); /* Graphic primitive is a Quadratic or 4 sided cube */
 glColor3f(1.0, 0.0, 0.0); /* Color in RGB is Red */
 glVertex3f(-1,-1,-1); glColor3f(0.5, 0.5, 0.5); /* define vertices of cube */
 glVertex3f(-1,1,-1); glVertex3f(1,1,-1); glVertex3f(1,-1,-1);
 glColor3f(1.0, 0.5, 0.0); /* Orange */
   glVertex3f(-1,1,-1); glColor3f(0.5, 0.5, 0.5); /* Grey color */
   glVertex3f(-1,1,1); glVertex3f(1,1,1); glVertex3f(1,1,-1);
 glColor3f(0.0, 0.0, 1.0); /* Blue */
   glVertex3f(1,1,1); glColor3f(0.5, 0.5, 0.5); /* Grey color */
   glVertex3f(-1,1,1); glVertex3f(-1,-1,1); glVertex3f(1,-1,1);
 glColor3f(0.0, 0.0, 0.0); /* Black */
   glVertex3f(-1,1,1); glColor3f(0.5, 0.5, 0.5); /* Grey color */
   glVertex3f(-1,1,-1); glVertex3f(-1,-1,-1); glVertex3f(-1,-1,1);
 glColor3f(1.0, 1.0, 1.0);  /* White */
   glVertex3f(-1,-1,1); glColor3f(0.5, 0.5, 0.5); /* Grey color */
   glVertex3f(-1,-1,-1);
   glVertex3f(1,-1,-1);
   glVertex3f(1,-1,1);
 glEnd(); /* Finish and render */
}

All operations start with a glBegin() function and end with a glEnd() function.
In glBegin, you specify the type of object to define whether its a point, a line, a triangle, a quadrilateral or polygon shape (see glBegin definition).
The glEnd, completes a object definition or transformation and then then renders the new or updated object.
The glColor3f defines the Red Green and Blue colours of the following vertexes (see glColor definition).
The glVertex3f specifies the x, y, and z co-ordinates of a vertex. (see glVertex definition).

You can also manipulate by 'transforming' a object using commands such as:

glTranslate(Xpos, Ypos, 0.0) - multiply the current matrix by a translation matrix
glRotatef(8.0, 0.0, 0.0, 1.0) - rotate the object by angle, x, y, z values.
glScalef(2.f, 2.f, 2.f) - Scale the object by x,y,z values.
glFrontFace(GL_CCW) - define front and back facing polygons. GL_CCW = counterclockwise polygons, GL_CW = clockwise polygons.
glCullFace(GL_BACK) - defines whether front or back facets can be culled. GL_BACK = back facet, GL_FRONT = front facet.
glShadeModel(GL_FLAT) - defines flat or smooth shading. Values are GL_FLAT or GL_SMOOTH.
glBindTexture(GL_TEXTURE_2D, 1) - binds a named texture to a texturing target.
glTexImage2D(GL_TEXTURE_2D, 0, 3, x,y, 0, GL_RGB, GL_UNSIGNED_BYTE, tmap) - specify a 2D Texture image (see tmap which contains the texture data in PPM format).

and there are many other commands available to draw and manipulate 3D images.
Best way to learn MiniGL and OpenGL is to look at some source code (see above), try to compile and run them and see how they work. Then use the references below to look at the commands.

b) Web Links

Talisman OpenGL 1.0 docs
OpenGL Tutorial (v2 or later)
OpenGL Reference and documentation

c) Books

OpenGL SuperBible by Graham Sellers, Richard Wright and Nicholas Haemel

OpenGL Programming Guide by Dave Shreiner, Graham Sellers, John Kessenich, Bill Licea-Kane

Memory