Jump to content
  • Advertisement
Sign in to follow this  
daniel98mex

OpenGL 2D opengl optimization and solution problem

This topic is 4616 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 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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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?

Share this post


Link to post
Share on other sites
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.

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!