Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Simple 2D Paint

  1. #1
    Newbie Newbie
    Join Date
    Sep 2017

    Simple 2D Paint

    I'm trying to generate a texture from a fragment shader to be used as a brush in a simple 2D paint program. I'm having a little trouble wrapping my head around creating a texture and applying it to a quad for later use. Has anyone tried anything similar? I'm using freeglut. If anyone can point me in the right direction that would be awesome.


  2. #2
    Member Regular Contributor
    Join Date
    Jul 2012
    I never did that. But if you need to generate a texture dynamically, I would draw it into an FBO with a 2D texture attached to it. If the brush needs not to be generated dynamically (ie if only color, intensity or size would change in the paint program), then I would simply use a program like Gimp to create the image of the brush.

    Then I will use the texture generated from the FBO (or from the external tool) to draw it on screen. With the fragment shader, it will be easy to change the colors, or its intensity. From the main program, you'll be able to change the size.

    To draw in a texture with FBO, you can follow a tutorial like this one for example.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts