the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "FloatBuffer.h"
3
4//Allocates a new float buffer.
5//The new buffer's position will be zero, its limit will be its capacity, and its mark will be undefined.
6//It will have a backing array, and its array offset will be zero.
7//
8//Parameters:
9//capacity - The new buffer's capacity, in floats
10FloatBuffer::FloatBuffer(unsigned int capacity) : Buffer( capacity )
11{
12 buffer = new float[capacity];
13 memset( buffer,0,sizeof(float)*capacity);
14}
15
16FloatBuffer::FloatBuffer( unsigned int capacity, float *backingArray ) : Buffer( capacity )
17{
18 hasBackingArray = true;
19 buffer = backingArray;
20}
21
22FloatBuffer::~FloatBuffer()
23{
24 if( !hasBackingArray )
25 delete[] buffer;
26}
27
28//Flips this buffer. The limit is set to the current position and then the position is set to zero.
29//If the mark is defined then it is discarded.
30//
31//Returns:
32//This buffer
33FloatBuffer *FloatBuffer::flip()
34{
35 m_limit = m_position;
36 m_position = 0;
37 return this;
38}
39
40//Relative put method (optional operation).
41//Writes the given float into this buffer at the current position, and then increments the position.
42//
43//Parameters:
44//f - The float to be written
45//Returns:
46//This buffer
47FloatBuffer *FloatBuffer::put(float f)
48{
49 buffer[m_position++] = f;
50 return this;
51}
52
53//Relative bulk get method.
54//This method transfers floats from this buffer into the given destination array.
55//An invocation of this method of the form src.get(a) behaves in exactly the same way as the invocation
56//
57// src.get(a, 0, a.length)
58//Returns:
59//This buffer
60void FloatBuffer::get(floatArray *dst)
61{
62 assert( dst->length <= m_capacity );
63
64 for (unsigned int i = 0; i < dst->length; i++)
65 dst->data[i] = buffer[i];
66}