Discussion:
triangles & aspects
(too old to reply)
speartip
2017-03-23 21:19:54 UTC
Permalink
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.
Sanette
2017-03-24 06:58:11 UTC
Permalink
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 >
***@lists.libsdl.org > 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
Clangray
2017-03-24 21:03:33 UTC
Permalink
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
Post by Sanette
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 >
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
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Clangray
2017-03-24 21:48:01 UTC
Permalink
I didn't articulate that very well but thats more of what I am needing:
getting the 3rd point.


--

Gray Family
Post by Clangray
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
Post by Sanette
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.
Post by speartip
Before venturing out on some crazy triangle project, just
wanted to know whether I was missing some piece of info. > > >
_______________________________________________ > SDL mailing list
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
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
_________________________________________________
SDL mailing list
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Sanette
2017-03-25 12:07:49 UTC
Permalink
Post by Clangray
*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
Sanette
2017-03-25 19:11:45 UTC
Permalink
Post by Sanette
Post by Clangray
*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
* 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.
Jonathan Dearborn
2017-03-24 19:23:38 UTC
Permalink
Are you looking for information on trigonometry?

Jonny D
If anybody can point me to a guide containing a blurb/teach on triangles
would appreciate it.
_______________________________________________
SDL mailing list
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
capehill
2017-03-25 19:18:50 UTC
Permalink
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.
Jonathan Dearborn
2017-03-26 12:01:13 UTC
Permalink
SDL_gpu also has a built-in triangle primitive, GPU_Tri:
http://dinomage.com/reference/SDL_gpu/group__Shapes.html

Jonny D
Post by capehill
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
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Loading...