PDA

View Full Version : graphical chart drwaing



glcrazy
03-08-2004, 10:32 AM
Hello ,

If I have a 2D - Array image [X][Y] , I wonder if there is in the Opengl any support for drawing a chart or Histogram like this one :

http://www.pqview.com/graphics/ss-histogram.gif

If there is asupport in opengl for histogram drawing where I can find a tutorial or source code help me on that ?

With my thanks in advance

Aeluned
03-08-2004, 02:16 PM
I think you're out of luck for histogram support; there isn't any as far as I know.

Off the top of my head the only thing I could think of is iterating over the image (reading width(x)*height(y) pixels with glReadPixels) and keeping a running sum of each instance of a color.
Then you have your histogram data and it's a matter of drawing a chart at that point.

Good luck.

glcrazy
03-10-2004, 12:40 AM
Thank you Aeluned,

Could pls explain your idea in deatils so I can get easily?

glcrazy
03-11-2004, 01:14 AM
Any Hint ? http://www.opengl.org/discussion_boards/ubb/smile.gif

glcrazy
03-20-2004, 10:44 AM
Is it too easy or too dificult to answer http://www.opengl.org/discussion_boards/ubb/frown.gif

fuxiulian
03-20-2004, 11:25 AM
Hello !

If I understand correctly, you want to draw a histogram that you already have.

OpenGL is not specialized in any way. All that it can do is draw lines, points and polygons with or without textures. It can light, do depth, alpha, stencil test and so on. It does not have functions for displaying buttons, function graphics, windows and the like.

In order to display a plot you should code all that you want to be displayed.

Here are the elements of that plot:

- the 2 axis (draw with glBegin(GL_LINES))
- the text (draw it with wglUseFontOutlines or similar name and with glCallList). You can display rotated text also because you draw text like geometry
- the function (display it as red boxes with glBegin(GL_QUADS));
- the dotted lines (use glLineStipple)


As you can see, there is much to do to draw that function...

I made a function drawing class for myself a while ago since I didn't want to code all that everytime I would have displayed a function.

All the logic behind the function draw, as the scaling and showing important points is up to you to code.

Hope I have helped you.

03-25-2004, 12:04 PM
Hello fuxiulian ,

Thank you Vmuch for your useful help. But the difficult I faced that I didn't know exactly how to start the code . I mean I have the array[x][y] which value goes from 0 .. 255 ( integers) . What will be values of x-axis and what will be the values of Y-axis?. Do I have to draw fixed lines using (GL_LINES)for x,y axises?.

Could you pls post the draw function you wrote as a demo I can followed? .

Thanks in advance.

glcrazy
03-28-2004, 06:51 AM
Done .