/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Benjamin Grauer co-programmer: ... */ #include "array.h" Array::Array () { createArray (); } void Array::createArray () { if (verbose >= 2) printf ("crating new Array\n"); firstEntry = new Entry; firstEntry->next =NULL; currentEntry=firstEntry; finalized = false; entryCount = 0; //0 means one entry return; } void Array::finalizeArray (void) { if (verbose >= 3) printf ("Finalizing array.\n"); if ((array = (GLfloat*)malloc( entryCount* sizeof(GLfloat))) == NULL) printf ("could not allocate %i data Blocks\n", entryCount); Entry* walker = firstEntry; for (int i=0; ivalue; walker = walker->next; } finalized = true; return; } void Array::addEntry (GLfloat entry) { if (!finalized) { if (verbose >= 3) printf ("adding new Entry to Array: %f\n", entry); entryCount++; currentEntry->value = entry; currentEntry->next = new Entry; currentEntry = currentEntry->next; currentEntry->next = NULL; } else if (verbose >= 1) printf ("adding failed, because list has been finalized\n"); } void Array::addEntry (GLfloat entry0, GLfloat entry1, GLfloat entry2) { addEntry (entry0); addEntry (entry1); addEntry (entry2); } GLfloat* Array::getArray () { return array; } int Array::getCount() { return entryCount; } void Array::debug () { printf ("entryCount=%i, address=%p\n", entryCount, array); }