
I'm having an unusual problem with OpenGL. To be honest I probably shouldn't be using OpenGL for this, as I'm just doing 2D and only drawing Points, but I don't know about any other display packages, so I'm making due. If this is a problem because of OpenGL however, then I'll have to learn another package. The problem is speed. I have a list of points representing the color of 800x600 pixels. All I'm trying to do is display the pixels on the screen. I use the following: renderPrimitive Points $ mapM_ display list flush where display [] = return () display ((x,y,i):n) = do color $ Color3 i i i vertex $ Vertex2 x y display n But, for some reason this takes FOREVER. I don't know how to use debugging hooks yet without an IDE -- and I don't use an IDE -- but I used a cleverly placed putStrLn to see that it was actually working, just really really slowly. Is there a solution to this speed problem or should I use a package that's more suited to 2D applications like this? Also, if I should use another package, are there any suggestions for which to use? Thanks for any help. -Eitan

2010/7/29 Eitan Goldshtrom
I'm having an unusual problem with OpenGL. To be honest I probably shouldn't be using OpenGL for this, as I'm just doing 2D and only drawing Points, but I don't know about any other display packages, so I'm making due. If this is a problem because of OpenGL however, then I'll have to learn another package. The problem is speed. I have a list of points representing the color of 800x600 pixels. All I'm trying to do is display the pixels on the screen. I use the following:
renderPrimitive Points $ mapM_ display list flush where display [] = return () display ((x,y,i):n) = do color $ Color3 i i i vertex $ Vertex2 x y display n
But, for some reason this takes FOREVER. I don't know how to use debugging hooks yet without an IDE -- and I don't use an IDE -- but I used a cleverly placed putStrLn to see that it was actually working, just really really slowly. Is there a solution to this speed problem or should I use a package that's more suited to 2D applications like this? Also, if I should use another package, are there any suggestions for which to use? Thanks for any help.
Hi, Although you can use Vertex* to put a single Point on the screen, it is not meant to be used as some kind of setPixel function. If your goal is simply to set pixels' value of a raster, you can still use OpenGL but should use a single textured quad (and thus manipulate the texture's pixels). There other possibilities to deal with raster graphics: - Use gtk; i.e. something like http://hackage.haskell.org/package/AC-EasyRaster-GTK - Output the data in some image format (if you want to do it yourself, the most simple is PPM) - Use X11 directly (if you're on unix) - ... HTH, Thu

Yeah, using openGL Points to draw 2D images will probably be pretty slow.
However, if you don't need to change your points every frame, a display list
might improve the speed quite a bit (you could still transform the points as
a whole).
Also, you could try the SDL bindings for haskell:
http://hackage.haskell.org/package/SDL
SDL is better suited for 2D drawing (IMHO).
http://www.libsdl.org/
- Job
On Thu, Jul 29, 2010 at 6:51 AM, Vo Minh Thu
I'm having an unusual problem with OpenGL. To be honest I probably shouldn't be using OpenGL for this, as I'm just doing 2D and only drawing Points, but I don't know about any other display packages, so I'm making due. If this is a problem because of OpenGL however, then I'll have to learn another package. The problem is speed. I have a list of points representing the color of 800x600 pixels. All I'm trying to do is display the pixels on
screen. I use the following:
renderPrimitive Points $ mapM_ display list flush where display [] = return () display ((x,y,i):n) = do color $ Color3 i i i vertex $ Vertex2 x y display n
But, for some reason this takes FOREVER. I don't know how to use debugging hooks yet without an IDE -- and I don't use an IDE -- but I used a cleverly placed putStrLn to see that it was actually working, just really really slowly. Is there a solution to this speed problem or should I use a
2010/7/29 Eitan Goldshtrom
: the package that's more suited to 2D applications like this? Also, if I should use another package, are there any suggestions for which to use? Thanks for any help.
Hi,
Although you can use Vertex* to put a single Point on the screen, it is not meant to be used as some kind of setPixel function.
If your goal is simply to set pixels' value of a raster, you can still use OpenGL but should use a single textured quad (and thus manipulate the texture's pixels).
There other possibilities to deal with raster graphics: - Use gtk; i.e. something like http://hackage.haskell.org/package/AC-EasyRaster-GTK - Output the data in some image format (if you want to do it yourself, the most simple is PPM) - Use X11 directly (if you're on unix) - ...
HTH, Thu _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

