blobt
4 years ago
6 changed files with 98 additions and 24 deletions
-
BIN.vs/3dMath/v15/.suo
-
13dMath.vcxproj
-
33dMath.vcxproj.filters
-
46CFloat32Array.h
-
4GMath.cpp
-
68main.cpp
@ -0,0 +1,46 @@ |
|||
#pragma once |
|||
#include <iostream> |
|||
#include "CArrayBuffer.h" |
|||
#include "CDataView.h" |
|||
|
|||
class CFloat32Array { |
|||
public: |
|||
CArrayBuffer* buffer; |
|||
int byteOffset; |
|||
int byteLength; |
|||
|
|||
private: |
|||
int _length; |
|||
bool _deleteBuffer; |
|||
|
|||
public: |
|||
CFloat32Array(int length) { |
|||
this->buffer = new CArrayBuffer(length * sizeof(float32)); |
|||
this->_length = length; |
|||
this->_deleteBuffer = true; |
|||
} |
|||
|
|||
CFloat32Array(CArrayBuffer* buffer, int byteOffset, int length) { |
|||
this->buffer = buffer; |
|||
this->byteOffset = byteOffset; |
|||
this->_length = length; |
|||
this->byteLength = length * sizeof(float32); |
|||
this->_deleteBuffer = false; |
|||
} |
|||
|
|||
~CFloat32Array() { |
|||
if (this->_deleteBuffer) { |
|||
delete this->buffer; |
|||
this->buffer = nullptr; |
|||
printf("delete"); |
|||
} |
|||
} |
|||
|
|||
float32& operator [](int idx) { |
|||
return *((float32*)(this->buffer->pData + (this->byteOffset + idx * sizeof(float32)))); |
|||
} |
|||
|
|||
int length() { |
|||
return this->_length; |
|||
} |
|||
}; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue