triangles & aspects

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

triangles & aspects

speartip
Hi,

I am endeavoring to put some simple triangles in my screen. The SDL wiki gives an example of - yes - connecting 3 drawlines. Am I overlooking something or do these lines have to be arrived at mathematically or hardcoded to know what anchoring coordinates they must belong to form the triangle. I don't see a function to make the triangle for you. This becomes rather labor intensive to create your triangle. Also once made, if your aspect ratio changes the lines of the triangle will have to be recalculated to maintain the equality of the angles. I can make a function to correct, no prob.

Before venturing out on some crazy triangle project, just wanted to know whether I was missing some piece of info.

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|

Re: triangles & aspects

sanette-linux
Le 23/03/2017 à 22:19, speartip a écrit :
> Hi, > > I am endeavoring to put some simple triangles in my screen. The SDL wiki gives an example of - yes - connecting 3 drawlines. Am I overlooking something or do these lines have to be arrived at mathematically or hardcoded to know what anchoring coordinates they must belong to form the triangle. I don't see a function to make the triangle for you. This becomes rather labor intensive to create your triangle. Also once made, if your aspect ratio changes the lines of the triangle will have to be recalculated to maintain the equality of the angles. I can make a function to correct, no prob. > > Before venturing out on some crazy triangle project, just wanted to know whether I was missing some piece of info. > > > _______________________________________________ > SDL mailing list > [hidden email] > http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Hi

your question is not terribly clear. Mathematically, a triangle is
just given by 3 points, so there is no problem. (By the way do you want
simple triangles or filled triangles ? Do you want anti-aliasing ?)

Maybe what you mean in fact is an equilateral triangle: all sides have
same length. Then, yes there is some math behind this. There are many
possibilities. Either you compute the position of the third point
given the first two.  Or it might be easier to draw a horizontal
segment (the base of the triangle), and then use SDL_RenderCopyEx to
copy+rotate by 60° to obtain the two other sides.

--
sanette -- full_time_linux


_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|

Re: triangles & aspects

speartip
In reply to this post by speartip
If anybody can point me to a guide containing a blurb/teach on triangles would appreciate it.

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|

Re: triangles & aspects

Jonathan Dearborn-2
Are you looking for information on trigonometry?

Jonny D

On Fri, Mar 24, 2017 at 3:15 PM, speartip <[hidden email]> wrote:
If anybody can point me to a guide containing a blurb/teach on triangles would appreciate it.

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|

Re: triangles & aspects

speartip
In reply to this post by sanette-linux
I know the math, its just if I want to place an equilateral triangle in several different places on the screen I'd like to know what anybody has done before me in this situation: are there any automated functions in SDL2?

Most importantly they need to be filled triangles. How do I fill traingles?? : )

--
  Gray Family



On Fri, Mar 24, 2017, at 02:58 AM, Sanette wrote:
Le 23/03/2017 à 22:19, speartip a écrit :
> Hi, > > I am endeavoring to put some simple triangles in my screen. The SDL wiki gives an example of - yes - connecting 3 drawlines. Am I overlooking something or do these lines have to be arrived at mathematically or hardcoded to know what anchoring coordinates they must belong to form the triangle. I don't see a function to make the triangle for you. This becomes rather labor intensive to create your triangle. Also once made, if your aspect ratio changes the lines of the triangle will have to be recalculated to maintain the equality of the angles. I can make a function to correct, no prob. > > Before venturing out on some crazy triangle project, just wanted to know whether I was missing some piece of info. > > > _______________________________________________ > SDL mailing list > [hidden email] > http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Hi

your question is not terribly clear. Mathematically, a triangle is
just given by 3 points, so there is no problem. (By the way do you want
simple triangles or filled triangles ? Do you want anti-aliasing ?)

Maybe what you mean in fact is an equilateral triangle: all sides have
same length. Then, yes there is some math behind this. There are many
possibilities. Either you compute the position of the third point
given the first two.  Or it might be easier to draw a horizontal
segment (the base of the triangle), and then use SDL_RenderCopyEx to
copy+rotate by 60° to obtain the two other sides.

--
sanette -- full_time_linux


