openGL right for per-pixel 2D ?

Howdy.

I’m an experienced 3d programmer and now have an idea for a pretty application doing per-pixel calculations in a purely 2D setting.

Stuff similar to music visualizers.

Is openGL a good place to do this ?
(if not, what is?)

Where could i look for windows examples ?

thanks in advance,
orion

Define “a purely 2D setting”.

If this means that you’re not allowed to use any 3D graphics hardware, then OpenGL is not going to be helpful to you.

If it means that you’re not rendering in perspective 3D, then OpenGL can draw orthographics 3D just fine. And if you only use 1 z-value, it’s no different from 2D.

thanks for the reply.

by purely 2D i just mean without any appearance of 3D. using modern graphics hardware is fine.

effectively i just want to set pixels in the frame buffer as fast as possible. how i do that is an open question.

the obvious approach is to draw the pixels to a texture each frame and render that on a screen-aligned quad, but i’m wondering if there’s a faster way if i want one texel to be exactly one pixel.

(i’ll probably go with the texture route anyhow since it can be wrapped on geometry, but i thought openGL might let you just write straight to the frameBuffer)

The best way to do 2D through OpenGL is to do it all through OpenGL. I don’t mean just displaying a finished image. I mean generating that image in OpenGL.

If you’re just wanting to display some image you loaded off of disk, that’s fine. But if you’re doing some 2D rendering (sprite graphics, line drawing, whatever), you should be using OpenGL to do that rendering.

OpenGL doesnt give you direct access to the framebuffer, but the method you describe (updating a texture) is fine.

Depending on your application and your target hardware it might be worth looking into pixel shaders.

If you can write your code to run on the GPU you will see massive speed benefits, but this will also limit your target audience.

Or you could use SDL, which allows exactly the kind of access you’re talking about in a cross-platform compatible kind of way.

http://www.libsdl.org/index.php

Huh - SDL might be the ticket.

I’m a bit aesthetically underwhelmed by some of the demos there, but maybe it’s because i haven’t compiled most them yet.

I might be able to use GPUs to do the actual math via texture look-ups and such, but for starters i’m just going to do the crunch in CPU and dump it to a texture (or the frame buffer, if SDL allows that)

Many thanks all.

orion

Doing a 2d-look is very simple in OpenGL - you just fix your camera above the scene and do your lighting with several tiled textures. I tried it out some time ago - great quality, very simple and lighting fast! As said above, it will limit your target audiency thought…
BTW, already baldurs gate 2 was rendered using OpenGL for images! They rendered textured squads to represent the world and the characters.