View Full Version : Waterfall Display
11-19-2008, 05:53 PM
Sorry I needed help in figuring out how to create a "waterfall display". It basically takes in a 2 dimensional array of 8bit pixels and displays it streaming down the screen. This data is just 8bit pixels and keeps streaming down my display (1600x1200).
I've implemented this using QT but it the PaintEvent() which gets called to refresh the image each time is too slow in scrolling the data down the screen.
I was wondering would the best solution be to generate a texture out of the 8bit pixels using opengl? Also, would I need to generate multiple textures of each line of data that comes in?
Or can somebody please help me figure out what's the best solution?
11-20-2008, 12:03 AM
You mean currently, you use glDrawPixels ? This is not really fast indeed.
Not sure if using 1200 1D textures would be efficient.
To me the best would be to split background in textured quads (for example size 256*256), reusing the 8*6 different textures : as soon as block is falls out of the view, glTexSubImage it with the next upper block.
Ideally you should implement both ways and benchmark to find the best.
About the repaint, I don't know Qt enough, is there something like the GLUT Idle Callback, to repaint screen continuously ?
11-20-2008, 03:27 AM
I'd use a single rectangular texture that is exactly as big as the screen.
Each time you just update texture coordinates to scroll the image and update one or more rows (that got wrapped around in current frame) with new data using single glTexSubImage2D call.
11-20-2008, 06:10 AM
a waterfall could be just a plane rendered with 2 triangles where seamless texture is applied to move the water in v direction with a texture matrix or shader. i believe this would not look cutting edge style.
11-20-2008, 06:28 AM
Well, he asked about "waterfall display" not "waterfall" :)
Waterfall display is simply put a window that scrolls vertically above continous image (a stream of data).
11-20-2008, 07:42 AM
ups. understand now. thanks for correction k_szczech. something new every day.
11-20-2008, 10:08 AM
Wow thanks guys for responding so quickly!
k_szczech, that's what I was originally thinking about doing. I just wanted to make sure that this is the correct approach in opengl and that it's possible (b/c I'm completely new to opengl).
ZbufferR, your approach is basically the same except I'm using blocks of textures right? (I don't really understand your comment about reusing the 8*6 different textures). Anyways, using this method, wouldn't I need to wait for (i.e.256) lines of data to come in before I can update the display?
Thanks again for your replies. Now I just need to figure out how to create texture from the char buffer where the 8bit pixels are coming in.
11-20-2008, 10:24 AM
indeed, k_szczech wrote the best solution :)
02-08-2009, 05:24 PM
I'm trying to do the same thing but I'm not clear about the suggested approach from k_szczech.
Currently I am able to fill in the next row of data from my texture as new updates come in but I'm not actually scrolling the old data down the screen. Changing the texture coordinates doesn't really make sense to me.
Can someone give a little more of a concrete example?
to get your waterfall looking much nicer an easy method
is to have 2 textures drawn blended over each other
have them scroll down in the water direction but also have one slowly scroll left + the other slowly scrolling right.
02-09-2009, 05:02 AM
I believe you're thinking of an actual waterfall visual. I'm talking about getting a new set of pixels every second, moving the existing texture down by 1 pixel, and putting the new pixels at the newly vacated spot at the top of the texture. Or another approach like the one that was discusses above but I don't understand.
02-09-2009, 11:01 PM
Can any one help me out the same by any set of examples(code)..
I have to refresh the display at the milli second level..
i.e my data comes at the rate of 1 milli sec and i have to present it on the WaterFall Display ..
02-11-2009, 01:02 AM
@NaveenKumarPuli: the solution (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=249089#Post249089)
02-11-2009, 07:09 PM
You cannot update at 1ms, you are limited by the display rate.
You have not explained what you want to draw.
02-12-2009, 05:39 AM
Thank you for the Response. But i have said earlier that i am new to OpenGl.. But still i tried to read out the solution which i did not understand. Can you suggest me with some examples code.
02-12-2009, 05:43 AM
Detail Description of my kind of work.
Operating System: Windows-XP. Language: C++. IDE=Visual Studio-2005(VC++), Using both wxWidgets 2.8.9 and OpenGl.
Data Recvied: Data is received from network at the rate of 1ms.Data size if of 1600.. Which i have to display each pixel as one data and color it accoring to value in it.
Display : I have to display the data in WaterFall Display Model.
WaterFall Display: If (0,0) is taken as on top left corner of the screen, First data will be displayed on the 0 row.
When Second data comes, it should be displayed on the Zero row and the previous data should be displayed in the 1st row. In this way, as the data comes I have display it on the top and the previous ones should be slided down.
So, This data should be shown in a scrollable manner and upto 3000 inputs and then scrolling down.
Till now i Have developed a screen by using wxFrame(1280x1024). On that a wxPanel(1000x700) is taken and then wxGLCanvas(1000,700). and But from here i am not able to proceed.
Need of great help
02-16-2009, 05:43 PM
Can any one suggest me some ideas of displaying the data in the WaterFall Display.....
02-17-2009, 01:18 AM
02-18-2009, 04:37 PM
Hi Cranson, Did you get the scrolling of old data down the screen?
if yes can you help me out to do so...
02-18-2009, 05:38 PM
Can you send me the an concrete example for this WaterFall..
02-18-2009, 05:40 PM
How bout a little background on this waterfall thingamajig, preferably something in PDF format with lots of pictures if it's not too much trouble.
I still can't get my head around it..
P.S. No need to jack this thread with your own over here
Oops, that thread isn't yours either. Sorry.
Consider creating your own thread so we can get to the bottom of this thing ;-)
02-18-2009, 06:48 PM
Link below is my thread..
02-21-2009, 05:18 AM
As suggested by you , i have created rectangular screen texture,but unable to scroll down...
can you pls suggest me some more
Thanks for the Response
02-21-2009, 06:36 AM
scroll with texture coordinates.
assume some variables, in float (not int, otherwise division will be very wrong) :
TOTAL_MILLISECONDS (total time elapsed, updated every frame)
glTexCoord2f(0,0); becomes :
glTexCoord2f(0,1); becomes :
by the way, if you use one of the TEXTURE_RECTANGLE extensions, you don't need the TEXTURE_HEIGHT divide.
02-21-2009, 08:02 PM
Thank you for your response..
I will try this ...
02-22-2009, 03:16 AM
As you have suggested i have done some experiment using glut.
but i am not able to create it using wxGlCanvas.
Can we create textures on a Canvas which is inherited by wxGlCanvas.
02-22-2009, 11:51 PM
I have done whatever suggested by you but the screen is not updating with the new cordinates.
Here is the code...
Pls verify it and suggest me...
const int IMAGE_WIDTH = 1000;
const int IMAGE_HEIGHT = 1000;
const int CHANNEL_COUNT = 4;
const int DATA_SIZE = IMAGE_WIDTH * IMAGE_HEIGHT * CHANNEL_COUNT;
const GLenum PIXEL_FORMAT = GL_BGRA;
GLuint textureId; // ID of texture
GLubyte* imageData = 0; // pointer to texture buffer
if(fp3 == NULL) wxMessageBox("Unable to open KKK.txt");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, IMAGE_WIDTH, IMAGE_HEIGHT, 0, PIXEL_FORMAT, GL_UNSIGNED_BYTE, (GLvoid*)imageData);
void updatePixels(GLubyte* dst, int size)
static int color = 0;
fprintf(fp3,"IN UpdatePixels \n");
int* ptr = (int*)dst;
// copy 4 bytes at once
for(int i = 0; i < IMAGE_HEIGHT; ++i)
for(int j = 0; j < IMAGE_WIDTH; ++j)
*ptr = color;
color += 257; // add an arbitary number (no meaning)
++color; // scroll down
void WaterFall::OnPaint(wxPaintEvent& event)
// save the initial ModelView matrix before modifying ModelView matrix
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT, PIXEL_FORMAT, GL_UNSIGNED_BYTE, (GLvoid*)imageData);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// draw a point with texture
glColor4f(1, 1, 1,1);
glNormal3f(0, 0, 1);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1, -1, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1, -1, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, x, 0.0f);
glTexCoord2f(0,1); glVertex3f(-1, x, 0.0f);
// unbind texture
//if(TOTAL_MILLISECONDS == 0) TOTAL_MILLISECONDS=1000;
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.