If you still want to use glVertex with GL_POINTS, instead of a display
list, you'd better go with vertex array or VBO.
But still, if the implicit coordinates of a raster is assumed, pairing
the coordinates with their value is overkill.
Cheers,
Thu
2010/7/29 Job Vranish
Yeah, using openGL Points to draw 2D images will probably be pretty slow. However, if you don't need to change your points every frame, a display list might improve the speed quite a bit (you could still transform the points as a whole).
Also, you could try the SDL bindings for haskell: http://hackage.haskell.org/package/SDL SDL is better suited for 2D drawing (IMHO). http://www.libsdl.org/
- Job
On Thu, Jul 29, 2010 at 6:51 AM, Vo Minh Thu
wrote: 2010/7/29 Eitan Goldshtrom
: I'm having an unusual problem with OpenGL. To be honest I probably shouldn't be using OpenGL for this, as I'm just doing 2D and only drawing Points, but I don't know about any other display packages, so I'm making due. If this is a problem because of OpenGL however, then I'll have to learn another package. The problem is speed. I have a list of points representing the color of 800x600 pixels. All I'm trying to do is display the pixels on the screen. I use the following:
renderPrimitive Points $ mapM_ display list flush where display [] = return () display ((x,y,i):n) = do color $ Color3 i i i vertex $ Vertex2 x y display n
But, for some reason this takes FOREVER. I don't know how to use debugging hooks yet without an IDE -- and I don't use an IDE -- but I used a cleverly placed putStrLn to see that it was actually working, just really really slowly. Is there a solution to this speed problem or should I use a package that's more suited to 2D applications like this? Also, if I should use another package, are there any suggestions for which to use? Thanks for any help.
Hi,
Although you can use Vertex* to put a single Point on the screen, it is not meant to be used as some kind of setPixel function.
If your goal is simply to set pixels' value of a raster, you can still use OpenGL but should use a single textured quad (and thus manipulate the texture's pixels).
There other possibilities to deal with raster graphics: - Use gtk; i.e. something like http://hackage.haskell.org/package/AC-EasyRaster-GTK - Output the data in some image format (if you want to do it yourself, the most simple is PPM) - Use X11 directly (if you're on unix) - ...
HTH, Thu _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Vo Minh Thu schrieb:
There other possibilities to deal with raster graphics: - Use gtk; i.e. something like http://hackage.haskell.org/package/AC-EasyRaster-GTK - Output the data in some image format (if you want to do it yourself, the most simple is PPM) - Use X11 directly (if you're on unix) - ...
or good old HGL: http://hackage.haskell.org/package/HGL

HGL actually looks like EXACTLY what I need. I only need to set pixels, which looks like just what HGL would be good at. Only problem is that I can't find a single tutorial for HGL. Does anyone know or any, or where I could find one? -Eitan On 7/30/2010 12:22 PM, Henning Thielemann wrote:
Vo Minh Thu schrieb:
There other possibilities to deal with raster graphics: - Use gtk; i.e. something like http://hackage.haskell.org/package/AC-EasyRaster-GTK - Output the data in some image format (if you want to do it yourself, the most simple is PPM) - Use X11 directly (if you're on unix) - ...
or good old HGL: http://hackage.haskell.org/package/HGL

On Fri, 30 Jul 2010, Eitan Goldshtrom wrote:
HGL actually looks like EXACTLY what I need. I only need to set pixels, which looks like just what HGL would be good at. Only problem is that I can't find a single tutorial for HGL. Does anyone know or any, or where I could find one?
I found the Haddock documentation enough for what I tried. Maybe my example can help you: http://hackage.haskell.org/package/hgl-example

Yep, no surprise there. I would suggest using bitmap[1] to construct
your bitmap, and bitmap-opengl to put it into an OpenGL texture and
draw it on a textured quad. I think OpenGL is actually an OK choice
for this application, because it is the most portable graphics method
we have available.
If you are trying to redraw in realtime, eg. 30 FPS or so, I don't
think you're going to be able to. There is just not enough GPU
bandwidth (and probably not enough CPU) for that (unless you write it
in a pixel shader, which IIRC haskell has some neat tools for, but I
don't remember). If this is the case, see if you can boil down what
you have into something that doesn't require so much data, e.g.
polygons.
[1] http://hackage.haskell.org/package/bitmap
[2] http://hackage.haskell.org/package/bitmap-opengl
On Thu, Jul 29, 2010 at 3:57 AM, Eitan Goldshtrom
I'm having an unusual problem with OpenGL. To be honest I probably shouldn't be using OpenGL for this, as I'm just doing 2D and only drawing Points, but I don't know about any other display packages, so I'm making due. If this is a problem because of OpenGL however, then I'll have to learn another package. The problem is speed. I have a list of points representing the color of 800x600 pixels. All I'm trying to do is display the pixels on the screen. I use the following:
renderPrimitive Points $ mapM_ display list flush where display [] = return () display ((x,y,i):n) = do color $ Color3 i i i vertex $ Vertex2 x y display n
But, for some reason this takes FOREVER. I don't know how to use debugging hooks yet without an IDE -- and I don't use an IDE -- but I used a cleverly placed putStrLn to see that it was actually working, just really really slowly. Is there a solution to this speed problem or should I use a package that's more suited to 2D applications like this? Also, if I should use another package, are there any suggestions for which to use? Thanks for any help.
-Eitan
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 2010-07-29 11:30 -0600, Luke Palmer wrote:
If you are trying to redraw in realtime, eg. 30 FPS or so, I don't think you're going to be able to. There is just not enough GPU bandwidth (and probably not enough CPU).
Updating an 800x600 texture at 30fps on a somewhat modern system is absolutely *not* a problem. -- Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)