_______________________________________________
SDL mailing list


_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|

Re: triangles & aspects

speartip
I didn't articulate that very well but thats more of what I am needing: getting the 3rd point.

--
  Gray Family



On Fri, Mar 24, 2017, at 05:03 PM, Clangray wrote:
I know the math, its just if I want to place an equilateral triangle in several different places on the screen I'd like to know what anybody has done before me in this situation: are there any automated functions in SDL2?

Most importantly they need to be filled triangles. How do I fill traingles?? : )

--
  Gray Family



On Fri, Mar 24, 2017, at 02:58 AM, Sanette wrote:
Le 23/03/2017 à 22:19, speartip a écrit :
> Hi, > > I am endeavoring to put some simple triangles in my screen. The SDL wiki gives an example of - yes - connecting 3 drawlines. Am I overlooking something or do these lines have to be arrived at mathematically or hardcoded to know what anchoring coordinates they must belong to form the triangle. I don't see a function to make the triangle for you. This becomes rather labor intensive to create your triangle. Also once made, if your aspect ratio changes the lines of the triangle will have to be recalculated to maintain the equality of the angles. I can make a function to correct, no prob. > > Before venturing out on some crazy triangle project, just wanted to know whether I was missing some piece of info. > > > _______________________________________________ > SDL mailing list > [hidden email] > http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Hi

your question is not terribly clear. Mathematically, a triangle is
just given by 3 points, so there is no problem. (By the way do you want
simple triangles or filled triangles ? Do you want anti-aliasing ?)

Maybe what you mean in fact is an equilateral triangle: all sides have
same length. Then, yes there is some math behind this. There are many
possibilities. Either you compute the position of the third point
given the first two.  Or it might be easier to draw a horizontal
segment (the base of the triangle), and then use SDL_RenderCopyEx to
copy+rotate by 60° to obtain the two other sides.

--
sanette -- full_time_linux


_______________________________________________
SDL mailing list

_______________________________________________
SDL mailing list


_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|

Re: <DKIM> Re: triangles & aspects

sanette-linux
In reply to this post by speartip
Le 24/03/2017 à 22:03, Clangray a écrit :
Most importantly they need to be filled triangles. How do I fill traingles?? : )

if you can use opengl, then it's easy (and super fast. filled triangles are the most basic shape in opengl).

It you want to stick to the SDL renderer API, one possibility is the following:

 * draw a rotated filled rectangle on a TARGET texture
 * clip two corners by blitting a suitably rotated texture with 0 color

-- 
sanette -- full_time_linux

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|

Re: <DKIM> Re: <DKIM> Re: triangles & aspects

sanette-linux
Le 25/03/2017 à 13:07, Sanette a écrit :
Le 24/03/2017 à 22:03, Clangray a écrit :
Most importantly they need to be filled triangles. How do I fill traingles?? : )

if you can use opengl, then it's easy (and super fast. filled triangles are the most basic shape in opengl).

It you want to stick to the SDL renderer API, one possibility is the following:

 * draw a rotated filled rectangle on a TARGET texture
 * clip two corners by blitting a suitably rotated texture with 0 color

Here is a C implementation of the SDL renderer idea.



_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

triangle.c (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: triangles & aspects

capehill
In reply to this post by speartip
How many triangles do you intend to draw? In 2D or 3D? If have a more ambituous project at hand, you may need to study some OpenGL. With SDL you can create an OpenGL context.

Check also SDL2_gfx project.

If you want to use basic SDL2 renderer features, you may need to create your own triangle function.

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Reply | Threaded
Open this post in threaded view
|

Re: triangles & aspects

Jonathan Dearborn-2
SDL_gpu also has a built-in triangle primitive, GPU_Tri:

Jonny D

On Sat, Mar 25, 2017 at 3:18 PM, capehill <[hidden email]> wrote:
How many triangles do you intend to draw? In 2D or 3D? If have a more ambituous project at hand, you may need to study some OpenGL. With SDL you can create an OpenGL context.

Check also SDL2_gfx project.

If you want to use basic SDL2 renderer features, you may need to create your own triangle function.

_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org



_______________________________________________
SDL mailing list
[hidden email]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org