Writing a minimal application using Mimas

This example will show you, how quickly you can get started with Mimas.

Create minimal make-file

Create a file called Makefile with the following content:
.SUFFIXES:
.SUFFIXES: .cc .h .o

MIMAS=/usr/local
LIBTOOL=libtool
CXX=g++

MINIMALOBJECTS = minimal.o

# CXXOPTS = -Wall -g
CXXOPTS = -Wall -O6 -DNDEBUG

all: minimal

minimal: $(MINIMALOBJECTS)
	$(LIBTOOL) --mode=link g++ -o $@ $(MINIMALOBJECTS) $(MIMAS)/lib/libmimas.la

clean:
	rm -Rf *~ *.o minimal .libs .deps

DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)

.cc.o:
	$(CXX) -Wp,-MD,.deps/$(*F).pp -c $< -o $@ $(CXXOPTS) -I$(MIMAS)/include
	@-cp .deps/$(*F).pp .deps/$(*F).P; \
	tr ' ' '\012' < .deps/$(*F).pp \
	  | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
	    >> .deps/$(*F).P; \
	rm .deps/$(*F).pp

-include $(wildcard .deps/*.P) :-)
    

Note, that you need to use tabulators for intendation! You also may have to change the values for QTDIR and MIMAS depending on your installation.

Create minimal C++ program

Then create a file called minimal.cc with the following content:
#include <fstream>
#include <GL/glut.h>
#include <mimas/image.h>
#include <mimas/image_fileinput.h>
#include <mimas/image_mesaoutput.h>
#include <mimas/rgba.h>

using namespace mimas;
using namespace std;

int main( int argc, char *argv[] )
{
  int retval = 0;
  
  try {
    
    // Initialise GLUT.
    glutInit( &argc, argv );

    // Throw exception, if argc is not equal to 2.
    MMERROR( argc == 2, mimasexception, ,
             "Syntax: " << argv[0] << " <image-file>" );

    // Load image.
    image< rgba< unsigned char > > img;
    ifstream f( argv[1], ios::binary );
    MMERROR( f >> img, mimasexception, ,
             "Error reading file \"" << argv[1] << "\"." );

    // Access display and open a window.
    x11_display displ;
    image_mesaoutput< rgba< unsigned char > > win( &displ );

    // Display the image and wait for three seconds.
    win << img << mimas::wait( 3000 );
    
  } catch ( exception &e ) {

    // Display error message and set return value.
    cerr << e.what() << endl;
    retval = 1;
    
  };

  return retval;
}

Build the minimal program

Just type
    $ make
    

If everything went well, then you should have a program, which can open and display single images.

See also:
mimas::image_fileinput

mimas::image_mesaoutput


[GNU/Linux] [Qt] [Mesa] [STL] [Lapack] [Boost] [Magick++] [Xalan-C and Xerces-C] [doxygen] [graphviz] [FFTW] [popt] [xine] [Gnuplot] [gnu-arch] [gcc] [gstreamer] [autoconf/automake/make] [freshmeat.net] [opensource.org] [sourceforge.net] [MMVL]
mimas 2.1 - Copyright Mon Oct 30 11:31:17 2006, Bala Amavasai, Stuart Meikle, Arul Selvan, Fabio Caparrelli, Jan Wedekind, Manuel Boissenin, ...