IyonixMesa

IyonixMesa is a port of Rudolf Cornelissen's 3D accelerant for BeOS, and Mesa 3.2. It includes the following:

  • Port of BeOS 2D accelerant 0.43 for nVidia graphics accelerators
  • Port of BeOs 3D accelerant alpha 1f for nVidia graphics accelerators
  • Port of Mesa 3.2

It allows you to build many OpenGL programs and run them using the hardware graphics accelerator provided with every Iyonix computer. The driver will work with the GeForce 2 MX cards supplied with the Iyonix, and also most current PCI GeForce cards, provided a suitable nvidia module from Castle is used. OpenGL is a standard for 3D graphics, whether hardware accelerated or not. Many current games use OpenGL for the rendering.

In addition, functions are available for accelerating certain 2D operations, such as rectangle copying and sprite plotting. An API for these operations will be provided soon. Also, a module allowing 3D to be used in BASIC may be created in the future. Also, a fixed point version of Mesa (similar to OpenGL ES) is on the cards.

How Much?

It's free! I don't intend to charge for any of my RISC OS software. However, if you'd like to make a donation, I will put the money towards buying a faster 3D accelerator (these cost from $50 to $200) and also into buying a HDTV card with integrated MPEG decoder, so that I can make future RISC OS developments. I am also the author of PCITV, and I have mentioned writing a driver for hardware MPEG decoder boards before.

Download (RISC OS 5.10 only)

Due to a change in the nvidia module in RISC OS 5.10, old versions of IyonixMesa will continue to run but will cause a hang when exited. If there is sufficient demand, I will add a detection routine to check the version of the operating system and run the appropriate setup function.

IyonixMesa 2.96MB 1.02 (based on BeOS alpha 1f) 22nd September 2005 Required for building Mesa applications (includes source code and libraries). For usage instructions, read the rest of this page.

This version requires RISC OS 5.10.

Earth 1.77MB 1.03 22nd September 2005 Spinning earth demo for RISC OS 5.10. Includes moon texture for those interested in recompiling the program. Demonstrates powerful fillrate - the moon texture is nearly eight times larger (1440x720) and yet the framerate is unaffected. Yes, I realise we can only actually see one side of the moon at a time. ;o) I've fixed the lighting in this version.

Download (RISC OS 5.09 and earlier)

IyonixMesa 2.80MB 1.01 (based on BeOS alpha 1f) 7th September 2005

This version is for RISC OS 5.09 and earlier.

Earth 1.77MB 1.02 7th September 2005 Spinning earth demo for RISC OS 5.09 and earlier.

Issues

The following are a list of issues with IyonixMesa:

  • Triangle rate is not particularly good right now due to some areas of the graphics pipeline (such as transformation) being done in software.
  • You must be sure to break out of the IyonixMesa code at a good point (i.e. not in the middle of rendering) to avoid a crash.
  • Mip-mapping must be used to draw textures in many cases, otherwise textures can become distorted as they come close to the near clipping plane. Using mip-maps usually speeds up the rendering of textures (the trade-off being greater memory usage), so they should be used anyway.
  • Windowing support is not currently implemented. It will be in a future version.
  • Double-buffering currently uses an accelerated routine to copy from the back buffer to the front. A future version will use true buffer swapping.

Thanks

In no particular order, thanks to:

  • Rudolf Cornelissen for kind access to his accelerant source code.
  • David Boddie for his excellent Mesa 3.4.2 for RISC OS port, and source code.
  • People on #netsurf for their testing and tips, and for being there in the early hours.
  • John Ballance for his comments and assistance.
  • The other kind folks who all tested my code, and were fascinated by the spinning cubes!

IyonixMesa API

This API is subject to change once I get windowing support completed. For now, the API provides function to initialise and close down the IyonixMesa context, and to swap buffers.

IyonixMesaInitialise

void IyonixMesaInitialise(void)

Initialises the IyonixMesa context and associated buffers. This must be called before any Mesa functions are called as this will set up the environment for Mesa within RISC OS. IyonixMesa will auto-detect the current screen mode (and will bail if anything other than 32bpp is used), but you must obtain the width and height yourself in your program to correctly set up the viewport and projections. IyonixMesa will run full screen in any mode you throw at it, as long as it is 32bpp. In larger modes, the fill rate will suffer. The fill rate is the rate at which triangles are rasterised to the back buffer.

The following steps are performed, in order:

  1. The IyonixMesa context is allocated
  2. The Mesa buffers are allocated
  3. A handle to an nVidia graphics card is obtained
  4. The locations of nVidia registers and the front buffer are determined
  5. The nVidia 2D and 3D acceleration engines are initialised
  6. Texture memory blocks are allocated
  7. Pointers to the nVidia device driver are set up for Mesa's use
  8. The viewport is set to fill the screen

IyonixMesaSwapBuffers

void IyonixMesaSwapBuffers(void)

Copies the back buffer to the front buffer using an accelerated BLT. In future versions, true buffer swapping will be performed; a call to IyonixMesaSwapBuffers() will point the screen to the location of the newly rendered buffer, and the front buffer will become the new back buffer.

IyonixMesaCloseDown

void IyonixMesaCloseDown(void)

Must be called when an application has finished using Mesa. Once called, no more Mesa functions may be called. This function frees all memory used by Mesa.

Building and Linking

IyonixMesa is supplied with pre-built 32 bit libraries which are linked with the RISC OS standard C library (-mlibscl). Compile your OpenGL project using the headers in the include directory (add this directory to your include path with -I followed by the include path) and link with the libraries. There is no Mesa module; applications are standalone.

Compile:

gcc -c myApp.c -I../include -mlibscl

Link:

gcc -o !RunImage myApp.o myOtherFile.o ^.lib.libGL ^.lib.libAux ^.lib.libGlu -mlibscl

Of course, you may just need to link to libGL and not the other two. I cannot get the link command to use the standard Unix format. If anyone can improve the makefiles, please let me know!

Here's a suitable makefile (one is included in the distribution):

# Iyonix Mesa application build file

CC = gcc -c -O3 -I../include -mlibscl
LINK = gcc -o

OBJECTS = cubes.o
LIBS = ^.lib.libGL ^.lib.libAux ^.lib.libGlu

#----------------------------------------------------------------------

# Rules

!RunImage : $(OBJECTS)
	$(LINK) $@ $(OBJECTS) $(LIBS) -mlibscl

%.o : %.c
	$(CC) $<

Skeleton Application

A full-screen Mesa application would normally first change to a suitable screen mode, then initialise Mesa, then switch off the cursor and mouse pointer, before performing rendering. Here is a skeleton application:

void getScreenDimensions(int *w, int *h);
void reshape(int w, int h);

int main()
{
   int *mode_block;
   int w, h;
   
   getScreenDimensions(&w, &h);
   
   IyonixMesaInitialise();

   /* Turn off cursors */
   _kernel_swi(OS_RemoveCursors, &r, &r);
   
   /* Set up projection matrix and viewport */
   reshape(w, h);
   
   while(rendering)
   {
      /* Render here */
      IyonixMesaSwapBuffers();
   }

   IyonixMesaCloseDown();

   return 0;
}

void getScreenDimensions(int *w, int *h)
{
   /* Get screen dimensions */
   r.r[0] = 1;
   _kernel_swi(OS_ScreenMode, &r, &r);
   mode_block = (int *)r.r[1];
   if(mode_block[3] != 5)
   {
      printf("Only 32bpp modes supported at the moment, sorry\n");
      exit(1);
   }
   *w = mode_block[1];
   *h = mode_block[2];
}

void reshape(int w, int h)
{
   /* Set up projection matrix and viewport */
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   
   glViewport(0, 0, w, h);
   
   gluPerspective(60, (float)w / (float)h, 1, 100);
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
   
   /* First three coords are the eye's position.
    * Next three are the coords of the object being looked at.
    * Last three are the up vector.
    */
   gluLookAt(0.0f, 0.0f, 15.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
}
22nd September 2005: Updated IyonixMesa so that applications use same NVidia configuration as RISC OS 5.10's nvidia module.

7th September 2005: Fixed red/blue byte ordering, so colours work correctly.

3rd September 2005: Added spinning earth demo.

1st September 2005: Added first downloadable version of Mesa 3.2 and 3D accelerant for RISC OS.