Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

How to decode array of floats from ofBuffer

$
0
0

@SpaceK33z wrote:

I’m using ofxLibwebsockets to receive an array of 32-bit floats as binary (JSON is too slow for my usecase).

From ofxLibwebsockets I get an ofBuffer variable that I have saved as buffer:

char *data = (char *)buffer.getData();

int size = buffer.size() / sizeof(float);

for (int i = 0; i < size; i++) {
    std::cout << data[i] << endl;
}

I would expect this to output each float value from the array, but instead it outputs random values like \312. I’m a complete beginner in C++ but after searching like crazy I still cannot find how to do this. Any pointers (pun intended)?

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles