2D opengl optimization and solution problem

Started by
3 comments, last by Stani R 18 years, 4 months ago
Hello to everyone… I’m thinking of doing a program like adobe Photoshop but a little bit different. Ok, this is what I’m searching for… (Speed in 2D) 1. When I’m doing a 2d line in opengl, I can set the original and end point colors. Then the graphic card will do a linear interpolation of the color, but how can I set my own function for each pixel of the line? The only way I know is draw the line using a point function but it will take a lot of processing power of the CPU and it will be too slow. I think if you start a 2d line in opengl the cpu will only tell the graphic card where to start and end the line...(I might be wrong about this). 2. What is the fastest way to create a curve in opengl? (Do I do it with lines? Cause I tried to do the curve by dots but is too slow and it has like 3 pixel of width.) Ok, I have lots of questions left over but I will try to solve them by myself, meanwhile can someone provide me any information of this? Thanks in advance!
Advertisement
For acting on each pixel on the line, the easiest is probably a fragment shader program.

For drawing curves, take a look at evaluators (chapter 11) in the red book.
There is no need to write a shader to make a line which varies in colour along its length.

Just use a texture. You can use a 1d texture - which will do what you want.

Mark
thanks alot lightbringer, you are right I need the fragment shader program...

the reason why I want to have shaders its because I don't want to use textures at all...

One more thing... to do polygons can I use this shading method too?
You wouldn't actually be using any textures with markr's idea, you would generate a texture procedurally based on the function you want to perform.

As for the second question, I'm not sure what you mean, but I think the concept should translate to two dimensions also.

This topic is closed to new replies.

Advertisement