Last change
on this file since 2808 was
2795,
checked in by bensch, 20 years ago
|
orxonox/branches/importer: importer includes into the source
|
File size:
1.1 KB
|
Line | |
---|
1 | #include "array.h" |
---|
2 | |
---|
3 | Array::Array () |
---|
4 | { |
---|
5 | createArray (2000); |
---|
6 | } |
---|
7 | Array::Array (unsigned int arraySize) |
---|
8 | { |
---|
9 | createArray (arraySize); |
---|
10 | } |
---|
11 | |
---|
12 | void Array::createArray (unsigned int newArraySize) |
---|
13 | { |
---|
14 | array = new GLfloat [newArraySize]; |
---|
15 | entryCount = -1; //0 means one entry |
---|
16 | arraySize = newArraySize; |
---|
17 | return; |
---|
18 | } |
---|
19 | |
---|
20 | void Array::resizeArray (unsigned int newSize) |
---|
21 | { |
---|
22 | GLfloat* newArray = new GLfloat [newSize]; |
---|
23 | |
---|
24 | for (int i=0; i<=entryCount; i++) |
---|
25 | newArray[i] = array[i]; |
---|
26 | |
---|
27 | delete [] array; |
---|
28 | array = newArray; |
---|
29 | arraySize = newSize; |
---|
30 | |
---|
31 | return; |
---|
32 | } |
---|
33 | |
---|
34 | void Array::finalizeArray (void) |
---|
35 | { |
---|
36 | resizeArray (entryCount+1); |
---|
37 | return; |
---|
38 | } |
---|
39 | |
---|
40 | |
---|
41 | void Array::addEntry (GLfloat entry) |
---|
42 | { |
---|
43 | entryCount++; |
---|
44 | |
---|
45 | if (entryCount > arraySize) |
---|
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 | } |
---|
64 | |
---|
65 | int Array::getCount() |
---|
66 | { |
---|
67 | return entryCount; |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
71 | |
---|
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.