View Full Version : How to display pixel-data (fast), comming from serial interface?

03-09-2005, 10:43 AM
I work with Borland C++ Builder and started learning OpenGL basics some weeks ago. I want to read in data via the serial interface of the PC. This can be done with C++. The data contains 200x200 sets of 2 bytes. The first byte encodes the XY-coordinate within the 200x200 matrix. The second one is a datavalue between 0 and 255. My question is now: As you can imagine, the data contains a visual information (picture) I would like to display on the PC. But I miss a step. I read about GLBitmap, but what is the very fastest way to get the data from the serial interface onto the screen? Is there a possibility to avoid saving on the hard disk?

Your help is appreciated a lot!

03-09-2005, 12:47 PM
Why do you want to save to disk if you don't need to ?
Just transform your 'serial' data into a usable format for opengl texture (ie. single big array of continuous rgba pixels), and use glTexImage2D to upload the texture data to opengl video card. Even faster use glTexImage2D only at startup then glTexSubImage2D to update texture.
Then it is only a matter of drawing a textured quad on sreen with texturing enabled.

The first byte encodes the XY-coordinate within the 200x200 matrix. I don't understand this : why is this XY coordinate is needed ? And how a single byte can index 200*200=40000 different coordinates ?

03-10-2005, 10:22 AM
ZBufferR, thanks for your advice, I will study this direction.

To your question: The coordinate of the Pixel is needed, to sort the data in the PC. It is random, how the single spots within the 200x200 matrix comes in. But you are right, to be precise one "position-byte" indexes X-Coordinate and another one indexes Y-Coordinate.

To your description, could you try to explain to a bloody.....Newcomer, how the program flow would look like? The single commands I will study then.

Lets say I have a while(1){
} loop.

In here, I get random XY-coordinates and data-values within the 200x200 matrix. This means within the 200x200 chess board, single fields pop up after each other in another color. Random. Could you try to describe again. In the meantime I will read about the gl-instructions you metioned.

Best regards,

03-10-2005, 03:28 PM
Why not creating a class and put the data in a vector, for the structure and then as the data comes in:

vector<DataClass> theData;
theData.push_back(new DataClass(x, y, value));

//then in your display callback
for (int i = 0; i < theData.size(); i++) {