You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
891 B
36 lines
891 B
#pragma once
|
|
#include <cstring>
|
|
#include "CArrayBuffer.h"
|
|
|
|
typedef unsigned short uint16;
|
|
typedef float float32;
|
|
|
|
class CDataView {
|
|
public:
|
|
CArrayBuffer* buffer;
|
|
|
|
int byteOffset;
|
|
int byteLength;
|
|
|
|
CDataView(CArrayBuffer* pBuffer, int byteOffset, int byteLength) {
|
|
this->buffer = pBuffer;
|
|
this->byteOffset = byteOffset;
|
|
this->byteLength = byteLength;
|
|
}
|
|
|
|
void setFloat32(int offset, float32 value) {
|
|
memcpy(this->buffer->pData + (this->byteOffset + offset), &value, sizeof(float32));
|
|
}
|
|
|
|
float32 getFloat32(int offset) {
|
|
return *((float32*)(this->buffer->pData + (this->byteOffset + offset)));
|
|
}
|
|
|
|
void setUint16(int offset, uint16 value) {
|
|
memcpy(this->buffer->pData + (this->byteOffset + offset), &value, sizeof(uint16));
|
|
}
|
|
|
|
uint16 getUint16(int offset) {
|
|
return *((uint16*)(this->buffer->pData + (this->byteOffset + offset)));
|
|
}
|
|
};
|