Jump to content
  • Advertisement
Sign in to follow this  

coloring an area made with glDrawPixel

This topic is 3736 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

Hey guys, I've got a PPM data file which i need in - its an image (or an outline image) and I'm wondering how i can fill this? When the PPM is read the canvas draws the weird looking shape - which is correct. I'm just wondering how i can fill it. Cheers. the PPM reader function:
void loadImg(void)
    glRasterPos2f(80.0, 30.0);
    glPixelZoom(1.0, -1.0);
    glDrawPixels(700, 800, GL_RGB, GL_UNSIGNED_BYTE, pixelMap);


Share this post

Link to post
Share on other sites
OpenGl does not offer higher level API such as Fill() etc.. but there are some things you can do here which might work quite well.

Essentially use this as mask on a solid texture - of what ever color you want

Assume the PPM data is an 8-bit (or one channel) mask of size NxN pixels.
Create 4 channel channel texture image using the PPM mask data as the alpha channel. In the RGB channel just write 255 in to each channel. It will be a solid white square (but with a mask)

Enable alpha test
Set alpha func and threshold values
Enable texture 2d

Use gl immediate mode to draw a quad of NxN pixels - with the user specified color

Now due to the alpha test - you should only see the area within the texture (i.e. the filled in area).

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!