On 07/30/10 03:37, Nick Bowler wrote:
On 2010-07-29 11:30 -0600, Luke Palmer wrote:
If you are trying to redraw in realtime, eg. 30 FPS or so, I don't think you're going to be able to. There is just not enough GPU bandwidth (and probably not enough CPU).
Updating an 800x600 texture at 30fps on a somewhat modern system is absolutely *not* a problem.
It depends. Updating 800x600 screen at 24-bit color 30 times per second requires 800*600*24*30 = 345600000 bytes/s = 329 MB/s which is larger than the size of typical Video Memory, and the first version of PCI Express (introduced 2003) is only 250 MB/s/lane. While the bandwidth and Video Memory size is sufficient to transfer 329MB/s, it is quite near to the limit, especially if you have another programs running, which may cause some resource contention or if you used some memory-heavy techniques like double buffering. You're probably quite safe if you have PCI Express version 2, have over 1GB RAM, and a good Video Card. You're probably quite screwed if your VGA uses a Shared Memory Architecture (i.e. it uses RAM for video memory, this easily causes resource contention).

On a modern PC, this is no problem at all.
We are actually doing this with a 1920 x 1080 x 32-bit bitmap, at 60 FPS, on
a 2-year old PC
You can easily test your GPU <-> CPU bandwidth using this tool:
http://sourceforge.net/projects/gpubench
On Fri, Sep 17, 2010 at 7:53 PM, Lie Ryan
On 07/30/10 03:37, Nick Bowler wrote:
On 2010-07-29 11:30 -0600, Luke Palmer wrote:
If you are trying to redraw in realtime, eg. 30 FPS or so, I don't think you're going to be able to. There is just not enough GPU bandwidth (and probably not enough CPU).
Updating an 800x600 texture at 30fps on a somewhat modern system is absolutely *not* a problem.
It depends. Updating 800x600 screen at 24-bit color 30 times per second requires 800*600*24*30 = 345600000 bytes/s = 329 MB/s which is larger than the size of typical Video Memory, and the first version of PCI Express (introduced 2003) is only 250 MB/s/lane.
While the bandwidth and Video Memory size is sufficient to transfer 329MB/s, it is quite near to the limit, especially if you have another programs running, which may cause some resource contention or if you used some memory-heavy techniques like double buffering.
You're probably quite safe if you have PCI Express version 2, have over 1GB RAM, and a good Video Card. You're probably quite screwed if your VGA uses a Shared Memory Architecture (i.e. it uses RAM for video memory, this easily causes resource contention).
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Fri, Sep 17, 2010 at 7:53 PM, Lie Ryan
It depends. Updating 800x600 screen at 24-bit color 30 times per second requires 800*600*24*30 = 345600000 bytes/s = 329 MB/s which is larger than the size of typical Video Memory, and the first version of PCI Express (introduced 2003) is only 250 MB/s/lane.
Hold on, don't GPUs typically use 16 lanes? -- Svein Ove Aas

On 09/18/10 07:49, Mats Klingberg wrote:
On Friday September 17 2010 19.53.01, Lie Ryan wrote:
It depends. Updating 800x600 screen at 24-bit color 30 times per second requires 800*600*24*30 = 345600000 bytes/s = 329 MB/s which is larger
Shouldn't that be bits/s, or 800*600*3*30 = 41 MB/s?
yep, blame that on lack of sleep, I guess... (that's why those numbers feels a bit too fishy when I calculated them)

On 2010-09-18 13:57 +1000, Lie Ryan wrote:
On 09/18/10 07:49, Mats Klingberg wrote:
On Friday September 17 2010 19.53.01, Lie Ryan wrote:
It depends. Updating 800x600 screen at 24-bit color 30 times per second requires 800*600*24*30 = 345600000 bytes/s = 329 MB/s which is larger
Shouldn't that be bits/s, or 800*600*3*30 = 41 MB/s?
yep, blame that on lack of sleep, I guess...
Nevertheless, 4x AGP (circa 2000) can easily sustain the significantly exaggerated rate of 329 MB/s. -- Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)
participants (11)
-
Eitan Goldshtrom
-
Henning Thielemann
-
Henning Thielemann
-
Job Vranish
-
Lie Ryan
-
Luke Palmer
-
Mats Klingberg
-
Nick Bowler
-
Peter Verswyvelen
-
Svein Ove Aas
-
Vo Minh Thu