Jump to content
  • Advertisement
Sign in to follow this  
rrr_r

OpenGL Pixel Alteration Question

This topic is 4107 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I have been scouring the internet for an answer to this question for quite a while, but I have been unsuccessful as of now. I am attempted, with Visual C++ 6.0, to be able to edit individual pixels in a timely manner of an opengl window, or even a standard window. However, the only functions I can find that will do that are SetPixel/SetPixelV and glDrawPixels. The problem is that both are extremely slow. SetPixel is slow since I do not believe that it runs off of the graphics card. glDrawPixels is even slower, because, as I have read, it runs through the entire graphics pipeline before being placed instead of simply directly editing the pixel on screen. Obviously, drawing a pixel on screen is extremely fast, since clearing the entire screen is next to instantaneous. I couldn't find the OpenGL source code, so I have no idea how to draw a single pixel as fast as possible. Does anyone know how to do this? My apologies if this is unclear. Thank you.

Share this post


Link to post
Share on other sites
Advertisement
You may do it in the old fashion way. That is, updating rectangle on demand by using InvalidateRect(). However, it is really a step backward.

Besides, if you are using OpenGL correctly, glDrawPixels() should be still in an acceptable range for manual editing purpose. Have you double check your source code for pitfall?

Share this post


Link to post
Share on other sites
Thanks for the quick answer. However, as I am dealing with many many pixel alterations (800x600 in fact), calling glDrawPixels that many times is slow, as is SetPixel. However, even using glDrawPixels once with an 800 height and 600 width is just as slow. I require the method with which glClearBuffer writes to the framebuffer so quickly. Thanks.

Share this post


Link to post
Share on other sites
I you really need to modify each pixel, you should do that to a buffer, upload it as a texture and draw a quad covering the entire screen.

Share this post


Link to post
Share on other sites
I tried that, but unfortunately that slowed things down about as much, given the fact that I was using a texture of that resolution(800x600). Thanks though.

Is OpenGL open source, and if so, where can I find it?

Share this post


Link to post
Share on other sites
1) Why do you need to draw individual pixels? Any hardware accelerated graphics API is going to be completely usless at drawing pixels.
2) Don't use VC6. Seriously. It's a decade old (That's from the last millenium), is NOT a C++ compiler, jsut a C compiler with classes, it generates substandard code, and in some cases it can actually generate broken code. VC2005 Express is free and can do everything VC6 can do, with a few minor exceptions, and is a far more standards compliant compiler.

Share this post


Link to post
Share on other sites
Quote:
Original post by rrr_r
I tried that, but unfortunately that slowed things down about as much, given the fact that I was using a texture of that resolution(800x600). Thanks though.

Is OpenGL open source, and if so, where can I find it?


It is a specification. The specification is Open.
http://www.opengl.org/documentation/specs/

There is the mesa project www.mesa3d.org which is a software implementation. I don't think it's useful for you.

You need to find out why rendering a quad is slow. Is it your code or GL. Most likely your code or you are misusing GL.

Share this post


Link to post
Share on other sites
Alright, after a little experimentation, I have found that it is not the rendering of a quad that is slow, it is in fact the building of a texture (glTexImage2D) that is 800x600 that is slowing things down so much, since I am having to call it every frame. This is a problem which I doubt I will be able to get around.

I am thinking of finding a 2d software renderer, but unfortunately I can't find any. Mesa3d doesn't seem to have any documentations either. Does anyone know of any 2d software renderers that can do pixel manipulations at a fast speed?

Share this post


Link to post
Share on other sites
Quote:
Original post by rrr_r
Alright, after a little experimentation, I have found that it is not the rendering of a quad that is slow, it is in fact the building of a texture (glTexImage2D) that is 800x600 that is slowing things down so much, since I am having to call it every frame. This is a problem which I doubt I will be able to get around.
glTexImage2D recreates the entire texture. If you just want to update new texel data to an already created texture, use glTexSubImage2D instead.
Quote:
Original post by rrr_r
I am thinking of finding a 2d software renderer, but unfortunately I can't find any. Mesa3d doesn't seem to have any documentations either. Does anyone know of any 2d software renderers that can do pixel manipulations at a fast speed?
OpenGL is not designed for manipulating pixels. If that's what you want to do, I've heard PixelToaster is pretty good, although I've never personally used it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!