source:
orxonox.OLD/orxonox/branches/importer/src/array.cc
@
2808
Last change on this file since 2808 was 2795, checked in by bensch, 20 years ago | |
---|---|
File size: 1.1 KB |
Rev | Line | |
---|---|---|
[2754] | 1 | #include "array.h" |
2 | ||
3 | Array::Array () | |
4 | { | |
5 | createArray (2000); | |
6 | } | |
[2758] | 7 | Array::Array (unsigned int arraySize) |
[2754] | 8 | { |
9 | createArray (arraySize); | |
10 | } | |
11 | ||
[2758] | 12 | void Array::createArray (unsigned int newArraySize) |
[2754] | 13 | { |
14 | array = new GLfloat [newArraySize]; | |
15 | entryCount = -1; //0 means one entry | |
16 | arraySize = newArraySize; | |
17 | return; | |
18 | } | |
19 | ||
[2758] | 20 | void Array::resizeArray (unsigned int newSize) |
[2754] | 21 | { |
[2758] | 22 | GLfloat* newArray = new GLfloat [newSize]; |
[2754] | 23 | |
24 | for (int i=0; i<=entryCount; i++) | |
25 | newArray[i] = array[i]; | |
26 | ||
[2758] | 27 | delete [] array; |
[2754] | 28 | array = newArray; |
[2758] | 29 | arraySize = newSize; |
[2754] | 30 | |
31 | return; | |
32 | } | |
33 | ||
34 | void Array::finalizeArray (void) | |
35 | { | |
[2758] | 36 | resizeArray (entryCount+1); |
[2754] | 37 | return; |
38 | } | |
39 | ||
40 | ||
41 | void Array::addEntry (GLfloat entry) | |
42 | { | |
43 | entryCount++; | |
44 | ||
[2758] | 45 | if (entryCount > arraySize) |
[2754] | 46 | resizeArray(arraySize+2000); |
47 | ||
48 | array[entryCount] = entry; | |
49 | ||
50 | } | |
51 | ||
52 | void Array::addEntry (GLfloat entry0, GLfloat entry1, GLfloat entry2) | |
53 | { | |
54 | addEntry (entry0); | |
55 | addEntry (entry1); | |
56 | addEntry (entry2); | |
57 | } | |
58 | ||
59 | ||
60 | GLfloat* Array::getArray () | |
61 | { | |
62 | return array; | |
63 | } | |
[2758] | 64 | |
[2760] | 65 | int Array::getCount() |
66 | { | |
67 | return entryCount; | |
68 | } | |
[2758] | 69 | |
70 | ||
[2760] | 71 | |
[2758] | 72 | void Array::debug () |
73 | { | |
74 | printf ("arraySize=%i, entryCount=%i, address=%p\n", arraySize, entryCount, array); | |
75 | } |
Note: See TracBrowser
for help on using the repository browser.